beta-0.89.2
[luatex.git] / source / libs / zziplib / zziplib-0.13.62 / m4 / ac_compile_check_sizeof.m4
bloba1cdb402636bd5c8e73bdfe3371a52557e6c8ef6
1 dnl /usr/share/aclocal/ac-archive-cvs/ac_compile_check_sizeof.m4
2 dnl @synopsis AC_COMPILE_CHECK_SIZEOF(TYPE [, HEADERS [, EXTRA_SIZES...]])
3 dnl
4 dnl This macro checks for the size of TYPE using compile checks, not
5 dnl run checks. You can supply extra HEADERS to look into. the check
6 dnl will cycle through 1 2 4 8 16 and any EXTRA_SIZES the user
7 dnl supplies. If a match is found, it will #define SIZEOF_`TYPE' to
8 dnl that value. Otherwise it will emit a configure time error
9 dnl indicating the size of the type could not be determined.
10 dnl
11 dnl The trick is that C will not allow duplicate case labels. While
12 dnl this is valid C code:
13 dnl
14 dnl      switch (0) case 0: case 1:;
15 dnl
16 dnl The following is not:
17 dnl
18 dnl      switch (0) case 0: case 0:;
19 dnl
20 dnl Thus, the AC_TRY_COMPILE will fail if the currently tried size does
21 dnl not match.
22 dnl
23 dnl Here is an example skeleton configure.in script, demonstrating the
24 dnl macro's usage:
25 dnl
26 dnl      AC_PROG_CC
27 dnl      AC_CHECK_HEADERS(stddef.h unistd.h)
28 dnl      AC_TYPE_SIZE_T
29 dnl      AC_CHECK_TYPE(ssize_t, int)
30 dnl
31 dnl      headers='#ifdef HAVE_STDDEF_H
32 dnl      #include <stddef.h>
33 dnl      #endif
34 dnl      #ifdef HAVE_UNISTD_H
35 dnl      #include <unistd.h>
36 dnl      #endif
37 dnl      '
38 dnl
39 dnl      AC_COMPILE_CHECK_SIZEOF(char)
40 dnl      AC_COMPILE_CHECK_SIZEOF(short)
41 dnl      AC_COMPILE_CHECK_SIZEOF(int)
42 dnl      AC_COMPILE_CHECK_SIZEOF(long)
43 dnl      AC_COMPILE_CHECK_SIZEOF(unsigned char *)
44 dnl      AC_COMPILE_CHECK_SIZEOF(void *)
45 dnl      AC_COMPILE_CHECK_SIZEOF(size_t, $headers)
46 dnl      AC_COMPILE_CHECK_SIZEOF(ssize_t, $headers)
47 dnl      AC_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers)
48 dnl      AC_COMPILE_CHECK_SIZEOF(off_t, $headers)
49 dnl
50 dnl @category Misc
51 dnl @author Kaveh Ghazi <ghazi@caip.rutgers.edu>
52 dnl @version 2000-07-19
53 dnl @license GPLWithACException
55 AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
56 [changequote(<<, >>)dnl
57 dnl The name to #define.
58 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
59 dnl The cache variable name.
60 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
61 changequote([, ])dnl
62 AC_MSG_CHECKING(size of $1)
63 AC_CACHE_VAL(AC_CV_NAME,
64 [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
65   AC_TRY_COMPILE([#include "confdefs.h"
66 #include <sys/types.h>
68 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
69   if test x$AC_CV_NAME != x ; then break; fi
70 done
72 if test x$AC_CV_NAME = x ; then
73   AC_MSG_ERROR([cannot determine a size for $1])
75 AC_MSG_RESULT($AC_CV_NAME)
76 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
77 undefine([AC_TYPE_NAME])dnl
78 undefine([AC_CV_NAME])dnl