Esempio n. 1
0
File: main.c Progetto: 8l/CompCert
int main(int argc, char ** argv)
{
  arena_init();
  init_lexer();
  execute_program(parse_program());
  return 0;
}
Esempio n. 2
0
static
void ensure_mm_init ( void )
{
   static Int  client_rz_szW;
   static Bool init_done = False;
   
   if (init_done) {
      // Make sure the client arena's redzone size never changes.  Could
      // happen if VG_(arena_malloc) was called too early, ie. before the
      // tool was loaded.
      vg_assert(client_rz_szW == VG_(vg_malloc_redzone_szB)/4);
      return;
   }

   /* Use checked red zones (of various sizes) for our internal stuff,
      and an unchecked zone of arbitrary size for the client.  Of
      course the client's red zone can be checked by the tool, eg. 
      by using addressibility maps, but not by the mechanism implemented
      here, which merely checks at the time of freeing that the red 
      zone words are unchanged. */

   arena_init ( &vg_arena[VG_AR_CORE],      "core",     2, True, CORE_ARENA_MIN_SZW, False );

   arena_init ( &vg_arena[VG_AR_TOOL],      "tool",     2, True, 262144, False );

   arena_init ( &vg_arena[VG_AR_SYMTAB],    "symtab",   2, True, 262144, False );

   arena_init ( &vg_arena[VG_AR_JITTER],    "JITter",   2, True, 8192,   False );

   /* No particular reason for this figure, it's just smallish */
   sk_assert(VG_(vg_malloc_redzone_szB) < 128);
   sk_assert(VG_(vg_malloc_redzone_szB) >= 0);
   client_rz_szW = VG_(vg_malloc_redzone_szB)/4;

   arena_init ( &vg_arena[VG_AR_CLIENT],    "client",  
               client_rz_szW, False, 262144, True );

   arena_init ( &vg_arena[VG_AR_DEMANGLE],  "demangle", 4 /*paranoid*/,
                                                           True, 16384, False );

   arena_init ( &vg_arena[VG_AR_EXECTXT],   "exectxt",  2, True, 16384, False );

   arena_init ( &vg_arena[VG_AR_ERRORS],    "errors",   2, True, 16384, False );

   arena_init ( &vg_arena[VG_AR_TRANSIENT], "transien", 2, True, 16384, False );

   init_done = True;
#  ifdef DEBUG_MALLOC
   VG_(mallocSanityCheckAll)();
#  endif
}
Esempio n. 3
0
byte *block_alloc(byte type, size_t size)
{
  int s, b, found = 0, blocks = BLOCKS(size);
  byte *block_map;
  byte *space;

  if (arena_state != INITIALIZED)
    arena_init();

  if (blocks > BLOCKS_PER_SPACE)
    error("Trying to allocate too many contiguous blocks.");

  for(s=0; s<SPACES_IN_ARENA; ++s) {
    if (space_type[s] == TYPE_BLOCKS) {
      block_map = SPACE_MAP(s);
      for (b=0; b<BLOCKS_PER_SPACE; b++) {
	if (block_map[b] == TYPE_FREE) {
	  found ++;
	  if(found >= blocks) {
	    int start = b+1-found, k;

	    for(k=start; k<=b; ++k)
	      block_map[k] = type;
	    map(BLOCK_BASE(s,start), GRAINROUND(page_size, size));
	    return(BLOCK_BASE(s,start));
	  }
	}
	else
	  found = 0;
      }
      found = 0;
    }
  }

  /* None of the existing block spaces have room; let's make a new one */

  space = space_alloc(TYPE_BLOCKS,0);    /* allocate the new space */
  s = SPACE(space);
  block_map = SPACE_MAP(s) = block_maps + s*BLOCKS_PER_SPACE;
  /* This is where the map is */

  for(b=0; b< blocks; ++b)
    block_map[b] = type;
  for (b=blocks; b < BLOCKS_PER_SPACE; b++)
    block_map[b] = TYPE_FREE;		 /* ... and initialize it */

  map(space, GRAINROUND(page_size, size));
  return(space);
}
Esempio n. 4
0
/* LWIP network stack implementation */
LWIP::LWIP()
{
    default_interface = NULL;

    // Seed lwip random
    lwip_seed_random();

    // Initialise TCP sequence number
    uint32_t tcp_isn_secret[4];
    for (int i = 0; i < 4; i++) {
        tcp_isn_secret[i] = LWIP_RAND();
    }
    lwip_init_tcp_isn(0, (u8_t *) &tcp_isn_secret);

    tcpip_init(&LWIP::tcpip_init_irq, this);
    tcpip_inited.wait(0);

    // Zero out socket set
    arena_init();
}
Esempio n. 5
0
static
void ensure_mm_init ( void )
{
   static Bool init_done = False;
   if (init_done) return;

   /* Use a checked red zone size of 1 word for our internal stuff,
      and an unchecked zone of arbitrary size for the client.  Of
      course the client's red zone is checked really, but using the
      addressibility maps, not by the mechanism implemented here,
      which merely checks at the time of freeing that the red zone
      words are unchanged. */

   arena_init ( &vg_arena[VG_AR_PRIVATE], "private ", 
                1, True, 262144 );

   arena_init ( &vg_arena[VG_AR_SYMTAB],  "symtab  ", 
                1, True, 262144 );

   arena_init ( &vg_arena[VG_AR_CLIENT],  "client  ",  
                VG_AR_CLIENT_REDZONE_SZW, False, 262144 );

   arena_init ( &vg_arena[VG_AR_DEMANGLE], "demangle",  
                4 /*paranoid*/, True, 16384 );

   arena_init ( &vg_arena[VG_AR_EXECTXT],  "exectxt ",  
                1, True, 16384 );

   arena_init ( &vg_arena[VG_AR_ERRCTXT],  "errctxt ",  
                1, True, 16384 );

   arena_init ( &vg_arena[VG_AR_TRANSIENT], "transien",  
                2, True, 16384 );

   init_done = True;
#  ifdef DEBUG_MALLOC
   VG_(mallocSanityCheckAll)();
#  endif
}