void lts_set_type(lts_t lts,LTS_TYPE type){ uint32_t i,j; if (lts->type==type) return; /* no type change */ /* first change to LTS_LIST */ switch(lts->type){ case LTS_LIST: lts->begin=(u_int32_t*)RTmalloc(sizeof(u_int32_t)*(lts->states+1)); break; case LTS_BLOCK: lts->src=(u_int32_t*)RTmalloc(sizeof(u_int32_t)*(lts->transitions)); for(i=0;i<lts->states;i++){ for(j=lts->begin[i];j<lts->begin[i+1];j++){ lts->src[j]=i; } } break; case LTS_BLOCK_INV: lts->dest=(u_int32_t*)RTmalloc(sizeof(u_int32_t)*(lts->transitions)); for(i=0;i<lts->states;i++){ for(j=lts->begin[i];j<lts->begin[i+1];j++){ lts->dest[j]=i; } } break; } // MEMSTAT_CHECK; /* then change to requried type */ lts->type=type; switch(type){ case LTS_LIST: free(lts->begin); lts->begin=NULL; return; case LTS_BLOCK: build_block(lts->states,lts->transitions,lts->begin,lts->src,lts->label,lts->dest); free(lts->src); lts->src=NULL; return; case LTS_BLOCK_INV: build_block(lts->states,lts->transitions,lts->begin,lts->dest,lts->label,lts->src); free(lts->dest); lts->dest=NULL; return; } }
static ssize_t __qwrite(struct queue *q, void *vp, size_t len, int mem_flags, int qio_flags) { size_t n, sofar; struct block *b; uint8_t *p = vp; void *ext_buf; sofar = 0; do { n = len - sofar; /* This is 64K, the max amount per single block. Still a good value? */ if (n > Maxatomic) n = Maxatomic; b = build_block(p + sofar, n, mem_flags); if (!b) break; if (__qbwrite(q, b, qio_flags) < 0) break; sofar += n; } while ((sofar < len) && (q->state & Qmsg) == 0); return sofar; }
tree poplevel (int keep, int functionbody) { /* Points to a BLOCK tree node. This is the BLOCK node constructed for the binding level that we are about to exit and which is returned by this routine. */ tree block_node = NULL_TREE; tree decl_chain = current_binding_level->names; tree subblock_chain = current_binding_level->blocks; tree subblock_node; /* If there were any declarations in the current binding level, or if this binding level is a function body, or if there are any nested blocks then create a BLOCK node to record them for the life of this function. */ if (keep || functionbody) block_node = build_block (keep ? decl_chain : 0, subblock_chain, 0, 0); /* Record the BLOCK node just built as the subblock its enclosing scope. */ for (subblock_node = subblock_chain; subblock_node; subblock_node = BLOCK_CHAIN (subblock_node)) BLOCK_SUPERCONTEXT (subblock_node) = block_node; /* Clear out the meanings of the local variables of this level. */ for (subblock_node = decl_chain; subblock_node; subblock_node = DECL_CHAIN (subblock_node)) if (DECL_NAME (subblock_node) != 0) /* If the identifier was used or addressed via a local extern decl, don't forget that fact. */ if (DECL_EXTERNAL (subblock_node)) { if (TREE_USED (subblock_node)) TREE_USED (DECL_NAME (subblock_node)) = 1; if (TREE_ADDRESSABLE (subblock_node)) TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (subblock_node)) = 1; } /* Pop the current level. */ current_binding_level = current_binding_level->level_chain; if (functionbody) /* This is the top level block of a function. */ DECL_INITIAL (current_function_decl) = block_node; else if (current_binding_level == global_binding_level) /* When using gfc_start_block/gfc_finish_block from middle-end hooks, don't add newly created BLOCKs as subblocks of global_binding_level. */ ; else if (block_node) { current_binding_level->blocks = block_chainon (current_binding_level->blocks, block_node); } /* If we did not make a block for the level just exited, any blocks made for inner levels (since they cannot be recorded as subblocks in that level) must be carried forward so they will later become subblocks of something else. */ else if (subblock_chain) current_binding_level->blocks = block_chainon (current_binding_level->blocks, subblock_chain); if (block_node) TREE_USED (block_node) = 1; return block_node; }