Remove tests
[pkg-perl] / deb-src / libfilter-perl / libfilter-perl-1.34 / Call / ppport.h
1 /* This file is Based on output from 
2  * Perl/Pollution/Portability Version 2.0000 */
3
4 #ifndef _P_P_PORTABILITY_H_
5 #define _P_P_PORTABILITY_H_
6
7 #ifndef PERL_REVISION
8 #   ifndef __PATCHLEVEL_H_INCLUDED__
9 #       include "patchlevel.h"
10 #   endif
11 #   ifndef PERL_REVISION
12 #       define PERL_REVISION    (5)
13         /* Replace: 1 */
14 #       define PERL_VERSION     PATCHLEVEL
15 #       define PERL_SUBVERSION  SUBVERSION
16         /* Replace PERL_PATCHLEVEL with PERL_VERSION */
17         /* Replace: 0 */
18 #   endif
19 #endif
20
21 #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
22
23 #ifndef ERRSV
24 #       define ERRSV perl_get_sv("@",FALSE)
25 #endif
26
27 #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
28 /* Replace: 1 */
29 #       define PL_Sv            Sv
30 #       define PL_compiling     compiling
31 #       define PL_copline       copline
32 #       define PL_curcop        curcop
33 #       define PL_curstash      curstash
34 #       define PL_defgv         defgv
35 #       define PL_dirty         dirty
36 #       define PL_hints         hints
37 #       define PL_na            na
38 #       define PL_perldb        perldb
39 #       define PL_rsfp_filters  rsfp_filters
40 #       define PL_rsfp          rsfp
41 #       define PL_stdingv       stdingv
42 #       define PL_sv_no         sv_no
43 #       define PL_sv_undef      sv_undef
44 #       define PL_sv_yes        sv_yes
45 /* Replace: 0 */
46 #endif
47
48 #ifndef pTHX
49 #    define pTHX
50 #    define pTHX_
51 #    define aTHX
52 #    define aTHX_
53 #endif         
54
55 #ifndef PTR2IV
56 #    define PTR2IV(d)   (IV)(d)
57 #endif
58  
59 #ifndef INT2PTR
60 #    define INT2PTR(any,d)      (any)(d)
61 #endif
62
63 #ifndef dTHR
64 #  ifdef WIN32
65 #       define dTHR extern int Perl___notused
66 #  else
67 #       define dTHR extern int errno
68 #  endif
69 #endif
70
71 #ifndef boolSV
72 #       define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
73 #endif
74
75 #ifndef gv_stashpvn
76 #       define gv_stashpvn(str,len,flags) gv_stashpv(str,flags)
77 #endif
78
79 #ifndef newSVpvn
80 #       define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0))
81 #endif
82
83 #ifndef Pid_t
84 #    define Pid_t       pid_t
85 #endif
86
87 #ifndef newRV_inc
88 /* Replace: 1 */
89 #       define newRV_inc(sv) newRV(sv)
90 /* Replace: 0 */
91 #endif
92
93 /* DEFSV appears first in 5.004_56 */
94 #ifndef DEFSV
95 #  define DEFSV GvSV(PL_defgv)
96 #endif
97
98 #ifndef SAVE_DEFSV
99 #    define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
100 #endif
101
102 #ifndef newRV_noinc
103 #  ifdef __GNUC__
104 #    define newRV_noinc(sv)               \
105       ({                                  \
106           SV *nsv = (SV*)newRV(sv);       \
107           SvREFCNT_dec(sv);               \
108           nsv;                            \
109       })
110 #  else
111 #    if defined(CRIPPLED_CC) || defined(USE_THREADS)
112 static SV * newRV_noinc (SV * sv)
113 {
114           SV *nsv = (SV*)newRV(sv);       
115           SvREFCNT_dec(sv);               
116           return nsv;                     
117 }
118 #    else
119 #      define newRV_noinc(sv)    \
120         ((PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv)
121 #    endif
122 #  endif
123 #endif
124
125 /* Provide: newCONSTSUB */
126
127 /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
128 #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))
129
130 #if defined(NEED_newCONSTSUB)
131 static
132 #else
133 extern void newCONSTSUB _((HV * stash, char * name, SV *sv));
134 #endif
135
136 #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
137 void
138 newCONSTSUB(stash,name,sv)
139 HV *stash;
140 char *name;
141 SV *sv;
142 {
143         U32 oldhints = PL_hints;
144         HV *old_cop_stash = PL_curcop->cop_stash;
145         HV *old_curstash = PL_curstash;
146         line_t oldline = PL_curcop->cop_line;
147         PL_curcop->cop_line = PL_copline;
148
149         PL_hints &= ~HINT_BLOCK_SCOPE;
150         if (stash)
151                 PL_curstash = PL_curcop->cop_stash = stash;
152
153         newSUB(
154
155 #if (PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22))
156      /* before 5.003_22 */
157                 start_subparse(),
158 #else
159 #  if (PERL_VERSION == 3) && (PERL_SUBVERSION == 22)
160      /* 5.003_22 */
161                 start_subparse(0),
162 #  else
163      /* 5.003_23  onwards */
164                 start_subparse(FALSE, 0),
165 #  endif
166 #endif
167
168                 newSVOP(OP_CONST, 0, newSVpv(name,0)),
169                 newSVOP(OP_CONST, 0, &PL_sv_no),   /* SvPV(&PL_sv_no) == "" -- GMB */
170                 newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
171         );
172
173         PL_hints = oldhints;
174         PL_curcop->cop_stash = old_cop_stash;
175         PL_curstash = old_curstash;
176         PL_curcop->cop_line = oldline;
177 }
178 #endif
179
180 #endif /* newCONSTSUB */
181
182
183 #ifndef START_MY_CXT
184
185 /*
186  * Boilerplate macros for initializing and accessing interpreter-local
187  * data from C.  All statics in extensions should be reworked to use
188  * this, if you want to make the extension thread-safe.  See ext/re/re.xs
189  * for an example of the use of these macros.
190  *
191  * Code that uses these macros is responsible for the following:
192  * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
193  * 2. Declare a typedef named my_cxt_t that is a structure that contains
194  *    all the data that needs to be interpreter-local.
195  * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
196  * 4. Use the MY_CXT_INIT macro such that it is called exactly once
197  *    (typically put in the BOOT: section).
198  * 5. Use the members of the my_cxt_t structure everywhere as
199  *    MY_CXT.member.
200  * 6. Use the dMY_CXT macro (a declaration) in all the functions that
201  *    access MY_CXT.
202  */
203
204 #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
205     defined(PERL_CAPI)    || defined(PERL_IMPLICIT_CONTEXT)
206
207 /* This must appear in all extensions that define a my_cxt_t structure,
208  * right after the definition (i.e. at file scope).  The non-threads
209  * case below uses it to declare the data as static. */
210 #define START_MY_CXT
211
212 #if PERL_REVISION == 5 && \
213     (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68 ))
214 /* Fetches the SV that keeps the per-interpreter data. */
215 #define dMY_CXT_SV \
216         SV *my_cxt_sv = perl_get_sv(MY_CXT_KEY, FALSE)
217 #else /* >= perl5.004_68 */
218 #define dMY_CXT_SV \
219         SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
220                                   sizeof(MY_CXT_KEY)-1, TRUE)
221 #endif /* < perl5.004_68 */
222
223 /* This declaration should be used within all functions that use the
224  * interpreter-local data. */
225 #define dMY_CXT \
226         dMY_CXT_SV;                                                     \
227         my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
228
229 /* Creates and zeroes the per-interpreter data.
230  * (We allocate my_cxtp in a Perl SV so that it will be released when
231  * the interpreter goes away.) */
232 #define MY_CXT_INIT \
233         dMY_CXT_SV;                                                     \
234         /* newSV() allocates one more than needed */                    \
235         my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
236         Zero(my_cxtp, 1, my_cxt_t);                                     \
237         sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
238
239 /* This macro must be used to access members of the my_cxt_t structure.
240  * e.g. MYCXT.some_data */
241 #define MY_CXT          (*my_cxtp)
242
243 /* Judicious use of these macros can reduce the number of times dMY_CXT
244  * is used.  Use is similar to pTHX, aTHX etc. */
245 #define pMY_CXT         my_cxt_t *my_cxtp
246 #define pMY_CXT_        pMY_CXT,
247 #define _pMY_CXT        ,pMY_CXT
248 #define aMY_CXT         my_cxtp
249 #define aMY_CXT_        aMY_CXT,
250 #define _aMY_CXT        ,aMY_CXT
251
252 #else /* single interpreter */
253
254 #ifndef NOOP
255 #  define NOOP (void)0
256 #endif
257
258 #ifdef HASATTRIBUTE
259 #  define PERL_UNUSED_DECL __attribute__((unused))
260 #else
261 #  define PERL_UNUSED_DECL
262 #endif    
263
264 #ifndef dNOOP
265 #  define dNOOP extern int Perl___notused PERL_UNUSED_DECL
266 #endif
267
268 #define START_MY_CXT    static my_cxt_t my_cxt;
269 #define dMY_CXT_SV      dNOOP
270 #define dMY_CXT         dNOOP
271 #define MY_CXT_INIT     NOOP
272 #define MY_CXT          my_cxt
273
274 #define pMY_CXT         void
275 #define pMY_CXT_
276 #define _pMY_CXT
277 #define aMY_CXT
278 #define aMY_CXT_
279 #define _aMY_CXT
280
281 #endif 
282
283 #endif /* START_MY_CXT */
284
285
286 #endif /* _P_P_PORTABILITY_H_ */