From b2193274eba2e40046f5c1d4ab557796c6a2bce1 Mon Sep 17 00:00:00 2001 From: "Bradley C. Kuszmaul" Date: Wed, 5 Sep 2007 20:16:26 +0000 Subject: [PATCH] key_range lsn txn_active git-svn-id: file:///svn/tokudb@264 c7de825b-a66e-492c-adef-691d508d4ae1 --- buildheader/make_db_h.c | 27 +++++++++++++++++++++++---- buildheader/sample_offsets.c | 22 ++++++++++++++++++++++ buildheader/sample_offsets_32.h | 15 +++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/buildheader/make_db_h.c b/buildheader/make_db_h.c index c377e5d38c9..a357747df73 100644 --- a/buildheader/make_db_h.c +++ b/buildheader/make_db_h.c @@ -34,7 +34,7 @@ void print_struct (const char *structname, int need_internal, struct fieldinfo * // int total32 = fields32[N-1].size; // int total64 = fields32[N-1].size; printf("struct __toku_%s {\n", structname); - for (i=0; i0) printf(" void* dummy%d[%d];\n", dummy_counter++, n_dummys); + if (n_dummys>0) printf(" void* __toku_dummy%d[%d];\n", dummy_counter++, n_dummys); diff64-=diff*2; diff32-=diff; } assert(diff32==diff64); if (diff32>0) { - printf(" char dummy%d[%d];\n", dummy_counter++, diff32); + printf(" char __toku_dummy%d[%d];\n", dummy_counter++, diff32); } current_32 = this_32; current_64 = this_64; @@ -75,8 +75,27 @@ void print_struct (const char *structname, int need_internal, struct fieldinfo * current_32 += fields32[i].size; current_64 += fields64[i].size; } - assert(did_toku_internal || !need_internal); + { + unsigned int this_32 = fields32[N-1].off; + unsigned int this_64 = fields64[N-1].off; + unsigned int diff32 = this_32-current_32; + unsigned int diff64 = this_64-current_64; + if (diff32>0 && diff320) { + printf(" char __toku_dummy%d[%d]; /* Padding at the end */ \n", dummy_counter++, diff32); + diff64-=diff32; + diff32=0; + } + if (diff64>0) printf(" /* %d more bytes of alignment in the 64-bit case. */\n", diff64); + assert(diff64<8); /* there could be a few left from alignment. */ + } printf("};\n"); + assert(did_toku_internal || !need_internal); } int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { diff --git a/buildheader/sample_offsets.c b/buildheader/sample_offsets.c index ec3bbc39937..87a022bc83e 100644 --- a/buildheader/sample_offsets.c +++ b/buildheader/sample_offsets.c @@ -116,10 +116,29 @@ void sample_db_env_offsets (void) { STRUCT_SETUP(DB_ENV, set_verbose, "int (*%s) (DB_ENV *, u_int32_t, int)"); STRUCT_SETUP(DB_ENV, txn_checkpoint, "int (*%s) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t)"); STRUCT_SETUP(DB_ENV, txn_stat, "int (*%s) (DB_ENV *, DB_TXN_STAT **, u_int32_t)"); + STRUCT_SETUP(DB_ENV, txn_begin, "int (*%s) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t)"); sort_and_dump_fields("db_env", sizeof(DB_ENV)); } +void sample_db_key_range_offsets (void) { + field_counter=0; + STRUCT_SETUP(DB_KEY_RANGE, less, "double %s"); + STRUCT_SETUP(DB_KEY_RANGE, equal, "double %s"); + STRUCT_SETUP(DB_KEY_RANGE, greater, "double %s"); + sort_and_dump_fields("db_key_range", sizeof(DB_ENV)); +} +void sample_db_lsn_offsets (void) { + field_counter=0; + sort_and_dump_fields("db_lsn", sizeof(DB_LSN)); +} + +void sample_db_txn_active_offsets (void) { + field_counter=0; + STRUCT_SETUP(DB_TXN_ACTIVE, lsn, "DB_LSN %s"); + STRUCT_SETUP(DB_TXN_ACTIVE, txnid, "u_int32_t %s"); + sort_and_dump_fields("db_txn_active", sizeof(DB_TXN_ACTIVE)); +} int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { open_file(); @@ -129,5 +148,8 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un sample_db_txn_offsets(); sample_dbc_offsets(); sample_db_env_offsets(); + sample_db_key_range_offsets(); + sample_db_lsn_offsets(); + sample_db_txn_active_offsets(); return 0; } diff --git a/buildheader/sample_offsets_32.h b/buildheader/sample_offsets_32.h index 16ed91b32e7..caf12b58b96 100644 --- a/buildheader/sample_offsets_32.h +++ b/buildheader/sample_offsets_32.h @@ -53,7 +53,22 @@ struct fieldinfo db_env_fields32[] = { {"int (*set_lk_detect) (DB_ENV *, u_int32_t)", 392, 4}, {"int (*set_lk_max) (DB_ENV *, u_int32_t)", 396, 4}, {"int (*set_cachesize) (DB_ENV *, u_int32_t, u_int32_t, int)", 460, 4}, + {"int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t)", 548, 4}, {"int (*txn_checkpoint) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t)", 552, 4}, {"int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, u_int32_t)", 564, 4}, {0, 584, 584} /* size of whole struct */ }; +struct fieldinfo db_key_range_fields32[] = { + {"double less", 0, 8}, + {"double equal", 8, 8}, + {"double greater", 16, 8}, + {0, 584, 584} /* size of whole struct */ +}; +struct fieldinfo db_lsn_fields32[] = { + {0, 8, 8} /* size of whole struct */ +}; +struct fieldinfo db_txn_active_fields32[] = { + {"u_int32_t txnid", 0, 4}, + {"DB_LSN lsn", 8, 8}, + {0, 16, 16} /* size of whole struct */ +};