2N/Adnl Copyright (C) 2003, 2005-2006, 2008-2010 Free Software Foundation, Inc.
2N/Adnl This file is free software; the Free Software Foundation
2N/Adnl gives unlimited permission to copy
and/or distribute it,
2N/Adnl with or without modifications, as long as this notice is preserved.
2N/Adnl From Bruno Haible.
2N/AAC_DEFUN([gl_SIZE_MAX],
2N/A dnl First test whether the system already has SIZE_MAX.
2N/A AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [
2N/A AC_EGREP_CPP([Found it], [
2N/A], [gl_cv_size_max=yes])
2N/A if test -z "$gl_cv_size_max"; then
2N/A dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
2N/A dnl than the type 'unsigned long'. Try hard to find a definition that can
2N/A dnl be used in a preprocessor #if,
i.e. doesn't contain a cast.
2N/A AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1],
2N/A AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)],
2N/A if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
2N/A if test $fits_in_uint = 1; then
2N/A dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
2N/A dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
2N/A extern unsigned long foo;
2N/A dnl We cannot use 'expr' to simplify this expression, because 'expr'
2N/A dnl works only with 'long' integers in the host environment, while we
2N/A dnl might be cross-compiling from a 32-bit platform to a 64-bit platform.
2N/A if test $fits_in_uint = 1; then
2N/A gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)"
2N/A gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)"
2N/A dnl Shouldn't happen, but who knows...
2N/A gl_cv_size_max='((size_t)~(size_t)0)'
2N/A if test "$gl_cv_size_max" != yes; then
2N/A AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max],
2N/A [Define as the maximum value of type 'size_t', if the system doesn't define it.])
2N/A dnl <
stdint.h>. Remember that the #undef in AH_VERBATIM gets replaced with
2N/A dnl #define by AC_DEFINE_UNQUOTED.
2N/A AH_VERBATIM([SIZE_MAX],
2N/A[/* Define as the maximum value of type 'size_t', if the system doesn't define
2N/Adnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
2N/Adnl Remove this when we can assume autoconf >= 2.61.
2N/Am4_ifdef([AC_COMPUTE_INT], [], [
2N/A AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])