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