Debian Codegraph @

ulib/PORT.h

raw
1 #ifndef ULIB__PORT_H
2 #define ULIB__PORT_H
3
4 #ifdef cBOOL
5 #undef cBOOL
6 #endif
7 #define cBOOL(cbool) ((bool) (cbool))
8
9 #ifdef EXPECT
10 #undef EXPECT
11 #ifdef HAS_BUILTIN_EXPECT
12 # define EXPECT(expr,val) __builtin_expect(expr,val)
13 #else
14 # define EXPECT(expr,val) (expr)
15 #endif
16 #endif
17
18 #ifdef LIKELY
19 #undef LIKELY
20 #define LIKELY(cond) EXPECT(cBOOL(cond),TRUE)
21 #endif
22
23 #ifdef UNLIKELY
24 #undef UNLIKELY
25 #define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
26 #endif
27
28 #ifdef PERL_MALLOC_WRAP
29
30 # ifdef _MEM_WRAP_NEEDS_RUNTIME_CHECK
31 # undef _MEM_WRAP_NEEDS_RUNTIME_CHECK
32 # endif
33 # define _MEM_WRAP_NEEDS_RUNTIME_CHECK(n,t) \
34 (sizeof(MEM_SIZE) < sizeof(n) || sizeof(t) > ((MEM_SIZE)1 << 8*(sizeof(MEM_SIZE) - sizeof(n))))
35
36 # ifdef _MEM_WRAP_WILL_WRAP
37 # undef _MEM_WRAP_WILL_WRAP
38 # endif
39 # define _MEM_WRAP_WILL_WRAP(n,t) \
40 ((_MEM_WRAP_NEEDS_RUNTIME_CHECK(n,t) ? (MEM_SIZE)(n) : MEM_SIZE_MAX/sizeof(t)) > MEM_SIZE_MAX/sizeof(t))
41
42 # ifdef MEM_WRAP_CHECK
43 # undef MEM_WRAP_CHECK
44 # endif
45 # define MEM_WRAP_CHECK(n,t) \
46 (void)(UNLIKELY(_MEM_WRAP_WILL_WRAP(n,t)) && (Perl_croak_nocontext("panic: memory wrap"),0))
47
48 #endif /* PERL_MALLOC_WRAP */
49
50
51 #ifndef MUTEX_LOCK
52 # define MUTEX_LOCK(m) NOOP
53 #endif
54
55 #ifndef MUTEX_UNLOCK
56 # define MUTEX_UNLOCK(m) NOOP
57 #endif
58
59 #ifndef MUTEX_INIT
60 # define MUTEX_INIT(m) NOOP
61 #endif
62
63 #ifndef MUTEX_DESTROY
64 # define MUTEX_DESTROY(m) NOOP
65 #endif
66
67 #ifndef SVf_THINKFIRST
68 #define SVf_THINKFIRST (SVf_READONLY|SVf_PROTECT|SVf_ROK|SVf_FAKE \
69 |SVs_RMG|SVf_IsCOW)
70 #endif
71
72 #ifndef SvTHINKFIRST
73 #define SvTHINKFIRST(sv) (SvFLAGS(sv) & SVf_THINKFIRST
74 #endif
75
76 #ifndef SV_CHECK_THINKFIRST_COW_DROP
77 #define SV_CHECK_THINKFIRST_COW_DROP(sv) \
78 if (SvTHINKFIRST(sv)) \
79 sv_force_normal_flags(sv, SV_COW_DROP_PV)
80 #endif
81
82 #ifndef CVf_AUTOLOAD
83 #define CvAUTOLOAD_off(cv) NOOP
84 #endif
85
86 #ifndef ibcmp
87 #define ibcmp Perl_my_ibcmp
88 I32 Perl_my_ibcmp(pTHX_ const char *s1, const char *s2, register I32 len) {
89 register U8 *a = (U8 *)s1;
90 register U8 *b = (U8 *)s2;
91 while (len--) {
92 if (*a != *b && *a != PL_fold[*b])
93 return 1;
94 a++,b++;
95 }
96 return 0;
97 }
98 #endif
99
100 #ifndef NOT_REACHED
101 #define NOT_REACHED
102 #endif
103
104 #ifndef croak_caller
105 #define croak_caller my_croak_caller
106 #endif
107
108 #ifndef PERL_VERSION
109 # undef SUBVERSION /* OS/390 */
110 # include <patchlevel.h>
111 # ifndef SUBVERSION
112 # define SUBVERSION 0
113 # endif
114 # if !defined(PATCHLEVEL)))
115 # include <could_not_find_Perl_patchlevel.h>
116 # endif
117 # define PERL_REVISION 5
118 # define PERL_VERSION PATCHLEVEL
119 # define PERL_SUBVERSION SUBVERSION
120 #endif
121
122 #ifndef PERL_VERSION_DECIMAL
123 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
124 #endif
125 #ifndef PERL_DECIMAL_VERSION
126 # define PERL_DECIMAL_VERSION \
127 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
128 #endif
129
130 #ifndef PERL_VERSION_LT
131 # define PERL_VERSION_LT(r,v,s) \
132 (PERL_DECIMAL_VERSION < PERL_VERSION_DECIMAL(r,v,s))
133 #endif
134
135 #ifndef PERL_VERSION_EQ
136 # define PERL_VERSION_EQ(r,v,s) \
137 (PERL_DECIMAL_VERSION == PERL_VERSION_DECIMAL(r,v,s))
138 #endif
139
140 #ifdef SvPVbyte
141 # if PERL_VERSION_EQ(5,6,1)
142 /* SvPVbyte does not work in perl-5.6.1, borrowed version for 5.7.3 */
143 # undef SvPVbyte
144 # define SvPVbyte(sv, lp) \
145 ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
146 ? ((lp = SvCUR(sv)), SvPVX(sv)) : my_sv_2pvbyte(aTHX_ sv, &lp))
147
148 static char *
149 my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp) {
150 sv_utf8_downgrade(sv,0);
151 return SvPV(sv,*lp);
152 }
153 # endif
154 #else
155 # define SvPVbyte SvPV
156 #endif
157
158 #endif
159 /* ex:set ts=2 sw=2 itab=spaces: */