From: Nick Ing-Simmons Date: Sat, 29 Nov 1997 01:35:45 +0000 (+0000) Subject: GCC + Threads on Win32 - best gcc results yet X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c69f112c145fabe210a7e2c5c2406baeea71af2f;p=p5sagit%2Fp5-mst-13.2.git GCC + Threads on Win32 - best gcc results yet p4raw-id: //depot/ansiperl@331 --- diff --git a/XSUB.h b/XSUB.h index 611eac6..75e65cf 100644 --- a/XSUB.h +++ b/XSUB.h @@ -7,7 +7,8 @@ #endif #if defined(WIN32) && defined(__GNUC__) -#define FORCE_ARG_STRING(x) #x +#define STRINGIFY_THINGY(x) #x +#define FORCE_ARG_STRING(x) STRINGIFY_THINGY(x) #else #define FORCE_ARG_STRING(x) x #endif diff --git a/perl.h b/perl.h index 150a9d8..665af31 100644 --- a/perl.h +++ b/perl.h @@ -1474,7 +1474,11 @@ EXT struct stat statbuf; #ifdef HAS_TIMES EXT struct tms timesbuf; #endif +#if defined(WIN32) && defined(__GNUC__) +static STRLEN na; +#else EXT STRLEN na; /* for use in SvPV when length is Not Applicable */ +#endif /* for tmp use in stupid debuggers */ EXT int * di; diff --git a/thread.h b/thread.h index 656a693..e29f8ad 100644 --- a/thread.h +++ b/thread.h @@ -171,7 +171,9 @@ struct perl_thread { SV * TSv; XPV * TXpv; struct stat Tstatbuf; +#ifdef HAS_TIMES struct tms Ttimesbuf; +#endif /* XXX What about regexp stuff? */ diff --git a/win32/makedef.pl b/win32/makedef.pl index d87cbed..87f1d93 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -159,6 +159,11 @@ Perl_cshname Perl_opsave !END!OF!SKIP! +if ($CCTYPE eq 'GCC') + { + $skip_sym .= "Perl_na\n"; + } + if ($define{'MYMALLOC'}) { $skip_sym .= <<'!END!OF!SKIP!'; diff --git a/win32/makegcc.mk b/win32/makegcc.mk index a6c574e..dfe372c 100644 --- a/win32/makegcc.mk +++ b/win32/makegcc.mk @@ -11,7 +11,7 @@ # newly built perl. INST_DRV=c: INST_TOP=$(INST_DRV)\perl5004.5x -#BUILDOPT=-DUSE_THREADS +BUILDOPT=-DUSE_THREADS # diff --git a/win32/win32.h b/win32/win32.h index 791d92a..93b74ef 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -15,6 +15,8 @@ typedef long long __int64; #define Win32_Winsock #endif + + #define WIN32_LEAN_AND_MEAN #include @@ -33,6 +35,13 @@ typedef long long __int64; #include "EXTERN.h" #endif +struct tms { + long tms_utime; + long tms_stime; + long tms_cutime; + long tms_cstime; +}; + #ifndef START_EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { diff --git a/win32/win32iop.h b/win32/win32iop.h index ccc1a65..a2b318a 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -30,13 +30,6 @@ */ START_EXTERN_C -struct tms { - long tms_utime; - long tms_stime; - long tms_cutime; - long tms_cstime; -}; - EXT int * win32_errno(void); EXT char *** win32_environ(void); EXT FILE* win32_stdin(void); diff --git a/win32/win32thread.c b/win32/win32thread.c index 039f8b4..d62dadd 100644 --- a/win32/win32thread.c +++ b/win32/win32thread.c @@ -1,18 +1,28 @@ #include "EXTERN.h" #include "perl.h" +#ifdef USE_DECLSPEC_THREAD __declspec(thread) struct perl_thread *Perl_current_thread = NULL; +#endif void Perl_setTHR(struct perl_thread *t) { +#ifdef USE_DECLSPEC_THREAD Perl_current_thread = t; +#else + TlsSetValue(thr_key,t); +#endif } struct perl_thread * Perl_getTHR(void) { +#ifdef USE_DECLSPEC_THREAD return Perl_current_thread; +#else + return (struct perl_thread *) TlsGetValue(thr_key); +#endif } void diff --git a/win32/win32thread.h b/win32/win32thread.h index 591184b..6f355f0 100644 --- a/win32/win32thread.h +++ b/win32/win32thread.h @@ -108,7 +108,7 @@ typedef THREAD_RET_TYPE thread_func_t(void *); START_EXTERN_C -#if defined(PERLDLL) && (!defined(__BORLANDC__) || defined(_DLL)) +#if defined(PERLDLL) && defined(USE_DECLSPEC_THREAD) && (!defined(__BORLANDC__) || defined(_DLL)) extern __declspec(thread) struct perl_thread *Perl_current_thread; #define SET_THR(t) (Perl_current_thread = t) #define THR Perl_current_thread @@ -116,6 +116,7 @@ extern __declspec(thread) struct perl_thread *Perl_current_thread; #define THR Perl_getTHR() #define SET_THR(t) Perl_setTHR(t) #endif +struct perl_thread; void Perl_alloc_thread_key _((void)); int Perl_thread_create _((struct perl_thread *thr, thread_func_t *fn)); @@ -126,7 +127,7 @@ void Perl_setTHR _((struct perl_thread *t)); END_EXTERN_C #define INIT_THREADS NOOP -#define ALLOC_THREAD_KEY NOOP +#define ALLOC_THREAD_KEY Perl_alloc_thread_key() #define SET_THREAD_SELF(thr) Perl_set_thread_self(thr) #define JOIN(t, avp) \