2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

Use built-in tests for bit types instead of using AC_CHECK_TYPES.

This should be more portable as it handles the quirks of some older
systems.
This commit is contained in:
Todd C. Miller 2023-03-22 15:37:12 -06:00
parent a17491972b
commit f0f5e1b5bc
3 changed files with 435 additions and 145 deletions

View File

@ -470,18 +470,6 @@
/* Define to 1 if you have the 'innetgr' function. */
#undef HAVE_INNETGR
/* Define to 1 if the system has the type 'int16_t'. */
#undef HAVE_INT16_T
/* Define to 1 if the system has the type 'int32_t'. */
#undef HAVE_INT32_T
/* Define to 1 if the system has the type 'int64_t'. */
#undef HAVE_INT64_T
/* Define to 1 if the system has the type 'int8_t'. */
#undef HAVE_INT8_T
/* Define to 1 if the system has the type 'intmax_t'. */
#undef HAVE_INTMAX_T
@ -610,6 +598,9 @@
/* Define to 1 if you have the <login_cap.h> header file. */
#undef HAVE_LOGIN_CAP_H
/* Define to 1 if the system has the type 'long long int'. */
#undef HAVE_LONG_LONG_INT
/* Define to 1 if you have the <machine/endian.h> header file. */
#undef HAVE_MACHINE_ENDIAN_H
@ -1038,18 +1029,6 @@
/* Define to 1 if you have the 'ttyslot' function. */
#undef HAVE_TTYSLOT
/* Define to 1 if the system has the type 'uint16_t'. */
#undef HAVE_UINT16_T
/* Define to 1 if the system has the type 'uint32_t'. */
#undef HAVE_UINT32_T
/* Define to 1 if the system has the type 'uint64_t'. */
#undef HAVE_UINT64_T
/* Define to 1 if the system has the type 'uint8_t'. */
#undef HAVE_UINT8_T
/* Define to 1 if the system has the type 'uintmax_t'. */
#undef HAVE_UINTMAX_T
@ -1062,6 +1041,9 @@
/* Define to 1 if you have the 'unsetenv' function. */
#undef HAVE_UNSETENV
/* Define to 1 if the system has the type 'unsigned long long int'. */
#undef HAVE_UNSIGNED_LONG_LONG_INT
/* Define to 1 if you have the <util.h> header file. */
#undef HAVE_UTIL_H
@ -1455,6 +1437,21 @@
/* Number of bits in time_t, on hosts where this is settable. */
#undef _TIME_BITS
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT64_T
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT8_T
/* Define to 1 on platforms where this makes time_t a 64-bit type. */
#undef __MINGW_USE_VC2005_COMPAT
@ -1474,6 +1471,26 @@
#undef inline
#endif
/* Define to the type of a signed integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef int16_t
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef int32_t
/* Define to the type of a signed integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef int64_t
/* Define to the type of a signed integer type of width exactly 8 bits if such
a type exists and the standard includes do not define it. */
#undef int8_t
/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
not define. */
#undef intmax_t
/* Define to an OS-specific initialization function or 'os_init_common'. */
#undef os_init
@ -1483,44 +1500,30 @@
/* Define to 'int' if <sys/types.h> doesn't define. */
#undef uid_t
/* Define to the type of an unsigned integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef uint16_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef uint32_t
/* Define to the type of an unsigned integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef uint64_t
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
#undef uint8_t
/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
do not define. */
#undef uintmax_t
/* Define to empty if the keyword 'volatile' does not work. Warning: valid
code using 'volatile' can become incorrect without. Disable with care. */
#undef volatile
/* Define C99 types if stdint.h and inttypes.h are missing. */
#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H)
# ifndef HAVE_INT8_T
typedef char int8_t;
# endif
# ifndef HAVE_UINT8_T
typedef unsigned char uint8_t;
# endif
# ifndef HAVE_INT16_T
typedef short int16_t;
# endif
# ifndef HAVE_UINT16_T
typedef unsigned short uint16_t;
# endif
# ifndef HAVE_INT32_T
typedef int int32_t;
# endif
# ifndef HAVE_UINT32_T
typedef unsigned int uint32_t;
# endif
# ifndef HAVE_INT64_T
typedef long long int64_t;
# endif
# ifndef HAVE_UINT64_T
typedef unsigned long long uint64_t;
# endif
# ifndef HAVE_INTMAX_T
typedef long long intmax_t;
# endif
# ifndef HAVE_UINTMAX_T
typedef unsigned long long uintmax_t;
# endif
#endif /* !HAVE_STDINT_H && !HAVE_INTTYPES_H */
#ifndef HAVE_SIG_ATOMIC_T
typedef int sig_atomic_t;
#endif

