2007-11-29 14:27:03 +00:00
/* -*- mode: C; c-basic-offset: 4 -*- */
2008-01-24 15:10:32 +00:00
# ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
2007-11-29 14:27:03 +00:00
/* LICENSE: This file is licensed under the GPL or from Tokutek. */
2007-09-04 20:59:50 +00:00
/* Make a db.h that will be link-time compatible with Sleepycat's Berkeley DB. */
# include <db.h>
# include <stdio.h>
# include <stdlib.h>
2007-09-04 21:39:03 +00:00
# include <assert.h>
# include <string.h>
2007-09-04 20:59:50 +00:00
2008-03-05 11:54:58 +00:00
# define VISIBLE "__attribute__((__visibility__(\"default\")))"
2007-09-04 20:59:50 +00:00
void print_dbtype ( void ) {
/* DBTYPE is mentioned by db_open.html */
printf ( " typedef enum { \n " ) ;
2007-12-11 19:34:21 +00:00
printf ( " DB_BTREE=%d, \n " , DB_BTREE ) ;
printf ( " DB_UNKNOWN=%d \n " , DB_UNKNOWN ) ;
2007-09-04 20:59:50 +00:00
printf ( " } DBTYPE; \n " ) ;
}
2007-10-09 22:00:34 +00:00
#if 0
2007-09-06 14:18:08 +00:00
void print_db_notices ( void ) {
printf ( " typedef enum { /* This appears to be a mysql-specific addition to the api. */ \n " ) ;
printf ( " DB_NOTICE_LOGFILE_CHANGED=%d \n " , DB_NOTICE_LOGFILE_CHANGED ) ;
printf ( " } db_notices; \n " ) ;
}
2007-10-09 22:00:34 +00:00
# endif
2007-09-06 14:18:08 +00:00
# define dodefine(name) printf("#define %s %d\n", #name, name)
2008-03-19 14:33:39 +00:00
enum {
2013-04-16 23:57:49 -04:00
TOKUDB_OUT_OF_LOCKS = - 100000 ,
TOKUDB_SUCCEEDED_EARLY = - 100001 ,
TOKUDB_FOUND_BUT_REJECTED = - 100002 ,
TOKUDB_USER_CALLBACK_ERROR = - 100003 ,
TOKUDB_DICTIONARY_TOO_OLD = - 100004 ,
TOKUDB_DICTIONARY_TOO_NEW = - 100005 ,
TOKUDB_DICTIONARY_NO_HEADER = - 100006
2008-03-19 14:33:39 +00:00
} ;
2007-09-06 14:18:08 +00:00
void print_defines ( void ) {
2007-10-19 17:05:10 +00:00
printf ( " #ifndef _TOKUDB_WRAP_H \n " ) ;
2007-09-06 14:18:08 +00:00
dodefine ( DB_VERB_DEADLOCK ) ;
dodefine ( DB_VERB_RECOVERY ) ;
dodefine ( DB_VERB_REPLICATION ) ;
dodefine ( DB_VERB_WAITSFOR ) ;
dodefine ( DB_DBT_MALLOC ) ;
dodefine ( DB_DBT_REALLOC ) ;
dodefine ( DB_DBT_USERMEM ) ;
dodefine ( DB_DBT_DUPOK ) ;
dodefine ( DB_ARCH_ABS ) ;
dodefine ( DB_ARCH_LOG ) ;
dodefine ( DB_CREATE ) ;
2007-12-18 16:22:21 +00:00
dodefine ( DB_CXX_NO_EXCEPTIONS ) ;
2007-11-19 16:30:50 +00:00
dodefine ( DB_EXCL ) ;
2007-09-06 14:18:08 +00:00
dodefine ( DB_PRIVATE ) ;
dodefine ( DB_RDONLY ) ;
dodefine ( DB_RECOVER ) ;
dodefine ( DB_THREAD ) ;
dodefine ( DB_TXN_NOSYNC ) ;
dodefine ( DB_LOCK_DEFAULT ) ;
dodefine ( DB_LOCK_OLDEST ) ;
dodefine ( DB_LOCK_RANDOM ) ;
dodefine ( DB_DUP ) ;
2007-11-14 17:50:28 +00:00
dodefine ( DB_DUPSORT ) ;
2007-09-04 20:59:50 +00:00
2007-12-13 23:32:51 +00:00
dodefine ( DB_KEYFIRST ) ;
dodefine ( DB_KEYLAST ) ;
2007-12-07 14:57:13 +00:00
dodefine ( DB_NODUPDATA ) ;
2007-09-06 14:18:08 +00:00
dodefine ( DB_NOOVERWRITE ) ;
2007-12-14 14:26:22 +00:00
printf ( " #define DB_YESOVERWRITE 254 \n " ) ; // tokudb
dodefine ( DB_OPFLAGS_MASK ) ;
2007-09-06 14:18:08 +00:00
2008-02-11 19:55:37 +00:00
dodefine ( DB_AUTO_COMMIT ) ;
2007-09-06 14:18:08 +00:00
dodefine ( DB_INIT_LOCK ) ;
dodefine ( DB_INIT_LOG ) ;
dodefine ( DB_INIT_MPOOL ) ;
dodefine ( DB_INIT_TXN ) ;
2007-11-26 17:24:43 +00:00
dodefine ( DB_USE_ENVIRON ) ;
dodefine ( DB_USE_ENVIRON_ROOT ) ;
2007-09-06 20:13:56 +00:00
2013-04-16 23:57:25 -04:00
# ifdef DB_READ_UNCOMMITTED
dodefine ( DB_READ_UNCOMMITTED ) ;
# endif
2013-04-16 23:57:41 -04:00
//dodefine(DB_KEYEMPTY); /// KEYEMPTY is no longer used. We just use DB_NOTFOUND
2007-09-06 20:13:56 +00:00
dodefine ( DB_KEYEXIST ) ;
dodefine ( DB_LOCK_DEADLOCK ) ;
2008-01-21 23:59:04 +00:00
dodefine ( DB_LOCK_NOTGRANTED ) ;
2007-09-06 20:13:56 +00:00
dodefine ( DB_NOTFOUND ) ;
2007-12-03 05:01:43 +00:00
dodefine ( DB_SECONDARY_BAD ) ;
2007-11-30 05:04:06 +00:00
dodefine ( DB_DONOTINDEX ) ;
2007-12-11 14:53:18 +00:00
# ifdef DB_BUFFER_SMALL
2007-12-10 17:04:02 +00:00
dodefine ( DB_BUFFER_SMALL ) ;
2007-12-11 14:53:18 +00:00
# endif
2007-09-06 20:13:56 +00:00
printf ( " #define DB_BADFORMAT -30500 \n " ) ; // private tokudb
2007-11-28 20:04:35 +00:00
printf ( " #define DB_DELETE_ANY %d \n " , 1 < < 16 ) ; // private tokudb
2007-09-06 20:13:56 +00:00
dodefine ( DB_FIRST ) ;
dodefine ( DB_GET_BOTH ) ;
2007-12-17 13:48:20 +00:00
dodefine ( DB_GET_BOTH_RANGE ) ;
2007-09-06 20:13:56 +00:00
dodefine ( DB_LAST ) ;
2007-12-03 05:01:43 +00:00
dodefine ( DB_CURRENT ) ;
2007-09-06 20:13:56 +00:00
dodefine ( DB_NEXT ) ;
dodefine ( DB_NEXT_DUP ) ;
2008-01-10 12:51:09 +00:00
dodefine ( DB_NEXT_NODUP ) ;
2007-09-06 20:13:56 +00:00
dodefine ( DB_PREV ) ;
2013-04-16 23:57:41 -04:00
# if defined(DB_PREV_DUP)
2008-01-10 12:51:09 +00:00
dodefine ( DB_PREV_DUP ) ;
# endif
dodefine ( DB_PREV_NODUP ) ;
2007-09-06 20:13:56 +00:00
dodefine ( DB_SET ) ;
dodefine ( DB_SET_RANGE ) ;
2008-02-03 18:26:01 +00:00
printf ( " #define DB_CURRENT_BINDING 253 \n " ) ; // private tokudb
2007-09-06 20:13:56 +00:00
dodefine ( DB_RMW ) ;
2008-06-10 15:39:31 +00:00
printf ( " #define DB_PRELOCKED 0x00800000 \n " ) ; // private tokudb
2008-06-10 19:46:00 +00:00
printf ( " #define DB_PRELOCKED_WRITE 0x00400000 \n " ) ; // private tokudb
2007-11-30 05:04:06 +00:00
dodefine ( DB_DBT_APPMALLOC ) ;
# ifdef DB_DBT_MULTIPLE
dodefine ( DB_DBT_MULTIPLE ) ;
# endif
2008-01-02 15:54:00 +00:00
// flags for the env->set_flags function
# if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3
dodefine ( DB_LOG_AUTOREMOVE ) ;
# endif
dodefine ( DB_TXN_WRITE_NOSYNC ) ;
2008-01-22 15:42:54 +00:00
dodefine ( DB_TXN_NOWAIT ) ;
dodefine ( DB_TXN_SYNC ) ;
2008-01-02 15:54:00 +00:00
2008-03-19 14:33:39 +00:00
2007-10-19 17:05:10 +00:00
printf ( " #endif \n " ) ;
2008-03-19 14:33:39 +00:00
/* TOKUDB specific error codes*/
printf ( " /* TOKUDB specific error codes */ \n " ) ;
dodefine ( TOKUDB_OUT_OF_LOCKS ) ;
2008-05-16 20:09:13 +00:00
dodefine ( TOKUDB_SUCCEEDED_EARLY ) ;
2013-04-16 23:57:47 -04:00
dodefine ( TOKUDB_DICTIONARY_TOO_OLD ) ;
2013-04-16 23:57:49 -04:00
dodefine ( TOKUDB_DICTIONARY_TOO_NEW ) ;
dodefine ( TOKUDB_DICTIONARY_NO_HEADER ) ;
2013-04-16 23:57:41 -04:00
dodefine ( TOKUDB_FOUND_BUT_REJECTED ) ;
dodefine ( TOKUDB_USER_CALLBACK_ERROR ) ;
2007-09-06 14:18:08 +00:00
}
2007-09-04 20:59:50 +00:00
2007-09-05 18:59:12 +00:00
//#define DECL_LIMIT 100
2007-09-04 20:59:50 +00:00
struct fieldinfo {
2007-09-05 18:59:12 +00:00
char * decl ;
2007-09-04 20:59:50 +00:00
unsigned int off ;
unsigned int size ;
2007-09-04 21:39:03 +00:00
} ;
2007-09-04 20:59:50 +00:00
2007-10-14 13:56:25 +00:00
# if USE_MAJOR==4 && USE_MINOR==1
# include "sample_offsets_32_4_1.h"
# include "sample_offsets_64_4_1.h"
# elif USE_MAJOR==4 && USE_MINOR==3
# include "sample_offsets_32_4_3.h"
# include "sample_offsets_64_4_3.h"
2007-11-15 14:09:40 +00:00
# elif USE_MAJOR==4 && USE_MINOR==4
# include "sample_offsets_32_4_4.h"
# include "sample_offsets_64_4_4.h"
2007-12-03 18:44:41 +00:00
# elif USE_MAJOR==4 && USE_MINOR==5
# include "sample_offsets_32_4_5.h"
# include "sample_offsets_64_4_5.h"
2007-11-15 14:09:40 +00:00
# elif USE_MAJOR==4 && USE_MINOR==6
# include "sample_offsets_32_4_6.h"
# include "sample_offsets_64_4_6.h"
2007-10-14 13:56:25 +00:00
# else
# error
# endif
2007-09-04 20:59:50 +00:00
2008-05-13 13:07:25 +00:00
void print_struct ( const char * structname , int need_internal , struct fieldinfo * fields32 , struct fieldinfo * fields64 , unsigned int N , const char * extra_decls [ ] ) {
2007-09-04 21:39:03 +00:00
unsigned int i ;
unsigned int current_32 = 0 ;
unsigned int current_64 = 0 ;
2007-09-04 20:59:50 +00:00
int dummy_counter = 0 ;
2007-09-05 18:59:12 +00:00
int did_toku_internal = 0 ;
2007-09-05 19:08:41 +00:00
// int total32 = fields32[N-1].size;
// int total64 = fields32[N-1].size;
2007-09-05 17:52:04 +00:00
printf ( " struct __toku_%s { \n " , structname ) ;
2007-09-05 20:16:26 +00:00
for ( i = 0 ; i < N - 1 ; i + + ) {
2007-09-04 21:39:03 +00:00
unsigned int this_32 = fields32 [ i ] . off ;
unsigned int this_64 = fields64 [ i ] . off ;
2007-09-05 18:59:12 +00:00
//fprintf(stderr, "this32=%d current32=%d this64=%d current64=%d\n", this_32, current_32, this_64, current_64);
2007-09-04 21:39:03 +00:00
if ( this_32 > 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 ;
2007-09-05 18:59:12 +00:00
unsigned int n_dummys = diff / 4 ;
if ( need_internal & & ! did_toku_internal ) {
2013-04-16 23:57:48 -04:00
if ( TDB_NATIVE & &
( strcmp ( structname , " dbc " ) = = 0 | |
strcmp ( structname , " db_txn " ) = = 0 ) ) {
printf ( " struct __toku_%s_internal ii; \n " , structname ) ;
printf ( " #define %s_struct_i(x) (&(x)->ii) \n " , structname ) ;
} else {
printf ( " struct __toku_%s_internal *i; \n " , structname ) ;
printf ( " #define %s_struct_i(x) ((x)->i) \n " , structname ) ;
}
2007-09-05 18:59:12 +00:00
n_dummys - - ;
did_toku_internal = 1 ;
}
2008-07-09 16:55:59 +00:00
while ( n_dummys > 0 & & extra_decls & & * extra_decls ) {
printf ( " %s; \n " , * extra_decls ) ;
extra_decls + + ;
n_dummys - - ;
}
2008-05-13 13:07:25 +00:00
if ( n_dummys > 0 ) {
2013-04-16 23:57:48 -04:00
if ( ! TDB_NATIVE )
printf ( " void* __toku_dummy%d[%d]; \n " , dummy_counter , n_dummys ) ;
dummy_counter + + ;
2008-05-13 13:07:25 +00:00
}
2007-09-04 21:39:03 +00:00
diff64 - = diff * 2 ;
diff32 - = diff ;
}
assert ( diff32 = = diff64 ) ;
if ( diff32 > 0 ) {
2013-04-16 23:57:48 -04:00
if ( ! TDB_NATIVE )
printf ( " char __toku_dummy%d[%d]; \n " , dummy_counter , diff32 ) ;
dummy_counter + + ;
2007-09-04 21:39:03 +00:00
}
current_32 = this_32 ;
current_64 = this_64 ;
2007-09-04 20:59:50 +00:00
}
2007-09-04 21:39:03 +00:00
if ( this_32 < current_32 | | this_64 < current_64 ) {
2007-09-05 19:20:25 +00:00
printf ( " Whoops this_32=%d this_64=%d \n " , this_32 , this_64 ) ;
}
if ( i + 1 < N ) {
assert ( strcmp ( fields32 [ i ] . decl , fields64 [ i ] . decl ) = = 0 ) ;
2013-04-16 23:57:48 -04:00
printf ( " %s; " , fields32 [ i ] . decl ) ;
if ( ! TDB_NATIVE )
printf ( " /* 32-bit offset=%d size=%d, 64=bit offset=%d size=%d */ " , fields32 [ i ] . off , fields32 [ i ] . size , fields64 [ i ] . off , fields64 [ i ] . size ) ;
printf ( " \n " ) ;
2007-09-05 19:20:25 +00:00
} else {
assert ( fields32 [ i ] . decl = = 0 ) ;
assert ( fields64 [ i ] . decl = = 0 ) ;
2007-09-04 20:59:50 +00:00
}
2007-09-04 21:39:03 +00:00
current_32 + = fields32 [ i ] . size ;
current_64 + = fields64 [ i ] . size ;
2007-09-04 20:59:50 +00:00
}
2008-07-09 16:55:59 +00:00
if ( extra_decls ) assert ( NULL = = * extra_decls ) ; // make sure that the extra decls all got used up.
2007-09-05 20:16:26 +00:00
{
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 & & diff32 < diff64 ) {
unsigned int diff = diff64 - diff32 ;
2013-04-16 23:57:48 -04:00
if ( ! TDB_NATIVE )
printf ( " void* __toku_dummy%d[%d]; /* Padding at the end */ \n " , dummy_counter , diff / 4 ) ;
dummy_counter + + ;
2007-09-05 20:16:26 +00:00
diff64 - = diff * 2 ;
diff32 - = diff ;
}
if ( diff32 > 0 ) {
2013-04-16 23:57:48 -04:00
if ( ! TDB_NATIVE )
printf ( " char __toku_dummy%d[%d]; /* Padding at the end */ \n " , dummy_counter , diff32 ) ;
dummy_counter + + ;
2007-09-05 20:16:26 +00:00
diff64 - = diff32 ;
diff32 = 0 ;
}
2013-04-16 23:57:48 -04:00
if ( diff64 > 0 )
if ( ! TDB_NATIVE )
printf ( " /* %d more bytes of alignment in the 64-bit case. */ \n " , diff64 ) ;
2007-09-05 20:16:26 +00:00
assert ( diff64 < 8 ) ; /* there could be a few left from alignment. */
}
2007-09-04 21:39:03 +00:00
printf ( " }; \n " ) ;
2007-09-05 20:16:26 +00:00
assert ( did_toku_internal | | ! need_internal ) ;
2007-09-04 20:59:50 +00:00
}
2007-09-04 21:39:03 +00:00
2007-09-04 20:59:50 +00:00
int main ( int argc __attribute__ ( ( __unused__ ) ) , char * argv [ ] __attribute__ ( ( __unused__ ) ) ) {
printf ( " #ifndef _DB_H \n " ) ;
printf ( " #define _DB_H \n " ) ;
2008-01-24 15:10:32 +00:00
printf ( " /* This code generated by make_db_h. Copyright (c) 2007, 2008 Tokutek */ \n " ) ;
printf ( " #ident \" Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved. \" \n " ) ;
2007-09-06 14:18:08 +00:00
printf ( " #include <sys/types.h> \n " ) ;
2007-10-15 02:08:49 +00:00
printf ( " /*stdio is needed for the FILE* in db->verify*/ \n " ) ;
printf ( " #include <stdio.h> \n " ) ;
2007-09-06 14:18:08 +00:00
//printf("#include <inttypes.h>\n");
2007-09-04 20:59:50 +00:00
printf ( " #if defined(__cplusplus) \n extern \" C \" { \n #endif \n " ) ;
2007-09-06 14:18:08 +00:00
2007-10-14 13:56:25 +00:00
assert ( DB_VERSION_MAJOR = = DB_VERSION_MAJOR_32 ) ;
assert ( DB_VERSION_MINOR = = DB_VERSION_MINOR_32 ) ;
2007-11-28 20:04:35 +00:00
printf ( " #define TOKUDB 1 \n " ) ;
2013-04-16 23:57:48 -04:00
printf ( " #define TOKUDB_NATIVE_H %d \n " , TDB_NATIVE ) ;
2007-09-19 18:34:17 +00:00
dodefine ( DB_VERSION_MAJOR ) ;
dodefine ( DB_VERSION_MINOR ) ;
dodefine ( DB_VERSION_PATCH ) ;
2007-09-06 14:18:08 +00:00
printf ( " #ifndef _TOKUDB_WRAP_H \n " ) ;
2007-10-14 13:56:25 +00:00
printf ( " #define DB_VERSION_STRING \" Tokutek: TokuDB %d.%d.%d \" \n " , DB_VERSION_MAJOR , DB_VERSION_MINOR , DB_VERSION_PATCH ) ;
2007-09-06 14:18:08 +00:00
printf ( " #else \n " ) ;
2007-10-19 17:05:10 +00:00
printf ( " #define DB_VERSION_STRING_ydb \" Tokutek: TokuDB (wrapped bdb) \" \n " ) ;
2007-09-06 14:18:08 +00:00
printf ( " #endif \n " ) ;
2013-04-16 23:57:48 -04:00
2007-09-06 14:18:08 +00:00
if ( 0 ) {
printf ( " #ifndef __BIT_TYPES_DEFINED__ \n " ) ;
printf ( " /* Define some int types if not provided by the system. BIND does this, so we do it too. */ \n " ) ;
printf ( " typedef unsigned int u_int32_t; \n " ) ;
printf ( " #endif \n " ) ;
}
2013-04-16 23:57:43 -04:00
//Typedef toku_off_t
printf ( " #ifndef TOKU_OFF_T_DEFINED \n "
" #define TOKU_OFF_T_DEFINED \n "
" typedef int64_t toku_off_t; \n "
" #endif \n " ) ;
2013-04-16 23:57:47 -04:00
//printf("typedef struct __toku_db_btree_stat DB_BTREE_STAT;\n");
2007-09-06 14:18:08 +00:00
printf ( " typedef struct __toku_db_env DB_ENV; \n " ) ;
2007-09-05 20:32:12 +00:00
printf ( " typedef struct __toku_db_key_range DB_KEY_RANGE; \n " ) ;
printf ( " typedef struct __toku_db_lsn DB_LSN; \n " ) ;
2007-09-04 20:59:50 +00:00
printf ( " typedef struct __toku_db DB; \n " ) ;
2007-09-05 20:32:12 +00:00
printf ( " typedef struct __toku_db_txn DB_TXN; \n " ) ;
2007-09-06 14:18:08 +00:00
printf ( " typedef struct __toku_db_txn_active DB_TXN_ACTIVE; \n " ) ;
2007-09-05 20:32:12 +00:00
printf ( " typedef struct __toku_db_txn_stat DB_TXN_STAT; \n " ) ;
printf ( " typedef struct __toku_dbc DBC; \n " ) ;
printf ( " typedef struct __toku_dbt DBT; \n " ) ;
2008-01-10 16:29:45 +00:00
printf ( " typedef u_int32_t db_recno_t; \n " ) ;
2013-04-16 23:57:41 -04:00
printf ( " typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); \n " ) ;
printf ( " typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); \n " ) ;
printf ( " typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); \n " ) ;
2013-04-16 23:57:47 -04:00
2013-04-16 23:57:48 -04:00
printf ( " #include <tdb-internal.h> \n " ) ;
2013-04-16 23:57:47 -04:00
//stat64
2013-04-16 23:57:47 -04:00
printf ( " typedef struct __toku_db_btree_stat64 { \n " ) ;
printf ( " u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ \n " ) ;
printf ( " u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */ \n " ) ;
printf ( " u_int64_t bt_dsize; /* how big are the keys+values (not counting the lengths) (an estimate, unless flattened) */ \n " ) ;
printf ( " u_int64_t bt_fsize; /* how big is the underlying file */ \n " ) ;
printf ( " } DB_BTREE_STAT64; \n " ) ;
2013-04-16 23:57:47 -04:00
2007-09-04 20:59:50 +00:00
print_dbtype ( ) ;
2007-10-09 22:00:34 +00:00
// print_db_notices();
2007-09-06 14:18:08 +00:00
print_defines ( ) ;
2007-09-05 17:52:04 +00:00
2007-09-06 14:18:08 +00:00
printf ( " /* in wrap mode, top-level function txn_begin is renamed, but the field isn't renamed, so we have to hack it here.*/ \n " ) ;
printf ( " #ifdef _TOKUDB_WRAP_H \n #undef txn_begin \n #endif \n " ) ;
2007-09-05 20:28:58 +00:00
assert ( sizeof ( db_btree_stat_fields32 ) = = sizeof ( db_btree_stat_fields64 ) ) ;
2013-04-16 23:57:47 -04:00
// Don't produce db_btree_stat records.
//print_struct("db_btree_stat", 0, db_btree_stat_fields32, db_btree_stat_fields64, sizeof(db_btree_stat_fields32)/sizeof(db_btree_stat_fields32[0]), 0);
2007-09-05 19:20:25 +00:00
assert ( sizeof ( db_env_fields32 ) = = sizeof ( db_env_fields64 ) ) ;
2013-04-16 23:57:47 -04:00
{
const char * extra [ ] = {
2013-04-16 23:57:49 -04:00
" int (*checkpointing_set_period) (DB_ENV*, u_int32_t) /* Change the delay between automatic checkpoints. 0 means disabled. */ " ,
" int (*checkpointing_get_period) (DB_ENV*, u_int32_t*) /* Retrieve the delay between automatic checkpoints. 0 means disabled. */ " ,
2013-04-16 23:57:47 -04:00
" int (*checkpointing_postpone) (DB_ENV*) /* Use for 'rename table' or any other operation that must be disjoint from a checkpoint */ " ,
" int (*checkpointing_resume) (DB_ENV*) /* Alert tokudb 'postpone' is no longer necessary */ " ,
" int (*checkpointing_begin_atomic_operation) (DB_ENV*) /* Begin a set of operations (that must be atomic as far as checkpoints are concerned). i.e. inserting into every index in one table */ " ,
" int (*checkpointing_end_atomic_operation) (DB_ENV*) /* End a set of operations (that must be atomic as far as checkpoints are concerned). */ " ,
" int (*set_default_bt_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (key) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */ " ,
" int (*set_default_dup_compare) (DB_ENV*,int (*bt_compare) (DB *, const DBT *, const DBT *)) /* Set default (val) comparison function for all DBs in this environment. Required for RECOVERY since you cannot open the DBs manually. */ " ,
NULL } ;
print_struct ( " db_env " , 1 , db_env_fields32 , db_env_fields64 , sizeof ( db_env_fields32 ) / sizeof ( db_env_fields32 [ 0 ] ) , extra ) ;
}
2007-09-05 19:20:25 +00:00
2007-09-05 20:24:17 +00:00
assert ( sizeof ( db_key_range_fields32 ) = = sizeof ( db_key_range_fields64 ) ) ;
2008-05-13 13:07:25 +00:00
print_struct ( " db_key_range " , 0 , db_key_range_fields32 , db_key_range_fields64 , sizeof ( db_key_range_fields32 ) / sizeof ( db_key_range_fields32 [ 0 ] ) , 0 ) ;
2007-09-05 20:24:17 +00:00
assert ( sizeof ( db_lsn_fields32 ) = = sizeof ( db_lsn_fields64 ) ) ;
2008-05-13 13:07:25 +00:00
print_struct ( " db_lsn " , 0 , db_lsn_fields32 , db_lsn_fields64 , sizeof ( db_lsn_fields32 ) / sizeof ( db_lsn_fields32 [ 0 ] ) , 0 ) ;
2007-09-05 20:24:17 +00:00
2013-04-16 23:57:47 -04:00
assert ( sizeof ( dbt_fields32 ) = = sizeof ( dbt_fields64 ) ) ;
print_struct ( " dbt " , 0 , dbt_fields32 , dbt_fields64 , sizeof ( dbt_fields32 ) / sizeof ( dbt_fields32 [ 0 ] ) , 0 ) ;
2013-04-16 23:57:48 -04:00
printf ( " typedef int (*toku_dbt_upgradef)(DB*, \n " ) ;
printf ( " u_int32_t old_version, const DBT *old_descriptor, const DBT *old_key, const DBT *old_val, \n " ) ;
printf ( " u_int32_t new_version, const DBT *new_descriptor, const DBT *new_key, const DBT *new_val); \n " ) ;
2007-09-05 20:28:58 +00:00
assert ( sizeof ( db_fields32 ) = = sizeof ( db_fields64 ) ) ;
2008-06-10 15:39:31 +00:00
{
const char * extra [ ] = { " int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact) " ,
2013-04-16 23:57:47 -04:00
" int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *) " ,
2008-06-10 15:39:31 +00:00
" int (*pre_acquire_read_lock)(DB*, DB_TXN*, const DBT*, const DBT*, const DBT*, const DBT*) " ,
2008-06-11 19:38:51 +00:00
" int (*pre_acquire_table_lock)(DB*, DB_TXN*) " ,
2008-06-10 15:39:31 +00:00
" const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/ " ,
" const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/ " ,
2008-08-18 03:27:56 +00:00
" int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */ " ,
2013-04-16 23:57:42 -04:00
" int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */ " ,
2013-04-16 23:57:48 -04:00
" const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */ " ,
2013-04-16 23:57:48 -04:00
" int (*set_descriptor) (DB*, u_int32_t version, const DBT* descriptor, toku_dbt_upgradef dbt_userformat_upgrade) /* set row/dictionary descriptor for a db. Available only while db is open */ " ,
2008-06-10 15:39:31 +00:00
NULL } ;
print_struct ( " db " , 1 , db_fields32 , db_fields64 , sizeof ( db_fields32 ) / sizeof ( db_fields32 [ 0 ] ) , extra ) ;
}
2007-09-05 20:28:58 +00:00
2007-09-05 20:24:17 +00:00
assert ( sizeof ( db_txn_active_fields32 ) = = sizeof ( db_txn_active_fields64 ) ) ;
2008-05-13 13:07:25 +00:00
print_struct ( " db_txn_active " , 0 , db_txn_active_fields32 , db_txn_active_fields64 , sizeof ( db_txn_active_fields32 ) / sizeof ( db_txn_active_fields32 [ 0 ] ) , 0 ) ;
2007-09-05 20:28:58 +00:00
assert ( sizeof ( db_txn_fields32 ) = = sizeof ( db_txn_fields64 ) ) ;
2013-04-16 23:57:38 -04:00
{
printf ( " struct txn_stat { \n u_int64_t rolltmp_raw_count; \n }; \n " ) ;
const char * extra [ ] = { " int (*txn_stat)(DB_TXN *, struct txn_stat **) " } ;
print_struct ( " db_txn " , 1 , db_txn_fields32 , db_txn_fields64 , sizeof ( db_txn_fields32 ) / sizeof ( db_txn_fields32 [ 0 ] ) , extra ) ;
}
2007-09-05 20:28:58 +00:00
2007-09-05 20:24:17 +00:00
assert ( sizeof ( db_txn_stat_fields32 ) = = sizeof ( db_txn_stat_fields64 ) ) ;
2008-05-13 13:07:25 +00:00
print_struct ( " db_txn_stat " , 0 , db_txn_stat_fields32 , db_txn_stat_fields64 , sizeof ( db_txn_stat_fields32 ) / sizeof ( db_txn_stat_fields32 [ 0 ] ) , 0 ) ;
2007-09-05 20:24:17 +00:00
2008-06-10 15:39:31 +00:00
{
2013-04-16 23:57:41 -04:00
const char * extra [ ] = {
" int (*c_getf_first)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_last)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_next)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_next_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_next_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_prev)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_prev_dup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_prev_nodup)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_current)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_current_binding)(DBC *, u_int32_t, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_heaviside)(DBC *, u_int32_t, "
" YDB_HEAVISIDE_CALLBACK_FUNCTION f, void *extra_f, "
" YDB_HEAVISIDE_FUNCTION h, void *extra_h, int direction) " ,
" int (*c_getf_set)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_set_range)(DBC *, u_int32_t, DBT *, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_get_both)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *) " ,
" int (*c_getf_get_both_range)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *) " ,
2008-06-10 15:39:31 +00:00
NULL } ;
assert ( sizeof ( dbc_fields32 ) = = sizeof ( dbc_fields64 ) ) ;
print_struct ( " dbc " , 1 , dbc_fields32 , dbc_fields64 , sizeof ( dbc_fields32 ) / sizeof ( dbc_fields32 [ 0 ] ) , extra ) ;
}
2007-09-05 20:28:58 +00:00
2007-09-06 14:18:08 +00:00
printf ( " #ifdef _TOKUDB_WRAP_H \n #define txn_begin txn_begin_tokudb \n #endif \n " ) ;
2008-03-05 11:54:58 +00:00
printf ( " int db_env_create(DB_ENV **, u_int32_t) %s; \n " , VISIBLE ) ;
printf ( " int db_create(DB **, DB_ENV *, u_int32_t) %s; \n " , VISIBLE ) ;
printf ( " char *db_strerror(int) %s; \n " , VISIBLE ) ;
printf ( " const char *db_version(int*,int *,int *) %s; \n " , VISIBLE ) ;
printf ( " int log_compare (const DB_LSN*, const DB_LSN *) %s; \n " , VISIBLE ) ;
2008-03-08 21:29:27 +00:00
printf ( " int db_env_set_func_fsync (int (*)(int)) %s; \n " , VISIBLE ) ;
2008-04-12 09:12:22 +00:00
printf ( " int toku_set_trace_file (char *fname) %s; \n " , VISIBLE ) ;
printf ( " int toku_close_trace_file (void) %s; \n " , VISIBLE ) ;
2013-04-16 23:57:38 -04:00
printf ( " int db_env_set_func_free (void (*)(void*)) %s; \n " , VISIBLE ) ;
2013-04-16 23:57:34 -04:00
printf ( " int db_env_set_func_malloc (void *(*)(size_t)) %s; \n " , VISIBLE ) ;
2013-04-16 23:57:42 -04:00
printf ( " int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s; \n " , VISIBLE ) ;
2013-04-16 23:57:38 -04:00
printf ( " int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) %s; \n " , VISIBLE ) ;
2013-04-16 23:57:34 -04:00
printf ( " int db_env_set_func_realloc (void *(*)(void*, size_t)) %s; \n " , VISIBLE ) ;
2013-04-16 23:57:49 -04:00
printf ( " void db_env_set_checkpoint_callback (void (*)(void*), void*) %s; \n " , VISIBLE ) ;
2007-09-04 21:40:11 +00:00
printf ( " #if defined(__cplusplus) \n } \n #endif \n " ) ;
2007-09-04 20:59:50 +00:00
printf ( " #endif \n " ) ;
return 0 ;
}
2007-09-28 17:11:22 +00:00