Blame autoconf-archive/m4/ax_compile_check_sizeof.m4

Packit Service def718
# ===========================================================================
Packit Service def718
#  http://www.gnu.org/software/autoconf-archive/ax_compile_check_sizeof.html
Packit Service def718
# ===========================================================================
Packit Service def718
#
Packit Service def718
# SYNOPSIS
Packit Service def718
#
Packit Service def718
#   AX_COMPILE_CHECK_SIZEOF(TYPE [, HEADERS [, EXTRA_SIZES...]])
Packit Service def718
#
Packit Service def718
# DESCRIPTION
Packit Service def718
#
Packit Service def718
#   This macro checks for the size of TYPE using compile checks, not run
Packit Service def718
#   checks. You can supply extra HEADERS to look into. the check will cycle
Packit Service def718
#   through 1 2 4 8 16 and any EXTRA_SIZES the user supplies. If a match is
Packit Service def718
#   found, it will #define SIZEOF_`TYPE' to that value. Otherwise it will
Packit Service def718
#   emit a configure time error indicating the size of the type could not be
Packit Service def718
#   determined.
Packit Service def718
#
Packit Service def718
#   The trick is that C will not allow duplicate case labels. While this is
Packit Service def718
#   valid C code:
Packit Service def718
#
Packit Service def718
#     switch (0) case 0: case 1:;
Packit Service def718
#
Packit Service def718
#   The following is not:
Packit Service def718
#
Packit Service def718
#     switch (0) case 0: case 0:;
Packit Service def718
#
Packit Service def718
#   Thus, the AC_TRY_COMPILE will fail if the currently tried size does not
Packit Service def718
#   match.
Packit Service def718
#
Packit Service def718
#   Here is an example skeleton configure.in script, demonstrating the
Packit Service def718
#   macro's usage:
Packit Service def718
#
Packit Service def718
#     AC_PROG_CC
Packit Service def718
#     AC_CHECK_HEADERS(stddef.h unistd.h)
Packit Service def718
#     AC_TYPE_SIZE_T
Packit Service def718
#     AC_CHECK_TYPE(ssize_t, int)
Packit Service def718
#
Packit Service def718
#     headers='#ifdef HAVE_STDDEF_H
Packit Service def718
#     #include <stddef.h>
Packit Service def718
#     #endif
Packit Service def718
#     #ifdef HAVE_UNISTD_H
Packit Service def718
#     #include <unistd.h>
Packit Service def718
#     #endif
Packit Service def718
#     '
Packit Service def718
#
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(char)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(short)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(int)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(long)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(unsigned char *)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(void *)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(size_t, $headers)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(ssize_t, $headers)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers)
Packit Service def718
#     AX_COMPILE_CHECK_SIZEOF(off_t, $headers)
Packit Service def718
#
Packit Service def718
# LICENSE
Packit Service def718
#
Packit Service def718
#   Copyright (c) 2008 Kaveh Ghazi <ghazi@caip.rutgers.edu>
Packit Service def718
#
Packit Service def718
#   This program is free software: you can redistribute it and/or modify it
Packit Service def718
#   under the terms of the GNU General Public License as published by the
Packit Service def718
#   Free Software Foundation, either version 3 of the License, or (at your
Packit Service def718
#   option) any later version.
Packit Service def718
#
Packit Service def718
#   This program is distributed in the hope that it will be useful, but
Packit Service def718
#   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service def718
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit Service def718
#   Public License for more details.
Packit Service def718
#
Packit Service def718
#   You should have received a copy of the GNU General Public License along
Packit Service def718
#   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit Service def718
#
Packit Service def718
#   As a special exception, the respective Autoconf Macro's copyright owner
Packit Service def718
#   gives unlimited permission to copy, distribute and modify the configure
Packit Service def718
#   scripts that are the output of Autoconf when processing the Macro. You
Packit Service def718
#   need not follow the terms of the GNU General Public License when using
Packit Service def718
#   or distributing such scripts, even though portions of the text of the
Packit Service def718
#   Macro appear in them. The GNU General Public License (GPL) does govern
Packit Service def718
#   all other use of the material that constitutes the Autoconf Macro.
Packit Service def718
#
Packit Service def718
#   This special exception to the GPL applies to versions of the Autoconf
Packit Service def718
#   Macro released by the Autoconf Archive. When you make and distribute a
Packit Service def718
#   modified version of the Autoconf Macro, you may extend this special
Packit Service def718
#   exception to the GPL to apply to your modified version as well.
Packit Service def718
Packit Service def718
#serial 5
Packit Service def718
Packit Service def718
AU_ALIAS([AC_COMPILE_CHECK_SIZEOF], [AX_COMPILE_CHECK_SIZEOF])
Packit Service def718
AC_DEFUN([AX_COMPILE_CHECK_SIZEOF],
Packit Service def718
[changequote(<<, >>)dnl
Packit Service def718
dnl The name to #define.
Packit Service def718
define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
Packit Service def718
dnl The cache variable name.
Packit Service def718
define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
Packit Service def718
changequote([, ])dnl
Packit Service def718
AC_MSG_CHECKING(size of $1)
Packit Service def718
AC_CACHE_VAL(AC_CV_NAME,
Packit Service def718
[for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
Packit Service def718
  AC_TRY_COMPILE([#include "confdefs.h"
Packit Service def718
#include <sys/types.h>
Packit Service def718
$2
Packit Service def718
], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
Packit Service def718
  if test x$AC_CV_NAME != x ; then break; fi
Packit Service def718
done
Packit Service def718
])
Packit Service def718
if test x$AC_CV_NAME = x ; then
Packit Service def718
  AC_MSG_ERROR([cannot determine a size for $1])
Packit Service def718
fi
Packit Service def718
AC_MSG_RESULT($AC_CV_NAME)
Packit Service def718
AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
Packit Service def718
undefine([AC_TYPE_NAME])dnl
Packit Service def718
undefine([AC_CV_NAME])dnl
Packit Service def718
])