cfa5150349996af7c3f8031380e3cce0ae911bbd
[gnulib.git] / m4 / uint32_t.m4
1 # uint32_t.m4 serial 2
2
3 # Copyright (C) 2004 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 # Written by Paul Eggert.
20
21 AC_DEFUN([gl_AC_TYPE_UINT32_T],
22 [
23   AC_CACHE_CHECK([for uint32_t], gl_cv_c_uint32_t,
24     [gl_cv_c_uint32_t=no
25      for ac_type in "uint32_t" "unsigned int" \
26          "unsigned long int" "unsigned short int"; do
27        AC_COMPILE_IFELSE(
28          [AC_LANG_BOOL_COMPILE_TRY(
29             [AC_INCLUDES_DEFAULT],
30             [[(uint32_t) -1 == 4294967295U]])],
31          [gl_cv_c_uint32_t=$ac_type])
32        test $gl_cv_c_uint32_t != no && break
33      done])
34   case $gl_cv_c_uint32_t in
35   no|uint32_t) ;;
36   *)
37     AC_DEFINE_UNQUOTED(uint32_t, $gl_cv_c_uint32_t,
38       [Define to the type of a unsigned integer type of width exactly 32 bits
39        if such a type exists and the standard includes do not define it.])
40     ;;
41   esac
42
43   AC_CACHE_CHECK([for UINT32_MAX], gl_cv_c_uint32_max,
44     [AC_COMPILE_IFELSE(
45        [AC_LANG_BOOL_COMPILE_TRY(
46           [AC_INCLUDES_DEFAULT],
47           [[UINT32_MAX == 4294967295U]])],
48        [gl_cv_c_uint32_max=yes],
49        [gl_cv_c_uint32_max=no])])
50   case $gl_cv_c_uint32_max,$gl_cv_c_uint32_t in
51   yes,*) ;;
52   *,no) ;;
53   *)
54     AC_DEFINE(UINT32_MAX, 4294967295U,
55       [Define to its maximum value if an unsigned integer type of width
56        exactly 32 bits exists and the standard includes do not define
57        UINT32_MAX.])
58     ;;
59   esac
60 ])