diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-10-26 13:03:01 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-10-26 13:03:01 +0000 |
commit | df3728a2a53a64c63edf08a4429a7a57b76ca4aa (patch) | |
tree | 41cb3c77a25414e4bf6259507dfbadcbc2ea463d /ext/DB_File | |
parent | 9ece3ee6650e9c2f6d5131c19ae5e80f2a8bfc4a (diff) | |
download | perl-df3728a2a53a64c63edf08a4429a7a57b76ca4aa.tar.gz |
Integrate maintperl changes #12268 and #12669;
final touches to the audit for statics and thread-unsafe code
* make DB_File, ODBM_File thread-safe
* remove unnecessary/dangerous statics and protect others
from not getting accidentally enabled under threaded perls
windows support functions get_childdir() et al aren't exported
correctly under vanilla build
Testing under win32 appreciated since changes there had
to be manually merged and I cannot test how badly did I do.
p4raw-link: @12268 on //depot/perlio: bb407f0b8769c638c05e60ebfd157a1e676a6c22
p4raw-id: //depot/perl@12678
p4raw-integrated: from //depot/maint-5.6/perl@12677 'copy in'
win32/vmem.h (@5902..) 'merge in' ext/DB_File/DB_File.xs
(@8693..) win32/win32iop.h (@8917..) ext/ODBM_File/ODBM_File.xs
(@8995..) iperlsys.h (@9154..) scope.c (@9584..) makedef.pl
(@11425..) gv.c (@12026..) op.c (@12145..) util.c (@12220..)
toke.c (@12550..) ext/B/B.xs ext/File/Glob/Glob.xs
ext/Opcode/Opcode.xs ext/re/re.xs (@12653..) mg.c win32/win32.c
(@12668..)
Diffstat (limited to 'ext/DB_File')
-rw-r--r-- | ext/DB_File/DB_File.xs | 66 |
1 files changed, 58 insertions, 8 deletions
diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs index 52c7670f9b..0beb9f6f26 100644 --- a/ext/DB_File/DB_File.xs +++ b/ext/DB_File/DB_File.xs @@ -463,10 +463,21 @@ extern void __getBerkeleyDBInfo(void); #endif /* Internal Global Data */ -static recno_t Value ; -static recno_t zero = 0 ; -static DB_File CurrentDB ; -static DBTKEY empty ; +#define MY_CXT_KEY "DB_File::_guts" XS_VERSION + +typedef struct { + recno_t x_Value; + recno_t x_zero; + DB_File x_CurrentDB; + DBTKEY x_empty; +} my_cxt_t; + +START_MY_CXT + +#define Value (MY_CXT.x_Value) +#define zero (MY_CXT.x_zero) +#define CurrentDB (MY_CXT.x_CurrentDB) +#define empty (MY_CXT.x_empty) #ifdef DB_VERSION_MAJOR @@ -560,7 +571,8 @@ const DBT * key2 ; dTHX; #endif dSP ; - char * data1, * data2 ; + dMY_CXT ; + void * data1, * data2 ; int retval ; int count ; @@ -631,6 +643,7 @@ const DBT * key2 ; dTHX; #endif dSP ; + dMY_CXT ; char * data1, * data2 ; int retval ; int count ; @@ -709,6 +722,7 @@ HASH_CB_SIZE_TYPE size ; dTHX; #endif dSP ; + dMY_CXT; int retval ; int count ; @@ -884,6 +898,7 @@ SV * sv ; void * openinfo = NULL ; INFO * info = &RETVAL->info ; STRLEN n_a; + dMY_CXT; /* printf("In ParseOpenInfo name=[%s] flags=[%d] mode = [%d]\n", name, flags, mode) ; */ Zero(RETVAL, 1, DB_File_type) ; @@ -1157,6 +1172,7 @@ SV * sv ; DB * dbp ; STRLEN n_a; int status ; + dMY_CXT; /* printf("In ParseOpenInfo name=[%s] flags=[%d] mode = [%d]\n", name, flags, mode) ; */ Zero(RETVAL, 1, DB_File_type) ; @@ -1639,6 +1655,7 @@ MODULE = DB_File PACKAGE = DB_File PREFIX = db_ BOOT: { + MY_CXT_INIT; __getBerkeleyDBInfo() ; DBT_clear(empty) ; @@ -1680,6 +1697,8 @@ db_DoTie_(isHASH, dbtype, name=undef, flags=O_CREAT|O_RDWR, mode=0666, type=DB_H int db_DESTROY(db) DB_File db + PREINIT: + dMY_CXT; INIT: CurrentDB = db ; CLEANUP: @@ -1711,6 +1730,8 @@ db_DELETE(db, key, flags=0) DB_File db DBTKEY key u_int flags + PREINIT: + dMY_CXT; INIT: CurrentDB = db ; @@ -1719,6 +1740,8 @@ int db_EXISTS(db, key) DB_File db DBTKEY key + PREINIT: + dMY_CXT; CODE: { DBT value ; @@ -1736,7 +1759,8 @@ db_FETCH(db, key, flags=0) DBTKEY key u_int flags PREINIT: - int RETVAL; + dMY_CXT ; + int RETVAL ; CODE: { DBT value ; @@ -1755,6 +1779,8 @@ db_STORE(db, key, value, flags=0) DBTKEY key DBT value u_int flags + PREINIT: + dMY_CXT; INIT: CurrentDB = db ; @@ -1763,7 +1789,8 @@ void db_FIRSTKEY(db) DB_File db PREINIT: - int RETVAL; + dMY_CXT ; + int RETVAL ; CODE: { DBTKEY key ; @@ -1782,7 +1809,8 @@ db_NEXTKEY(db, key) DB_File db DBTKEY key = NO_INIT PREINIT: - int RETVAL; + dMY_CXT ; + int RETVAL ; CODE: { DBT value ; @@ -1803,6 +1831,8 @@ int unshift(db, ...) DB_File db ALIAS: UNSHIFT = 1 + PREINIT: + dMY_CXT; CODE: { DBTKEY key ; @@ -1843,6 +1873,8 @@ unshift(db, ...) void pop(db) DB_File db + PREINIT: + dMY_CXT; ALIAS: POP = 1 PREINIT: I32 RETVAL; @@ -1872,6 +1904,8 @@ pop(db) void shift(db) DB_File db + PREINIT: + dMY_CXT; ALIAS: SHIFT = 1 PREINIT: I32 RETVAL; @@ -1901,6 +1935,8 @@ shift(db) I32 push(db, ...) DB_File db + PREINIT: + dMY_CXT; ALIAS: PUSH = 1 CODE: { @@ -1943,6 +1979,8 @@ push(db, ...) I32 length(db) DB_File db + PREINIT: + dMY_CXT; ALIAS: FETCHSIZE = 1 CODE: CurrentDB = db ; @@ -1960,6 +1998,8 @@ db_del(db, key, flags=0) DB_File db DBTKEY key u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; RETVAL = db_del(db, key, flags) ; @@ -1979,6 +2019,8 @@ db_get(db, key, value, flags=0) DBTKEY key DBT value = NO_INIT u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; DBT_clear(value) ; @@ -1999,6 +2041,8 @@ db_put(db, key, value, flags=0) DBTKEY key DBT value u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; RETVAL = db_put(db, key, value, flags) ; @@ -2015,6 +2059,8 @@ db_put(db, key, value, flags=0) int db_fd(db) DB_File db + PREINIT: + dMY_CXT ; CODE: CurrentDB = db ; #ifdef DB_VERSION_MAJOR @@ -2039,6 +2085,8 @@ int db_sync(db, flags=0) DB_File db u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; RETVAL = db_sync(db, flags) ; @@ -2056,6 +2104,8 @@ db_seq(db, key, value, flags) DBTKEY key DBT value = NO_INIT u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; DBT_clear(value) ; |