414
configure vendored
View File

@ -2408,6 +2408,148 @@ printf "%s\n" "$ac_res" >&6; }
} # ac_fn_c_check_member
# ac_fn_c_find_intX_t LINENO BITS VAR
# -----------------------------------
# Finds a signed integer type with width BITS, setting cache variable VAR
# accordingly.
ac_fn_c_find_intX_t ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5
printf %s "checking for int$2_t... " >&6; }
if eval test \${$3+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) eval "$3=no"
# Order is important - never check a type that is potentially smaller
# than half of the expected target width.
for ac_type in int$2_t 'int' 'long int' \
'long long int' 'short int' 'signed char'; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
enum { N = $2 / 2 - 1 };
int
main (void)
{
static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
enum { N = $2 / 2 - 1 };
int
main (void)
{
static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
< ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
else case e in #(
e) case $ac_type in #(
int$2_t) :
eval "$3=yes" ;; #(
*) :
eval "$3=\$ac_type" ;;
esac ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
if eval test \"x\$"$3"\" = x"no"
then :
else case e in #(
e) break ;;
esac
fi
done ;;
esac
fi
eval ac_res=\$$3
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
printf "%s\n" "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_find_intX_t
# ac_fn_c_find_uintX_t LINENO BITS VAR
# ------------------------------------
# Finds an unsigned integer type with width BITS, setting cache variable VAR
# accordingly.
ac_fn_c_find_uintX_t ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
printf %s "checking for uint$2_t... " >&6; }
if eval test \${$3+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) eval "$3=no"
# Order is important - never check a type that is potentially smaller
# than half of the expected target width.
for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
'unsigned long long int' 'unsigned short int' 'unsigned char'; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
int
main (void)
{
static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
case $ac_type in #(
uint$2_t) :
eval "$3=yes" ;; #(
*) :
eval "$3=\$ac_type" ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
if eval test \"x\$"$3"\" = x"no"
then :
else case e in #(
e) break ;;
esac
fi
done ;;
esac
fi
eval ac_res=\$$3
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
printf "%s\n" "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_find_uintX_t
# ac_fn_c_try_run LINENO
# ----------------------
# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that
@ -20316,91 +20458,261 @@ fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for unsigned long long int" >&5
printf %s "checking for unsigned long long int... " >&6; }
if test ${ac_cv_type_unsigned_long_long_int+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) ac_cv_type_unsigned_long_long_int=yes
case $ac_prog_cc_stdc in
no | c89) ;;
*)
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* For now, do not test the preprocessor; as of 2007 there are too many
implementations with broken preprocessors. Perhaps this can
be revisited in 2012. In the meantime, code should not expect
#if to work with literals wider than 32 bits. */
/* Test literals. */
long long int ll = 9223372036854775807ll;
long long int nll = -9223372036854775807LL;
unsigned long long int ull = 18446744073709551615ULL;
/* Test constant expressions. */
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
? 1 : -1)];
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
? 1 : -1)];
int i = 63;
int
main (void)
{
/* Test availability of runtime routines for shift and division. */
long long int llmax = 9223372036854775807ll;
unsigned long long int ullmax = 18446744073709551615ull;
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
| (llmax / ll) | (llmax % ll)
| (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
| (ullmax / ull) | (ullmax % ull));
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
else case e in #(
e) ac_cv_type_unsigned_long_long_int=no ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext;;
esac ;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5
printf "%s\n" "$ac_cv_type_unsigned_long_long_int" >&6; }
if test $ac_cv_type_unsigned_long_long_int = yes; then
printf "%s\n" "#define HAVE_UNSIGNED_LONG_LONG_INT 1" >>confdefs.h
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5
printf %s "checking for long long int... " >&6; }
if test ${ac_cv_type_long_long_int+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) ac_cv_type_long_long_int=yes
case $ac_prog_cc_stdc in
no | c89) ;;
*)
ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
if test $ac_cv_type_long_long_int = yes; then
if test "$cross_compiling" = yes
then :
:
else case e in #(
e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <limits.h>
#ifndef LLONG_MAX
# define HALF \\
(1LL << (sizeof (long long int) * CHAR_BIT - 2))
# define LLONG_MAX (HALF - 1 + HALF)
#endif
int
main (void)
{
long long int n = 1;
int i;
for (i = 0; ; i++)
{
long long int m = n << i;
if (m >> i != n)
return 1;
if (LLONG_MAX / 2 < m)
break;
}
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"
then :
else case e in #(
e) ac_cv_type_long_long_int=no ;;
esac
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
esac
fi
fi;;
esac ;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5
printf "%s\n" "$ac_cv_type_long_long_int" >&6; }
if test $ac_cv_type_long_long_int = yes; then
printf "%s\n" "#define HAVE_LONG_LONG_INT 1" >>confdefs.h
fi
if test X"${ac_cv_header_stdint_h}${ac_cv_header_inttypes_h}" = X"nono"
then :
ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default"
if test "x$ac_cv_type_int8_t" = xyes
then :
ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t"
case $ac_cv_c_int8_t in #(
no|yes) ;; #(
*)
printf "%s\n" "#define HAVE_INT8_T 1" >>confdefs.h
printf "%s\n" "#define int8_t $ac_cv_c_int8_t" >>confdefs.h
;;
esac
ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"
case $ac_cv_c_uint8_t in #(
no|yes) ;; #(
*)
printf "%s\n" "#define _UINT8_T 1" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default"
if test "x$ac_cv_type_uint8_t" = xyes
then :
printf "%s\n" "#define uint8_t $ac_cv_c_uint8_t" >>confdefs.h
;;
esac
printf "%s\n" "#define HAVE_UINT8_T 1" >>confdefs.h
ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t"
case $ac_cv_c_int16_t in #(
no|yes) ;; #(
*)
printf "%s\n" "#define int16_t $ac_cv_c_int16_t" >>confdefs.h
;;
esac
ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"
case $ac_cv_c_uint16_t in #(
no|yes) ;; #(
*)
fi
ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
if test "x$ac_cv_type_int16_t" = xyes
then :
printf "%s\n" "#define uint16_t $ac_cv_c_uint16_t" >>confdefs.h
;;
esac
printf "%s\n" "#define HAVE_INT16_T 1" >>confdefs.h
ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t"
case $ac_cv_c_int32_t in #(
no|yes) ;; #(
*)
printf "%s\n" "#define int32_t $ac_cv_c_int32_t" >>confdefs.h
;;
esac
ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
case $ac_cv_c_uint32_t in #(
no|yes) ;; #(
*)
printf "%s\n" "#define _UINT32_T 1" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default"
if test "x$ac_cv_type_uint16_t" = xyes
then :
printf "%s\n" "#define uint32_t $ac_cv_c_uint32_t" >>confdefs.h
;;
esac
printf "%s\n" "#define HAVE_UINT16_T 1" >>confdefs.h
ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t"
case $ac_cv_c_int64_t in #(
no|yes) ;; #(
*)
printf "%s\n" "#define int64_t $ac_cv_c_int64_t" >>confdefs.h
;;
esac
ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t"
case $ac_cv_c_uint64_t in #(
no|yes) ;; #(
*)
printf "%s\n" "#define _UINT64_T 1" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default"
if test "x$ac_cv_type_int32_t" = xyes
then :
printf "%s\n" "#define HAVE_INT32_T 1" >>confdefs.h
printf "%s\n" "#define uint64_t $ac_cv_c_uint64_t" >>confdefs.h
;;
esac
fi
ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
if test "x$ac_cv_type_uint32_t" = xyes
then :
printf "%s\n" "#define HAVE_UINT32_T 1" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "int64_t" "ac_cv_type_int64_t" "$ac_includes_default"
if test "x$ac_cv_type_int64_t" = xyes
then :
printf "%s\n" "#define HAVE_INT64_T 1" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "$ac_includes_default"
if test "x$ac_cv_type_uint64_t" = xyes
then :
printf "%s\n" "#define HAVE_UINT64_T 1" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "intmax_t" "ac_cv_type_intmax_t" "$ac_includes_default"
ac_fn_c_check_type "$LINENO" "intmax_t" "ac_cv_type_intmax_t" "$ac_includes_default"
if test "x$ac_cv_type_intmax_t" = xyes
then :
printf "%s\n" "#define HAVE_INTMAX_T 1" >>confdefs.h
else case e in #(
e) test $ac_cv_type_long_long_int = yes \
&& ac_type='long long int' \
|| ac_type='long int'
printf "%s\n" "#define intmax_t $ac_type" >>confdefs.h
;;
esac
fi
ac_fn_c_check_type "$LINENO" "uintmax_t" "ac_cv_type_uintmax_t" "$ac_includes_default"
ac_fn_c_check_type "$LINENO" "uintmax_t" "ac_cv_type_uintmax_t" "$ac_includes_default"
if test "x$ac_cv_type_uintmax_t" = xyes
then :
printf "%s\n" "#define HAVE_UINTMAX_T 1" >>confdefs.h
else case e in #(
e) test $ac_cv_type_unsigned_long_long_int = yes \
&& ac_type='unsigned long long int' \
|| ac_type='unsigned long int'
printf "%s\n" "#define uintmax_t $ac_type" >>confdefs.h
;;
esac
fi
fi
ac_fn_c_check_type "$LINENO" "sig_atomic_t" "ac_cv_type_sig_atomic_t" "
$ac_includes_default

