"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 */
#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
dTHX;
#endif
dSP ;
- char * data1, * data2 ;
+ dMY_CXT ;
+ void * data1, * data2 ;
int retval ;
int count ;
dTHX;
#endif
dSP ;
+ dMY_CXT ;
char * data1, * data2 ;
int retval ;
int count ;
dTHX;
#endif
dSP ;
+ dMY_CXT;
int retval ;
int count ;
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) ;
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) ;
BOOT:
{
+ MY_CXT_INIT;
__getBerkeleyDBInfo() ;
DBT_clear(empty) ;
int
db_DESTROY(db)
DB_File db
+ PREINIT:
+ dMY_CXT;
INIT:
CurrentDB = db ;
CLEANUP:
DB_File db
DBTKEY key
u_int flags
+ PREINIT:
+ dMY_CXT;
INIT:
CurrentDB = db ;
db_EXISTS(db, key)
DB_File db
DBTKEY key
+ PREINIT:
+ dMY_CXT;
CODE:
{
DBT value ;
DBTKEY key
u_int flags
PREINIT:
- int RETVAL;
+ dMY_CXT ;
+ int RETVAL ;
CODE:
{
DBT value ;
DBTKEY key
DBT value
u_int flags
+ PREINIT:
+ dMY_CXT;
INIT:
CurrentDB = db ;
db_FIRSTKEY(db)
DB_File db
PREINIT:
- int RETVAL;
+ dMY_CXT ;
+ int RETVAL ;
CODE:
{
DBTKEY key ;
DB_File db
DBTKEY key = NO_INIT
PREINIT:
- int RETVAL;
+ dMY_CXT ;
+ int RETVAL ;
CODE:
{
DBT value ;
unshift(db, ...)
DB_File db
ALIAS: UNSHIFT = 1
+ PREINIT:
+ dMY_CXT;
CODE:
{
DBTKEY key ;
void
pop(db)
DB_File db
+ PREINIT:
+ dMY_CXT;
ALIAS: POP = 1
PREINIT:
I32 RETVAL;
void
shift(db)
DB_File db
+ PREINIT:
+ dMY_CXT;
ALIAS: SHIFT = 1
PREINIT:
I32 RETVAL;
I32
push(db, ...)
DB_File db
+ PREINIT:
+ dMY_CXT;
ALIAS: PUSH = 1
CODE:
{
I32
length(db)
DB_File db
+ PREINIT:
+ dMY_CXT;
ALIAS: FETCHSIZE = 1
CODE:
CurrentDB = db ;
DB_File db
DBTKEY key
u_int flags
+ PREINIT:
+ dMY_CXT;
CODE:
CurrentDB = db ;
RETVAL = db_del(db, key, flags) ;
DBTKEY key
DBT value = NO_INIT
u_int flags
+ PREINIT:
+ dMY_CXT;
CODE:
CurrentDB = db ;
DBT_clear(value) ;
DBTKEY key
DBT value
u_int flags
+ PREINIT:
+ dMY_CXT;
CODE:
CurrentDB = db ;
RETVAL = db_put(db, key, value, flags) ;
int
db_fd(db)
DB_File db
+ PREINIT:
+ dMY_CXT ;
CODE:
CurrentDB = db ;
#ifdef DB_VERSION_MAJOR
db_sync(db, flags=0)
DB_File db
u_int flags
+ PREINIT:
+ dMY_CXT;
CODE:
CurrentDB = db ;
RETVAL = db_sync(db, flags) ;
DBTKEY key
DBT value = NO_INIT
u_int flags
+ PREINIT:
+ dMY_CXT;
CODE:
CurrentDB = db ;
DBT_clear(value) ;
#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;
#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
MODULE = ODBM_File PACKAGE = ODBM_File PREFIX = odbm_
+BOOT:
+{
+ MY_CXT_INIT;
+}
+
ODBM_File
odbm_TIEHASH(dbtype, filename, flags, mode)
char * dbtype
{
char *tmpbuf;
void * dbp ;
+ dMY_CXT;
+
if (dbmrefcnt++)
croak("Old dbm can only open one database");
New(0, tmpbuf, strlen(filename) + 5, char);
void
DESTROY(db)
ODBM_File db
+ PREINIT:
+ dMY_CXT;
CODE:
dbmrefcnt--;
dbmclose();
#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 */
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 */
GV*
Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method)
{
- static char autoload[] = "AUTOLOAD";
- static STRLEN autolen = 8;
+ char autoload[] = "AUTOLOAD";
+ STRLEN autolen = sizeof(autoload)-1;
GV* gv;
CV* cv;
HV* varstash;
#define PerlEnv_putenv(str) putenv((str))
#define PerlEnv_getenv(str) getenv((str))
#define PerlEnv_getenv_len(str,l) getenv_len((str), (l))
-#define PerlEnv_clearenv() clearenv()
-#define PerlEnv_get_childenv() get_childenv()
-#define PerlEnv_free_childenv(e) free_childenv((e))
-#define PerlEnv_get_childdir() get_childdir()
-#define PerlEnv_free_childdir(d) free_childdir((d))
#ifdef HAS_ENVGETENV
# define PerlEnv_ENVgetenv(str) ENVgetenv((str))
# define PerlEnv_ENVgetenv_len(str,l) ENVgetenv_len((str), (l))
#define PerlEnv_sitelib_path(str) win32_get_sitelib(str)
#define PerlEnv_vendorlib_path(str) win32_get_vendorlib(str)
#define PerlEnv_get_child_IO(ptr) win32_get_child_IO(ptr)
+#define PerlEnv_clearenv() win32_clearenv()
+#define PerlEnv_get_childenv() win32_get_childenv()
+#define PerlEnv_free_childenv(e) win32_free_childenv((e))
+#define PerlEnv_get_childdir() win32_get_childdir()
+#define PerlEnv_free_childdir(d) win32_free_childdir((d))
+#else
+#define PerlEnv_clearenv() clearenv()
+#define PerlEnv_get_childenv() get_childenv()
+#define PerlEnv_free_childenv(e) free_childenv((e))
+#define PerlEnv_get_childdir() get_childdir()
+#define PerlEnv_free_childdir(d) free_childdir((d))
#endif
#endif /* PERL_IMPLICIT_SYS */
win32_getpid
win32_crypt
win32_dynaload
-
+ win32_get_childenv
+ win32_free_childenv
+ win32_clearenv
+ win32_get_childdir
+ win32_free_childdir
win32_stdin
win32_stdout
win32_stderr
#if defined(VMS) || defined(EPOC)
Perl_die(aTHX_ "Can't make list assignment to %%ENV on this system");
#else
-# ifdef PERL_IMPLICIT_SYS
+# if defined(PERL_IMPLICIT_SYS) || defined(WIN32)
PerlEnv_clearenv();
# else
-# ifdef WIN32
- char *envv = GetEnvironmentStrings();
- char *cur = envv;
- STRLEN len;
- while (*cur) {
- char *end = strchr(cur,'=');
- if (end && end != cur) {
- *end = '\0';
- my_setenv(cur,Nullch);
- *end = '=';
- cur = end + strlen(end+1)+2;
- }
- else if ((len = strlen(cur)))
- cur += len+1;
- }
- FreeEnvironmentStrings(envv);
-# else
-#ifdef USE_ENVIRON_ARRAY
+#if !defined(MACOS_TRADITIONAL)
# ifndef PERL_USE_SAFE_PUTENV
I32 i;
environ[0] = Nullch;
-#endif /* USE_ENVIRON_ARRAY */
-# endif /* WIN32 */
+#endif /* !defined(MACOS_TRADITIONAL) */
# endif /* PERL_IMPLICIT_SYS */
#endif /* VMS */
return 0;
return 0;
}
+#if !defined(PERL_IMPLICIT_CONTEXT)
static SV* sig_sv;
+#endif
Signal_t
Perl_sighandler(int sig)
if(PL_psig_name[sig]) {
sv = SvREFCNT_inc(PL_psig_name[sig]);
flags |= 64;
+#if !defined(PERL_IMPLICIT_CONTEXT)
sig_sv = sv;
+#endif
} else {
sv = sv_newmortal();
sv_setpv(sv,PL_sig_name[sig]);
if (flags & 1)
PL_savestack_ix -= 5; /* Unprotect save in progress. */
/* cxstack_ix-- Not needed, die already unwound it. */
+#if !defined(PERL_IMPLICIT_CONTEXT)
if (flags & 64)
SvREFCNT_dec(sig_sv);
+#endif
}
/* #define PL_OP_SLAB_ALLOC */
-#ifdef PL_OP_SLAB_ALLOC
+#if defined(PL_OP_SLAB_ALLOC) && !defined(PERL_IMPLICIT_CONTEXT)
#define SLAB_SIZE 8192
-static char *PL_OpPtr = NULL;
-static int PL_OpSpace = 0;
+static char *PL_OpPtr = NULL; /* XXX threadead */
+static int PL_OpSpace = 0; /* XXX threadead */
#define NewOp(m,var,c,type) do { if ((PL_OpSpace -= c*sizeof(type)) >= 0) \
var = (type *)(PL_OpPtr -= c*sizeof(type)); \
else \
SV**
Perl_stack_grow(pTHX_ SV **sp, SV **p, int n)
{
-#if defined(DEBUGGING) && !defined(USE_5005THREADS)
- static int growing = 0;
- if (growing++)
- abort();
-#endif
PL_stack_sp = sp;
#ifndef STRESS_REALLOC
av_extend(PL_curstack, (p - PL_stack_base) + (n) + 128);
#else
av_extend(PL_curstack, (p - PL_stack_base) + (n) + 1);
#endif
-#if defined(DEBUGGING) && !defined(USE_5005THREADS)
- growing--;
-#endif
return PL_stack_sp;
}
case KEY_write:
#ifdef EBCDIC
{
- static char ctl_l[2];
-
- if (ctl_l[0] == '\0')
- ctl_l[0] = toCTRL('L');
+ char ctl_l[2];
+ ctl_l[0] = toCTRL('L');
+ ctl_l[1] = '\0';
gv_fetchpv(ctl_l,TRUE, SVt_PV);
}
#else
return PerlProc_signal(signo, handler);
}
-static int sig_trapped;
+static int sig_trapped; /* XXX signals are process-wide anyway, so we
+ ignore the implications of this for threading */
static
Signal_t
long m_lAllocSize; // current alloc size
long m_lRefCount; // number of current users
CRITICAL_SECTION m_cs; // access lock
+#ifdef _DEBUG_MEM
+ FILE* m_pLog;
+#endif
};
// #define _DEBUG_MEM
ASSERT(bRet);
InitializeCriticalSection(&m_cs);
+#ifdef _DEBUG_MEM
+ m_pLog = 0;
+#endif
Init();
}
{
ASSERT(HeapValidate(m_hHeap, HEAP_NO_SERIALIZE, NULL));
WALKHEAPTRACE();
+#ifdef _DEBUG_MEM
+ MemoryUsageMessage(NULL, 0, 0, 0);
+#endif
DeleteCriticalSection(&m_cs);
BOOL bRet = HeapDestroy(m_hHeap);
ASSERT(bRet);
}
#ifdef _DEBUG_MEM
-#define LOG_FILENAME "P:\\Apps\\Perl\\Result.txt"
+#define LOG_FILENAME ".\\MemLog.txt"
void MemoryUsageMessage(char *str, long x, long y, int c)
{
- static FILE* fp = NULL;
char szBuffer[512];
if(str) {
- if(!fp)
- fp = fopen(LOG_FILENAME, "w");
+ if(!m_pLog)
+ m_pLog = fopen(LOG_FILENAME, "w");
sprintf(szBuffer, str, x, y, c);
- fputs(szBuffer, fp);
+ fputs(szBuffer, m_pLog);
}
else {
- fflush(fp);
- fclose(fp);
+ fflush(m_pLog);
+ fclose(m_pLog);
+ m_pLog = 0;
}
}
return -1;
}
+#ifndef PERL_IMPLICIT_CONTEXT
+
static UINT timerid = 0;
static VOID CALLBACK TimerProc(HWND win, UINT msg, UINT id, DWORD time)
CALL_FPTR(PL_sighandlerp)(14);
}
+#endif /* !PERL_IMPLICIT_CONTEXT */
+
DllExport unsigned int
win32_alarm(unsigned int sec)
{
+#ifndef PERL_IMPLICIT_CONTEXT
/*
* the 'obvious' implentation is SetTimer() with a callback
* which does whatever receiving SIGALRM would do
}
}
return 0;
+#endif /* !PERL_IMPLICIT_CONTEXT */
}
#ifdef HAVE_DES_FCRYPT
* environment and the current directory to CreateProcess
*/
-void*
-get_childenv(void)
+DllExport void*
+win32_get_childenv(void)
{
return NULL;
}
-void
-free_childenv(void* d)
+DllExport void
+win32_free_childenv(void* d)
{
}
-char*
-get_childdir(void)
+DllExport void
+win32_clearenv(void)
+{
+ char *envv = GetEnvironmentStrings();
+ char *cur = envv;
+ STRLEN len;
+ while (*cur) {
+ char *end = strchr(cur,'=');
+ if (end && end != cur) {
+ *end = '\0';
+ SetEnvironmentVariable(cur, NULL);
+ *end = '=';
+ cur = end + strlen(end+1)+2;
+ }
+ else if ((len = strlen(cur)))
+ cur += len+1;
+ }
+ FreeEnvironmentStrings(envv);
+}
+
+DllExport char*
+win32_get_childdir(void)
{
dTHX;
char* ptr;
return ptr;
}
-void
-free_childdir(char* d)
+DllExport void
+win32_free_childdir(char* d)
{
dTHX;
Safefree(d);
#ifndef USE_PERL_SBRK
-static char *committed = NULL;
-static char *base = NULL;
-static char *reserved = NULL;
-static char *brk = NULL;
-static DWORD pagesize = 0;
-static DWORD allocsize = 0;
+static char *committed = NULL; /* XXX threadead */
+static char *base = NULL; /* XXX threadead */
+static char *reserved = NULL; /* XXX threadead */
+static char *brk = NULL; /* XXX threadead */
+static DWORD pagesize = 0; /* XXX threadead */
+static DWORD allocsize = 0; /* XXX threadead */
void *
sbrk(int need)
DllExport char * win32_crypt(const char *txt, const char *salt);
+DllExport void * win32_get_childenv(void);
+DllExport void win32_free_childenv(void* d);
+DllExport void win32_clearenv(void);
+DllExport char * win32_get_childdir(void);
+DllExport void win32_free_childdir(char* d);
+
END_EXTERN_C
/*
#undef crypt
#define crypt(t,s) win32_crypt(t,s)
+#undef get_childenv
+#undef free_childenv
+#undef clearenv
+#undef get_childdir
+#undef free_childdir
+#define get_childenv() win32_get_childenv()
+#define free_childenv(d) win32_free_childenv(d)
+#define clearenv() win32_clearenv()
+#define get_childdir() win32_get_childdir()
+#define free_childdir(d) win32_free_childdir(d)
+
#undef getenv
#define getenv win32_getenv
#undef putenv