#endif
#include <fcntl.h>
-static U32 threadnum = 0;
static int sig_pipe[2];
#ifndef THREAD_RET_TYPE
-typedef struct 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(),
/*
* 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);
av_store(av, 0, &sv_no);
av_store(av, 1, newSVsv(thr->errsv));
DEBUG_L(PerlIO_printf(PerlIO_stderr(), "%p died: %s\n",
- SvPV(thr->errsv, na));
+ SvPV(thr->errsv, na)));
} else {
DEBUG_L(STMT_START {
for (i = 1; i <= retval; i++) {
PerlIO_printf(PerlIO_stderr(), "%p return[%d] = %s\n",
- thr, i, SvPEEK(sp[i - 1]));)
+ thr, i, SvPEEK(sp[i - 1]));
}
} STMT_END);
av_store(av, 0, &sv_yes);
SvREFCNT_dec(curstack);
#endif
SvREFCNT_dec(thr->cvcache);
- SvREFCNT_dec(thr->magicals);
+ SvREFCNT_dec(thr->threadsv);
SvREFCNT_dec(thr->specific);
SvREFCNT_dec(thr->errsv);
SvREFCNT_dec(thr->errhv);
SV *sv;
int err;
#ifndef THREAD_CREATE
+ static pthread_attr_t attr;
+ static int attr_inited = 0;
sigset_t fullmask, oldmask;
#endif
sigfillset(&fullmask);
if (sigprocmask(SIG_SETMASK, &fullmask, &oldmask) == -1)
croak("panic: sigprocmask");
- err = pthread_create(&thr->self, pthread_attr_default,
- threadstart, (void*) thr);
+ err = 0;
+ if (!attr_inited) {
+ attr_inited = 1;
+ err = pthread_attr_init(&attr);
+ if (err == 0)
+ err = pthread_attr_setdetachstate(&attr, ATTR_JOINABLE);
+ }
+ if (err == 0)
+ err = pthread_create(&thr->self, &attr, threadstart, (void*) thr);
/* Go */
MUTEX_UNLOCK(&thr->mutex);
#endif
if (err) {
DEBUG_L(PerlIO_printf(PerlIO_stderr(),
- "%p: create of %p failed %d\n", savethread, thr, err));
+ "%p: create of %p failed %d\n",
+ savethread, thr, err));
/* Thread creation failed--clean up */
SvREFCNT_dec(thr->cvcache);
remove_thread(thr);
data(classname = "Thread::Specific")
char * classname
PPCODE:
+#ifdef USE_THREADS
if (AvFILL(thr->specific) == -1) {
GV *gv = gv_fetchpv("Thread::Specific::FIELDS", TRUE, SVt_PVHV);
av_store(thr->specific, 0, newRV((SV*)GvHV(gv)));
}
XPUSHs(sv_bless(newRV((SV*)thr->specific),gv_stashpv(classname,TRUE)));
+#endif