View File

@ -2489,7 +2489,16 @@ dnl
dnl typedef checks
dnl
AS_IF([test X"${ac_cv_header_stdint_h}${ac_cv_header_inttypes_h}" = X"nono"], [
AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, intmax_t, uintmax_t])
AC_TYPE_INT8_T
AC_TYPE_UINT8_T
AC_TYPE_INT16_T
AC_TYPE_UINT16_T
AC_TYPE_INT32_T
AC_TYPE_UINT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT64_T
AC_TYPE_INTMAX_T
AC_TYPE_UINTMAX_T
])
AC_CHECK_TYPES([sig_atomic_t], [], [], [
AC_INCLUDES_DEFAULT
@ -4673,41 +4682,7 @@ dnl
AH_TOP([#ifndef SUDO_CONFIG_H
#define SUDO_CONFIG_H])
AH_BOTTOM([/* Define C99 types if stdint.h and inttypes.h are missing. */
#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H)
# ifndef HAVE_INT8_T
typedef char int8_t;
# endif
# ifndef HAVE_UINT8_T
typedef unsigned char uint8_t;
# endif
# ifndef HAVE_INT16_T
typedef short int16_t;
# endif
# ifndef HAVE_UINT16_T
typedef unsigned short uint16_t;
# endif
# ifndef HAVE_INT32_T
typedef int int32_t;
# endif
# ifndef HAVE_UINT32_T
typedef unsigned int uint32_t;
# endif
# ifndef HAVE_INT64_T
typedef long long int64_t;
# endif
# ifndef HAVE_UINT64_T
typedef unsigned long long uint64_t;
# endif
# ifndef HAVE_INTMAX_T
typedef long long intmax_t;
# endif
# ifndef HAVE_UINTMAX_T
typedef unsigned long long uintmax_t;
# endif
#endif /* !HAVE_STDINT_H && !HAVE_INTTYPES_H */
#ifndef HAVE_SIG_ATOMIC_T
AH_BOTTOM([#ifndef HAVE_SIG_ATOMIC_T
typedef int sig_atomic_t;
#endif