| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#define _POSIX_PTHREAD_SEMANTICS |
|
2
|
|
|
|
|
|
|
#include |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
|
5
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
6
|
|
|
|
|
|
|
#include "perl.h" |
|
7
|
|
|
|
|
|
|
#include "XSUB.h" |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#define NEED_newRV_noinc |
|
10
|
|
|
|
|
|
|
#define NEED_sv_2pv_flags |
|
11
|
|
|
|
|
|
|
#include "ppport.h" |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
static void get_sys_error(char* buffer, size_t buffer_size, int errnum) { |
|
14
|
|
|
|
|
|
|
#ifdef HAS_STRERROR_R |
|
15
|
|
|
|
|
|
|
# if STRERROR_R_PROTO == REENTRANT_PROTO_B_IBW |
|
16
|
|
|
|
|
|
|
const char* message = strerror_r(errno, buffer, buffer_size); |
|
17
|
|
|
|
|
|
|
if (message != buffer) |
|
18
|
|
|
|
|
|
|
memcpy(buffer, message, buffer_size); |
|
19
|
|
|
|
|
|
|
# else |
|
20
|
|
|
|
|
|
|
strerror_r(errno, buffer, buffer_size); |
|
21
|
|
|
|
|
|
|
# endif |
|
22
|
|
|
|
|
|
|
#else |
|
23
|
|
|
|
|
|
|
const char* message = strerror(errno); |
|
24
|
|
|
|
|
|
|
strncpy(buffer, message, buffer_size - 1); |
|
25
|
|
|
|
|
|
|
buffer[buffer_size - 1] = '\0'; |
|
26
|
|
|
|
|
|
|
#endif |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#if defined(USE_ITHREADS) && (defined(__linux) || defined(__FreeBSD__)) |
|
30
|
|
|
|
|
|
|
#define THREAD_SCHED |
|
31
|
|
|
|
|
|
|
static pthread_t S_get_pthread(pTHX_ SV* thread_handle) { |
|
32
|
|
|
|
|
|
|
SV* tmp; |
|
33
|
|
|
|
|
|
|
pthread_t* ret; |
|
34
|
|
|
|
|
|
|
dSP; |
|
35
|
|
|
|
|
|
|
PUSHMARK(SP); |
|
36
|
|
|
|
|
|
|
PUSHs(thread_handle); |
|
37
|
|
|
|
|
|
|
PUTBACK; |
|
38
|
|
|
|
|
|
|
call_method("_handle", G_SCALAR); |
|
39
|
|
|
|
|
|
|
SPAGAIN; |
|
40
|
|
|
|
|
|
|
tmp = POPs; |
|
41
|
|
|
|
|
|
|
ret = INT2PTR(pthread_t* ,SvUV(tmp)); |
|
42
|
|
|
|
|
|
|
return *ret; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
#define get_pthread(handle) S_get_pthread(aTHX_ handle) |
|
45
|
|
|
|
|
|
|
#endif |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#define undef &PL_sv_undef |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
typedef int signo_t; |
|
50
|
|
|
|
|
|
|
typedef siginfo_t* Signal__Info; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
MODULE = POSIX::RT::Signal PACKAGE = POSIX::RT::Signal |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
int sigwait(sigset_t* sigset) |
|
55
|
|
|
|
|
|
|
PREINIT: |
|
56
|
|
|
|
|
|
|
int val; |
|
57
|
|
|
|
|
|
|
CODE: |
|
58
|
1
|
|
|
|
|
|
val = sigwait(sigset, &RETVAL); |
|
59
|
1
|
50
|
|
|
|
|
if (val != 0) |
|
60
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
61
|
|
|
|
|
|
|
OUTPUT: |
|
62
|
|
|
|
|
|
|
RETVAL |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Signal::Info sigwaitinfo(sigset_t* set) |
|
65
|
|
|
|
|
|
|
PREINIT: |
|
66
|
|
|
|
|
|
|
int val; |
|
67
|
|
|
|
|
|
|
CODE: |
|
68
|
2
|
|
|
|
|
|
RETVAL = safecalloc(1, sizeof(siginfo_t)); |
|
69
|
2
|
|
|
|
|
|
val = sigwaitinfo(set, RETVAL); |
|
70
|
|
|
|
|
|
|
|
|
71
|
2
|
50
|
|
|
|
|
if (val < 0) { |
|
72
|
0
|
|
|
|
|
|
Safefree(RETVAL); |
|
73
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
OUTPUT: |
|
76
|
|
|
|
|
|
|
RETVAL |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Signal::Info sigtimedwait(sigset_t* set, struct timespec timeout) |
|
79
|
|
|
|
|
|
|
PREINIT: |
|
80
|
|
|
|
|
|
|
int val; |
|
81
|
|
|
|
|
|
|
CODE: |
|
82
|
2
|
|
|
|
|
|
RETVAL = safecalloc(1, sizeof(siginfo_t)); |
|
83
|
2
|
|
|
|
|
|
val = sigtimedwait(set, RETVAL, &timeout); |
|
84
|
|
|
|
|
|
|
|
|
85
|
2
|
50
|
|
|
|
|
if (val < 0) { |
|
86
|
2
|
|
|
|
|
|
Safefree(RETVAL); |
|
87
|
2
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
OUTPUT: |
|
90
|
|
|
|
|
|
|
RETVAL |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
bool sigqueue(SV* pid, signo_t signo, int number = 0) |
|
93
|
|
|
|
|
|
|
PREINIT: |
|
94
|
|
|
|
|
|
|
int ret; |
|
95
|
|
|
|
|
|
|
union sigval number_val; |
|
96
|
|
|
|
|
|
|
CODE: |
|
97
|
4
|
|
|
|
|
|
number_val.sival_int = number; |
|
98
|
|
|
|
|
|
|
#ifdef THREAD_SCHED |
|
99
|
|
|
|
|
|
|
if (SvOK(pid) && SvROK(pid) && sv_derived_from(pid, "threads")) |
|
100
|
|
|
|
|
|
|
ret = pthread_sigqueue(get_pthread(pid), signo, number_val); |
|
101
|
|
|
|
|
|
|
else |
|
102
|
|
|
|
|
|
|
#endif |
|
103
|
4
|
|
|
|
|
|
ret = sigqueue(SvIV(pid), signo, number_val); |
|
104
|
|
|
|
|
|
|
RETVAL = ret == 0; |
|
105
|
|
|
|
|
|
|
OUTPUT: |
|
106
|
|
|
|
|
|
|
RETVAL |
|
107
|
|
|
|
|
|
|
|