Debian Codegraph @

src/xh_config.h

raw
1 #ifndef _XH_CONFIG_H_
2 #define _XH_CONFIG_H_
3
4 #include "EXTERN.h"
5 #include "perl.h"
6 #define NO_XSLOCKS
7 #include "XSUB.h"
8 #define NEED_newRV_noinc
9 #define NEED_newSVpvn_flags
10 #define NEED_sv_2pv_flags_GLOBAL
11 #include "ppport.h"
12 #include <stdint.h>
13 #include <sys/stat.h>
14 #include <fcntl.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <errno.h>
19 #ifdef WIN32
20 #include <windows.h>
21 #include <io.h>
22 #else
23 #include <sys/mman.h>
24 #endif
25
26 #if defined(__sparc__) || defined(__sparc)
27 # define XH_SPARC_ARCH
28 #endif
29
30 #if defined(sun) || defined(__sun)
31 # include <sys/isa_defs.h>
32 # if defined(_LITTLE_ENDIAN)
33 # define XH_LITTLE_ENDIAN
34 # else
35 # define XH_BIG_ENDIAN
36 # endif
37 #else
38 # if defined(SVR4) || defined(__SVR4)
39 # include <sys/types.h>
40 # include <sys/byteorder.h>
41 # elif defined(_AIX) || defined(__TOS_AIX__)
42 # include <sys/machine.h>
43 # elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) \
44 || defined(__APPLE__)
45 # if defined(__NetBSD__) || defined(__OpenBSD__)
46 # include <sys/types.h>
47 # endif
48 # include <machine/endian.h>
49 # elif defined(__linux__) || defined(__CYGWIN__)
50 # include <endian.h>
51 # endif
52 # ifndef LITTLE_ENDIAN
53 # ifdef __LITTLE_ENDIAN
54 # define LITTLE_ENDIAN __LITTLE_ENDIAN
55 # else
56 # define LITTLE_ENDIAN _LITTLE_ENDIAN
57 # endif
58 # endif
59 # ifndef BIG_ENDIAN
60 # ifdef __BIG_ENDIAN
61 # define BIG_ENDIAN __BIG_ENDIAN
62 # else
63 # define BIG_ENDIAN _BIG_ENDIAN
64 # endif
65 # endif
66 # ifndef BYTE_ORDER
67 # ifdef __BYTE_ORDER
68 # define BYTE_ORDER __BYTE_ORDER
69 # else
70 # define BYTE_ORDER _BYTE_ORDER
71 # endif
72 # endif
73 # if BYTE_ORDER == LITTLE_ENDIAN
74 # define XH_LITTLE_ENDIAN
75 # else
76 # define XH_BIG_ENDIAN
77 # endif
78 #endif
79
80 #ifndef MUTABLE_PTR
81 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
82 # define MUTABLE_PTR(p) ({ void *_p = (p); _p; })
83 #else
84 # define MUTABLE_PTR(p) ((void *) (p))
85 #endif
86 #endif
87
88 #ifndef MUTABLE_SV
89 #define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p))
90 #endif
91
92 #ifndef SvRXOK
93 #define SvRX(sv) (Perl_get_re_arg(aTHX_ sv))
94 #define SvRXOK(sv) (Perl_get_re_arg(aTHX_ sv) ? TRUE : FALSE)
95 static REGEXP *
96 Perl_get_re_arg(pTHX_ SV *sv) {
97 MAGIC *mg;
98 if (sv) {
99 if (SvMAGICAL(sv))
100 mg_get(sv);
101 if (SvROK(sv))
102 sv = MUTABLE_SV(SvRV(sv));
103 #if PERL_VERSION < 11
104 if (SvTYPE(sv) == SVt_PVMG && (mg = mg_find(sv, PERL_MAGIC_qr)))
105 return (REGEXP *) mg->mg_obj;
106 #else
107 if (SvTYPE(sv) == SVt_REGEXP)
108 return (REGEXP *) sv;
109 #endif
110 }
111
112 return NULL;
113 }
114 #endif
115
116 #if PERL_VERSION > 17
117 # define XH_AMAGIC(sv) HvAMAGIC(SvSTASH(sv))
118 #else
119 # if PERL_VERSION > 8
120 # define XH_AMAGIC(sv) (SvFLAGS(sv) & SVf_AMAGIC)
121 # else
122 # define XH_AMAGIC(sv) ((SvFLAGS(sv) & SVf_AMAGIC) \
123 || ((mg = mg_find((SV*) SvSTASH(sv), PERL_MAGIC_overload_table)) \
124 && mg->mg_ptr && AMT_AMAGIC((AMT*)mg->mg_ptr)))
125 # endif
126 #endif
127
128 #if PERL_VERSION > 13
129 # define XH_AMG_CALL_STRING(sv) AMG_CALLunary(sv, string_amg)
130 #else
131 # define XH_AMG_CALL_STRING(sv) AMG_CALLun(sv ,string)
132 #endif
133
134 #if __GNUC__ >= 3
135 # define expect(expr,value) __builtin_expect ((expr), (value))
136 # define XH_INLINE static inline
137 # define XH_UNUSED(v) x __attribute__((unused))
138 #else
139 # define expect(expr,value) (expr)
140 # define XH_INLINE static
141 # define XH_UNUSED(v) v
142 #endif
143
144 #if __STDC_VERSION__ < 199901L
145 # if __GNUC__ >= 2
146 # define XH_FUNCTION __FUNCTION__
147 # else
148 # define XH_FUNCTION "<unknown>"
149 # endif
150 #else
151 # define XH_FUNCTION __func__
152 #endif
153
154 #ifdef _MSC_VER
155 #define _CRT_SECURE_NO_WARNINGS
156 #define _CRT_NONSTDC_NO_DEPRECATE
157 #define strncasecmp _strnicmp
158 #define strcasecmp _stricmp
159 #endif
160
161 #define expect_false(expr) expect ((expr) != 0, 0)
162 #define expect_true(expr) expect ((expr) != 0, 1)
163
164 typedef uintptr_t xh_bool_t;
165 typedef uintptr_t xh_uint_t;
166 typedef intptr_t xh_int_t;
167 typedef u_char xh_char_t;
168
169 #define XH_CHAR_CAST (xh_char_t *)
170 #define XH_EMPTY_STRING (XH_CHAR_CAST "")
171
172 #if defined(XH_HAVE_ICONV) || defined(XH_HAVE_ICU)
173 #define XH_HAVE_ENCODER
174 #endif
175
176 #if defined(XH_HAVE_XML2) && defined(XH_HAVE_XML__LIBXML)
177 #define XH_HAVE_DOM
178 #endif
179
180 #ifdef XH_HAVE_DOM
181 #include <libxml/parser.h>
182 #endif
183
184 #define XH_HAVE_MMAP
185
186 #endif /* _XH_CONFIG_H_ */