From dad9d95a97824b459ea2e31c7eb4e6a593617eb2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 30 Dec 2021 19:12:00 -0800 Subject: configure: support 64 bit time_t on glibc. There is a new feature in glibc: -D_TIME_BITS=64 makes time_t 64 bits wide, as part of a solution to Y2038. Let's detect this together with _FILE_OFFSET_BITS in the same test. I've not tested this because I need a system with a bleeding edge glibc that supports _TIME_BITS. * configure (time_bits_define): New variable. Test which searches some known command line options for 64 bit off_t expanded to also check for 64 bit time_t. This complicates the loop only slightly; it is much better than copy and pasting the code --- configure | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 2e395da7..e894aa0f 100755 --- a/configure +++ b/configure @@ -3391,13 +3391,15 @@ else printf "no\n" fi -printf "Checking how to enable 64 bit file offsets ... " +printf "Checking how to enable 64 bit off_t and time_t ..." file_offset_define=none +time_bits_define=none -for try in NOTHING _LARGE_FILES=1 _FILE_OFFSET_BITS=64 ; do +for try in NOTHING _LARGE_FILES=1 _FILE_OFFSET_BITS=64 _TIME_BITS=64; do cat > conftest.c < +#include #include #define D(N, Z) ((N) ? (N) + '0' : Z) @@ -3408,10 +3410,12 @@ for try in NOTHING _LARGE_FILES=1 _FILE_OFFSET_BITS=64 ; do struct sizes { char h_BYTE[32], s_BYTE[2]; char h_OFF_T[32], s_OFF_T[2]; + char h_TIME_T[32], s_TIME_T[2]; char nl[2]; } foo = { "\nSIZEOF_BYTE=", DEC(CHAR_BIT), "\nSIZEOF_OFF_T=", DEC(sizeof (off_t)), + "\nSIZEOF_TIME_T=", DEC(sizeof (time_t)), "\n" }; @@ -3431,24 +3435,45 @@ struct sizes { exit 1 fi - if [ $(( SIZEOF_BYTE * SIZEOF_OFF_T )) -eq 64 ] ; then - if [ $try = NOTHING ] ; then - printf "default\n" - file_offset_define= - else - printf -- "-D%s\n" $try - file_offset_define=$try + if [ "$file_offset_define" = none ] ; then + if [ $(( SIZEOF_BYTE * SIZEOF_OFF_T )) -eq 64 ] ; then + if [ $try = NOTHING ] ; then + file_offset_define= + else + printf -- " -D%s" $try + file_offset_define=$try + fi fi - break; fi + + if [ "$time_bits_define" = none ] ; then + if [ $(( SIZEOF_BYTE * SIZEOF_TIME_T )) -eq 64 ] ; then + if [ $try = NOTHING ] ; then + time_bits_define= + else + printf -- " -D%s" $try + time_bits_define=$try + fi + fi + fi + + [ $file_offset_define = none -o $time_bits_define = none ] || break done if [ "$file_offset_define" = none ] ; then - printf "unable\n" + printf " (no 64 bit off_t)" elif [ -n "$file_offset_define" ] ; then lang_flags="$lang_flags -D$file_offset_define" fi +if [ "$time_bits_define" = none ] ; then + printf " (no 64 bit time_t)" +elif [ -n "$time_bits_define" ] ; then + lang_flags="$lang_flags -D$time_bits_define" +fi + +printf "\n" + printf "Checking for socket API ... " cat > conftest.c <