1 #define PERL_NO_GET_CONTEXT
13 static int sig_pipe[2];
15 #ifndef THREAD_RET_TYPE
16 #define THREAD_RET_TYPE void *
17 #define THREAD_RET_CAST(x) ((THREAD_RET_TYPE) x)
21 remove_thread(pTHX_ Thread t)
25 static THREAD_RET_TYPE
26 threadstart(void *arg)
28 return THREAD_RET_CAST(NULL);
32 newthread (pTHX_ SV *startsv, AV *initargs, char *classname)
35 croak("This perl was built for \"ithreads\", which currently does not support Thread.pm.\n"
36 "Run \"perldoc Thread\" for more information");
38 croak("This perl was not built with support for 5.005-style threads.\n"
39 "Run \"perldoc Thread\" for more information");
44 static Signal_t handle_thread_signal (int sig);
47 handle_thread_signal(int sig)
49 unsigned char c = (unsigned char) sig;
52 * We're not really allowed to call fprintf in a signal handler
53 * so don't be surprised if this isn't robust while debugging
56 DEBUG_S(PerlIO_printf(Perl_debug_log,
57 "handle_thread_signal: got signal %d\n", sig));
58 write(sig_pipe[1], &c, 1);
61 MODULE = Thread PACKAGE = Thread
65 new(classname, startsv, ...)
68 AV * av = av_make(items - 2, &ST(2));
70 XPUSHs(sv_2mortal(newthread(aTHX_ startsv, av, classname)));
76 #ifdef USE_5005THREADS
92 PUSHs((t1 == t2) ? &PL_sv_yes : &PL_sv_no);
108 #ifdef USE_5005THREADS
125 PUSHs(t ? &PL_sv_yes : &PL_sv_no);
152 MODULE = Thread PACKAGE = Thread::Signal
155 kill_sighandler_thread()
157 write(sig_pipe[1], "\0", 1);
161 init_thread_signals()
163 PL_sighandlerp = handle_thread_signal;
164 if (pipe(sig_pipe) == -1)
175 ret = read(sig_pipe[0], &c, 1);
176 } while (ret == -1 && errno == EINTR);
178 croak("panic: await_signal");
179 ST(0) = sv_newmortal();
181 sv_setsv(ST(0), c ? PL_psig_ptr[c] : &PL_sv_no);
182 DEBUG_S(PerlIO_printf(Perl_debug_log,
183 "await_signal returning %s\n", SvPEEK(ST(0))));
185 MODULE = Thread PACKAGE = Thread::Specific
188 data(classname = "Thread::Specific")