1 #define PERL_NO_GET_CONTEXT
6 /* Magic signature for Thread's mg_private is "Th" */
7 #define Thread_MAGIC_SIGNATURE 0x5468
16 static int sig_pipe[2];
18 #ifndef THREAD_RET_TYPE
19 #define THREAD_RET_TYPE void *
20 #define THREAD_RET_CAST(x) ((THREAD_RET_TYPE) x)
24 remove_thread(pTHX_ Thread t)
28 static THREAD_RET_TYPE
29 threadstart(void *arg)
31 return THREAD_RET_CAST(NULL);
35 newthread (pTHX_ SV *startsv, AV *initargs, char *classname)
38 croak("This perl was built for \"ithreads\", which currently does not support Thread.pm.\n"
39 "Run \"perldoc Thread\" for more information");
41 croak("This perl was not built with support for 5.005-style threads.\n"
42 "Run \"perldoc Thread\" for more information");
47 static Signal_t handle_thread_signal (int sig);
50 handle_thread_signal(int sig)
52 unsigned char c = (unsigned char) sig;
55 * We're not really allowed to call fprintf in a signal handler
56 * so don't be surprised if this isn't robust while debugging
59 DEBUG_S(PerlIO_printf(Perl_debug_log,
60 "handle_thread_signal: got signal %d\n", sig));
61 write(sig_pipe[1], &c, 1);
64 MODULE = Thread PACKAGE = Thread
68 new(classname, startsv, ...)
71 AV * av = av_make(items - 2, &ST(2));
73 XPUSHs(sv_2mortal(newthread(aTHX_ startsv, av, classname)));
79 #ifdef USE_5005THREADS
95 PUSHs((t1 == t2) ? &PL_sv_yes : &PL_sv_no);
111 #ifdef USE_5005THREADS
128 PUSHs(t ? &PL_sv_yes : &PL_sv_no);
155 MODULE = Thread PACKAGE = Thread::Signal
158 kill_sighandler_thread()
160 write(sig_pipe[1], "\0", 1);
164 init_thread_signals()
166 PL_sighandlerp = handle_thread_signal;
167 if (pipe(sig_pipe) == -1)
178 ret = read(sig_pipe[0], &c, 1);
179 } while (ret == -1 && errno == EINTR);
181 croak("panic: await_signal");
182 ST(0) = sv_newmortal();
184 sv_setsv(ST(0), c ? PL_psig_ptr[c] : &PL_sv_no);
185 DEBUG_S(PerlIO_printf(Perl_debug_log,
186 "await_signal returning %s\n", SvPEEK(ST(0))));
188 MODULE = Thread PACKAGE = Thread::Specific
191 data(classname = "Thread::Specific")