Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
7a220cdd
Commit
7a220cdd
authored
Sep 05, 2007
by
Bradley C. Kuszmaul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do dbt
git-svn-id:
file:///svn/tokudb@247
c7de825b-a66e-492c-adef-691d508d4ae1
parent
2fe4eccd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
40 deletions
+61
-40
buildheader/sample_offsets.c
buildheader/sample_offsets.c
+44
-30
buildheader/sample_offsets_32.h
buildheader/sample_offsets_32.h
+17
-10
No files found.
buildheader/sample_offsets.c
View file @
7a220cdd
/* Make a db.h that will be link-time compatible with Sleepycat's Berkeley DB. */
#include
<db.h>
#include
"../../mysql-5.0.27/mysql-5.0.27/bdb/build_win32/db.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
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
s
ample_offsets
(
void
)
{
void
s
ort_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
<
db_field_counter
;
i
++
)
{
fprintf
(
outf
,
" {
\"
%s
\"
, %d, %d}"
,
db_fields
[
i
].
decl
,
db_fields
[
i
].
off
,
db_fields
[
i
].
size
);
if
(
i
+
1
<
db_field_counter
)
fprintf
(
outf
,
","
);
qsort
(
fields
,
field_counter
,
sizeof
(
fields
[
0
]),
compare_fields
);
fprintf
(
outf
,
"struct fieldinfo %s_fields%d[] = {
\n
"
,
structname
,
__WORDSIZE
);
for
(
i
=
0
;
i
<
field_counter
;
i
++
)
{
fprintf
(
outf
,
" {
\"
%s
\"
, %d, %d}"
,
fields
[
i
].
decl
,
fields
[
i
].
off
,
fields
[
i
].
size
);
if
(
i
+
1
<
field_counter
)
fprintf
(
outf
,
","
);
fprintf
(
outf
,
"
\n
"
);
}
fprintf
(
outf
,
"};
\n
"
);
}
void
sample_db_offsets
(
void
)
{
/* Do these in alphabetical order. */
field_counter
=
0
;
STRUCT_SETUP
(
DB
,
app_private
,
"void *%s"
);
STRUCT_SETUP
(
DB
,
close
,
"int (*%s) (DB*, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
cursor
,
"int (*%s) (DB *, DB_TXN *, DBC **, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
del
,
"int (*%s) (DB *, DB_TXN *, DBT *, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
get
,
"int (*%s) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
key_range
,
"int (*%s) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
open
,
"int (*%s) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int)"
);
STRUCT_SETUP
(
DB
,
put
,
"int (*%s) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
remove
,
"int (*%s) (DB *, const char *, const char *, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
rename
,
"int (*%s) (DB *, const char *, const char *, const char *, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
set_bt_compare
,
"int (*%s) (DB *, int (*)(DB *, const DBT *, const DBT *))"
);
STRUCT_SETUP
(
DB
,
set_flags
,
"int (*%s) (DB *, u_int32_t)"
);
STRUCT_SETUP
(
DB
,
stat
,
"int (*%s) (DB *, void *, u_int32_t)"
);
sort_and_dump_fields
(
"db"
);
}
void
sample_dbt_offsets
(
void
)
{
field_counter
=
0
;
STRUCT_SETUP
(
DBT
,
app_private
,
"void*%s"
);
STRUCT_SETUP
(
DBT
,
data
,
"void*%s"
);
STRUCT_SETUP
(
DBT
,
flags
,
"u_int32_t %s"
);
STRUCT_SETUP
(
DBT
,
size
,
"u_int32_t %s"
);
STRUCT_SETUP
(
DBT
,
ulen
,
"u_int32_t %s"
);
sort_and_dump_fields
(
"dbt"
);
}
int
main
(
int
argc
__attribute__
((
__unused__
)),
char
*
argv
[]
__attribute__
((
__unused__
)))
{
open_file
();
fprintf
(
outf
,
"/* BDB offsets on a %d-bit machine */
\n
"
,
__WORDSIZE
);
sample_offsets
();
sample_db_offsets
();
sample_dbt_offsets
();
return
0
;
}
buildheader/sample_offsets_32.h
View file @
7a220cdd
/* BDB offsets on a 32-bit machine */
struct
fieldinfo
fields32
[]
=
{
struct
fieldinfo
db_
fields32
[]
=
{
{
"void *app_private"
,
16
,
4
},
{
"int (*close) (DB*, u_int32_t)"
,
272
,
4
},
{
"int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t)"
,
276
,
4
},
{
"int (*del) (DB *, DB_TXN *, DBT *, u_int32_t)"
,
280
,
4
},
{
"int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)"
,
300
,
4
},
{
"int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t)"
,
364
,
4
},
{
"int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int)"
,
368
,
4
},
{
"int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)"
,
372
,
4
},
{
"int (*remove) (DB *, const char *, const char *, u_int32_t)"
,
376
,
4
},
{
"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)"
,
380
,
4
},
{
"int (*set_flags) (DB *, u_int32_t)"
,
424
,
4
},
{
"int (*stat) (DB *, void *, u_int32_t)"
,
452
,
4
},
{
"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))"
,
476
,
4
}
{
"int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)"
,
296
,
4
},
{
"int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t)"
,
316
,
4
},
{
"int (*open) (DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int)"
,
320
,
4
},
{
"int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t)"
,
324
,
4
},
{
"int (*remove) (DB *, const char *, const char *, u_int32_t)"
,
328
,
4
},
{
"int (*rename) (DB *, const char *, const char *, const char *, u_int32_t)"
,
332
,
4
},
{
"int (*set_flags) (DB *, u_int32_t)"
,
380
,
4
},
{
"int (*stat) (DB *, void *, u_int32_t)"
,
396
,
4
},
{
"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))"
,
412
,
4
}
};
struct
fieldinfo
dbt_fields32
[]
=
{
{
"void*data"
,
0
,
4
},
{
"u_int32_t size"
,
4
,
4
},
{
"u_int32_t ulen"
,
8
,
4
},
{
"void*app_private"
,
20
,
4
},
{
"u_int32_t flags"
,
24
,
4
}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment