xref: /netbsd/external/gpl2/xcvs/dist/m4/stdint.m4 (revision 6550d01e)
1# stdint.m4 serial 4
2dnl Copyright (C) 2001-2002, 2004-2005 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether <stdint.h> is supported or must be substituted.
9
10AC_DEFUN([gl_STDINT_H],
11[dnl Check for <inttypes.h>.
12AC_REQUIRE([gt_HEADER_INTTYPES_H])
13dnl Check for <sys/inttypes.h>.
14AC_CHECK_HEADERS([sys/inttypes.h])
15
16AC_MSG_CHECKING([for stdint.h])
17AC_CACHE_VAL(gl_cv_header_stdint_h, [
18  AC_TRY_COMPILE([#include <stdint.h>], [],
19    gl_cv_header_stdint_h=yes, gl_cv_header_stdint_h=no)])
20AC_MSG_RESULT([$gl_cv_header_stdint_h])
21if test $gl_cv_header_stdint_h = yes; then
22  AC_DEFINE(HAVE_STDINT_H, 1,
23            [Define if you have a working <stdint.h> header file.])
24  STDINT_H=''
25else
26  STDINT_H='stdint.h'
27
28  dnl Is long == int64_t ?
29  AC_CACHE_CHECK([whether 'long' is 64 bit wide], gl_cv_long_bitsize_64, [
30    AC_TRY_COMPILE([
31#define POW63  ((((((long) 1 << 15) << 15) << 15) << 15) << 3)
32#define POW64  ((((((long) 1 << 15) << 15) << 15) << 15) << 4)
33typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
34], , gl_cv_long_bitsize_64=yes, gl_cv_long_bitsize_64=no)])
35  if test $gl_cv_long_bitsize_64 = yes; then
36    HAVE_LONG_64BIT=1
37  else
38    HAVE_LONG_64BIT=0
39  fi
40  AC_SUBST(HAVE_LONG_64BIT)
41
42  dnl Is long long == int64_t ?
43  AC_CACHE_CHECK([whether 'long long' is 64 bit wide], gl_cv_longlong_bitsize_64, [
44    AC_TRY_COMPILE([
45#define POW63  ((((((long long) 1 << 15) << 15) << 15) << 15) << 3)
46#define POW64  ((((((long long) 1 << 15) << 15) << 15) << 15) << 4)
47typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
48], , gl_cv_longlong_bitsize_64=yes, gl_cv_longlong_bitsize_64=no)])
49  if test $gl_cv_longlong_bitsize_64 = yes; then
50    HAVE_LONG_LONG_64BIT=1
51  else
52    HAVE_LONG_LONG_64BIT=0
53  fi
54  AC_SUBST(HAVE_LONG_LONG_64BIT)
55
56fi
57AC_SUBST(STDINT_H)
58])
59