Beispiel #1
0
int region_main(int argc, char *argv[]) {
  region r[4];
  Updater u[3];
  region quint = newregion();
  region temp = newregion();
  int i = 0;
  struct quint *q = NULL, *q2;
  translation tr;

  r[0] = quint; r[1] = NULL;
  u[0] = update_quint;

  for(i = 0; i < NUM; i++) {
    q = new_quint(quint, i, q);
  }

  serialize(r,"data","offsets");
  tr = deserialize("data", "offsets", u, temp); 
  q2 = (struct quint *) translate_pointer(tr, (void *) q);
  
  for(i = 0; i < NUM; i++) {
    if ((q == q2) || (q->i != q2->i)) {
      printf("FAIL triple\n");
      exit(1);
    }
    q = q->next;
    q2 = q2->next;
  }

  printf("OK\n");
  return 0;
}
int main(int argc, char *argv[])
{
  region r[11];
  int i = 0;
  node n = NULL;
  region node_region;
  
  region_init();
  list_init();
  hash_table_init();
  banshee_region_persistence_init();
  seed_fn_ptr_table(newregion());

  node_region = newregion();

  r[10] = NULL;
  r[9] = strbucket_region;
  r[8] = banshee_ptr_region;
  r[7] = list_strnode_region;
  r[6] = list_node_region;
  r[5] = list_header_region;
  r[4] = banshee_nonptr_region;
  r[3] = bucket_region;
  r[2] = table_region;
  r[1] = bucketptr_region;
  r[0] = node_region;

  thetable = make_persistent_string_hash_table(8, 1);
  thelist = new_persistent_node_list();

  for(i = 0; i < NUM_NODES; i++) {
    char str[512];
    node prev = n;
    n = ralloc(node_region, struct node_);
    n->data = i;
    n->next = prev;

    snprintf(str, 512,"node(%d)", i);

    hash_table_insert(thetable, (hash_key)rstrdup(banshee_nonptr_region, str),
		      (hash_data)n);
    node_list_append_tail(n, thelist);
  }

  serialize(r, "data", "offsets");

  update();
  if (!verify()) {
    printf("Failed region persist test\n");
    exit(1);
  }
  else {
    printf("Passed region persist test\n");
    exit(0);
  }

}
Beispiel #3
0
/* Complete inclusion check. First fast checks to eliminate simple
   cases. Eventually defaults to a complete check */
