summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makedef.pl1
-rw-r--r--thread.h6
-rw-r--r--util.c8
-rw-r--r--win32/Makefile7
-rw-r--r--win32/makefile.mk7
-rw-r--r--win32/win32.h2
-rw-r--r--win32/win32thread.h8
7 files changed, 23 insertions, 16 deletions
diff --git a/makedef.pl b/makedef.pl
index a54b26c227..1cd85c7eb6 100644
--- a/makedef.pl
+++ b/makedef.pl
@@ -551,6 +551,7 @@ if ($PLATFORM eq 'win32') {
foreach my $symbol (qw(
boot_DynaLoader
Perl_init_os_extras
+ Perl_thread_create
Perl_win32_init
RunPerl
win32_errno
diff --git a/thread.h b/thread.h
index 09ed596a52..72292b50c1 100644
--- a/thread.h
+++ b/thread.h
@@ -264,8 +264,10 @@
#ifndef ALLOC_THREAD_KEY
# define ALLOC_THREAD_KEY \
STMT_START { \
- if (pthread_key_create(&PL_thr_key, 0)) \
- Perl_croak(aTHX_ "panic: pthread_key_create"); \
+ if (pthread_key_create(&PL_thr_key, 0)) { \
+ fprintf(stderr, "panic: pthread_key_create"); \
+ exit(1); \
+ } \
} STMT_END
#endif
diff --git a/util.c b/util.c
index 1202b33d6a..091e162e69 100644
--- a/util.c
+++ b/util.c
@@ -3303,8 +3303,12 @@ Perl_get_context(void)
Perl_croak_nocontext("panic: pthread_getspecific");
return (void*)t;
# else
+# ifdef I_MACH_CTHREADS
+ return (void*)cthread_data(cthread_self());
+# else
return (void*)pthread_getspecific(PL_thr_key);
# endif
+# endif
#else
return (void*)NULL;
#endif
@@ -3314,8 +3318,12 @@ void
Perl_set_context(void *t)
{
#if defined(USE_THREADS) || defined(USE_ITHREADS)
+# ifdef I_MACH_CTHREADS
+ cthread_set_data(cthread_self(), t);
+# else
if (pthread_setspecific(PL_thr_key, t))
Perl_croak_nocontext("panic: pthread_setspecific");
+# endif
#endif
}
diff --git a/win32/Makefile b/win32/Makefile
index 321d341ab7..27e597f738 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -535,11 +535,8 @@ EXTRACORE_SRC = $(EXTRACORE_SRC) ..\perlio.c
WIN32_SRC = \
.\win32.c \
- .\win32sck.c
-
-!IF "$(USE_5005THREADS)" == "define"
-WIN32_SRC = $(WIN32_SRC) .\win32thread.c
-!ENDIF
+ .\win32sck.c \
+ .\win32thread.c
!IF "$(CRYPT_SRC)" != ""
WIN32_SRC = $(WIN32_SRC) .\$(CRYPT_SRC)
diff --git a/win32/makefile.mk b/win32/makefile.mk
index c235e9dcf1..44b5b3a2d7 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -658,11 +658,8 @@ EXTRACORE_SRC += ..\perlio.c
WIN32_SRC = \
.\win32.c \
- .\win32sck.c
-
-.IF "$(USE_5005THREADS)" == "define"
-WIN32_SRC += .\win32thread.c
-.ENDIF
+ .\win32sck.c \
+ .\win32thread.c
.IF "$(CRYPT_SRC)" != ""
WIN32_SRC += .\$(CRYPT_SRC)
diff --git a/win32/win32.h b/win32/win32.h
index f102234b78..6f4c0d061e 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -158,6 +158,8 @@ struct utsname {
# define F_OK 0
#endif
+#define PERL_GET_CONTEXT_DEFINED
+
/* Compiler-specific stuff. */
#ifdef __BORLANDC__ /* Borland C++ */
diff --git a/win32/win32thread.h b/win32/win32thread.h
index cfa13cc9f5..46c6bf5f84 100644
--- a/win32/win32thread.h
+++ b/win32/win32thread.h
@@ -168,8 +168,6 @@ extern __declspec(thread) void *PL_current_context;
#define PERL_SET_CONTEXT(t) Perl_set_context(t)
#endif
-#define PERL_GET_CONTEXT_DEFINED
-
#if defined(USE_THREADS)
struct perl_thread;
int Perl_thread_create (struct perl_thread *thr, thread_func_t *fn);
@@ -185,8 +183,10 @@ END_EXTERN_C
#define INIT_THREADS NOOP
#define ALLOC_THREAD_KEY \
STMT_START { \
- if ((PL_thr_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) \
- Perl_croak_nocontext("panic: TlsAlloc"); \
+ if ((PL_thr_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) { \
+ fprintf(stderr,"panic: TlsAlloc"); \
+ exit(1); \
+ } \
} STMT_END
#if defined(USE_RTL_THREAD_API) && !defined(_MSC_VER)