-# intparam.m4 serial 1
-dnl Copyright (C) 2005 Free Software Foundation, Inc.
+# intparam.m4 serial 4 -*- Autoconf -*-
+dnl Copyright (C) 1993-2008, 2017, 2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
-dnl From Bruno Haible.
+dnl From Bruno Haible, Sam Steingold
AC_DEFUN([CL_INTPARAM_CROSS],
[
- AC_REQUIRE([CL_LONGLONG])
- AC_REQUIRE([CL_LONGDOUBLE])
AC_REQUIRE([AC_C_BIGENDIAN])
cl_machine_file_h=$1
{
CL_INTPARAM_BITSIZE([short], [short_bitsize])
CL_INTPARAM_BITSIZE([int], [int_bitsize])
CL_INTPARAM_BITSIZE([long], [long_bitsize])
- if test $cl_cv_c_longlong = yes; then
- CL_INTPARAM_BITSIZE([long long], [longlong_bitsize])
- fi
+ CL_INTPARAM_BITSIZE([long long], [longlong_bitsize])
CL_INTPARAM_BITSIZE([unsigned char], [uchar_bitsize])
CL_INTPARAM_BITSIZE([unsigned short], [ushort_bitsize])
CL_INTPARAM_BITSIZE([unsigned int], [uint_bitsize])
CL_INTPARAM_BITSIZE([unsigned long], [ulong_bitsize])
- if test $cl_cv_c_longlong = yes; then
- CL_INTPARAM_BITSIZE([unsigned long long], [ulonglong_bitsize])
- fi
+ CL_INTPARAM_BITSIZE([unsigned long long], [ulonglong_bitsize])
if test -n "$char_bitsize"; then
echo "/* Integers of type char have $char_bitsize bits. */"
echo "#define char_bitsize $char_bitsize"
else
echo "#error \"Integers of type long have no binary representation!!\""
fi
- if test $cl_cv_c_longlong = yes; then
- if test -n "$longlong_bitsize"; then
- echo "/* Integers of type long long have $longlong_bitsize bits. */"
- echo "#define long_long_bitsize $longlong_bitsize"
- echo
- else
- echo "#error \"Integers of type long long have no binary representation!!\""
- fi
+ if test -n "$longlong_bitsize"; then
+ echo "/* Integers of type long long have $longlong_bitsize bits. */"
+ echo "#define long_long_bitsize $longlong_bitsize"
+ echo
+ else
+ echo "#error \"Integers of type long long have no binary representation!!\""
fi
if test -n "$uchar_bitsize"; then
echo "/* Integers of type unsigned char have $uchar_bitsize bits. */"
else
echo "#error \"Integers of type unsigned long have no binary representation!!\""
fi
- if test $cl_cv_c_longlong = yes; then
- if test -n "$ulonglong_bitsize"; then
- echo "/* Integers of type unsigned long long have $ulonglong_bitsize bits. */"
- echo
- else
- echo "#error \"Integers of type unsigned long long have no binary representation!!\""
- fi
+ if test -n "$ulonglong_bitsize"; then
+ echo "/* Integers of type unsigned long long have $ulonglong_bitsize bits. */"
+ echo
+ else
+ echo "#error \"Integers of type unsigned long long have no binary representation!!\""
fi
if test "$char_bitsize" != "$uchar_bitsize"; then
echo "#error \"Integer types char and unsigned char have different sizes!!\""
if test "$long_bitsize" != "$ulong_bitsize"; then
echo "#error \"Integer types long and unsigned long have different sizes!!\""
fi
- if test $cl_cv_c_longlong = yes; then
- if test "$longlong_bitsize" != "$ulonglong_bitsize"; then
- echo "#error \"Integer types long long and unsigned long long have different sizes!!\""
- fi
+ if test "$longlong_bitsize" != "$ulonglong_bitsize"; then
+ echo "#error \"Integer types long long and unsigned long long have different sizes!!\""
fi
- AC_TRY_COMPILE([], [typedef int verify[2*(sizeof(char*)<=sizeof (long))-1];],
- [], [echo "#error \"Type char * does not fit into a long!!\""])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>]],
+ [[typedef int verify[2*(sizeof(char*)<=sizeof (intptr_t))-1];]])],
+ [], [echo "#error \"Type char * does not fit into an intptr_t!!\""])
_AC_COMPUTE_INT([sizeof (char *)], [pointer_size])
pointer_bitsize=`expr $pointer_size '*' $char_bitsize`
echo "/* Pointers of type char * have $pointer_bitsize bits. */"
CL_INTPARAM_ALIGNOF([unsigned long], [alignment_ulong])
echo "/* Type unsigned long has sizeof = $sizeof_ulong and alignment = $alignment_ulong. */"
echo
- if test $cl_cv_c_longlong = yes; then
- CL_INTPARAM_SIZEOF([long long], [sizeof_longlong])
- CL_INTPARAM_ALIGNOF([long long], [alignment_longlong])
- echo "/* Type long long has sizeof = $sizeof_longlong and alignment = $alignment_longlong. */"
- echo "#define sizeof_long_long $sizeof_longlong"
- echo "#define alignment_long_long $alignment_longlong"
- echo
- CL_INTPARAM_SIZEOF([unsigned long long], [sizeof_ulonglong])
- CL_INTPARAM_ALIGNOF([unsigned long long], [alignment_ulonglong])
- echo "/* Type unsigned long long has sizeof = $sizeof_ulonglong and alignment = $alignment_ulonglong. */"
- echo
- fi
+ CL_INTPARAM_SIZEOF([long long], [sizeof_longlong])
+ CL_INTPARAM_ALIGNOF([long long], [alignment_longlong])
+ echo "/* Type long long has sizeof = $sizeof_longlong and alignment = $alignment_longlong. */"
+ echo "#define sizeof_long_long $sizeof_longlong"
+ echo "#define alignment_long_long $alignment_longlong"
+ echo
+ CL_INTPARAM_SIZEOF([unsigned long long], [sizeof_ulonglong])
+ CL_INTPARAM_ALIGNOF([unsigned long long], [alignment_ulonglong])
+ echo "/* Type unsigned long long has sizeof = $sizeof_ulonglong and alignment = $alignment_ulonglong. */"
+ echo
CL_INTPARAM_SIZEOF([float], [sizeof_float])
CL_INTPARAM_ALIGNOF([float], [alignment_float])
echo "/* Type float has sizeof = $sizeof_float and alignment = $alignment_float. */"
echo "#define sizeof_double $sizeof_double"
echo "#define alignment_double $alignment_double"
echo
- if test $cl_cv_c_longdouble = yes; then
- CL_INTPARAM_SIZEOF([long double], [sizeof_longdouble])
- CL_INTPARAM_ALIGNOF([long double], [alignment_longdouble])
- echo "/* Type long double has sizeof = $sizeof_longdouble and alignment = $alignment_longdouble. */"
- echo "#define sizeof_long_double $sizeof_longdouble"
- echo "#define alignment_long_double $alignment_longdouble"
- echo
- fi
+ CL_INTPARAM_SIZEOF([long double], [sizeof_longdouble])
+ CL_INTPARAM_ALIGNOF([long double], [alignment_longdouble])
+ echo "/* Type long double has sizeof = $sizeof_longdouble and alignment = $alignment_longdouble. */"
+ echo "#define sizeof_long_double $sizeof_longdouble"
+ echo "#define alignment_long_double $alignment_longdouble"
+ echo
CL_INTPARAM_SIZEOF([char *], [sizeof_char_ptr])
CL_INTPARAM_ALIGNOF([char *], [alignment_char_ptr])
echo "/* Type char * has sizeof = $sizeof_char_ptr and alignment = $alignment_char_ptr. */"
CL_INTPARAM_ALIGNOF([long *], [alignment_long_ptr])
echo "/* Type long * has sizeof = $sizeof_long_ptr and alignment = $alignment_long_ptr. */"
echo
- CL_INTPARAM_SIZEOF([void (*)(void)], [sizeof_function_ptr])
- CL_INTPARAM_ALIGNOF([void (*)(void)], [alignment_function_ptr])
+ dnl disabled because:
+ dnl - the results of these are not used anywhere
+ dnl - the results of non-cross are not generated (see src/intparam.h)
+ dnl - the C code fails with "expected identifier or '(' before ')' token"
+ dnl on the line "typedef int verify[2*(alignof(void (*)(void)) == 256) - 1];"
+ dnl CL_INTPARAM_SIZEOF([void (*)(void)], [sizeof_function_ptr])
+ dnl CL_INTPARAM_ALIGNOF([void (*)(void)], [alignment_function_ptr])
echo "/* Type function * has sizeof = $sizeof_function_ptr and alignment = $alignment_function_ptr. */"
echo
case $ac_cv_c_bigendian in
echo "#define int_big_endian"
echo "/* Type unsigned long is stored BIG-ENDIAN in memory (i.e. like mc68000 or sparc). */"
echo "#define long_big_endian"
- if test $cl_cv_c_longlong = yes; then
- echo "/* Type unsigned long long is stored BIG-ENDIAN in memory (i.e. like mc68000 or sparc). */"
- echo "#define long_long_big_endian"
- fi
+ echo "/* Type unsigned long long is stored BIG-ENDIAN in memory (i.e. like mc68000 or sparc). */"
+ echo "#define long_long_big_endian"
;;
no)
echo "/* Type unsigned short is stored LITTLE-ENDIAN in memory (i.e. like Z80 or VAX). */"
echo "#define int_little_endian"
echo "/* Type unsigned long is stored LITTLE-ENDIAN in memory (i.e. like Z80 or VAX). */"
echo "#define long_little_endian"
- if test $cl_cv_c_longlong = yes; then
- echo "/* Type unsigned long long is stored LITTLE-ENDIAN in memory (i.e. like Z80 or VAX). */"
- echo "#define long_long_little_endian"
- fi
+ echo "/* Type unsigned long long is stored LITTLE-ENDIAN in memory (i.e. like Z80 or VAX). */"
+ echo "#define long_long_little_endian"
;;
*)
echo "#error \"Type short is stored in memory in an obscure manner!!\""
echo "#error \"Type int is stored in memory in an obscure manner!!\""
echo "#error \"Type long is stored in memory in an obscure manner!!\""
- if test $cl_cv_c_longlong = yes; then
- echo "#error \"Type long long is stored in memory in an obscure manner!!\""
- fi
+ echo "#error \"Type long long is stored in memory in an obscure manner!!\""
;;
esac
echo
[
n=1; x="($1)2"
while true; do
- AC_TRY_COMPILE([], [typedef int verify[2*(($1)($x) == 0) - 1];],
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
+ [[typedef int verify[2*(($1)($x) == 0) - 1];]])],
[$2=$n; break;],
[if test $n = 1000; then $2=; break; fi;])
n=`expr $n + 1`; x="$x * ($1)2"
dnl CL_INTPARAM_ALIGNOF(type, variable)
dnl puts into variable the determined alignment of the type.
-AC_DEFUN([CL_INTPARAM_ALIGNOF],
-[
+AC_DEFUN([CL_INTPARAM_ALIGNOF],[
dnl Simplify the guessing by assuming that the alignment is a power of 2.
n=1
while true; do
- AC_TRY_COMPILE([
-#ifdef __cplusplus
-# ifdef __GNUC__
-# define alignof(type) __alignof__ (type)
-# else
- template <class type> struct alignof_helper { char slot1; type slot2; };
-# define alignof(type) offsetof (alignof_helper<type>, slot2)
-# endif
-#else
-# define alignof(type) offsetof (struct { char slot1; type slot2; }, slot2)
-#endif
-], [typedef int verify[2*(alignof($1) == $n) - 1];],
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+ #include <stddef.h>
+ #ifdef __cplusplus
+ #ifdef __GNUC__
+ #define alignof(type) __alignof__ (type)
+ #else
+ template <class type> struct alignof_helper { char slot1; type slot2; };
+ #define alignof(type) offsetof (alignof_helper<type>, slot2)
+ #endif
+ #else
+ #define alignof(type) offsetof (struct { char slot1; type slot2; }, slot2)
+ #endif
+ ]],
+ [[typedef int verify[2*(alignof($1) == $n) - 1];]])],
[$2=$n; break;]
[if test $n = 0; then $2=; break; fi])
n=`expr $n '*' 2`