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