summaryrefslogtreecommitdiff
path: root/ext/Thread
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1997-11-19 22:10:51 -0800
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-11-25 14:16:29 +0000
commit52e1cb5ebf5e5a8cd5d3d9673b540b0c0dfe20df (patch)
tree078676a210b97f20bbebc123cfe028728a29a04e /ext/Thread
parent51dd5992be029393cb3f221313a1a6ec2a76c21a (diff)
downloadperl-52e1cb5ebf5e5a8cd5d3d9673b540b0c0dfe20df.tar.gz
AIX patch (including Configure support for {sched,pthread}_yield,
pthread initial detach state, renaming perl_thread to perl_os_thread and struct thread to struct perl_thread): Subject: Re: _54 on AIX p4raw-id: //depot/perl@290
Diffstat (limited to 'ext/Thread')
-rw-r--r--ext/Thread/Makefile.PL6
-rw-r--r--ext/Thread/Thread.pm4
-rw-r--r--ext/Thread/Thread.xs27
3 files changed, 32 insertions, 5 deletions
diff --git a/ext/Thread/Makefile.PL b/ext/Thread/Makefile.PL
index d699091cc1..bed0db43d7 100644
--- a/ext/Thread/Makefile.PL
+++ b/ext/Thread/Makefile.PL
@@ -1,2 +1,6 @@
use ExtUtils::MakeMaker;
-WriteMakefile(NAME => "Thread");
+WriteMakefile(
+ NAME => 'Thread',
+ VERSION_FROM => 'Thread.pm'
+ );
+
diff --git a/ext/Thread/Thread.pm b/ext/Thread/Thread.pm
index 1936142e52..48ca3047b9 100644
--- a/ext/Thread/Thread.pm
+++ b/ext/Thread/Thread.pm
@@ -1,6 +1,10 @@
package Thread;
require Exporter;
require DynaLoader;
+use vars qw($VERSION @ISA @EXPORT);
+
+$VERSION = "1.0";
+
@ISA = qw(Exporter DynaLoader);
@EXPORT_OK = qw(yield cond_signal cond_broadcast cond_wait async);
diff --git a/ext/Thread/Thread.xs b/ext/Thread/Thread.xs
index 0844312dd4..17c724ac9d 100644
--- a/ext/Thread/Thread.xs
+++ b/ext/Thread/Thread.xs
@@ -16,13 +16,13 @@ static U32 threadnum = 0;
static int sig_pipe[2];
#ifndef THREAD_RET_TYPE
-typedef struct thread *Thread;
+typedef struct perl_thread *Thread;
#define THREAD_RET_TYPE void *
#define THREAD_RET_CAST(x) ((THREAD_RET_TYPE) x)
#endif
static void
-remove_thread(struct thread *t)
+remove_thread(struct perl_thread *t)
{
#ifdef USE_THREADS
DEBUG_L(WITH_THR(PerlIO_printf(PerlIO_stderr(),
@@ -106,8 +106,8 @@ threadstart(void *arg)
/*
* It's safe to wait until now to set the thread-specific pointer
- * from our pthread_t structure to our struct thread, since we're
- * the only thread who can get at it anyway.
+ * from our pthread_t structure to our struct perl_thread, since
+ * we're the only thread who can get at it anyway.
*/
SET_THR(thr);
@@ -234,8 +234,27 @@ newthread (SV *startsv, AV *initargs, char *classname)
sigfillset(&fullmask);
if (sigprocmask(SIG_SETMASK, &fullmask, &oldmask) == -1)
croak("panic: sigprocmask");
+#ifdef PTHREADS_CREATED_JOINABLE
err = pthread_create(&thr->self, pthread_attr_default,
threadstart, (void*) thr);
+#else
+ {
+ pthread_attr_t attr;
+
+ err = pthread_attr_init(&attr);
+ if (err == 0) {
+#ifdef PTHREAD_CREATE_UNDETACHED
+ err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_UNDETACHED);
+#else
+ croak("panic: pthread_attr_setdetachstate");
+#endif
+ if (err == 0)
+ err = pthread_create(&thr->self, &attr,
+ threadstart, (void*) thr);
+ }
+ pthread_attr_destroy(&attr);
+ }
+#endif
/* Go */
MUTEX_UNLOCK(&thr->mutex);
#endif