bool regexp_inclusion(regexp r1, regexp r2) {
  /* a hashtable of visited states (positions in the regexps) */
  //  unsigned char visited[8192];

  /* Fast equality check */
  if (!strcmp((char *)r1->expr,(char *)r2->expr)) {
    return TRUE;
  }		

  /* Fast disinclusion check */
  else if (regexp_fast_disinclusion(r1, r2) == 1) {
    return FALSE;
  }
 
  /* Complete inclusion check */
  else {
    bool result = FALSE;
    region temp = newregion();
    hash_table visited = make_hash_table(temp, 32, state_hash, state_eq);
    /* TODO: I'd prefer to use a worklist instead of recursion */
    result = regexp_complete_inclusion(r1, r2, 0, 0, visited);
    deleteregion(temp);
    return result;
  }

}
Beispiel #4
0
void renew_region(region *r)
/* Effects: Delete region *r (if not null), allocate a new region in *r */
{
  if (*r)
    deleteregion_ptr(r);
  *r = newregion();
}
Beispiel #5
0
static ainfo find_ainfo(char *file, int line)
{
  ainfo ai;

  for (ai = ainfos; ai; ai = ai->next)
    if (line == ai->line && !strcmp(file, ai->file))
      return ai;

  if (!registered_exit)
    {
      if (atexit(regprofile))
	fprintf(stderr, "Registration of profile at exit failed\n");
      registered_exit = 1;
    }

  if (!profile_region)
    profile_region = newregion();
  ai = ralloc(profile_region, struct Alloc_info);
  ai->file = file;
  ai->line = line;
  ai->size = 0;
  ai->calls = 0;
  ai->next = ainfos;
  ainfos = ai;
  return ai;
}
Beispiel #6
0
void region_init(void)
{
  // VALGRIND_DO_QUICK_LEAK_CHECK;
  // fprintf(stderr, "## region_init\n");
  static int initialized = 0;

  if ( initialized )
    return;

  else
    {
#ifdef STAGGER_RSTART
      rstart = -64; /* Save 64 bytes of memory! (sometimes ;-)) */
#endif
      init_pages();
      permanent = newregion();
      if (getenv("REGIONSTATS"))
	benchmark_init();
#ifdef DEBUG_RALLOC
      atexit(memusage);
#endif
    }
  initialized = 1;
  // VALGRIND_DO_QUICK_LEAK_CHECK;
}
Beispiel #7
0
void xml_start(FILE *f)
{
    xml_region = newregion();
    xml_file = f;
    indent_level = 0;
    at_line_start = TRUE;
    tags = dd_new_list(xml_region);
}
Beispiel #8
0
void mr_dyck_init(bool pn,FILE *rconstraints)
{
  sig_elt s_sig[1] = {{vnc_pos,setif_sort}};

  assert(state == mr_dyck_raw);
  pn_reach = pn;
  mr_dyckregion = newregion();
  mr_all_nodes = new_mr_dyck_node_list(mr_dyckregion);

  mr_k_hash = make_hash_table(mr_dyckregion, 32, ptr_hash, ptr_eq);
  mr_o_hash = make_hash_table(mr_dyckregion, 32, ptr_hash, ptr_eq);
  mr_c_hash = make_hash_table(mr_dyckregion, 32, ptr_hash, ptr_eq);
  mr_seen_indices = make_hash_table(mr_dyckregion,32,ptr_hash,ptr_eq);

  mr_s_constructor = make_constructor("s",setif_sort,s_sig,1);
  mr_p_constructor = make_constructor("p",setif_sort,s_sig,1);
  mr_n_constructor = make_constructor("n",setif_sort,s_sig,1);
  mr_start_constructor = make_constructor("start",setif_sort,s_sig,1);

#ifdef DEBUG_ERRONEOUS_EDGES
  mr_erroneous_sources = new_mr_dyck_node_list(mr_dyckregion);
#endif

#ifdef MINIMIZE_CONSTRAINTS
  if (rconstraints) {
    char buf[100];
    region scratch = newregion();
    relevant_constraints = new_relevant_constraint_list(scratch);

    printf("Reading relevant constraints\n");

    while (fgets(buf,100,rconstraints)) {
      INT_PTR next_relevant = atoi(buf);
      assert(next_relevant);
      // printf("%d\n",next_relevant);
      relevant_constraint_list_cons(next_relevant, relevant_constraints);
    }
    fclose(rconstraints);
  }
#endif

  state = mr_dyck_inited;
}
Beispiel #9
0
/* Serialization */
void serialize_start(FILE *f, serialize_fn_ptr kind_map[], int length)
{
  assert(current_state == persist_raw);
  assert(f); 

  persist_rgn = newregion();
  current_state = persist_serializing;

  serialize_queue = new_persist_entry_queue(persist_rgn);
  serialized_objects = make_hash_table(persist_rgn, 128, ptr_hash, ptr_eq);
  
  current_file = f;
  num_kinds = length;
  serialize_fns = rarrayalloc(persist_rgn, length, serialize_fn_ptr);
  rarraycopy(serialize_fns, kind_map, length, serialize_fn_ptr);
}
Beispiel #10
0
void engine_init(void)
{
  region_init();

  engine_region = newregion();

  hash_table_init();
  seed_fn_ptr_table(permanent);

  banshee_region_persistence_init();
  bounds_init();
  stamp_init();
  list_init();
  uf_init();
  term_hash_init();

  rb_stack = new_persistent_banshee_rollback_stack();
  handle_error = default_error_handler;

}
void update()
{
  Updater u[10];
  translation t;
  region temp = newregion();

  u[9] = update_strbucket;
  u[8] = update_ptr_data;
  u[7] = update_list_strnode;
  u[6] = update_list_node;
  u[5] = update_list_header;
  u[4] = update_nonptr_data;
  u[3] = update_bucket;
  u[2] = update_hash_table;
  u[1] = update_bucketptr;
  u[0] = update_node;

  t = deserialize("data", "offsets", u, temp);
  thetable = (hash_table) translate_pointer(t, (void *)thetable);
  thelist = (node_list) translate_pointer(t, (void *)thelist);
}
Beispiel #12
0
int region_main(int argc, char *argv[]) {
  region r[2];
  Updater u[1];
  region temp = newregion();
  struct pair *p;
  translation t;

  if ((argc == 1) || (strcmp(argv[1],"d") && strcmp(argv[1],"b"))) {
    printf("Usage: time timer {d | b}\nd for deserialization only; b for both deserialization and serialization\n");
    exit(1);
  }

  u[0] = update_pair;
  t = deserialize("data", "offsets", u, temp);
  if (strcmp(argv[1],"b") == 0) {
    p = (struct pair *) translate_pointer(t, (void *) 1125667648);
    r[0] = regionof((void *) p);
    r[1] = NULL;
    serialize(r, "data2", "offsets2"); 
  }
  return 0;
}
Beispiel #13
0
int main() {
    FILE *fp;
    char line[100];
    char buf[20];
    int n1, n2, i, j;
    region r;
    double t1, t2;

    nonspec_init();
    dyck_init(TRUE);

    for(i = 0; i < 200000; i++) {
        nodes[i] = NULL;
    }

    t1 = gettime();
    fp = fopen("graph.txt", "r");
    if (fp == NULL) exit(EXIT_FAILURE);
    while ((fgets(line, 100, fp)) != NULL) {
        if (j % 1000 == 0) {
            t2 = gettime();
            //printf("1000 lines in %f seconds: ", t2 - t1); fflush(stdout);
            printf("%s", line);
            fflush(stdout);
            t1 = t2;
        }
        j++;
        switch(line[0]) {
        case '\n' :
            break;
        case '(' :
            sscanf(line+1, "%d %d %d", &n1, &n2, &i);
            make_dyck_open_edge(nodes[n1],nodes[n2],i);
            break;
        case ')' :
            sscanf(line+1, "%d %d %d", &n1, &n2, &i);
            make_dyck_close_edge(nodes[n1],nodes[n2],i);
            break;
        case 's' :
            sscanf(line+1, "%d %d", &n1, &n2);
            make_dyck_subtype_edge(nodes[n1], nodes[n2]);
            break;
        case 'g' :
            sscanf(line+1, "%d", &n1);
            mark_dyck_node_global(nodes[n1]);
            break;
        case 'c' :
            sscanf(line+1, "%d", &n1);
            if (n1 >= NUMNODES) {
                printf("Aborting:  Increase NUMNODES\n");
                exit(1);
            }
            sprintf(buf, "n%d", n1);
            nodes[n1] = make_tagged_dyck_node(buf);
            break;
        case 'm' :
            sscanf(line+1, "%d %d", &n1, &n2);
            dyck_check_reaches(nodes[n1], nodes[n2]);
            break;
        case 'p' :
            sscanf(line+1, "%d %d", &n1, &n2);
            dyck_check_pn_reaches(nodes[n1], nodes[n2]);
            break;
        case 'M' :
            sscanf(line+1, "%d", &n1);
            r = newregion();
            rdyck_reaches(r, nodes[n1]);
            deleteregion(r);
            //dyck_reaches(nodes[n1]);
            break;
        case 'P' :
            sscanf(line+1, "%d", &n1);
            r = newregion();
            rdyck_pn_reaches(r, nodes[n1]);
            deleteregion(r);
            break;
        }
    }
    return EXIT_SUCCESS;
}
Beispiel #14
0
/* Entry point of cc1/c++.  Decode command args, then call compile_file.
   Exit code is 35 if can't open files, 34 if fatal error,
   33 if had nonfatal errors, else success.  */
