From 798429c3cbaf4e828b12c09726f91fe4f73b80c7 Mon Sep 17 00:00:00 2001 From: "Bradley C. Kuszmaul" Date: Tue, 16 Apr 2013 23:58:57 -0400 Subject: [PATCH] Fixes #2276. closes[t:2276] git-svn-id: file:///svn/toku/tokudb@16801 c7de825b-a66e-492c-adef-691d508d4ae1 --- buildheader/Makefile | 34 ++++++++++++++++------------- buildheader/db.h_4_1 | 15 ++++++++----- buildheader/db.h_4_3 | 20 ++++++++++------- buildheader/db.h_4_4 | 15 ++++++++----- buildheader/db.h_4_5 | 15 ++++++++----- buildheader/db.h_4_6 | 15 ++++++++----- buildheader/make_db_h.c | 18 +++++++++++---- buildheader/sample_offsets_64_4_7.h | 2 ++ buildheader/tdb.h | 11 ++++++---- db-benchmark-test-cxx/Makefile | 2 +- include/db.h | 11 ++++++---- include/tdb-internal.h | 16 -------------- src/ydb-internal.h | 16 ++++++++++++++ src/ydb.c | 10 +++++---- toku_include/Makefile.include | 5 ++++- 15 files changed, 124 insertions(+), 81 deletions(-) diff --git a/buildheader/Makefile b/buildheader/Makefile index 2112cf3dc68..f1aa770110b 100644 --- a/buildheader/Makefile +++ b/buildheader/Makefile @@ -15,7 +15,11 @@ BDB = 4_6 BDBDIR = ../../../berkeleydb MYSQL_H = -I$(BDBDIR)/db-4.1.25/build_unix/ OPTFLAGS = -O2 -CFLAGS = -Wall -W -Werror -g $(OPTFLAGS) +ifeq ($(GCCVERSION),4.4.2) + GCC_VERSION_SPECIFIC_WARNINGS = -Wno-strict-aliasing -Wno-deprecated +endif +CFLAGS = $(GCC_VERSION_SPECIFIC_WARNINGS) -Wall -W -Werror -g $(OPTFLAGS) +CPPFLAGS = -I. -I../toku_include runs: runs_mysql runs_installed samples: sample_offsets_4_6 sample_offsets_4_5 sample_offsets_4_4 sample_offsets_4_3 sample_offsets_4_1 @@ -25,60 +29,60 @@ runs_mysql: ./sample_offsets_mysql ./sample_offsets_mysql runs_installed: sample_offsets ./sample_offsets -sample_offsets_mysql: CPPFLAGS=$(MYSQL_H) +sample_offsets_mysql: CPPFLAGS+=$(MYSQL_H) sample_offsets_mysql: sample_offsets.c $(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ make_db_h_4_1.o: make_db_h.c sample_offsets_32_4_1.h sample_offsets_64_4_1.h - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.1.25/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=1 -DTDB_NATIVE=0 + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.1.25/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=1 -DTDB_NATIVE=0 db.h_4_1: make_db_h_4_1 ./make_db_h_4_1 > $@ sample_offsets_4_1: sample_offsets.c - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.1.25/build_unix $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.1.25/build_unix $< -o $@ ./sample_offsets_4_1 make_db_h_4_3.o: make_db_h.c sample_offsets_32_4_3.h sample_offsets_64_4_3.h - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.3.29/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=3 -DTDB_NATIVE=0 + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.3.29/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=3 -DTDB_NATIVE=0 db.h_4_3: make_db_h_4_3 ./make_db_h_4_3 > $@ sample_offsets_4_3: sample_offsets.c - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.3.29/build_unix $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.3.29/build_unix $< -o $@ ./sample_offsets_4_3 make_db_h_4_4.o: make_db_h.c sample_offsets_32_4_4.h sample_offsets_64_4_4.h - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.4.20/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=4 -DTDB_NATIVE=0 + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.4.20/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=4 -DTDB_NATIVE=0 db.h_4_4: make_db_h_4_4 ./make_db_h_4_4 > $@ sample_offsets_4_4: sample_offsets.c - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.4.20/build_unix $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.4.20/build_unix $< -o $@ ./sample_offsets_4_4 make_db_h_4_5.o: make_db_h.c sample_offsets_32_4_5.h sample_offsets_64_4_5.h - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.5.20/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=5 -DTDB_NATIVE=0 + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.5.20/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=5 -DTDB_NATIVE=0 db.h_4_5: make_db_h_4_5 ./make_db_h_4_5 > $@ sample_offsets_4_5: sample_offsets.c - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.5.20/build_unix $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.5.20/build_unix $< -o $@ ./sample_offsets_4_5 make_db_h_4_6.o: make_db_h.c sample_offsets_32_4_6.h sample_offsets_64_4_6.h - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.6.19/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=6 -DTDB_NATIVE=0 + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.6.19/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=6 -DTDB_NATIVE=0 db.h_4_6: make_db_h_4_6 ./make_db_h_4_6 > $@ sample_offsets_4_6: sample_offsets.c - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.6.19/build_unix $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.6.19/build_unix $< -o $@ ./sample_offsets_4_6 make_tdb_h.o: make_db_h.c - $(CC) $(CFLAGS) -I. -I$(BDBDIR)/db-4.6.19/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=6 -DTDB_NATIVE=1 + $(CC) $(CFLAGS) $(CPPFLAGS) -I$(BDBDIR)/db-4.6.19/build_unix $< -c -o $@ -DUSE_MAJOR=4 -DUSE_MINOR=6 -DTDB_NATIVE=1 tdb.h: make_tdb_h ./make_tdb_h > $@ sample_offsets: sample_offsets_local: ./db.h sample_offsets_local: sample_offsets.c - $(CC) $(CFLAGS) -I. -DLOCAL $< -o $@ - + $(CC) $(CFLAGS) $(CPPFLAGS) -DLOCAL $< -o $@ + hfiles: db.h_4_1 db.h_4_3 db.h_4_4 db.h_4_5 db.h_4_6 tdb.h check32: sample_offsets_local diff --git a/buildheader/db.h_4_1 b/buildheader/db.h_4_1 index 0f36b074c57..ef6b4b32f9c 100644 --- a/buildheader/db.h_4_1 +++ b/buildheader/db.h_4_1 @@ -37,6 +37,9 @@ typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); #include +#ifndef __BIGGEST_ALIGNMENT__ + #define __BIGGEST_ALIGNMENT__ 16 +#endif typedef struct __toku_db_btree_stat64 { u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */ @@ -319,11 +322,9 @@ struct txn_stat { struct __toku_db_txn { DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */ - struct __toku_db_txn_internal *i; -#define db_txn_struct_i(x) ((x)->i) int (*txn_stat)(DB_TXN *, struct txn_stat **); struct { void *next, *prev; } open_txns; - void* __toku_dummy0[6]; + void* __toku_dummy0[7]; char __toku_dummy1[24]; void *api_internal; /* 32-bit offset=68 size=4, 64=bit offset=112 size=8 */ void* __toku_dummy2[1]; @@ -332,6 +333,8 @@ struct __toku_db_txn { void* __toku_dummy3[1]; u_int32_t (*id) (DB_TXN *); /* 32-bit offset=88 size=4, 64=bit offset=152 size=8 */ void* __toku_dummy4[3]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define db_txn_struct_i(x) ((struct __toku_db_txn_internal *)(&(x)->iic)) }; struct __toku_db_txn_stat { void* __toku_dummy0[1]; @@ -344,8 +347,6 @@ struct __toku_db_txn_stat { }; struct __toku_dbc { DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ - struct __toku_dbc_internal *i; -#define dbc_struct_i(x) ((x)->i) 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 *); @@ -363,7 +364,7 @@ struct __toku_dbc { 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 *); int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[2]; + void* __toku_dummy0[3]; char __toku_dummy1[104]; int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=272 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=280 size=8 */ @@ -371,6 +372,8 @@ struct __toku_dbc { void* __toku_dummy2[1]; int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */ void* __toku_dummy3[11]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define dbc_struct_i(x) ((struct __toku_dbc_internal *)(&(x)->iic)) }; #ifdef _TOKUDB_WRAP_H #define txn_begin txn_begin_tokudb diff --git a/buildheader/db.h_4_3 b/buildheader/db.h_4_3 index f76185a6153..9e358c2f6fa 100644 --- a/buildheader/db.h_4_3 +++ b/buildheader/db.h_4_3 @@ -37,6 +37,9 @@ typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); #include +#ifndef __BIGGEST_ALIGNMENT__ + #define __BIGGEST_ALIGNMENT__ 16 +#endif typedef struct __toku_db_btree_stat64 { u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */ @@ -335,11 +338,9 @@ struct txn_stat { struct __toku_db_txn { DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */ - struct __toku_db_txn_internal *i; -#define db_txn_struct_i(x) ((x)->i) int (*txn_stat)(DB_TXN *, struct txn_stat **); struct { void *next, *prev; } open_txns; - void* __toku_dummy0[11]; + void* __toku_dummy0[12]; char __toku_dummy1[24]; void *api_internal; /* 32-bit offset=88 size=4, 64=bit offset=152 size=8 */ void* __toku_dummy2[2]; @@ -348,6 +349,8 @@ struct __toku_db_txn { void* __toku_dummy3[1]; u_int32_t (*id) (DB_TXN *); /* 32-bit offset=112 size=4, 64=bit offset=200 size=8 */ void* __toku_dummy4[4]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define db_txn_struct_i(x) ((struct __toku_db_txn_internal *)(&(x)->iic)) }; struct __toku_db_txn_stat { void* __toku_dummy0[1]; @@ -360,8 +363,6 @@ struct __toku_db_txn_stat { }; struct __toku_dbc { DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ - struct __toku_dbc_internal *i; -#define dbc_struct_i(x) ((x)->i) 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 *); @@ -379,13 +380,16 @@ struct __toku_dbc { 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 *); int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - char __toku_dummy0[112]; + void* __toku_dummy0[1]; + char __toku_dummy1[112]; int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=264 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=272 size=8 */ int (*c_del) (DBC *, u_int32_t); /* 32-bit offset=196 size=4, 64=bit offset=280 size=8 */ - void* __toku_dummy1[1]; + void* __toku_dummy2[1]; int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=296 size=8 */ - void* __toku_dummy2[10]; /* Padding at the end */ + void* __toku_dummy3[10]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define dbc_struct_i(x) ((struct __toku_dbc_internal *)(&(x)->iic)) }; #ifdef _TOKUDB_WRAP_H #define txn_begin txn_begin_tokudb diff --git a/buildheader/db.h_4_4 b/buildheader/db.h_4_4 index beccc81b033..7b2a2de1d7f 100644 --- a/buildheader/db.h_4_4 +++ b/buildheader/db.h_4_4 @@ -37,6 +37,9 @@ typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); #include +#ifndef __BIGGEST_ALIGNMENT__ + #define __BIGGEST_ALIGNMENT__ 16 +#endif typedef struct __toku_db_btree_stat64 { u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */ @@ -342,11 +345,9 @@ struct txn_stat { struct __toku_db_txn { DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */ - struct __toku_db_txn_internal *i; -#define db_txn_struct_i(x) ((x)->i) int (*txn_stat)(DB_TXN *, struct txn_stat **); struct { void *next, *prev; } open_txns; - void* __toku_dummy0[14]; + void* __toku_dummy0[15]; char __toku_dummy1[8]; void *api_internal; /* 32-bit offset=84 size=4, 64=bit offset=160 size=8 */ void* __toku_dummy2[2]; @@ -355,6 +356,8 @@ struct __toku_db_txn { void* __toku_dummy3[2]; u_int32_t (*id) (DB_TXN *); /* 32-bit offset=112 size=4, 64=bit offset=216 size=8 */ void* __toku_dummy4[5]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define db_txn_struct_i(x) ((struct __toku_db_txn_internal *)(&(x)->iic)) }; struct __toku_db_txn_stat { void* __toku_dummy0[1]; @@ -367,8 +370,6 @@ struct __toku_db_txn_stat { }; struct __toku_dbc { DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ - struct __toku_dbc_internal *i; -#define dbc_struct_i(x) ((x)->i) 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 *); @@ -386,7 +387,7 @@ struct __toku_dbc { 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 *); int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[2]; + void* __toku_dummy0[3]; char __toku_dummy1[104]; int (*c_close) (DBC *); /* 32-bit offset=188 size=4, 64=bit offset=272 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=192 size=4, 64=bit offset=280 size=8 */ @@ -394,6 +395,8 @@ struct __toku_dbc { void* __toku_dummy2[1]; int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */ void* __toku_dummy3[10]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define dbc_struct_i(x) ((struct __toku_dbc_internal *)(&(x)->iic)) }; #ifdef _TOKUDB_WRAP_H #define txn_begin txn_begin_tokudb diff --git a/buildheader/db.h_4_5 b/buildheader/db.h_4_5 index 0489863153c..e5b0cb0c53a 100644 --- a/buildheader/db.h_4_5 +++ b/buildheader/db.h_4_5 @@ -37,6 +37,9 @@ typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); #include +#ifndef __BIGGEST_ALIGNMENT__ + #define __BIGGEST_ALIGNMENT__ 16 +#endif typedef struct __toku_db_btree_stat64 { u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */ @@ -343,11 +346,9 @@ struct txn_stat { struct __toku_db_txn { DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */ - struct __toku_db_txn_internal *i; -#define db_txn_struct_i(x) ((x)->i) int (*txn_stat)(DB_TXN *, struct txn_stat **); struct { void *next, *prev; } open_txns; - void* __toku_dummy0[14]; + void* __toku_dummy0[15]; char __toku_dummy1[8]; void *api_internal; /* 32-bit offset=84 size=4, 64=bit offset=160 size=8 */ void* __toku_dummy2[2]; @@ -356,6 +357,8 @@ struct __toku_db_txn { void* __toku_dummy3[2]; u_int32_t (*id) (DB_TXN *); /* 32-bit offset=112 size=4, 64=bit offset=216 size=8 */ void* __toku_dummy4[5]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define db_txn_struct_i(x) ((struct __toku_db_txn_internal *)(&(x)->iic)) }; struct __toku_db_txn_stat { void* __toku_dummy0[1]; @@ -368,8 +371,6 @@ struct __toku_db_txn_stat { }; struct __toku_dbc { DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ - struct __toku_dbc_internal *i; -#define dbc_struct_i(x) ((x)->i) 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 *); @@ -387,7 +388,7 @@ struct __toku_dbc { 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 *); int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[6]; + void* __toku_dummy0[7]; char __toku_dummy1[104]; int (*c_close) (DBC *); /* 32-bit offset=204 size=4, 64=bit offset=304 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=208 size=4, 64=bit offset=312 size=8 */ @@ -395,6 +396,8 @@ struct __toku_dbc { void* __toku_dummy2[1]; int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=220 size=4, 64=bit offset=336 size=8 */ void* __toku_dummy3[10]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define dbc_struct_i(x) ((struct __toku_dbc_internal *)(&(x)->iic)) }; #ifdef _TOKUDB_WRAP_H #define txn_begin txn_begin_tokudb diff --git a/buildheader/db.h_4_6 b/buildheader/db.h_4_6 index 952a0fa2780..fa544d893de 100644 --- a/buildheader/db.h_4_6 +++ b/buildheader/db.h_4_6 @@ -37,6 +37,9 @@ typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); #include +#ifndef __BIGGEST_ALIGNMENT__ + #define __BIGGEST_ALIGNMENT__ 16 +#endif typedef struct __toku_db_btree_stat64 { u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */ @@ -347,11 +350,9 @@ struct txn_stat { struct __toku_db_txn { DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ DB_TXN *parent; /* 32-bit offset=4 size=4, 64=bit offset=8 size=8 */ - struct __toku_db_txn_internal *i; -#define db_txn_struct_i(x) ((x)->i) int (*txn_stat)(DB_TXN *, struct txn_stat **); struct { void *next, *prev; } open_txns; - void* __toku_dummy0[15]; + void* __toku_dummy0[16]; char __toku_dummy1[8]; void *api_internal; /* 32-bit offset=88 size=4, 64=bit offset=168 size=8 */ void* __toku_dummy2[2]; @@ -360,6 +361,8 @@ struct __toku_db_txn { void* __toku_dummy3[2]; u_int32_t (*id) (DB_TXN *); /* 32-bit offset=116 size=4, 64=bit offset=224 size=8 */ void* __toku_dummy4[5]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define db_txn_struct_i(x) ((struct __toku_db_txn_internal *)(&(x)->iic)) }; struct __toku_db_txn_stat { void* __toku_dummy0[2]; @@ -373,8 +376,6 @@ struct __toku_db_txn_stat { }; struct __toku_dbc { DB *dbp; /* 32-bit offset=0 size=4, 64=bit offset=0 size=8 */ - struct __toku_dbc_internal *i; -#define dbc_struct_i(x) ((x)->i) 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 *); @@ -392,7 +393,7 @@ struct __toku_dbc { 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 *); int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *); - void* __toku_dummy0[16]; + void* __toku_dummy0[17]; char __toku_dummy1[104]; int (*c_close) (DBC *); /* 32-bit offset=244 size=4, 64=bit offset=384 size=8 */ int (*c_count) (DBC *, db_recno_t *, u_int32_t); /* 32-bit offset=248 size=4, 64=bit offset=392 size=8 */ @@ -400,6 +401,8 @@ struct __toku_dbc { void* __toku_dummy2[1]; int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); /* 32-bit offset=260 size=4, 64=bit offset=416 size=8 */ void* __toku_dummy3[10]; /* Padding at the end */ + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define dbc_struct_i(x) ((struct __toku_dbc_internal *)(&(x)->iic)) }; #ifdef _TOKUDB_WRAP_H #define txn_begin txn_begin_tokudb diff --git a/buildheader/make_db_h.c b/buildheader/make_db_h.c index 61a7be9b5b1..4461eb3e69e 100644 --- a/buildheader/make_db_h.c +++ b/buildheader/make_db_h.c @@ -197,7 +197,9 @@ struct fieldinfo { #error #endif -void print_struct (const char *structname, int need_internal, struct fieldinfo *fields32, struct fieldinfo *fields64, unsigned int N, const char *extra_decls[]) { +enum need_internal_type { NO_INTERNAL=0, INTERNAL_NAMED=1, INTERNAL_AT_END=2}; + +void print_struct (const char *structname, enum need_internal_type need_internal, struct fieldinfo *fields32, struct fieldinfo *fields64, unsigned int N, const char *extra_decls[]) { unsigned int i; unsigned int current_32 = 0; unsigned int current_64 = 0; @@ -205,6 +207,7 @@ void print_struct (const char *structname, int need_internal, struct fieldinfo * int did_toku_internal=0; // int total32 = fields32[N-1].size; // int total64 = fields32[N-1].size; + assert(need_internal==NO_INTERNAL || need_internal==INTERNAL_NAMED || need_internal==INTERNAL_AT_END); printf("struct __toku_%s {\n", structname); for (i=0; iiic))\n", structname, structname); + did_toku_internal = 1; + } printf("};\n"); assert(did_toku_internal || !need_internal); } @@ -354,6 +362,8 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un printf("#include \n"); + printf("#ifndef __BIGGEST_ALIGNMENT__\n #define __BIGGEST_ALIGNMENT__ 16\n#endif\n"); + //stat64 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"); @@ -486,7 +496,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un "struct { void *next, *prev; } open_txns", NULL, }; - print_struct("db_txn", 1, db_txn_fields32, db_txn_fields64, sizeof(db_txn_fields32)/sizeof(db_txn_fields32[0]), extra); + print_struct("db_txn", INTERNAL_AT_END, db_txn_fields32, db_txn_fields64, sizeof(db_txn_fields32)/sizeof(db_txn_fields32[0]), extra); } assert(sizeof(db_txn_stat_fields32)==sizeof(db_txn_stat_fields64)); @@ -515,7 +525,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un "int (*c_getf_get_both_range_reverse)(DBC *, u_int32_t, DBT *, DBT *, YDB_CALLBACK_FUNCTION, void *)", NULL}; assert(sizeof(dbc_fields32)==sizeof(dbc_fields64)); - print_struct("dbc", 1, dbc_fields32, dbc_fields64, sizeof(dbc_fields32)/sizeof(dbc_fields32[0]), extra); + print_struct("dbc", INTERNAL_AT_END, dbc_fields32, dbc_fields64, sizeof(dbc_fields32)/sizeof(dbc_fields32[0]), extra); } printf("#ifdef _TOKUDB_WRAP_H\n#define txn_begin txn_begin_tokudb\n#endif\n"); diff --git a/buildheader/sample_offsets_64_4_7.h b/buildheader/sample_offsets_64_4_7.h index 702db49b977..5153acdeab7 100644 --- a/buildheader/sample_offsets_64_4_7.h +++ b/buildheader/sample_offsets_64_4_7.h @@ -11,6 +11,8 @@ struct fieldinfo db_env_fields64[] = { {"void *app_private", 216, 8}, {"void *api1_internal", 224, 8}, {"int (*close) (DB_ENV *, u_int32_t)", 408, 8}, + {"int (*dbremove) (DB_ENV *, DB_TXN *, const char *, const char *, u_int32_t)", 416, 8}, + {"int (*dbrename) (DB_ENV *, DB_TXN *, const char *, const char *, const char *, u_int32_t)", 424, 8}, {"void (*err) (const DB_ENV *, int, const char *, ...)", 432, 8}, {"int (*get_cachesize) (DB_ENV *, u_int32_t *, u_int32_t *, int *)", 472, 8}, {"int (*get_flags) (DB_ENV *, u_int32_t *)", 520, 8}, diff --git a/buildheader/tdb.h b/buildheader/tdb.h index 9f4b39273fe..73bc160ef97 100644 --- a/buildheader/tdb.h +++ b/buildheader/tdb.h @@ -37,6 +37,9 @@ typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); #include +#ifndef __BIGGEST_ALIGNMENT__ + #define __BIGGEST_ALIGNMENT__ 16 +#endif typedef struct __toku_db_btree_stat64 { u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */ @@ -293,14 +296,14 @@ struct txn_stat { struct __toku_db_txn { DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; DB_TXN *parent; - struct __toku_db_txn_internal ii; -#define db_txn_struct_i(x) (&(x)->ii) int (*txn_stat)(DB_TXN *, struct txn_stat **); struct { void *next, *prev; } open_txns; void *api_internal; int (*abort) (DB_TXN *); int (*commit) (DB_TXN*, u_int32_t); u_int32_t (*id) (DB_TXN *); + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define db_txn_struct_i(x) ((struct __toku_db_txn_internal *)(&(x)->iic)) }; struct __toku_db_txn_stat { u_int32_t st_nactive; @@ -308,8 +311,6 @@ struct __toku_db_txn_stat { }; struct __toku_dbc { DB *dbp; - struct __toku_dbc_internal ii; -#define dbc_struct_i(x) (&(x)->ii) 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 *); @@ -331,6 +332,8 @@ struct __toku_dbc { int (*c_count) (DBC *, db_recno_t *, u_int32_t); int (*c_del) (DBC *, u_int32_t); int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define dbc_struct_i(x) ((struct __toku_dbc_internal *)(&(x)->iic)) }; #ifdef _TOKUDB_WRAP_H #define txn_begin txn_begin_tokudb diff --git a/db-benchmark-test-cxx/Makefile b/db-benchmark-test-cxx/Makefile index 46714ae226c..92c7871e608 100644 --- a/db-benchmark-test-cxx/Makefile +++ b/db-benchmark-test-cxx/Makefile @@ -20,7 +20,7 @@ include $(TOKUROOT)toku_include/Makefile.include BENCHDBS = bench.bdb/ bench.tokudb OPTFLAGS = -O2 -CXXFLAGS = -Wall -Werror -g $(OPTFLAGS) $(GCOV_FLAGS) +CXXFLAGS = $(GCC_VERSION_SPECIFIC) -Wall -Werror -g $(OPTFLAGS) $(GCOV_FLAGS) # CFLAGS += -pg ifdef BDBDIR diff --git a/include/db.h b/include/db.h index 9f4b39273fe..73bc160ef97 100644 --- a/include/db.h +++ b/include/db.h @@ -37,6 +37,9 @@ typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); #include +#ifndef __BIGGEST_ALIGNMENT__ + #define __BIGGEST_ALIGNMENT__ 16 +#endif typedef struct __toku_db_btree_stat64 { u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */ @@ -293,14 +296,14 @@ struct txn_stat { struct __toku_db_txn { DB_ENV *mgrp /*In TokuDB, mgrp is a DB_ENV not a DB_TXNMGR*/; DB_TXN *parent; - struct __toku_db_txn_internal ii; -#define db_txn_struct_i(x) (&(x)->ii) int (*txn_stat)(DB_TXN *, struct txn_stat **); struct { void *next, *prev; } open_txns; void *api_internal; int (*abort) (DB_TXN *); int (*commit) (DB_TXN*, u_int32_t); u_int32_t (*id) (DB_TXN *); + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define db_txn_struct_i(x) ((struct __toku_db_txn_internal *)(&(x)->iic)) }; struct __toku_db_txn_stat { u_int32_t st_nactive; @@ -308,8 +311,6 @@ struct __toku_db_txn_stat { }; struct __toku_dbc { DB *dbp; - struct __toku_dbc_internal ii; -#define dbc_struct_i(x) (&(x)->ii) 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 *); @@ -331,6 +332,8 @@ struct __toku_dbc { int (*c_count) (DBC *, db_recno_t *, u_int32_t); int (*c_del) (DBC *, u_int32_t); int (*c_get) (DBC *, DBT *, DBT *, u_int32_t); + char iic[0] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +#define dbc_struct_i(x) ((struct __toku_dbc_internal *)(&(x)->iic)) }; #ifdef _TOKUDB_WRAP_H #define txn_begin txn_begin_tokudb diff --git a/include/tdb-internal.h b/include/tdb-internal.h index afbb0d17cdc..ebd8c02475a 100644 --- a/include/tdb-internal.h +++ b/include/tdb-internal.h @@ -18,21 +18,5 @@ struct simple_dbt { void *data; }; -struct __toku_db_txn_internal { - //TXNID txnid64; /* A sixty-four bit txn id. */ - struct tokutxn *tokutxn; - struct __toku_lth *lth; //Hash table holding list of dictionaries this txn has touched - u_int32_t flags; - DB_TXN *child; - struct toku_list dbs_that_must_close_before_abort; -}; - -struct __toku_dbc_internal { - struct brt_cursor *c; - DB_TXN *txn; - struct simple_dbt skey_s,sval_s; - struct simple_dbt *skey,*sval; -}; - // end of _TDB_INTERNAL_H: #endif diff --git a/src/ydb-internal.h b/src/ydb-internal.h index cc138640a39..b58e6328012 100644 --- a/src/ydb-internal.h +++ b/src/ydb-internal.h @@ -163,4 +163,20 @@ int toku_env_is_panicked(DB_ENV *dbenv); void toku_locked_env_err(const DB_ENV * env, int error, const char *fmt, ...) __attribute__((__format__(__printf__, 3, 4))); +struct __toku_db_txn_internal { + //TXNID txnid64; /* A sixty-four bit txn id. */ + struct tokutxn *tokutxn; + struct __toku_lth *lth; //Hash table holding list of dictionaries this txn has touched + u_int32_t flags; + DB_TXN *child; + struct toku_list dbs_that_must_close_before_abort; +}; + +struct __toku_dbc_internal { + struct brt_cursor *c; + DB_TXN *txn; + struct simple_dbt skey_s,sval_s; + struct simple_dbt *skey,*sval; +}; + #endif diff --git a/src/ydb.c b/src/ydb.c index 4aa861e1b24..c3334387cdb 100644 --- a/src/ydb.c +++ b/src/ydb.c @@ -1737,10 +1737,11 @@ static int toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t f return toku_ydb_do_error(env, EINVAL, "DB_ENV->txn_begin: Child transaction isolation level must match parent's isolation level.\n"); } - DB_TXN *MALLOC(result); + size_t result_size = sizeof(DB_TXN)+sizeof(struct __toku_db_txn_internal); // the internal stuff is stuck on the end. + DB_TXN *result = toku_malloc(result_size); if (result == 0) return ENOMEM; - memset(result, 0, sizeof *result); + memset(result, 0, result_size); //toku_ydb_notef("parent=%p flags=0x%x\n", stxn, flags); result->mgrp = env; result->abort = locked_txn_abort; @@ -3599,10 +3600,11 @@ static int toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags, int HANDLE_DB_ILLEGAL_WORKING_PARENT_TXN(db, txn); if (flags != 0) return EINVAL; - DBC *MALLOC(result); + size_t result_size = sizeof(DBC)+sizeof(struct __toku_dbc_internal); // internal stuff stuck on the end + DBC *result = toku_malloc(result_size); if (result == 0) return ENOMEM; - memset(result, 0, sizeof *result); + memset(result, 0, result_size); #define SCRS(name) result->name = locked_ ## name SCRS(c_get); SCRS(c_close); diff --git a/toku_include/Makefile.include b/toku_include/Makefile.include index 6295ad1fdb1..2b883ac2c1d 100644 --- a/toku_include/Makefile.include +++ b/toku_include/Makefile.include @@ -100,7 +100,7 @@ endif # -Wno-deprecated is needed on gcc 4.4.2 to make the #ident complaints go away. # -Wno-strict-aliasing is needed on gcc 4.4.2 to make certain gratuitous warnings go away. ifeq ($(GCCVERSION),4.4.2) - GCC_VERSION_SPECIFIC = -Wno-strict-aliasing -Wno-deprecated + GCC_VERSION_SPECIFIC = -Wno-deprecated endif WALL = $(GCC_VERSION_SPECIFIC) -Wall -Wextra -Wcast-align -Wbad-function-cast -Wno-missing-noreturn -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations @@ -116,6 +116,9 @@ SYMBOLS = -g3 -ggdb3 PORTABILITY= SKIP_WARNING= COMBINE_C = -combine -c +ifeq ($(GCCVERSION),4.4.2) + COMBINE_C += -Wno-strict-aliasing +endif LIBPORTABILITY = $(TOKUROOT)lib/libtokuportability.$(AEXT) LIBPORTABILITY_BUNDLE = $(TOKUROOT)lib/libtokuportability.bundle