monotone

monotone Mtn Source Tree

Root/acinclude.m4

1AC_DEFUN(AC_HAVE_INADDR_NONE,
2[AC_CACHE_CHECK([whether INADDR_NONE is defined], ac_cv_have_inaddr_none,
3 [AC_TRY_COMPILE([
4#ifdef HAVE_SYS_TYPES_H
5#include <sys/types.h>
6#endif
7#ifdef HAVE_SYS_SOCKET_H
8#include <sys/socket.h>
9#endif
10#ifdef HAVE_NETINET_IN_H
11#include <netinet/in.h>
12#endif
13#ifdef HAVE_ARPA_INET_H
14#include <arpa/inet.h>
15#endif
16],[
17unsigned long foo = INADDR_NONE;
18],
19 ac_cv_have_inaddr_none=yes,
20 ac_cv_have_inaddr_none=no)])
21 if test $ac_cv_have_inaddr_none != yes; then
22 AC_DEFINE(INADDR_NONE, 0xffffffff, [Define to value of INADDR_NONE if not provided by your system header files.])
23 fi])
24
25dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
26dnl
27dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
28dnl existence of an include file <stdint.h> that defines a set of
29dnl typedefs, especially uint8_t,int32_t,uintptr_t.
30dnl Many older installations will not provide this file, but some will
31dnl have the very same definitions in <inttypes.h>. In other enviroments
32dnl we can use the inet-types in <sys/types.h> which would define the
33dnl typedefs int8_t and u_int8_t respectivly.
34dnl
35dnl This macros will create a local "_stdint.h" or the headerfile given as
36dnl an argument. In many cases that file will just "#include <stdint.h>"
37dnl or "#include <inttypes.h>", while in other environments it will provide
38dnl the set of basic 'stdint's definitions/typedefs:
39dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
40dnl int_least32_t.. int_fast32_t.. intmax_t
41dnl which may or may not rely on the definitions of other files,
42dnl or using the AC_COMPILE_CHECK_SIZEOF macro to determine the actual
43dnl sizeof each type.
44dnl
45dnl if your header files require the stdint-types you will want to create an
46dnl installable file mylib-int.h that all your other installable header
47dnl may include. So if you have a library package named "mylib", just use
48dnl AX_CREATE_STDINT_H(mylib-int.h)
49dnl in configure.ac and go to install that very header file in Makefile.am
50dnl along with the other headers (mylib.h) - and the mylib-specific headers
51dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
52dnl
53dnl Remember, if the system already had a valid <stdint.h>, the generated
54dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
55dnl
56dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
57dnl @version $Id: ax_create_stdint_h.m4,v 1.2 2003/07/08 12:22:49 jas Exp $
58dnl @author Guido Draheim <guidod@gmx.de>
59
60AC_DEFUN([AX_CREATE_STDINT_H],
61[# ------ AX CREATE STDINT H -------------------------------------
62AC_MSG_CHECKING([for stdint types])
63ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
64# try to shortcircuit - if the default include path of the compiler
65# can find a "stdint.h" header then we assume that all compilers can.
66AC_CACHE_VAL([ac_cv_header_stdint_t],[
67old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
68old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
69old_CFLAGS="$CFLAGS" ; CFLAGS=""
70AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
71[ac_cv_stdint_result="(assuming C99 compatible system)"
72 ac_cv_header_stdint_t="stdint.h"; ],
73[ac_cv_header_stdint_t=""])
74CXXFLAGS="$old_CXXFLAGS"
75CPPFLAGS="$old_CPPFLAGS"
76CFLAGS="$old_CFLAGS" ])
77
78v="... $ac_cv_header_stdint_h"
79if test "$ac_stdint_h" = "stdint.h" ; then
80 AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
81elif test "$ac_stdint_h" = "inttypes.h" ; then
82 AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
83elif test "_$ac_cv_header_stdint_t" = "_" ; then
84 AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
85else
86 ac_cv_header_stdint="$ac_cv_header_stdint_t"
87 AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
88fi
89
90if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
91
92dnl .....intro message done, now do a few system checks.....
93dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
94dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
95
96inttype_headers=`echo $2 | sed -e 's/,/ /g'`
97
98ac_cv_stdint_result="(no helpful system typedefs seen)"
99AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
100 ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
101 AC_MSG_RESULT([(..)])
102 for i in stdint.h inttypes.h sys/inttypes.h sys/types.h $inttype_headers ; do
103 unset ac_cv_type_uintptr_t
104 unset ac_cv_type_uint64_t
105 _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
106 continue,[#include <$i>])
107 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
108 ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
109 break;
110 done
111 AC_MSG_CHECKING([for stdint uintptr_t])
112 ])
113
114if test "_$ac_cv_header_stdint_x" = "_" ; then
115AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
116 ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
117 AC_MSG_RESULT([(..)])
118 for i in inttypes.h sys/inttypes.h stdint.h sys/types.h $inttype_headers ; do
119 unset ac_cv_type_uint32_t
120 unset ac_cv_type_uint64_t
121 AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
122 continue,[#include <$i>])
123 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
124 ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
125 break;
126 done
127 AC_MSG_CHECKING([for stdint uint32_t])
128 ])
129fi
130
131if test "_$ac_cv_header_stdint_x" = "_" ; then
132if test "_$ac_cv_header_stdint_o" = "_" ; then
133AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
134 ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
135 AC_MSG_RESULT([(..)])
136 for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
137 unset ac_cv_type_u_int32_t
138 unset ac_cv_type_u_int64_t
139 AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
140 continue,[#include <$i>])
141 AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
142 ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
143 break;
144 done
145 AC_MSG_CHECKING([for stdint u_int32_t])
146 ])
147fi fi
148
149dnl if there was no good C99 header file, do some typedef checks...
150if test "_$ac_cv_header_stdint_x" = "_" ; then
151 AC_MSG_CHECKING([for stdint datatype model])
152 AC_MSG_RESULT([(..)])
153 AC_COMPILE_CHECK_SIZEOF(char)
154 AC_COMPILE_CHECK_SIZEOF(short)
155 AC_COMPILE_CHECK_SIZEOF(int)
156 AC_COMPILE_CHECK_SIZEOF(long)
157 AC_COMPILE_CHECK_SIZEOF(void*)
158 ac_cv_stdint_char_model=""
159 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
160 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
161 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
162 ac_cv_stdint_long_model=""
163 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
164 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
165 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
166 name="$ac_cv_stdint_long_model"
167 case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
168 122/242) name="$name, IP16 (standard 16bit machine)" ;;
169 122/244) name="$name, LP32 (standard 32bit mac/win)" ;;
170 122/*) name="$name (unusual int16 model)" ;;
171 124/444) name="$name, ILP32 (standard 32bit unixish)" ;;
172 124/488) name="$name, LP64 (standard 64bit unixish)" ;;
173 124/448) name="$name, LLP64 (unusual 64bit unixish)" ;;
174 124/*) name="$name (unusual int32 model)" ;;
175 128/888) name="$name, ILP64 (unusual 64bit numeric)" ;;
176 128/*) name="$name (unusual int64 model)" ;;
177 222/*|444/*) name="$name (unusual dsptype)" ;;
178 *) name="$name (very unusal model)" ;;
179 esac
180 AC_MSG_RESULT([combined for stdint datatype model... $name])
181fi
182
183if test "_$ac_cv_header_stdint_x" != "_" ; then
184 ac_cv_header_stdint="$ac_cv_header_stdint_x"
185elif test "_$ac_cv_header_stdint_o" != "_" ; then
186 ac_cv_header_stdint="$ac_cv_header_stdint_o"
187elif test "_$ac_cv_header_stdint_u" != "_" ; then
188 ac_cv_header_stdint="$ac_cv_header_stdint_u"
189else
190 ac_cv_header_stdint="stddef.h"
191fi
192
193AC_MSG_CHECKING([for extra inttypes in chosen header])
194AC_MSG_RESULT([($ac_cv_header_stdint)])
195dnl see if int_least and int_fast types are present in _this_ header.
196unset ac_cv_type_int_least32_t
197unset ac_cv_type_int_fast32_t
198AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
199AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
200AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
201
202fi # shortcircut to system "stdint.h"
203# ------------------ PREPARE VARIABLES ------------------------------
204if test "$GCC" = "yes" ; then
205ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
206else
207ac_cv_stdint_message="using $CC"
208fi
209
210AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
211$ac_cv_stdint_result])
212
213# ----------------- DONE inttypes.h checks START header -------------
214AC_CONFIG_COMMANDS([$ac_stdint_h],[
215AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
216ac_stdint=$tmp/_stdint.h
217
218echo "#ifndef" $_ac_stdint_h >$ac_stdint
219echo "#define" $_ac_stdint_h "1" >>$ac_stdint
220echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
221echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
222echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
223if test "_$ac_cv_header_stdint_t" != "_" ; then
224echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
225fi
226
227cat >>$ac_stdint <<STDINT_EOF
228
229/* ................... shortcircuit part ........................... */
230
231#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
232#include <stdint.h>
233#else
234#include <stddef.h>
235
236/* .................... configured part ............................ */
237
238STDINT_EOF
239
240echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
241if test "_$ac_cv_header_stdint_x" != "_" ; then
242 ac_header="$ac_cv_header_stdint_x"
243 echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
244else
245 echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
246fi
247
248echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
249if test "_$ac_cv_header_stdint_o" != "_" ; then
250 ac_header="$ac_cv_header_stdint_o"
251 echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
252else
253 echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
254fi
255
256echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
257if test "_$ac_cv_header_stdint_u" != "_" ; then
258 ac_header="$ac_cv_header_stdint_u"
259 echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
260else
261 echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
262fi
263
264echo "" >>$ac_stdint
265
266if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
267 echo "#include <$ac_header>" >>$ac_stdint
268 echo "" >>$ac_stdint
269fi fi
270
271echo "/* which 64bit typedef has been found */" >>$ac_stdint
272if test "$ac_cv_type_uint64_t" = "yes" ; then
273echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
274else
275echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
276fi
277if test "$ac_cv_type_u_int64_t" = "yes" ; then
278echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
279else
280echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
281fi
282echo "" >>$ac_stdint
283
284echo "/* which type model has been detected */" >>$ac_stdint
285if test "_$ac_cv_stdint_char_model" != "_" ; then
286echo "#define _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
287echo "#define _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
288else
289echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
290echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
291fi
292echo "" >>$ac_stdint
293
294echo "/* whether int_least types were detected */" >>$ac_stdint
295if test "$ac_cv_type_int_least32_t" = "yes"; then
296echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
297else
298echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
299fi
300echo "/* whether int_fast types were detected */" >>$ac_stdint
301if test "$ac_cv_type_int_fast32_t" = "yes"; then
302echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
303else
304echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
305fi
306echo "/* whether intmax_t type was detected */" >>$ac_stdint
307if test "$ac_cv_type_intmax_t" = "yes"; then
308echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
309else
310echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
311fi
312echo "" >>$ac_stdint
313
314 cat >>$ac_stdint <<STDINT_EOF
315/* .................... detections part ............................ */
316
317/* whether we need to define bitspecific types from compiler base types */
318#ifndef _STDINT_HEADER_INTPTR
319#ifndef _STDINT_HEADER_UINT32
320#ifndef _STDINT_HEADER_U_INT32
321#define _STDINT_NEED_INT_MODEL_T
322#else
323#define _STDINT_HAVE_U_INT_TYPES
324#endif
325#endif
326#endif
327
328#ifdef _STDINT_HAVE_U_INT_TYPES
329#undef _STDINT_NEED_INT_MODEL_T
330#endif
331
332#ifdef _STDINT_CHAR_MODEL
333#if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
334#ifndef _STDINT_BYTE_MODEL
335#define _STDINT_BYTE_MODEL 12
336#endif
337#endif
338#endif
339
340#ifndef _STDINT_HAVE_INT_LEAST32_T
341#define _STDINT_NEED_INT_LEAST_T
342#endif
343
344#ifndef _STDINT_HAVE_INT_FAST32_T
345#define _STDINT_NEED_INT_FAST_T
346#endif
347
348#ifndef _STDINT_HEADER_INTPTR
349#define _STDINT_NEED_INTPTR_T
350#ifndef _STDINT_HAVE_INTMAX_T
351#define _STDINT_NEED_INTMAX_T
352#endif
353#endif
354
355
356/* .................... definition part ............................ */
357
358/* some system headers have good uint64_t */
359#ifndef _HAVE_UINT64_T
360#if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
361#define _HAVE_UINT64_T
362#elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
363#define _HAVE_UINT64_T
364typedef u_int64_t uint64_t;
365#endif
366#endif
367
368#ifndef _HAVE_UINT64_T
369/* .. here are some common heuristics using compiler runtime specifics */
370#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
371#define _HAVE_UINT64_T
372typedef long long int64_t;
373typedef unsigned long long uint64_t;
374
375#elif !defined __STRICT_ANSI__
376#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
377#define _HAVE_UINT64_T
378typedef __int64 int64_t;
379typedef unsigned __int64 uint64_t;
380
381#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
382/* note: all ELF-systems seem to have loff-support which needs 64-bit */
383#if !defined _NO_LONGLONG
384#define _HAVE_UINT64_T
385typedef long long int64_t;
386typedef unsigned long long uint64_t;
387#endif
388
389#elif defined __alpha || (defined __mips && defined _ABIN32)
390#if !defined _NO_LONGLONG
391typedef long int64_t;
392typedef unsigned long uint64_t;
393#endif
394 /* compiler/cpu type to define int64_t */
395#endif
396#endif
397#endif
398
399#if defined _STDINT_HAVE_U_INT_TYPES
400/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
401typedef u_int8_t uint8_t;
402typedef u_int16_t uint16_t;
403typedef u_int32_t uint32_t;
404
405/* glibc compatibility */
406#ifndef __int8_t_defined
407#define __int8_t_defined
408#endif
409#endif
410
411#ifdef _STDINT_NEED_INT_MODEL_T
412/* we must guess all the basic types. Apart from byte-adressable system, */
413/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
414/* (btw, those nibble-addressable systems are way off, or so we assume) */
415
416dnl /* have a look at "64bit and data size neutrality" at */
417dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
418dnl /* (the shorthand "ILP" types always have a "P" part) */
419
420#if defined _STDINT_BYTE_MODEL
421#if _STDINT_LONG_MODEL+0 == 242
422/* 2:4:2 = IP16 = a normal 16-bit system */
423typedef unsigned char uint8_t;
424typedef unsigned short uint16_t;
425typedef unsigned long uint32_t;
426#ifndef __int8_t_defined
427#define __int8_t_defined
428typedef char int8_t;
429typedef short int16_t;
430typedef long int32_t;
431#endif
432#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
433/* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
434/* 4:4:4 = ILP32 = a normal 32-bit system */
435typedef unsigned char uint8_t;
436typedef unsigned short uint16_t;
437typedef unsigned int uint32_t;
438#ifndef __int8_t_defined
439#define __int8_t_defined
440typedef char int8_t;
441typedef short int16_t;
442typedef int int32_t;
443#endif
444#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
445/* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
446/* 4:8:8 = LP64 = a normal 64-bit system */
447typedef unsigned char uint8_t;
448typedef unsigned short uint16_t;
449typedef unsigned int uint32_t;
450#ifndef __int8_t_defined
451#define __int8_t_defined
452typedef char int8_t;
453typedef short int16_t;
454typedef int int32_t;
455#endif
456/* this system has a "long" of 64bit */
457#ifndef _HAVE_UINT64_T
458#define _HAVE_UINT64_T
459typedef unsigned long uint64_t;
460typedef long int64_t;
461#endif
462#elif _STDINT_LONG_MODEL+0 == 448
463/* LLP64 a 64-bit system derived from a 32-bit system */
464typedef unsigned char uint8_t;
465typedef unsigned short uint16_t;
466typedef unsigned int uint32_t;
467#ifndef __int8_t_defined
468#define __int8_t_defined
469typedef char int8_t;
470typedef short int16_t;
471typedef int int32_t;
472#endif
473/* assuming the system has a "long long" */
474#ifndef _HAVE_UINT64_T
475#define _HAVE_UINT64_T
476typedef unsigned long long uint64_t;
477typedef long long int64_t;
478#endif
479#else
480#define _STDINT_NO_INT32_T
481#endif
482#else
483#define _STDINT_NO_INT8_T
484#define _STDINT_NO_INT32_T
485#endif
486#endif
487
488/*
489 * quote from SunOS-5.8 sys/inttypes.h:
490 * Use at your own risk. As of February 1996, the committee is squarely
491 * behind the fixed sized types; the "least" and "fast" types are still being
492 * discussed. The probability that the "fast" types may be removed before
493 * the standard is finalized is high enough that they are not currently
494 * implemented.
495 */
496
497#if defined _STDINT_NEED_INT_LEAST_T
498typedef int8_t int_least8_t;
499typedef int16_t int_least16_t;
500typedef int32_t int_least32_t;
501#ifdef _HAVE_UINT64_T
502typedef int64_t int_least64_t;
503#endif
504
505typedef uint8_t uint_least8_t;
506typedef uint16_t uint_least16_t;
507typedef uint32_t uint_least32_t;
508#ifdef _HAVE_UINT64_T
509typedef uint64_t uint_least64_t;
510#endif
511 /* least types */
512#endif
513
514#if defined _STDINT_NEED_INT_FAST_T
515typedef int8_t int_fast8_t;
516typedef int int_fast16_t;
517typedef int32_t int_fast32_t;
518#ifdef _HAVE_UINT64_T
519typedef int64_t int_fast64_t;
520#endif
521
522typedef uint8_t uint_fast8_t;
523typedef unsigned uint_fast16_t;
524typedef uint32_t uint_fast32_t;
525#ifdef _HAVE_UINT64_T
526typedef uint64_t uint_fast64_t;
527#endif
528 /* fast types */
529#endif
530
531#ifdef _STDINT_NEED_INTMAX_T
532#ifdef _HAVE_UINT64_T
533typedef int64_t intmax_t;
534typedef uint64_t uintmax_t;
535#else
536typedef long intmax_t;
537typedef unsigned long uintmax_t;
538#endif
539#endif
540
541#ifdef _STDINT_NEED_INTPTR_T
542#ifndef __intptr_t_defined
543#define __intptr_t_defined
544/* we encourage using "long" to store pointer values, never use "int" ! */
545#if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
546typedef unsinged int uintptr_t;
547typedef int intptr_t;
548#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
549typedef unsigned long uintptr_t;
550typedef long intptr_t;
551#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
552typedef uint64_t uintptr_t;
553typedef int64_t intptr_t;
554#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
555typedef unsigned long uintptr_t;
556typedef long intptr_t;
557#endif
558#endif
559#endif
560
561 /* shortcircuit*/
562#endif
563 /* once */
564#endif
565#endif
566STDINT_EOF
567 if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
568 AC_MSG_NOTICE([$ac_stdint_h is unchanged])
569 else
570 ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
571 AS_MKDIR_P(["$ac_dir"])
572 rm -f $ac_stdint_h
573 mv $ac_stdint $ac_stdint_h
574 fi
575],[# variables for create stdint.h replacement
576PACKAGE="$PACKAGE"
577VERSION="$VERSION"
578ac_stdint_h="$ac_stdint_h"
579_ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
580ac_cv_stdint_message="$ac_cv_stdint_message"
581ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
582ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
583ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
584ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
585ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
586ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
587ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
588ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
589ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
590ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
591ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
592])
593])
594
595dnl @synopsis AC_COMPILE_CHECK_SIZEOF(TYPE [, HEADERS [, EXTRA_SIZES...]])
596dnl
597dnl This macro checks for the size of TYPE using compile checks, not
598dnl run checks. You can supply extra HEADERS to look into. the check
599dnl will cycle through 1 2 4 8 16 and any EXTRA_SIZES the user
600dnl supplies. If a match is found, it will #define SIZEOF_`TYPE' to
601dnl that value. Otherwise it will emit a configure time error
602dnl indicating the size of the type could not be determined.
603dnl
604dnl The trick is that C will not allow duplicate case labels. While
605dnl this is valid C code:
606dnl
607dnl switch (0) case 0: case 1:;
608dnl
609dnl The following is not:
610dnl
611dnl switch (0) case 0: case 0:;
612dnl
613dnl Thus, the AC_TRY_COMPILE will fail if the currently tried size
614dnl does not match.
615dnl
616dnl Here is an example skeleton configure.in script, demonstrating the
617dnl macro's usage:
618dnl
619dnl AC_PROG_CC
620dnl AC_CHECK_HEADERS(stddef.h unistd.h)
621dnl AC_TYPE_SIZE_T
622dnl AC_CHECK_TYPE(ssize_t, int)
623dnl
624dnl headers='#ifdef HAVE_STDDEF_H
625dnl #include <stddef.h>
626dnl #endif
627dnl #ifdef HAVE_UNISTD_H
628dnl #include <unistd.h>
629dnl #endif
630dnl '
631dnl
632dnl AC_COMPILE_CHECK_SIZEOF(char)
633dnl AC_COMPILE_CHECK_SIZEOF(short)
634dnl AC_COMPILE_CHECK_SIZEOF(int)
635dnl AC_COMPILE_CHECK_SIZEOF(long)
636dnl AC_COMPILE_CHECK_SIZEOF(unsigned char *)
637dnl AC_COMPILE_CHECK_SIZEOF(void *)
638dnl AC_COMPILE_CHECK_SIZEOF(size_t, $headers)
639dnl AC_COMPILE_CHECK_SIZEOF(ssize_t, $headers)
640dnl AC_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers)
641dnl AC_COMPILE_CHECK_SIZEOF(off_t, $headers)
642dnl
643dnl @author Kaveh Ghazi <ghazi@caip.rutgers.edu>
644dnl @version $Id: ac_compile_check_sizeof.m4,v 1.1 2003/06/18 16:48:00 jas Exp $
645dnl
646AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
647[changequote(<<, >>)dnl
648dnl The name to #define.
649define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
650dnl The cache variable name.
651define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
652changequote([, ])dnl
653AC_MSG_CHECKING(size of $1)
654AC_CACHE_VAL(AC_CV_NAME,
655[for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
656 AC_TRY_COMPILE([#include "confdefs.h"
657#include <sys/types.h>
658$2
659], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
660 if test x$AC_CV_NAME != x ; then break; fi
661done
662])
663if test x$AC_CV_NAME = x ; then
664 AC_MSG_ERROR([cannot determine a size for $1])
665fi
666AC_MSG_RESULT($AC_CV_NAME)
667AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
668undefine([AC_TYPE_NAME])dnl
669undefine([AC_CV_NAME])dnl
670])
671

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status