annotate m4/size_max.m4 @ 267:bec6d2480f08 2.6

Added add'l generated files for release
author lost
date Tue, 22 Dec 2009 05:33:32 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
267
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
1 # size_max.m4 serial 7
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
2 dnl Copyright (C) 2003, 2005-2006, 2008 Free Software Foundation, Inc.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
6
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
7 dnl From Bruno Haible.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
8
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
9 AC_DEFUN([gl_SIZE_MAX],
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
10 [
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
11 AC_CHECK_HEADERS([stdint.h])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
12 dnl First test whether the system already has SIZE_MAX.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
13 AC_MSG_CHECKING([for SIZE_MAX])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
14 AC_CACHE_VAL([gl_cv_size_max], [
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
15 gl_cv_size_max=
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
16 AC_EGREP_CPP([Found it], [
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
17 #include <limits.h>
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
18 #if HAVE_STDINT_H
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
19 #include <stdint.h>
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
20 #endif
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
21 #ifdef SIZE_MAX
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
22 Found it
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
23 #endif
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
24 ], [gl_cv_size_max=yes])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
25 if test -z "$gl_cv_size_max"; then
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
26 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
27 dnl than the type 'unsigned long'. Try hard to find a definition that can
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
28 dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
29 AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1],
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
30 [#include <stddef.h>
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
31 #include <limits.h>], [size_t_bits_minus_1=])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
32 AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)],
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
33 [#include <stddef.h>], [fits_in_uint=])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
34 if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
35 if test $fits_in_uint = 1; then
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
36 dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
37 dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
38 AC_TRY_COMPILE([#include <stddef.h>
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
39 extern size_t foo;
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
40 extern unsigned long foo;
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
41 ], [], [fits_in_uint=0])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
42 fi
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
43 dnl We cannot use 'expr' to simplify this expression, because 'expr'
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
44 dnl works only with 'long' integers in the host environment, while we
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
45 dnl might be cross-compiling from a 32-bit platform to a 64-bit platform.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
46 if test $fits_in_uint = 1; then
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
47 gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)"
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
48 else
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
49 gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)"
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
50 fi
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
51 else
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
52 dnl Shouldn't happen, but who knows...
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
53 gl_cv_size_max='((size_t)~(size_t)0)'
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
54 fi
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
55 fi
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
56 ])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
57 AC_MSG_RESULT([$gl_cv_size_max])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
58 if test "$gl_cv_size_max" != yes; then
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
59 AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max],
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
60 [Define as the maximum value of type 'size_t', if the system doesn't define it.])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
61 fi
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
62 ])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
63
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
64 dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
65 dnl Remove this when we can assume autoconf >= 2.61.
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
66 m4_ifdef([AC_COMPUTE_INT], [], [
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
67 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
bec6d2480f08 Added add'l generated files for release
lost
parents:
diff changeset
68 ])