diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/B/B.xs | 2 | ||||
-rw-r--r-- | ext/DB_File/DB_File.xs | 66 | ||||
-rw-r--r-- | ext/File/Glob/Glob.xs | 2 | ||||
-rw-r--r-- | ext/ODBM_File/ODBM_File.xs | 19 | ||||
-rw-r--r-- | ext/Opcode/Opcode.xs | 2 | ||||
-rw-r--r-- | ext/re/re.xs | 2 |
6 files changed, 80 insertions, 13 deletions
diff --git a/ext/B/B.xs b/ext/B/B.xs index b2c163a4eb..491c640c68 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -70,7 +70,7 @@ static char *opclassnames[] = { "B::COP" }; -#define MY_CXT_KEY "B::_guts"##XS_VERSION +#define MY_CXT_KEY "B::_guts" XS_VERSION typedef struct { int x_walkoptree_debug; /* Flag for walkoptree debug hook */ 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) ; diff --git a/ext/File/Glob/Glob.xs b/ext/File/Glob/Glob.xs index f2210bcd04..037b85cc47 100644 --- a/ext/File/Glob/Glob.xs +++ b/ext/File/Glob/Glob.xs @@ -4,7 +4,7 @@ #include "bsd_glob.h" -#define MY_CXT_KEY "File::Glob::_guts"##XS_VERSION +#define MY_CXT_KEY "File::Glob::_guts" XS_VERSION typedef struct { int x_GLOB_ERROR; diff --git a/ext/ODBM_File/ODBM_File.xs b/ext/ODBM_File/ODBM_File.xs index 5a556bfd2f..3bc94fe073 100644 --- a/ext/ODBM_File/ODBM_File.xs +++ b/ext/ODBM_File/ODBM_File.xs @@ -81,7 +81,15 @@ typedef datum datum_value ; #define odbm_FIRSTKEY(db) firstkey() #define odbm_NEXTKEY(db,key) nextkey(key) -static int dbmrefcnt; +#define MY_CXT_KEY "ODBM_File::_guts" XS_VERSION + +typedef struct { + int x_dbmrefcnt; +} my_cxt_t; + +START_MY_CXT + +#define dbmrefcnt (MY_CXT.x_dbmrefcnt) #ifndef DBM_REPLACE #define DBM_REPLACE 0 @@ -89,6 +97,11 @@ static int dbmrefcnt; MODULE = ODBM_File PACKAGE = ODBM_File PREFIX = odbm_ +BOOT: +{ + MY_CXT_INIT; +} + ODBM_File odbm_TIEHASH(dbtype, filename, flags, mode) char * dbtype @@ -99,6 +112,8 @@ odbm_TIEHASH(dbtype, filename, flags, mode) { char *tmpbuf; void * dbp ; + dMY_CXT; + if (dbmrefcnt++) croak("Old dbm can only open one database"); New(0, tmpbuf, strlen(filename) + 5, char); @@ -126,6 +141,8 @@ odbm_TIEHASH(dbtype, filename, flags, mode) void DESTROY(db) ODBM_File db + PREINIT: + dMY_CXT; CODE: dbmrefcnt--; dbmclose(); diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs index c00a5e528b..4ef1347b45 100644 --- a/ext/Opcode/Opcode.xs +++ b/ext/Opcode/Opcode.xs @@ -7,7 +7,7 @@ #define OP_MASK_BUF_SIZE (MAXO + 100) /* XXX op_named_bits and opset_all are never freed */ -#define MY_CXT_KEY "Opcode::_guts"##XS_VERSION +#define MY_CXT_KEY "Opcode::_guts" XS_VERSION typedef struct { HV * x_op_named_bits; /* cache shared for whole process */ diff --git a/ext/re/re.xs b/ext/re/re.xs index 55f0f75884..31887255a1 100644 --- a/ext/re/re.xs +++ b/ext/re/re.xs @@ -17,7 +17,7 @@ extern char* my_re_intuit_start (pTHX_ regexp *prog, SV *sv, char *strpos, struct re_scream_pos_data_s *data); extern SV* my_re_intuit_string (pTHX_ regexp *prog); -#define MY_CXT_KEY "re::_guts"##XS_VERSION +#define MY_CXT_KEY "re::_guts" XS_VERSION typedef struct { int x_oldflag; /* debug flag */ |