Пример #1
0
void init() {
    read_mapping();
    read_table();
    read_rules();
    assert(num_rules<MAX_RULES);
    assert(num_symbols<MAX_SYMBOLS);
    assert(num_states<MAX_STATES);
}
Пример #2
0
ReaderMapping
ReaderMapping::read_mapping(const char* key) const
{
  if (!m_impl)
  {
    return {};
  }
  {
    ReaderMapping result;
    read_mapping(key, result);
    return result;
  }
}
Пример #3
0
bool
ReaderMapping::read_desc(const char* key, ResDescriptor& value) const
{
  ReaderMapping reader;
  if (read_mapping(key, reader))
  {
    reader.read_string("image", value.res_name);
    reader.read_enum("modifier", value.modifier, &ResourceModifier::from_string);
    return true;
  }
  else
  {
    return false;
  }
}
Пример #4
0
static int
fbsd_find_memory_regions (int (*func) (CORE_ADDR, unsigned long,
				       int, int, int, void *),
			  void *obfd)
{
  pid_t pid = ptid_get_pid (inferior_ptid);
  char *mapfilename;
  FILE *mapfile;
  unsigned long start, end, size;
  char protection[4];
  int read, write, exec;

  xasprintf (&mapfilename, "/proc/%ld/map", (long) pid);
  mapfile = fopen (mapfilename, "r");
  if (mapfile == NULL)
    error ("Couldn't open %s\n", mapfilename);

  if (info_verbose)
    fprintf_filtered (gdb_stdout, 
		      "Reading memory regions from %s\n", mapfilename);

  /* Now iterate until end-of-file.  */
  while (read_mapping (mapfile, &start, &end, &protection[0]))
    {
      size = end - start;

      read = (strchr (protection, 'r') != 0);
      write = (strchr (protection, 'w') != 0);
      exec = (strchr (protection, 'x') != 0);

      if (info_verbose)
	{
	  fprintf_filtered (gdb_stdout, 
			    "Save segment, %ld bytes at 0x%s (%c%c%c)\n", 
			    size, paddr_nz (start),
			    read ? 'r' : '-',
			    write ? 'w' : '-',
			    exec ? 'x' : '-');
	}

      /* Invoke the callback function to create the corefile segment. */
      func (start, size, read, write, exec, obfd);
    }

  fclose (mapfile);
  return 0;
}
Пример #5
0
int be_migrate_thread_to_domain(pid_t tid, int domain)
{
	int	ret;
	cpu_set_t *cpu_set;
	size_t sz;

	ret = read_mapping(domain, "domains", &cpu_set, &sz);
	if (ret != 0)
		return ret;

	/* apply to caller */
	if (tid == 0)
		tid = gettid();

	ret = sched_setaffinity(tid, sz, cpu_set);

	CPU_FREE(cpu_set);

	return ret;
}
Пример #6
0
aida2tree::aida2tree():rawaida()
{
    print_flag=0;
    //Enabled FEE module
    bool my_enable[33]={ false,
            true, true, true, true,
            false, true, true, true,
            false, true, true, false,
            true, true, false, true,
            false, false, false, false,
            false, false, false, false,
            false, false, false, false,
            false, false, false, false};

    for(int j=0;j<n_fee64;j++){
        enabled_FEE[j]=my_enable[j];
        first_sync_flag[j]=0;
    }

    //reset local parameters
    flag_mapping=false;

    fillFlag=false;
    //SOME LOCAL Var for sorter ==============
    for (int i=0;i<n_fee64;i++){
        tm_stp_msb_modules[i]=0;
        sync_flag_modules[i]=false;
        pause_flag_modules[i]=false;
        my_tm_stp_prev[i]=0;
        MBS_hit[i][0]=false;
        MBS_hit[i][1]=false;
        MBS_tm_stp_lsb[i][0]=0;
        MBS_tm_stp_lsb[i][1]=0;
        MBS_bits[i][0]=0;
        MBS_bits[i][1]=0;
        my_tm_stp_msb=0;
    }
    my_time_offset=0;
    t_prev=0;
    read_mapping();
}
Пример #7
0
int cpu_to_domains(int cpu, unsigned long long int* mask)
{
	/* TODO: Support more than 64 domains. Instead of using 'ull' for 'mask',
	   consider using gcc's __uint128_t or some struct. */

	cpu_set_t *bits;
	size_t sz;
	int ret;

	/* number of CPUs exceeds what we can pack in ull */
	if (num_online_cpus() > sizeof(unsigned long long int)*8)
		return -1;

	ret = read_mapping(cpu, "cpus", &bits, &sz);
	if (!ret) {
		*mask = cpusettoull(bits, sz);
		CPU_FREE(bits);
	}

	return ret;
}
Пример #8
0
int domain_to_first_cpu(int domain)
{
	cpu_set_t *bits;
	size_t sz;
	int i, n_online;
	int first;

	int ret = read_mapping(domain, "domains", &bits, &sz);

	if (ret)
		return ret;

	n_online = num_online_cpus();
	first = -1; /* assume failure */
	for (i = 0; i < n_online; ++i) {
		if(CPU_ISSET_S(i, sz, bits)) {
			first = i;
			break;
		}
	}
	CPU_FREE(bits);

	return first;
}
Пример #9
0
void Tagger::Init(int argc, char * argv[])
{

	setlocale(LC_CTYPE, "iso_8858_1");
#ifdef SpecialMalloc
	/* Force fast allocation */
	set_small_allocation(100);
#endif

	/* Clear data structures */
	InitDict(dict);
	InitDict(skip_dict);
	InitTrans(trans);
	InitTrans(c_newtrans);
	odictfile = otranfile = NULL;

	/* Verify command line */
	if (argc <= 2)
	  error_exit("Usage: label corpus options\n");

	/* Form options */
	InitOptions;

	set_up_options(argc, argv, &iterations, &initialise, &dict_size,
				dictname, tranname, odictname, otranname, outname, mapname,
				skipname, reducename, fsmname, grammarname, infername, ukwname,
				ofeaturesname, obadwordname, bdbmname, runkstatname, wunkstatname);

	any_output = !no_output || Option(report_stats) || OutOpt(prob_dist);


	/* Open BDBM dictionary */
	if (Option(bdbm)){
		/* Berkeley DB: first of all need to create the dbp data structure*/
		if((ret = db_create(&dbp, NULL, 0)) != 0) {
			fprintf(stderr, "db_create: %s\n", db_strerror(ret));
			exit (1);
		}
		/* Berkeley DB: Then you open it, readonly  */
		if((ret = dbp->open(dbp,bdbmname, NULL, DB_BTREE, DB_RDONLY, 0777)) != 0) {
			dbp->err(dbp, ret, "%s", bdbmname);
			exit(1);
		} 
	}

	/* Read mappings */
	if (Option(verbose)) printf("Read mappings\n");
	read_mapping(mapname);

	/* Read tag reduction mappings */
	if (Option(reduced_tags))
	{
		if (Option(verbose)) printf("Read reduced tag set\n");
		read_reduce_mapping(reducename);
	}

#ifdef Use_Parser
	/* Read parse rules */
	if (Option(use_parser))
	{
		if (Option(verbose)) printf("Read parse rules\n");
		parser_read_named(grammarname);
	}
#endif
#ifdef Use_FSM
	/* Read FSM definitions */
	if (Option(use_fsm))
	{
		if (Option(verbose)) printf("Read FSMs\n");
		fsm_read_named(fsmname);
	}
#endif

	/* Read skip list */
	if (Option(skip_list))
	{
		if (Option(verbose)) printf("Read skip list\n");
		read_named_dict(skipname, &skip_dict, -1);
	}

	/* Read unknown word rules */
	if (Option(unknown_rules))
	{
		if (Option(verbose)) printf("Read unknown word rules\n");
		read_unknown_rules(ukwname);
	}

	/* Set up dictionary [note]:it costs a few seconds*/
	if (dictname[0] == 0)
	{
		create_dict(&dict, dict_size);
		clear_dict(&dict);
	}
	else
	{
		if (Option(verbose)) printf("Read dictionary\n");
		read_named_dict(dictname, &dict, -1);
		if (infername[0] != 0)
		{
			if (Option(verbose)) printf("Read inference rules\n");
			infer_tags((char *)infername, &dict);

		}
	}

	/* Set up transitions [note] it costs a few seconds*/
	if (tranname[0] == 0)
	{
		create_trans(&trans, tags_all);
		clear_trans_all(&trans);
	}
	else
	{
		if (Option(verbose)) printf("Read transitions\n");
		read_named_ascii_trans(tranname, &trans);

		/* Analyze selected features of lexicon to generate tag probabilities for unknown words. */
		if ( Option(unknown_morph) || Option(unknown_rules))
		{
			/* Initialize feature values */

			Allocate(features->featuretags, sizeof(FeatureTagSt), "features->featuretags: main");
			features->featuretags->next_open_slot = 0;

			features->gamma = trans.gamma;

			if ( features->maxsuffix == 0 )
			  features->maxsuffix = MinSuffixLen;
			if ( features->maxunkwords == 0 )
			  features->maxunkwords = MAXUNKWORDS;
			if ( features->maxprefcut == 0 )
			  features->maxprefcut = MinPrefixLen;
			if ( features->maxsuffcut == 0 )
			  features->maxsuffcut = MinSuffixLen;

			unknown_word_handling_initialization();
			gather_unigram_freqs( &dict );
		}

		if ( Option(unknown_morph) )
		{
			analyze_features( &dict, ofeaturesname, obadwordname, &trans, dbp, &dict, runkstatname );
		}
	}

	set_special_words(&dict, features );

	/* Create space for re-estimation or training */
	if (Option(reestimate) || Option(training))
	{
		c_newtrans.gamma = trans.gamma; /* Share arrays */
		create_trans(&c_newtrans, tags_all);
	}

	if (odictname[0] != 0)
	  odictfile = open_file(odictname, "w");
	if (otranname[0] != 0)
	  otranfile = open_file(otranname, "w");

	/* Set up anchor word */
	set_anchor(&dict);

	adjust_dict(&dict, trans.gamma, FALSE);
	adjust_trans(&trans, NULL);
}