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
85b519be
Commit
85b519be
authored
Sep 05, 2007
by
Bradley C. Kuszmaul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fiddle around
git-svn-id:
file:///svn/tokudb@252
c7de825b-a66e-492c-adef-691d508d4ae1
parent
ccbebab6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
22 deletions
+33
-22
buildheader/make_db_h.c
buildheader/make_db_h.c
+15
-14
buildheader/sample_offsets.c
buildheader/sample_offsets.c
+14
-6
buildheader/sample_offsets_32.h
buildheader/sample_offsets_32.h
+4
-2
No files found.
buildheader/make_db_h.c
View file @
85b519be
...
...
@@ -15,9 +15,9 @@ void print_dbtype(void) {
}
#define DECL_LIMIT 100
//
#define DECL_LIMIT 100
struct
fieldinfo
{
char
decl
[
DECL_LIMIT
]
;
char
*
decl
;
unsigned
int
off
;
unsigned
int
size
;
};
...
...
@@ -25,31 +25,31 @@ struct fieldinfo {
#include "sample_offsets_32.h"
#include "sample_offsets_64.h"
void
print_struct
(
const
char
*
structname
,
struct
fieldinfo
*
fields32
,
struct
fieldinfo
*
fields64
,
unsigned
int
N
)
{
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
did_toku_internal
=
0
;
printf
(
"struct __toku_%s {
\n
"
,
structname
);
for
(
i
=
0
;
i
<
N
;
i
++
)
{
unsigned
int
this_32
=
fields32
[
i
].
off
;
unsigned
int
this_64
=
fields64
[
i
].
off
;
assert
(
strcmp
(
fields32
[
i
].
decl
,
fields64
[
i
].
decl
)
==
0
);
#if 0
if (!did_toku_internal && this_offset+sizeof(void*)>current_offset) {
printf(" struct __tokudb_internal *i;\n");
current_offset+=sizeof(void*);
did_toku_internal=1;
}
#endif
//fprintf(stderr, "this32=%d current32=%d this64=%d current64=%d\n", this_32, current_32, this_64, current_64);
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
;
printf
(
" void* dummy%d[%d];
\n
"
,
dummy_counter
++
,
diff
/
4
);
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
;
...
...
@@ -68,6 +68,7 @@ void print_struct (const char *structname, struct fieldinfo *fields32, struct fi
current_32
+=
fields32
[
i
].
size
;
current_64
+=
fields64
[
i
].
size
;
}
assert
(
did_toku_internal
||
!
need_internal
);
printf
(
"};
\n
"
);
}
...
...
@@ -80,10 +81,10 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
print_dbtype
();
assert
(
sizeof
(
db_fields32
)
==
sizeof
(
db_fields64
));
print_struct
(
"db"
,
db_fields32
,
db_fields64
,
sizeof
(
db_fields32
)
/
sizeof
(
db_fields32
[
0
]));
print_struct
(
"db"
,
1
,
db_fields32
,
db_fields64
,
sizeof
(
db_fields32
)
/
sizeof
(
db_fields32
[
0
]));
assert
(
sizeof
(
dbt_fields32
)
==
sizeof
(
dbt_fields64
));
print_struct
(
"dbt"
,
dbt_fields32
,
dbt_fields64
,
sizeof
(
dbt_fields32
)
/
sizeof
(
dbt_fields32
[
0
]));
print_struct
(
"dbt"
,
0
,
dbt_fields32
,
dbt_fields64
,
sizeof
(
dbt_fields32
)
/
sizeof
(
dbt_fields32
[
0
]));
printf
(
"#if defined(__cplusplus)
\n
}
\n
#endif
\n
"
);
printf
(
"#endif
\n
"
);
...
...
buildheader/sample_offsets.c
View file @
85b519be
...
...
@@ -39,15 +39,14 @@ void open_file (void) {
}
void
sort_and_dump_fields
(
const
char
*
structname
)
{
void
sort_and_dump_fields
(
const
char
*
structname
,
unsigned
int
sizeofstruct
)
{
int
i
;
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
,
" {
\"
%s
\"
, %d, %d},
\n
"
,
fields
[
i
].
decl
,
fields
[
i
].
off
,
fields
[
i
].
size
);
}
fprintf
(
outf
,
" {0, 0, %d} /* size of whole struct */
\n
"
,
sizeofstruct
);
fprintf
(
outf
,
"};
\n
"
);
}
...
...
@@ -67,8 +66,9 @@ void sample_db_offsets (void) {
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"
);
sort_and_dump_fields
(
"db"
,
sizeof
(
DB
)
);
}
void
sample_dbt_offsets
(
void
)
{
field_counter
=
0
;
STRUCT_SETUP
(
DBT
,
app_private
,
"void*%s"
);
...
...
@@ -76,8 +76,16 @@ void sample_dbt_offsets (void) {
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"
);
sort_and_dump_fields
(
"dbt"
,
sizeof
(
DBT
)
);
}
void
sample_db_txn_offsets
(
void
)
{
field_counter
=
0
;
STRUCT_SETUP
(
DB_TXN
,
commit
,
"int (*%s) (DB_TXN*, u_int32_t)"
);
STRUCT_SETUP
(
DB_TXN
,
id
,
"u_int32_t (*%s) (DB_TXN *)"
);
sort_and_dump_fields
(
"db_txn"
,
sizeof
(
DB_TXN
));
}
int
main
(
int
argc
__attribute__
((
__unused__
)),
char
*
argv
[]
__attribute__
((
__unused__
)))
{
open_file
();
fprintf
(
outf
,
"/* BDB offsets on a %d-bit machine */
\n
"
,
__WORDSIZE
);
...
...
buildheader/sample_offsets_32.h
View file @
85b519be
...
...
@@ -12,12 +12,14 @@ struct fieldinfo db_fields32[] = {
{
"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
}
{
"int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *))"
,
412
,
4
},
{
0
,
0
,
484
}
/* size of whole struct */
};
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
}
{
"u_int32_t flags"
,
24
,
4
},
{
0
,
0
,
28
}
/* size of whole struct */
};
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