Exemple #1
0
LibbfHashTable* libbf_hash_table_clone(LibbfHashTable *hash_table,
                                       LibbfCloneValue clone_value_func)
{
  LibbfHashTable *hash_table_new;
  LibbfHashNode *new_node;
  LibbfHashNode *node;
  int i;

  hash_table_new                     = alloc0 (LibbfHashTable, 1);
  hash_table_new->size               = hash_table->size;
  hash_table_new->nnodes             = hash_table->nnodes;
  hash_table_new->value_destroy_func = hash_table->value_destroy_func;
  hash_table_new->nodes              = alloc0 (LibbfHashNode*, hash_table_new->size);
  for (i = 0; i < hash_table->size; i++)
  {
    node = hash_table->nodes[i];
    while(node)
    {
      LibbfHashNode *next = hash_table_new->nodes[i];
      new_node = libbf_hash_node_new(node->key,
                                     (clone_value_func)? clone_value_func(node->value) : node->value);
      new_node->next = next;
      hash_table_new->nodes[i] = new_node;
      node = node->next;
    }
  }
  return hash_table_new;
}
Exemple #2
0
ssl_server_client * ssl_server_listen(ssl_server * serv){

  BIO * bio = BIO_new_dgram(serv->fd, BIO_NOCLOSE);
  {
    struct timeval timeout;
    timeout.tv_sec = 10;
    timeout.tv_usec = 0;
    BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, &timeout);
  }
  SSL * ssl = SSL_new(serv->ctx);
  SSL_set_bio(ssl, bio, bio);
  SSL_set_options(ssl, SSL_OP_COOKIE_EXCHANGE);

  struct sockaddr_storage client_addr;
  while (DTLSv1_listen(ssl, &client_addr) <= 0){
    SSL_free(ssl);
    return NULL;
  }
  ssl_server_client * con = alloc0(sizeof(ssl_server_client));
  con->ssl = ssl;
  con->addr = client_addr;
  con->bio = bio;
  return con;
  
}
Exemple #3
0
ssl_server * ssl_setup_server(int fd){
  ssl_ensure_initialized();
  SSL_CTX * ctx = SSL_CTX_new(DTLSv1_server_method());
  { // setup server SSL CTX
    SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL:!MD5:!RC4");
    SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
    
    if (!SSL_CTX_use_certificate_file(ctx, "certs/server-cert.pem", SSL_FILETYPE_PEM))
      printf("\nERROR: no certificate found!");
    
    if (!SSL_CTX_use_PrivateKey_file(ctx, "certs/server-key.pem", SSL_FILETYPE_PEM))
      printf("\nERROR: no private key found!");
    
    if (!SSL_CTX_check_private_key (ctx))
      printf("\nERROR: invalid private key!");
    
    /* Client has to authenticate */
    SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, dtls_verify_callback);
    
    SSL_CTX_set_read_ahead(ctx, 1);
    SSL_CTX_set_cookie_generate_cb(ctx, generate_cookie);
    SSL_CTX_set_cookie_verify_cb(ctx, verify_cookie);
  }
  ssl_server * srv = alloc0(sizeof(ssl_server));
  srv->ctx = ctx;
  srv->fd = fd;
  return srv;
}
Exemple #4
0
oct_node * oct_get_super(oct_node * oc){
  static int parent_it = 0;
  if(!oc->super){
    oc->super = alloc0(sizeof(oct_node));
    oc->super->sub[parent_it] = oc;
    parent_it = 7 - parent_it; 
  }
  return oc->super;
}
Exemple #5
0
oct_node * oct_get_sub(oct_node * oc, int idx){
  ASSERT(idx < 8 && idx >= 0);
  if(oc->sub[idx] == NULL){
    oc->sub[idx] = alloc0(sizeof(oct_node));
    oc->sub[idx]->super = oc;
  }

  return oc->sub[idx];
}
 SCCP(Allocator& alloc, InstrGraph* ir)
     : alloc(alloc)
     , ir(ir)
     , ssawork(alloc, ir->size())
     , cfgwork()
     , mark(alloc, ir->size())
     , analyzer(ir) {
     Allocator0 alloc0(alloc);
     eval_counts = new (alloc0) int[ir->size()];
 }
