Commit | Line | Data |
adfe19db |
1 | ################################################################################ |
2 | ## |
bfc37ff7 |
3 | ## $Revision: 8 $ |
adfe19db |
4 | ## $Author: mhx $ |
bfc37ff7 |
5 | ## $Date: 2010/03/07 13:15:47 +0100 $ |
adfe19db |
6 | ## |
7 | ################################################################################ |
8 | ## |
bfc37ff7 |
9 | ## Version 3.x, Copyright (C) 2004-2010, Marcus Holland-Moritz. |
adfe19db |
10 | ## Version 2.x, Copyright (C) 2001, Paul Marquess. |
11 | ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski. |
12 | ## |
13 | ## This program is free software; you can redistribute it and/or |
14 | ## modify it under the same terms as Perl itself. |
15 | ## |
16 | ################################################################################ |
17 | |
18 | =provides |
19 | |
20 | PERL_UCHAR_MIN |
21 | PERL_UCHAR_MAX |
22 | PERL_USHORT_MIN |
23 | PERL_USHORT_MAX |
24 | PERL_SHORT_MAX |
25 | PERL_SHORT_MIN |
26 | PERL_UINT_MAX |
27 | PERL_UINT_MIN |
28 | PERL_INT_MAX |
29 | PERL_INT_MIN |
30 | PERL_ULONG_MAX |
31 | PERL_ULONG_MIN |
32 | PERL_LONG_MAX |
33 | PERL_LONG_MIN |
34 | PERL_UQUAD_MAX |
35 | PERL_UQUAD_MIN |
36 | PERL_QUAD_MAX |
37 | PERL_QUAD_MIN |
38 | IVSIZE |
39 | UVSIZE |
40 | IVTYPE |
41 | UVTYPE |
42 | |
43 | =implementation |
44 | |
45 | #ifdef I_LIMITS |
46 | # include <limits.h> |
47 | #endif |
48 | |
49 | #ifndef PERL_UCHAR_MIN |
50 | # define PERL_UCHAR_MIN ((unsigned char)0) |
51 | #endif |
52 | |
53 | #ifndef PERL_UCHAR_MAX |
54 | # ifdef UCHAR_MAX |
55 | # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) |
56 | # else |
57 | # ifdef MAXUCHAR |
58 | # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) |
59 | # else |
60 | # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) |
61 | # endif |
62 | # endif |
63 | #endif |
64 | |
65 | #ifndef PERL_USHORT_MIN |
66 | # define PERL_USHORT_MIN ((unsigned short)0) |
67 | #endif |
68 | |
69 | #ifndef PERL_USHORT_MAX |
70 | # ifdef USHORT_MAX |
71 | # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) |
72 | # else |
73 | # ifdef MAXUSHORT |
74 | # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) |
75 | # else |
76 | # ifdef USHRT_MAX |
77 | # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) |
78 | # else |
79 | # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) |
80 | # endif |
81 | # endif |
82 | # endif |
83 | #endif |
84 | |
85 | #ifndef PERL_SHORT_MAX |
86 | # ifdef SHORT_MAX |
87 | # define PERL_SHORT_MAX ((short)SHORT_MAX) |
88 | # else |
89 | # ifdef MAXSHORT /* Often used in <values.h> */ |
90 | # define PERL_SHORT_MAX ((short)MAXSHORT) |
91 | # else |
92 | # ifdef SHRT_MAX |
93 | # define PERL_SHORT_MAX ((short)SHRT_MAX) |
94 | # else |
95 | # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) |
96 | # endif |
97 | # endif |
98 | # endif |
99 | #endif |
100 | |
101 | #ifndef PERL_SHORT_MIN |
102 | # ifdef SHORT_MIN |
103 | # define PERL_SHORT_MIN ((short)SHORT_MIN) |
104 | # else |
105 | # ifdef MINSHORT |
106 | # define PERL_SHORT_MIN ((short)MINSHORT) |
107 | # else |
108 | # ifdef SHRT_MIN |
109 | # define PERL_SHORT_MIN ((short)SHRT_MIN) |
110 | # else |
111 | # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) |
112 | # endif |
113 | # endif |
114 | # endif |
115 | #endif |
116 | |
117 | #ifndef PERL_UINT_MAX |
118 | # ifdef UINT_MAX |
119 | # define PERL_UINT_MAX ((unsigned int)UINT_MAX) |
120 | # else |
121 | # ifdef MAXUINT |
122 | # define PERL_UINT_MAX ((unsigned int)MAXUINT) |
123 | # else |
124 | # define PERL_UINT_MAX (~(unsigned int)0) |
125 | # endif |
126 | # endif |
127 | #endif |
128 | |
129 | #ifndef PERL_UINT_MIN |
130 | # define PERL_UINT_MIN ((unsigned int)0) |
131 | #endif |
132 | |
133 | #ifndef PERL_INT_MAX |
134 | # ifdef INT_MAX |
135 | # define PERL_INT_MAX ((int)INT_MAX) |
136 | # else |
137 | # ifdef MAXINT /* Often used in <values.h> */ |
138 | # define PERL_INT_MAX ((int)MAXINT) |
139 | # else |
140 | # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) |
141 | # endif |
142 | # endif |
143 | #endif |
144 | |
145 | #ifndef PERL_INT_MIN |
146 | # ifdef INT_MIN |
147 | # define PERL_INT_MIN ((int)INT_MIN) |
148 | # else |
149 | # ifdef MININT |
150 | # define PERL_INT_MIN ((int)MININT) |
151 | # else |
152 | # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) |
153 | # endif |
154 | # endif |
155 | #endif |
156 | |
157 | #ifndef PERL_ULONG_MAX |
158 | # ifdef ULONG_MAX |
159 | # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) |
160 | # else |
161 | # ifdef MAXULONG |
162 | # define PERL_ULONG_MAX ((unsigned long)MAXULONG) |
163 | # else |
164 | # define PERL_ULONG_MAX (~(unsigned long)0) |
165 | # endif |
166 | # endif |
167 | #endif |
168 | |
169 | #ifndef PERL_ULONG_MIN |
170 | # define PERL_ULONG_MIN ((unsigned long)0L) |
171 | #endif |
172 | |
173 | #ifndef PERL_LONG_MAX |
174 | # ifdef LONG_MAX |
175 | # define PERL_LONG_MAX ((long)LONG_MAX) |
176 | # else |
177 | # ifdef MAXLONG |
178 | # define PERL_LONG_MAX ((long)MAXLONG) |
179 | # else |
180 | # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) |
181 | # endif |
182 | # endif |
183 | #endif |
184 | |
185 | #ifndef PERL_LONG_MIN |
186 | # ifdef LONG_MIN |
187 | # define PERL_LONG_MIN ((long)LONG_MIN) |
188 | # else |
189 | # ifdef MINLONG |
190 | # define PERL_LONG_MIN ((long)MINLONG) |
191 | # else |
192 | # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) |
193 | # endif |
194 | # endif |
195 | #endif |
196 | |
197 | #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) |
198 | # ifndef PERL_UQUAD_MAX |
199 | # ifdef ULONGLONG_MAX |
200 | # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) |
201 | # else |
202 | # ifdef MAXULONGLONG |
203 | # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) |
204 | # else |
205 | # define PERL_UQUAD_MAX (~(unsigned long long)0) |
206 | # endif |
207 | # endif |
208 | # endif |
209 | |
210 | # ifndef PERL_UQUAD_MIN |
211 | # define PERL_UQUAD_MIN ((unsigned long long)0L) |
212 | # endif |
213 | |
214 | # ifndef PERL_QUAD_MAX |
215 | # ifdef LONGLONG_MAX |
216 | # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) |
217 | # else |
218 | # ifdef MAXLONGLONG |
219 | # define PERL_QUAD_MAX ((long long)MAXLONGLONG) |
220 | # else |
221 | # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) |
222 | # endif |
223 | # endif |
224 | # endif |
225 | |
226 | # ifndef PERL_QUAD_MIN |
227 | # ifdef LONGLONG_MIN |
228 | # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) |
229 | # else |
230 | # ifdef MINLONGLONG |
231 | # define PERL_QUAD_MIN ((long long)MINLONGLONG) |
232 | # else |
233 | # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) |
234 | # endif |
235 | # endif |
236 | # endif |
237 | #endif |
238 | |
239 | /* This is based on code from 5.003 perl.h */ |
240 | #ifdef HAS_QUAD |
241 | # ifdef cray |
242 | __UNDEFINED__ IVTYPE int |
243 | __UNDEFINED__ IV_MIN PERL_INT_MIN |
244 | __UNDEFINED__ IV_MAX PERL_INT_MAX |
245 | __UNDEFINED__ UV_MIN PERL_UINT_MIN |
246 | __UNDEFINED__ UV_MAX PERL_UINT_MAX |
247 | # ifdef INTSIZE |
248 | __UNDEFINED__ IVSIZE INTSIZE |
249 | # endif |
250 | # else |
251 | # if defined(convex) || defined(uts) |
252 | __UNDEFINED__ IVTYPE long long |
253 | __UNDEFINED__ IV_MIN PERL_QUAD_MIN |
254 | __UNDEFINED__ IV_MAX PERL_QUAD_MAX |
255 | __UNDEFINED__ UV_MIN PERL_UQUAD_MIN |
256 | __UNDEFINED__ UV_MAX PERL_UQUAD_MAX |
257 | # ifdef LONGLONGSIZE |
258 | __UNDEFINED__ IVSIZE LONGLONGSIZE |
259 | # endif |
260 | # else |
261 | __UNDEFINED__ IVTYPE long |
262 | __UNDEFINED__ IV_MIN PERL_LONG_MIN |
263 | __UNDEFINED__ IV_MAX PERL_LONG_MAX |
264 | __UNDEFINED__ UV_MIN PERL_ULONG_MIN |
265 | __UNDEFINED__ UV_MAX PERL_ULONG_MAX |
266 | # ifdef LONGSIZE |
267 | __UNDEFINED__ IVSIZE LONGSIZE |
268 | # endif |
269 | # endif |
270 | # endif |
271 | __UNDEFINED__ IVSIZE 8 |
272 | __UNDEFINED__ PERL_QUAD_MIN IV_MIN |
273 | __UNDEFINED__ PERL_QUAD_MAX IV_MAX |
274 | __UNDEFINED__ PERL_UQUAD_MIN UV_MIN |
275 | __UNDEFINED__ PERL_UQUAD_MAX UV_MAX |
276 | #else |
277 | __UNDEFINED__ IVTYPE long |
278 | __UNDEFINED__ IV_MIN PERL_LONG_MIN |
279 | __UNDEFINED__ IV_MAX PERL_LONG_MAX |
280 | __UNDEFINED__ UV_MIN PERL_ULONG_MIN |
281 | __UNDEFINED__ UV_MAX PERL_ULONG_MAX |
282 | #endif |
283 | |
284 | #ifndef IVSIZE |
285 | # ifdef LONGSIZE |
286 | # define IVSIZE LONGSIZE |
287 | # else |
288 | # define IVSIZE 4 /* A bold guess, but the best we can make. */ |
289 | # endif |
290 | #endif |
291 | |
292 | __UNDEFINED__ UVTYPE unsigned IVTYPE |
293 | __UNDEFINED__ UVSIZE IVSIZE |
294 | |
295 | =xsubs |
296 | |
297 | IV |
298 | iv_size() |
299 | CODE: |
300 | RETVAL = IVSIZE == sizeof(IV); |
301 | OUTPUT: |
302 | RETVAL |
303 | |
304 | IV |
305 | uv_size() |
306 | CODE: |
307 | RETVAL = UVSIZE == sizeof(UV); |
308 | OUTPUT: |
309 | RETVAL |
310 | |
311 | IV |
312 | iv_type() |
313 | CODE: |
314 | RETVAL = sizeof(IVTYPE) == sizeof(IV); |
315 | OUTPUT: |
316 | RETVAL |
317 | |
318 | IV |
319 | uv_type() |
320 | CODE: |
321 | RETVAL = sizeof(UVTYPE) == sizeof(UV); |
322 | OUTPUT: |
323 | RETVAL |
324 | |
325 | =tests plan => 4 |
326 | |
327 | ok(&Devel::PPPort::iv_size()); |
328 | ok(&Devel::PPPort::uv_size()); |
329 | ok(&Devel::PPPort::iv_type()); |
330 | ok(&Devel::PPPort::uv_type()); |
331 | |