/* Make a db.h that will be link-time compatible with Sleepycat's Berkeley DB. */ #include #include #include #include #include void print_dbtype(void) { /* DBTYPE is mentioned by db_open.html */ printf("typedef enum {\n"); printf(" DB_BTREE=%d\n", DB_BTREE); printf("} DBTYPE;\n"); } //#define DECL_LIMIT 100 struct fieldinfo { char *decl; unsigned int off; unsigned int size; }; #include "sample_offsets_32.h" #include "sample_offsets_64.h" void print_struct (const char *structname, int need_internal, struct fieldinfo *fields32, struct fieldinfo *fields64, unsigned int N) { unsigned int i; unsigned int current_32 = 0; unsigned int current_64 = 0; int dummy_counter=0; int did_toku_internal=0; // int total32 = fields32[N-1].size; // int total64 = fields32[N-1].size; printf("struct __toku_%s {\n", structname); for (i=0; i current_32 || this_64 > current_64) { unsigned int diff32 = this_32-current_32; unsigned int diff64 = this_64-current_64; assert(this_32 > current_32 && this_64 > current_64); if (diff32!=diff64) { unsigned int diff = diff64-diff32; unsigned int n_dummys = diff/4; if (need_internal && !did_toku_internal) { printf(" struct __toku_%s_internal *i;\n", structname); n_dummys--; did_toku_internal=1; } if (n_dummys>0) printf(" void* 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); } current_32 = this_32; current_64 = this_64; } if (this_32