Exemple #7
0
static LibbfHashNode*
libbf_hash_node_new (int key,
                     void* value)
{
  LibbfHashNode *hash_node = alloc0 (LibbfHashNode, 1);
  
  hash_node->key = key;
  hash_node->value = value;
  hash_node->next = NULL;
  
  return hash_node;
}
Exemple #8
0
LibbfHashTable*
libbf_hash_table_new (LibbfDestroyNotify  value_destroy_func)
{
  LibbfHashTable *hash_table;
  
  hash_table = alloc0 (LibbfHashTable, 1);
  hash_table->size               = HASH_TABLE_MIN_SIZE;
  hash_table->nnodes             = 0;
  hash_table->value_destroy_func = value_destroy_func;
  hash_table->nodes              = alloc0 (LibbfHashNode*, hash_table->size);
  
  return hash_table;
}
Exemple #9
0
bool test_connections(){
  web_context * ctx = alloc0(sizeof(web_context));
  for(int i = 0; i < 100; i++){
    char namebuf[100];
    sprintf(namebuf, "__test%i", i);
    add_connection(ctx, namebuf, "aa", "bb");
  }
  ASSERT(get_connection_by_name(ctx, "__test1"));
  remove_connection(ctx, "__test1");
  //ASSERT(get_connection_by_name(ctx, "__test1") == NULL);
  //ASSERT(get_connection_by_name(ctx, "__test14")->connection == (udpc_connection *) 14);
  dealloc(ctx->active_connections);
  dealloc(ctx);
  return true;
}
Exemple #10
0
ssl_server_con * ssl_server_accept(ssl_server_client * scli, int fd){
  BIO_set_fd(SSL_get_rbio(scli->ssl), fd, BIO_NOCLOSE);
  BIO_ctrl(SSL_get_rbio(scli->ssl), BIO_CTRL_DGRAM_SET_CONNECTED, 0, &scli->addr);
  int ret = 0;
  do{ret = SSL_accept(scli->ssl);}
  while(ret == 0);
  if(ret < 0){
    handle_ssl_error(scli->ssl, ret);
    return NULL;
  }
  ASSERT(ret > 0);
  struct timeval timeout;
  timeout.tv_sec = 5;
  timeout.tv_usec = 0;
  BIO_ctrl(SSL_get_rbio(scli->ssl), BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, &timeout);
  ssl_server_con * con = alloc0(sizeof(ssl_server_con));
  con->ssl = scli->ssl;
  return con;
}
Exemple #11
0
ssl_client * ssl_start_client(int fd, struct sockaddr * remote_addr){
  ssl_ensure_initialized();
  SSL_CTX * ctx = SSL_CTX_new(DTLSv1_client_method());
  SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL:!MD5:!RC4");
  
  if (!SSL_CTX_use_certificate_file(ctx, "certs/client-cert.pem", SSL_FILETYPE_PEM))
    printf("\nERROR: no certificate found!");
  
  if (!SSL_CTX_use_PrivateKey_file(ctx, "certs/client-key.pem", SSL_FILETYPE_PEM))
    printf("\nERROR: no private key found!");
  
  if (!SSL_CTX_check_private_key (ctx))
    printf("\nERROR: invalid private key!");
  
  SSL_CTX_set_verify_depth (ctx, 2);
  SSL_CTX_set_read_ahead(ctx, 1);
  
  SSL * ssl = SSL_new(ctx);
  
  // Create BIO, connect and set to already connected.
  BIO * bio = BIO_new_dgram(fd, BIO_CLOSE);
  
  BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_CONNECTED, 0, remote_addr);
  SSL_set_bio(ssl, bio, bio);
  int ret = SSL_connect(ssl);
  if(ret < 0){
    handle_ssl_error(ssl, ret);
  }
  
  {
    struct timeval timeout;
    timeout.tv_sec = 3;
    timeout.tv_usec = 0;
    BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, &timeout);
  }

  ssl_client * cli = alloc0(sizeof(ssl_client));
  cli->ssl = ssl;
  cli->ctx = ctx;
  return cli;
}
Exemple #12
0
i64 get_hash(oct_node n, oct_node bn, game_data * gd){
  
  { // Get hash quick
    bool ok = false;
    i64 hash = _get_hash(n, &ok);
    
    if(ok){
      logd("Found: %p\n", hash);
      return hash;
    }
  }
  { //Hash node not found, build hash tree.
    bool _ok = false;
    i64 hash2 = _get_hash(bn, &_ok);
    logd("init hash: %p\n", hash2);
    ASSERT(_ok);
    bool changed = false;
    while(oct_has_super(bn)){
      bn = oct_get_super(bn);
      hash2 = iron_hash(&hash2, sizeof(hash2));
      logd("next hash: %p\n", hash2);
      changed = true;
    }
    ASSERT(changed);
    hash_node * new_node = alloc0(sizeof(hash_node));
    new_node->type = HASH64;
    new_node->hash = hash2;
    add_entity(bn, (entity_header *) new_node);
    gd->hashed_node = bn;
  }
  { //now it should be possible to find a hash for n
    bool ok = false;
    i64 hash = _get_hash(n, &ok);
    logd("Final: %p\n", hash);
    ASSERT(ok);
    return hash;
  }
}
Exemple #13
0
oct_node * oct_create(){
  return alloc0(sizeof(oct_node));
}
Exemple #14
0
game_data * load_game_data(){
  game_data * gd = alloc0(sizeof(game_data));

  /*texture_asset * tile22 = renderer_load_texture(rnd2, "../racket_octree/tile62.png");
  texture_asset * tile25 = renderer_load_texture(rnd2, "../racket_octree/tile72.png");
  texture_asset * tile3 = renderer_load_texture(rnd2, "../racket_octree/tile2x2.png");
  texture_asset * tile1 = renderer_load_texture(rnd2, "../racket_octree/tile1.png");
  //  texture_asset * guy = renderer_load_texture(rnd2, "../racket_octree/guy2.png");
  //texture_asset * guy = renderer_load_texture(rnd2, "../racket_octree/guy3.png");
  texture_asset * guy = renderer_load_texture(rnd2, "mannie.png");
  texture_asset * guyupper = renderer_clone_texture(guy);
  texture_asset * tile4 = renderer_load_texture(rnd2, "../racket_octree/tile6.png");
  texture_asset * tile5 = renderer_load_texture(rnd2, "../racket_octree/tile8.png");
  texture_asset * rock_small = renderer_load_texture(rnd2, "../racket_octree/rock_small.png");
  texture_asset * tree1 = renderer_load_texture(rnd2, "../racket_octree/tree1.png");
  texture_asset * tree2 = renderer_load_texture(rnd2, "../racket_octree/tree2.png");
  texture_asset * tree3 = renderer_load_texture(rnd2, "../racket_octree/tree3.png");
  texture_asset * foilage = renderer_load_texture(rnd2, "../racket_octree/foilage.png");
  texture_asset * fireplace = renderer_load_texture(rnd2, "../racket_octree/fireplace.png");
  texture_asset * buggy = renderer_load_texture(rnd2, "../racket_octree/buggy.png");
  texture_asset * cat = renderer_load_texture(rnd2, "../racket_octree/cat.png");
  texture_asset * select_cube = renderer_load_texture(rnd2, "../racket_octree/select_cube.png");
  texture_asset_set_offset(tile22, vec2mk(0, -42));
  texture_asset_set_offset(tile25, vec2mk(0, -42));
  texture_asset_set_offset(tile5, vec2mk(0, -42));
  texture_asset_set_offset(tile4, vec2mk(0, -42));  
  texture_asset_set_offset(tile3, vec2mk(0, - 77));
  texture_asset_set_offset(tile1, vec2mk(0, -23));
  texture_asset_set_offset(rock_small, vec2mk(0, -19));
  texture_asset_set_offset(guy, vec2mk(0, -70));
  texture_asset_set_offset(guyupper, vec2mk(0, -42));
  texture_asset_set_offset(buggy, vec2mk(0, -42));
  texture_asset_set_offset(cat, vec2mk(0, -42));
  texture_asset_set_offset(select_cube, vec2mk(0, -42));
  texture_asset_set_size(guyupper, (vec2i){40, 40});
  texture_asset_set_offset(tree1, vec2mk(0, -42));
  texture_asset_set_offset(tree2, vec2mk(0, -42));
  texture_asset_set_offset(tree3, vec2mk(0, -42));
  texture_asset_set_offset(foilage, vec2mk(0, -42));
  texture_asset_set_offset(fireplace, vec2mk(0, -42));
  game_data_add_tile(gd, tile22);
  game_data_add_tile(gd, tile25);
  game_data_add_tile(gd, tile3);
  game_data_add_tile(gd, tile1);
  game_data_add_tile(gd, tile4);
  game_data_add_tile(gd, tile5);
  game_data_add_tile(gd, rock_small);
  game_data_add_tile(gd, tree1);
  game_data_add_tile(gd, tree2);
  game_data_add_tile(gd, tree3);
  game_data_add_tile(gd, foilage);
  game_data_add_sprite(gd, guy);
  game_data_add_sprite(gd, guyupper);
  game_data_add_sprite(gd, fireplace);
  game_data_add_sprite(gd, buggy);
  game_data_add_sprite(gd, cat);
  game_data_add_sprite(gd, select_cube);*/
  gd->loaded_nodes = ht_create(1024, sizeof(oct_node), 4);
  gd->enemies = ht_create(1024, 8, 4);
  return gd;
}
Exemple #15
0
image * image_new(int width, int height, image_pixel_type type){
  void * buffer = alloc0(width * height * image_pixel_type_size(type));
  image _pt = {.type = type, .width = width, .height = height, .buffer = buffer };
  return iron_clone(&_pt, sizeof(_pt));
}
Exemple #16
0
void* libbf_compiler_dynalloc_init(ExecutableCodeData_t* executableCodeData,
                                  OFFSET_t min_delta_offset,
                                  OFFSET_t max_delta_offset,
                                  int sizeof_my_type,
                                  void* executable_code,
                                  int size_of_executable_code,
                                  void* init_data_ptr,
                                  int count_active_pages,
                                  AdvancedOptions_t* options)
{
#if !defined(WIN32)
  struct sigaction action;
  sigset_t block_mask;
#endif
  int ret;
  
  long pagesize = libbf_getpagesize();
  
  DynAllocDesc* dynAllocDesc = alloc0(DynAllocDesc, 1); 
  void* mem;
  int reserved_size;
    
  int count_low_pages = (min_delta_offset * sizeof_my_type + pagesize - 1) / pagesize; /* ceil rounding */
  int count_high_pages = (max_delta_offset * sizeof_my_type + pagesize - 1) / pagesize; /* ceil rounding */
  if (count_active_pages <= 0)
    count_active_pages = NB_MIN_ACTIVE_PAGES; /* number of initial regular pages */
  
  reserved_size = (count_low_pages + count_active_pages + count_high_pages) * pagesize;
  mem = libbf_alloc_aligned(pagesize, reserved_size);
  if (mem == NULL) fatal("alloc_aligned failed");
  memset(mem, 0, reserved_size);
  
  if (init_data_ptr)
    memcpy((void*)((long)mem + count_low_pages * pagesize), init_data_ptr, count_active_pages * pagesize);
  
  dynAllocDesc->executableCodeData = *executableCodeData;
  dynAllocDesc->executableCodeData.input_output_data = dynAllocDesc;
  dynAllocDesc->executableCodeData.base_data_ptr = (void*)((long)mem + count_low_pages * pagesize);
  dynAllocDesc->signature1 = SIGNATURE_1;
  dynAllocDesc->signature2 = SIGNATURE_2;
  dynAllocDesc->sizeof_elt = sizeof_my_type;
  dynAllocDesc->increase_from_low = 0;
  dynAllocDesc->increase_from_high = 0;
  dynAllocDesc->current_mem = mem;
  dynAllocDesc->count_low_pages = count_low_pages;
  dynAllocDesc->count_active_pages = count_active_pages;
  dynAllocDesc->count_high_pages = count_high_pages;
  dynAllocDesc->max_total_pages = -1; /* unlimited */
  dynAllocDesc->current_executable_code = executable_code;
  dynAllocDesc->size_of_executable_code = size_of_executable_code;
  dynAllocDesc->options = options;
  dynAllocDesc->isInterrupted = FALSE;
  dynAllocDesc->sigalarm_set = FALSE;
  dynAllocDesc->sigalarm_active = FALSE;
  
#if !defined(WIN32)
  action.sa_sigaction = libbf_compiler_dynalloc_handler;
  sigemptyset(&(action.sa_mask));
  action.sa_flags = SA_SIGINFO;
  sigemptyset(&block_mask);
  sigaddset(&block_mask, SIGALRM);
  action.sa_mask = block_mask;

  ret = sigaction(SIGBUS, &action, &dynAllocDesc->old_action_sigbus);
  if (ret != 0) fatal("sigaction failed");
  
  ret = sigaction(SIGSEGV, &action, &dynAllocDesc->old_action_sigsegv);
  if (ret != 0) fatal("sigaction failed");
#endif

#if defined(WIN32)
  if (options && options->stop_after_ms > 0)
  {
    dynAllocDesc->hasStarted = FALSE;
    dynAllocDesc->start_time = GetTickCount();
    _beginthreadex(NULL, 0, libbf_compiler_timer_handler_win32, dynAllocDesc, 0, 0);
    while(dynAllocDesc->hasStarted == FALSE) Sleep(100);
  }
#elif (defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && (defined(__i386__) || defined(__x86_64__))
  if (options && (options->stop_after_ms > 0 || options->average_load > 0))
  {
    struct itimerval tv;
    tv.it_interval.tv_sec = 0;
    tv.it_interval.tv_usec = 0;
    if (options->average_load == 0)
    {
      tv.it_value.tv_sec = options->stop_after_ms / 1000;
      tv.it_value.tv_usec = (options->stop_after_ms % 1000) * 1000;
    }
    else
    {
      tv.it_value.tv_sec = 0;
      tv.it_value.tv_usec = TIMER_RESOLUTION;
    }
    setitimer(ITIMER_REAL, &tv, NULL);
    action.sa_sigaction = libbf_compiler_timer_handler;
    sigemptyset(&(action.sa_mask));
    action.sa_flags = SA_SIGINFO;
      
    memcpy(&dynAllocDesc->saved_action_sigalrm, &action, sizeof(struct sigaction));
    
    ret = sigaction(SIGALRM, &action, &dynAllocDesc->old_action_sigalrm);
    if (ret != 0) fatal("sigaction failed");
      
    gettimeofday(&dynAllocDesc->start_tv, NULL);
    
    dynAllocDesc->sigalarm_set = TRUE;
    dynAllocDesc->sigalarm_active = TRUE;
  }
#endif

  /* Lock low and high pages, upper reserved page and checker description page */
  ret = libbf_mprotect(mem, pagesize * count_low_pages, PROT_NONE);
  ret |= libbf_mprotect((void*)((long)mem + (count_low_pages + count_active_pages) * pagesize),
                        (count_high_pages) * pagesize, PROT_NONE);
  if (ret != 0) fatal("mprotect failed");
  
  return dynAllocDesc;
}
static void CONCAT(CONCAT(LIBBF_INTERPRETER_OPTIMIZER_RADIX, internal_), MY_TYPE_T_STR)
             (OptimizationUnit* code, OFFSET_t min_delta_offset, OFFSET_t max_delta_offset)
{
#if defined(GOTO_ADDR_SUPPORTED)
  DECLARE_LABEL(BF_AFFECT_EXPR);
  DECLARE_LABEL(BF_INC_DATA_PTR);
  DECLARE_LABEL(BF_PRINT_DATA);
  DECLARE_LABEL(BF_READ_DATA);
  DECLARE_LABEL(BF_WHILE_DATA);
  DECLARE_LABEL(BF_END_WHILE);
  DECLARE_LABEL(BF_END);
#ifndef PROFILE  
  DECLARE_LABEL(BF_SET_CST);
  DECLARE_LABEL(BF_SET_CST_0);
  DECLARE_LABEL(BF_INC_CST);
  DECLARE_LABEL(BF_INC_CST_1);
  DECLARE_LABEL(BF_INC_CST_M_1);
  DECLARE_LABEL(BF_SET_DATA);
  DECLARE_LABEL(BF_INC_DATA);
  DECLARE_LABEL(BF_DEC_DATA);
  DECLARE_LABEL(BF_INC_CST_MUL_DATA);
  DECLARE_LABEL(BF_INC_CST_ADD_DATA);
  DECLARE_LABEL(BF_INC_DATA_MUL_DATA);
  DECLARE_LABEL(BF_WHILE_INC_DATA_PTR);
#ifdef USE_END_WHILE_INC_DATA_PTR
  DECLARE_LABEL(BF_END_WHILE_INC_DATA_PTR);
#endif
#else
  DECLARE_LABEL(BF_NOP);
#endif  
  DECLARE_LABEL(BF_DYNALLOC_REALLOC_NEEDED);

#ifdef __cplusplus
  static const void* tab_addr[BF_COUNT_INSTR];
#else
  static const void* tab_addr[BF_COUNT_INSTR] =
  {
#endif
    FILL_TAB_ADDR(BF_AFFECT_EXPR)
    FILL_TAB_ADDR(BF_INC_DATA_PTR)
    FILL_TAB_ADDR(BF_PRINT_DATA)
    FILL_TAB_ADDR(BF_READ_DATA)
    FILL_TAB_ADDR(BF_WHILE_DATA)
    FILL_TAB_ADDR(BF_END_WHILE)
    FILL_TAB_ADDR(BF_END)
#ifndef PROFILE      
    FILL_TAB_ADDR(BF_SET_CST)
    FILL_TAB_ADDR(BF_SET_CST_0)
    FILL_TAB_ADDR(BF_INC_CST)
    FILL_TAB_ADDR(BF_INC_CST_1)
    FILL_TAB_ADDR(BF_INC_CST_M_1)
    FILL_TAB_ADDR(BF_SET_DATA)
    FILL_TAB_ADDR(BF_INC_DATA)
    FILL_TAB_ADDR(BF_DEC_DATA)
    FILL_TAB_ADDR(BF_INC_CST_MUL_DATA)
    FILL_TAB_ADDR(BF_INC_CST_ADD_DATA)
    FILL_TAB_ADDR(BF_INC_DATA_MUL_DATA)
    FILL_TAB_ADDR(BF_WHILE_INC_DATA_PTR)
#ifdef USE_END_WHILE_INC_DATA_PTR
    FILL_TAB_ADDR(BF_END_WHILE_INC_DATA_PTR)
#endif
#else
    FILL_TAB_ADDR(BF_NOP)
#endif  
    FILL_TAB_ADDR(BF_DYNALLOC_REALLOC_NEEDED)
#ifndef __cplusplus
  };
#endif
#endif

  void* void_data_ptr;
#if defined(DEBUG_INTERPRETER) || defined(__CYGWIN__) || defined(PROFILE)
  void* ori_data_ptr;
  unsigned MY_TYPE_T* data_ptr;
  void* current_code_ptr;
#else  
  void* old_action;
  register unsigned MY_TYPE_T* data_ptr;
#endif
  register OptimizationUnit* code_ptr;
  
#ifdef PROFILE
  long long count_instr = 0;
#endif
  register OFFSET_t offset;
  
#if defined(GOTO_ADDR_SUPPORTED)
  libbf_optimized_code_resolve_interpeter_addr(code, tab_addr);
#endif

#if defined(DEBUG_INTERPRETER) || defined(__CYGWIN__) || defined(PROFILE)
  void_data_ptr = alloc0(MY_TYPE_T, 32768);
  ori_data_ptr = void_data_ptr;
  data_ptr = ((unsigned MY_TYPE_T*)void_data_ptr) + 1024;
  void_data_ptr = data_ptr;
  current_code_ptr = NULL;
#else  
  libbf_interpreter_dynalloc_init(min_delta_offset,
                             max_delta_offset,
                             sizeof(MY_TYPE_T),
                             code,
#if defined(GOTO_ADDR_SUPPORTED)
                             tab_addr[BF_DYNALLOC_REALLOC_NEEDED],
#else
                             NULL,
#endif
                             &old_action,
                             &void_data_ptr);
  data_ptr = (unsigned MY_TYPE_T*)void_data_ptr;
#endif
  code_ptr = code;

#if defined(GOTO_ADDR_SUPPORTED)
  /* Start up execution ! */
  SAFE_JUMP_TO(code_ptr->ou_interpreter_addr); /* safe jump to begin... */
#else
  while(1)
  {
    switch(code_ptr->ou_instr)
    {
#endif
LABEL(BF_AFFECT_EXPR)
  DEAL_INSTR();
  data_ptr[offset] = CONCAT(libbf_compute_expr_,MY_TYPE_T_STR)(code_ptr->ou_expr, data_ptr);
  SAFE_NEXT_INSTR(); /* safe because of function call */

LABEL(BF_INC_DATA_PTR)
  DEAL_INSTR();
  data_ptr += offset;
  NEXT_INSTR();

LABEL(BF_PRINT_DATA)
  DEAL_INSTR();
  putchar(data_ptr[offset]);
  SAFE_NEXT_INSTR(); /* safe because of function call */

LABEL(BF_READ_DATA)
  DEAL_INSTR();
  data_ptr[offset] = getchar();
  SAFE_NEXT_INSTR(); /* safe because of function call */

LABEL(BF_WHILE_DATA)
  DEAL_INSTR();
  if (data_ptr[offset] == 0)
  {
    code_ptr = code_ptr->ou_jump_to;
    JUMP_TO(code_ptr->ou_interpreter_addr);
  }
  NEXT_INSTR();

LABEL(BF_END_WHILE)
  DEAL_INSTR();
  if (data_ptr[offset] != 0)
  {
    code_ptr = code_ptr->ou_jump_to;
    JUMP_TO(code_ptr->ou_interpreter_addr);
  }
  NEXT_INSTR();

#ifndef PROFILE
/* Very common subcases of BF_AFFECT_EXPR, so much more efficient to create */
/* dedicated opcodes */

LABEL(BF_SET_CST)
  DEAL_INSTR();
  data_ptr[offset] = code_ptr->ou_constant;
  NEXT_INSTR();

LABEL(BF_SET_CST_0)
  DEAL_INSTR();
  data_ptr[offset] = 0;
  NEXT_INSTR();

LABEL(BF_INC_CST)
  DEAL_INSTR();
  data_ptr[offset] += code_ptr->ou_constant;
  NEXT_INSTR();

LABEL(BF_INC_CST_1)
  DEAL_INSTR();
  data_ptr[offset] ++;
  NEXT_INSTR();

LABEL(BF_INC_CST_M_1)
  DEAL_INSTR();
  data_ptr[offset] --;
  NEXT_INSTR();

LABEL(BF_SET_DATA)
  DEAL_INSTR();
  data_ptr[offset] = data_ptr[code_ptr->ou_offset2];
  NEXT_INSTR();

LABEL(BF_INC_DATA)
  DEAL_INSTR();
  data_ptr[offset] += data_ptr[code_ptr->ou_offset2];
  NEXT_INSTR();

LABEL(BF_DEC_DATA)
  DEAL_INSTR();
  data_ptr[offset] -= data_ptr[code_ptr->ou_offset2];
  NEXT_INSTR();

LABEL(BF_INC_CST_ADD_DATA)
  DEAL_INSTR();
  data_ptr[offset] += code_ptr->ou_constant + data_ptr[code_ptr->ou_offset2];
  NEXT_INSTR();

LABEL(BF_INC_CST_MUL_DATA)
  DEAL_INSTR();
  data_ptr[offset] += code_ptr->ou_constant * data_ptr[code_ptr->ou_offset2];
  NEXT_INSTR();

LABEL(BF_INC_DATA_MUL_DATA)
  DEAL_INSTR();
  data_ptr[offset] += data_ptr[code_ptr->ou_offset2] * data_ptr[code_ptr->ou_offset3];
  NEXT_INSTR();

#ifdef USE_END_WHILE_INC_DATA_PTR
LABEL(BF_END_WHILE_INC_DATA_PTR)
  DEAL_INSTR();
  data_ptr += code_ptr->ou_offset2;
  if (data_ptr[offset] != 0)
  {
    code_ptr = code_ptr->ou_jump_to;
    JUMP_TO(code_ptr->ou_interpreter_addr);
  }
  NEXT_INSTR();
#endif

#define INC_PTR_WITH_BYTES(ptr, bytes)   ptr = (unsigned MY_TYPE_T*)(((long)ptr) + bytes)

LABEL(BF_WHILE_INC_DATA_PTR)
{
  register int offset2_bytes;
  DEAL_INSTR();
  offset2_bytes = sizeof(MY_TYPE_T) * code_ptr->ou_offset2;
  data_ptr += offset;
  while (*data_ptr)
  {
    INC_PTR_WITH_BYTES(data_ptr, offset2_bytes);
  }
  data_ptr -= offset;
  SAFE_NEXT_INSTR();
}
#else
LABEL(BF_NOP)
  DEAL_INSTR();
  NEXT_INSTR();

#endif

LABEL(BF_END)
#if !(defined(DEBUG_INTERPRETER)|| defined(__CYGWIN__) || defined(PROFILE))
  libbf_interpreter_dynalloc_end(old_action, data_ptr);
#else
  free(ori_data_ptr);
#endif
  #ifdef PROFILE
    libbf_dump_profiled_code(code);
    fprintf(stderr, "normal exit : %lld instructions executed\n", count_instr);
  #endif
  return;

LABEL(BF_DYNALLOC_REALLOC_NEEDED)
{
  long shift = libbf_interpreter_dynalloc_realloc(data_ptr);
  data_ptr += shift;
  if (shift == 0)
  {
    #if !(defined(DEBUG_INTERPRETER)|| defined(__CYGWIN__) || defined(PROFILE))
      libbf_interpreter_dynalloc_end(old_action, data_ptr);
    #else
      free(ori_data_ptr);
    #endif
    #ifdef PROFILE
      fprintf(stderr, "abnormal exit (not enough memory) : %lld instructions executed\n", count_instr);
    #endif
    return;
  }
  SAFE_JUMP_TO(code_ptr->ou_interpreter_addr); /* safe because of function call */
}

#if !defined(GOTO_ADDR_SUPPORTED)
      default: SHOULDNT_HAPPEN();
    }
  }
#endif

}