X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fwebcc.git;a=blobdiff_plain;f=src%2Fapc%2Firmem.c;fp=src%2Fapc%2Firmem.c;h=415399cb5a62f077f5bdc0be2058d05666940f5c;hp=3716d59f4f2c55a8428ccbde973096ebdf172f77;hb=3d03d8941abeb2a78f3334098a7bd09285023da8;hpb=cc4724ed8e52fd6de475f869c5e65ba0d9c82f03 diff --git a/src/apc/irmem.c b/src/apc/irmem.c index 3716d59..415399c 100644 --- a/src/apc/irmem.c +++ b/src/apc/irmem.c @@ -11,7 +11,7 @@ struct cdat* alloc_cdat(void); struct odat* alloc_odat(void); -void +struct vdat* alloc_vdat(void); struct link* alloc_link(void); @@ -23,6 +23,8 @@ struct odat* curr_odat(void); struct vdat* curr_vdat(void); +struct map* +curr_map(void); struct set* curr_set(void); struct ref* @@ -41,7 +43,7 @@ struct chunk_stack void* dsp[MAX_CHUNKS]; //dat stack pointer (per chunk) int chunk_size; //size of a chunk (including its forfeited page) int max_dats; //number of dats per chunk for this stack -} ocs, vcs, ccs, rcs, lcs, pcs; //odat, vdat, and cdat, ref, link, post stacks +} ocs, vcs, ccs, rcs, lcs, pcs, mcs; //odat, vdat, cdat,map, ref, link, post stacks //type safety handled by macro expansion (do not call these directly from code, make dependent macros for access to these) #define CHUNKS_LEN(STACK) ((STACK).csp - (STACK).chunks) @@ -80,6 +82,11 @@ struct chunk_stack #define CDAT_FULL() (DATA_FULL(ccs, struct cdat)) #define CDAT_ALLOC() (ALLOC_DAT(ccs, struct cdat)) #define CCS_FULL() (CHUNKS_FULL(ccs)) +#define INIT_MAP() (INIT_STACK(mcs, struct map)) +#define CURRENT_MAP() (CURRENT_DATP(mcs, struct map)) +#define MAP_FULL() (DATA_FULL(mcs, struct map)) +#define MAP_ALLOC() (ALLOC_DAT(mcs, struct map)) +#define MCS_FULL() (CHUNKS_FULL(mcs)) #define INIT_LINK() (INIT_STACK(lcs, struct link)) #define CURRENT_LINK() (CURRENT_DATP(lcs,struct link)) #define LDAT_FULL() (DATA_FULL(lcs, struct link)) @@ -98,10 +105,10 @@ struct chunk_stack #define RCS_FULL() (CHUNKS_FULL(rcs)) //Metadata #define CURRENT_SET() (CURRENT_CDAT()->set_list[CURRENT_CDAT()->num_sets]) -#define CURRENT_MODEL() (CURRENT_VDAT()->model_list[CURRENT_VDAT()->num_models]) +//#define CURRENT_QUAD() (CURRENT_MAP()->quad_list[CURRENT_MAP()->num_quads]) +//#define CURRENT_MODEL() (CURRENT_VDAT()->model_list[CURRENT_VDAT()->num_models]) -#define CURR_QUAD (CURR_ODAT->quad_file) long pagesize; @@ -114,8 +121,10 @@ int num_odats = 0; int num_vdats = 0; +int num_maps = 0; + int num_refs = 0; -uint64_t ss_ref_id = 0x00FFFFFF; /* system space for ref_ids */ +int ss_ref_id = 0x0FFFFFFF; /* system space for ref_ids */ int num_posts = 0; @@ -133,10 +142,12 @@ ir_init() INIT_CDAT(); *cdat_stackp = CURRENT_CDAT(); + memmove((*cdat_stackp)->name, root, 32); INIT_ODAT(); INIT_VDAT(); + INIT_MAP(); INIT_LINK(); INIT_REF(); INIT_POST(); @@ -201,7 +212,7 @@ struct odat* alloc_odat () { - num_odats++; + num_odats++; if(ODAT_FULL()) { if(!OCS_FULL()) { fprintf(stderr, "You have allocated to many (%d) odats ", num_odats); @@ -216,7 +227,7 @@ alloc_odat return CURRENT_ODAT(); } -void +struct vdat* alloc_vdat () { num_vdats++; @@ -230,8 +241,29 @@ alloc_vdat } else VDAT_ALLOC(); + + return CURRENT_VDAT(); +} + +struct map* +alloc_map +() +{ num_maps++; + if(MAP_FULL()) + { if(!MCS_FULL()) + { fprintf(stderr, "You have allocated to many (%d) maps ", num_maps); + exit(EXIT_FAILURE); + } + else + CSP_PUSH(mcs); + } + else + MAP_ALLOC(); + + return CURRENT_MAP(); } + struct link* alloc_link () @@ -322,9 +354,21 @@ curr_ref { return CURRENT_REF(); } -struct model* -curr_model +struct map* +curr_map () { - return &CURRENT_MODEL(); + return CURRENT_MAP(); } +/* struct quad* */ +/* curr_quad */ +/* () */ +/* { */ +/* return &CURRENT_QUAD(); */ +/* } */ +/* struct model* */ +/* curr_model */ +/* () */ +/* { */ +/* return &CURRENT_MODEL(); */ +/* } */