int main(int argc, char **argv)
{
  register int i;
  dd_list files, preludes;
  dd_list_pos cur;
  int version_flag = 0;
  char *p;
  char *config_file = NULL;

#ifdef TIMER_USERTIME
  reset_timer(&total_time);
#endif
  start_timer(&total_time);
  region_init();
  parse_region = newregion();
  in_prelude = FALSE;
  num_hotspots = 0;
  parsed_files = dd_new_list(parse_region);

  copy_argc = 0;
  copy_argv = xmalloc((argc + 1) * sizeof(*copy_argv));
  files = dd_new_list(parse_region);
  preludes = dd_new_list(parse_region);

  p = argv[0] + strlen (argv[0]);
  while (p != argv[0] && p[-1] != '/'
#ifdef DIR_SEPARATOR
	 && p[-1] != DIR_SEPARATOR
#endif
	 )
    --p;
  progname = p;

#ifdef SIGPIPE
  signal (SIGPIPE, pipe_closed);
#endif

  copy_argv[0] = argv[0];
  copy_argc = 1;
  for (i = 1; i < argc; i++)
    {
      int j;
      bool copy_arg = TRUE;

      /* If this is a language-specific option,
	 decode it in a language-specific way.  */
      for (j = 0; lang_options[j] != 0; j++)
	if (!strncmp (argv[i], lang_options[j],
		      strlen (lang_options[j])))
	  break;
      if (lang_options[j] != 0)
	/* If the option is valid for *some* language,
	   treat it as valid even if this language doesn't understand it.  */
	c_decode_option(argv[i]);
      else if (argv[i][0] == '-' && argv[i][1] != 0)
	{
	  register char *str = argv[i] + 1;
	  if (str[0] == 'Y')
	    str++;

	  if (!strcmp (str, "dumpbase"))
	    copy_argv[copy_argc++] = argv[i++];
	  else if (str[0] == 'f')
	    {
	      register char *p = &str[1];
	      int found = 0;

	      /* Some kind of -f option.
		 P's value is the option sans `-f'.
		 Search for it in the table of options.  */

	      for (j = 0;
		   !found && j < sizeof (f_options) / sizeof (f_options[0]);
		   j++)
		{
		  if (!strcmp (p, f_options[j].string))
		    {
		      *f_options[j].variable = f_options[j].on_value;
		      /* A goto here would be cleaner,
			 but breaks the vax pcc.  */
		      found = 1;
		    }
		  if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
		      && ! strcmp (p+3, f_options[j].string))
		    {
		      *f_options[j].variable = ! f_options[j].on_value;
		      found = 1;
		    }
		}
	    }
	  else if (!strcmp (str, "pedantic"))
	    pedantic = 1;
	  else if (!strcmp (str, "pedantic-errors"))
	    flag_pedantic_errors = pedantic = 1;
	  else if (!strcmp (str, "quiet"))
	    quiet_flag = 1;
	  else if (!strcmp (str, "version"))
	    version_flag = 1;
	  else if (!strcmp (str, "w"))
	    inhibit_warnings = 1;
	  else if (!strcmp (str, "W"))
	    {
	      extra_warnings = 1;
	      /* We save the value of warn_uninitialized, since if they put
		 -Wuninitialized on the command line, we need to generate a
		 warning about not using it without also specifying -O.  */
	      if (warn_uninitialized != 1)
		warn_uninitialized = 2;
	    }
	  else if (str[0] == 'W')
	    {
	      register char *p = &str[1];
	      int found = 0;

	      /* Some kind of -W option.
		 P's value is the option sans `-W'.
		 Search for it in the table of options.  */

	      for (j = 0;
		   !found && j < sizeof (W_options) / sizeof (W_options[0]);
		   j++)
		{
		  if (!strcmp (p, W_options[j].string))
		    {
		      *W_options[j].variable = W_options[j].on_value;
		      /* A goto here would be cleaner,
			 but breaks the vax pcc.  */
		      found = 1;
		    }
		  if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
		      && ! strcmp (p+3, W_options[j].string))
		    {
		      *W_options[j].variable = ! W_options[j].on_value;
		      found = 1;
		    }
		}

	      if (found)
		;
	      else if (!strncmp (p, "id-clash-", 9))
		{
		  char *endp = p + 9;

		  while (*endp)
		    {
		      if (*endp >= '0' && *endp <= '9')
			endp++;
		      else
			{
			  error ("Invalid option `%s'", argv[i]);
			  goto id_clash_lose;
			}
		    }
		  warn_id_clash = 1;
		  id_clash_len = atoi (str + 10);
		id_clash_lose: ;
		}
	      else if (!strncmp (p, "larger-than-", 12))
		{
		  char *endp = p + 12;

		  while (*endp)
		    {
		      if (*endp >= '0' && *endp <= '9')
			endp++;
		      else
			{
			  error ("Invalid option `%s'", argv[i]);
			  goto larger_than_lose;
			}
		    }
		  warn_larger_than = 1;
		  larger_than_size = atoi (str + 13);
		larger_than_lose: ;
		}
	    }
	  else if (!strcmp (str, "o"))
	    copy_argv[copy_argc++] = argv[i++];
	  else if (str[0] == 'G')
	    {
	      if (str[1] == '\0')
		copy_argv[copy_argc++] = argv[i++];
	    }
	  else if (!strncmp (str, "aux-info", 8))
	    {
	      if (str[8] == '\0')
		copy_argv[copy_argc++] = argv[i++];
	    }
	  else if (!strcmp(str, "config"))
	    {
	      if (i < argc - 1)
		{
		  i++;
		  config_file = strdup(argv[i]);
		}
	      else
		error ("Missing -config file");
	    }
	  else if (!strcmp(str, "prelude"))
	    {
	      if (i < argc - 1)
		{
		  i++;
		  dd_add_last(parse_region, preludes,
			      rstrdup(parse_region, argv[i]));
		}
	      else
		error("Missing -prelude file");
	    }
	  else if (!strcmp(str, "hotspots"))
	    {
	      if (i < argc - 1)
		{
		  i++;
		  num_hotspots = atoi(argv[i]);
		  if (num_hotspots < 0)
		    error("Negative value for -hotspots count");
		}
	      else
		error("Missing -hotspots count");
	    }
	  else if (!strcmp( str, "program-files"))
	    {
	      if (i < argc - 1)
		{
		  i++;
		  add_program_files(argv[i], files);
		}
	      else
		error("Missing -program-files file");
	    }
	}
      else if (argv[i][0] == '+')
	;
      else
	{
	  /* Allow wildcards, because PAM won't expand files */
	  glob_t globbuf;
	  char **cur;

	  if (glob(argv[i], 0, NULL, &globbuf))
	    {
	      /* glob returned non-zero error status; abort */
	      fprintf(stderr, "%s: file not found\n", argv[i]);
	      exit(FATAL_EXIT_CODE);
	    }
	  else
	    for (cur = globbuf.gl_pathv; *cur; cur++)
	      {
		/* Assume anything called prelude.i is a prelude file */
		if ( strlen(*cur) >= 9 &&
                    !strncmp("prelude.i", *cur + strlen(*cur) - 9, 9))
		  dd_add_last(parse_region, preludes,
			      rstrdup(parse_region, *cur));
		else
		  dd_add_last(parse_region, files,
			      rstrdup(parse_region, *cur));
	      }
	  copy_arg = FALSE;
	}

      if (copy_arg)
	copy_argv[copy_argc++] = argv[i];
    }
  copy_argv[copy_argc] = NULL;

  if (flag_casts_preserve && flag_flow_sensitive) {
    fprintf(stderr, "-fcasts-preserve currently not allowed with "
	    "-fflow_sensitive");
    exit(FATAL_EXIT_CODE);
  }

  /* Now analyze *all* of the files.  First, initialize all appropriate
     data structures. */
  init_types();
  cval_init();
  init_effects();
  init_qtype();
  init_quals();
  init_qerror();

  init_store();

  if (config_file)
    load_config_file_quals(config_file);

  /* Add const so that we can do -fconst-subtyping no matter what */
  if (!const_qual)
    {
      begin_po_qual();
      const_qual = add_qual("const");
      add_level_qual(const_qual, level_ref);
      set_po_nonprop();
      end_po_qual();
    }

  /* Add volatile so we can handle noreturn functions */
  if (!volatile_qual)
    {
      begin_po_qual();
      volatile_qual = add_qual("volatile");
      add_level_qual(volatile_qual, level_ref);
      add_sign_qual(volatile_qual, sign_eq);
      set_po_nonprop();
      end_po_qual();
    }

  /* Add noreturn, for non-returning functions */
  if (!noreturn_qual)
    {
      begin_po_qual();
      noreturn_qual = add_qual("noreturn");
      add_level_qual(noreturn_qual, level_value);
      add_sign_qual(noreturn_qual, sign_eq);
      set_po_nonprop();
      end_po_qual();
    }

  end_define_pos(); /* Allow cqual to run with no qualifiers */

  init_pam();
  init_analyze();
  found_fs_qual = FALSE; /* Force reset, since init_analyze may
			    look up some quals */

  /* Now analyze the prelude files */
  in_prelude = TRUE;
  dd_scan(cur, preludes)
    {
      char *file;
      
      file = DD_GET(char *, cur);
      fprintf(stderr, "Analyzing prelude %s\n", file);
      compile_file(file);
    }