From e3cd1f9826e6fbffa750a4bdaaad07bd66463faf Mon Sep 17 00:00:00 2001 From: "Bradley C. Kuszmaul" Date: Wed, 5 Sep 2007 17:40:16 +0000 Subject: [PATCH] Do dbt git-svn-id: file:///svn/tokudb@247 c7de825b-a66e-492c-adef-691d508d4ae1 --- buildheader/sample_offsets.c | 74 ++++++++++++++++++++------------- buildheader/sample_offsets_32.h | 27 +++++++----- 2 files changed, 61 insertions(+), 40 deletions(-) diff --git a/buildheader/sample_offsets.c b/buildheader/sample_offsets.c index 1157a59cefd..86bb89d8619 100644 --- a/buildheader/sample_offsets.c +++ b/buildheader/sample_offsets.c @@ -1,21 +1,19 @@ /* Make a db.h that will be link-time compatible with Sleepycat's Berkeley DB. */ -#include +#include "../../mysql-5.0.27/mysql-5.0.27/bdb/build_win32/db.h" #include #include #include -DB db_dummy; - #define DECL_LIMIT 100 #define FIELD_LIMIT 100 struct fieldinfo { char decl[DECL_LIMIT]; unsigned int off; unsigned int size; -} db_fields[FIELD_LIMIT]; -int db_field_counter=0; +} fields[FIELD_LIMIT]; +int field_counter=0; int compare_fields (const void *av, const void *bv) { @@ -26,10 +24,11 @@ int compare_fields (const void *av, const void *bv) { return 0; } -#define DB_STRUCT_SETUP(name, fstring) ({ snprintf(db_fields[db_field_counter].decl, DECL_LIMIT, fstring, #name); \ - db_fields[db_field_counter].off = offsetof(DB, name); \ - db_fields[db_field_counter].size = sizeof(db_dummy.name); \ - db_field_counter++; }) +#define STRUCT_SETUP(typ, name, fstring) ({ snprintf(fields[field_counter].decl, DECL_LIMIT, fstring, #name); \ + fields[field_counter].off = __builtin_offsetof(typ, name); \ + { typ dummy; \ + fields[field_counter].size = sizeof(dummy.name); } \ + field_counter++; }) FILE *outf; void open_file (void) { @@ -40,34 +39,49 @@ void open_file (void) { } -void sample_offsets (void) { +void sort_and_dump_fields (const char *structname) { int i; - /* Do these in alphabetical order. */ - DB_STRUCT_SETUP(app_private, "void *%s"); - DB_STRUCT_SETUP(close, "int (*%s) (DB*, u_int32_t)"); - DB_STRUCT_SETUP(cursor, "int (*%s) (DB *, DB_TXN *, DBC **, u_int32_t)"); - DB_STRUCT_SETUP(del, "int (*%s) (DB *, DB_TXN *, DBT *, u_int32_t)"); - DB_STRUCT_SETUP(get, "int (*%s) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)"); - DB_STRUCT_SETUP(key_range, "int (*%s) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t)"); - DB_STRUCT_SETUP(open, "int (*%s) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int)"); - DB_STRUCT_SETUP(put, "int (*%s) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)"); - DB_STRUCT_SETUP(remove, "int (*%s) (DB *, const char *, const char *, u_int32_t)"); - DB_STRUCT_SETUP(rename, "int (*%s) (DB *, const char *, const char *, const char *, u_int32_t)"); - DB_STRUCT_SETUP(set_bt_compare, "int (*%s) (DB *, int (*)(DB *, const DBT *, const DBT *))"); - DB_STRUCT_SETUP(set_flags, "int (*%s) (DB *, u_int32_t)"); - DB_STRUCT_SETUP(stat, "int (*%s) (DB *, void *, u_int32_t)"); - qsort(db_fields, db_field_counter, sizeof(db_fields[0]), compare_fields); - fprintf(outf, "struct fieldinfo fields%d[] = {\n", __WORDSIZE); - for (i=0; i