1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
|
|
4 | |
|
|
5 | #include <fcntl.h> |
|
|
6 | #include <unistd.h> |
4 | |
7 | |
5 | typedef CV *B__CV; |
8 | typedef CV *B__CV; |
6 | |
9 | |
7 | static OP *(*old_entersub)(pTHX); |
10 | static OP *(*old_entersub)(pTHX); |
8 | |
11 | |
9 | // this is, of course, a slower entersub |
12 | // this is, of course, a slower entersub |
10 | static OP * |
13 | static OP * |
11 | faster_entersub (pTHX) |
14 | faster_entersub (pTHX) |
12 | { |
15 | { |
|
|
16 | static int in_perl; |
|
|
17 | |
13 | if (!PL_compcv) // only when not compiling, reduces recompiling due to op-address-shift |
18 | if (!PL_compcv || in_perl) // only when not compiling, reduces recompiling due to op-address-shift |
14 | { |
19 | { |
15 | dSP; |
20 | dSP; |
16 | dTOPss; |
21 | dTOPss; |
|
|
22 | |
|
|
23 | ++in_perl; |
17 | |
24 | |
18 | if (SvTYPE (sv) == SVt_PVGV) |
25 | if (SvTYPE (sv) == SVt_PVGV) |
19 | sv = (SV *)GvCV (sv); |
26 | sv = (SV *)GvCV (sv); |
20 | |
27 | |
21 | if (sv) |
28 | if (sv) |
… | |
… | |
41 | SPAGAIN; |
48 | SPAGAIN; |
42 | FREETMPS; |
49 | FREETMPS; |
43 | LEAVE; |
50 | LEAVE; |
44 | } |
51 | } |
45 | } |
52 | } |
|
|
53 | |
|
|
54 | --in_perl; |
46 | } |
55 | } |
47 | |
56 | |
48 | return old_entersub (aTHX); |
57 | return old_entersub (aTHX); |
49 | } |
58 | } |
50 | |
59 | |
… | |
… | |
83 | op->op_ppaddr = ptr; |
92 | op->op_ppaddr = ptr; |
84 | |
93 | |
85 | CvSTART (cv) = op; |
94 | CvSTART (cv) = op; |
86 | } |
95 | } |
87 | |
96 | |
|
|
97 | bool |
|
|
98 | fcntl_lock (int fd) |
|
|
99 | CODE: |
|
|
100 | { |
|
|
101 | struct flock lck; |
|
|
102 | lck.l_type = F_WRLCK; |
|
|
103 | lck.l_whence = SEEK_SET; |
|
|
104 | lck.l_start = 0; |
|
|
105 | lck.l_len = 0; |
88 | |
106 | |
|
|
107 | RETVAL = fcntl (fd, F_SETLKW, &lck) == 0; |
|
|
108 | } |
|
|
109 | OUTPUT: |
|
|
110 | RETVAL |
|
|
111 | |
|
|
112 | |
|
|
113 | |