From: Olliver Schinagl Date: Fri, 4 Aug 2023 12:26:20 +0000 (+0200) Subject: Fix time for old 32bit systems X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c22d866f336d4d38dc0679a0cb03b11237c48fc;p=thirdparty%2Ftvheadend.git Fix time for old 32bit systems The fix introduced in fe47ecb5504a ("Fix time for 32bit systems again") made the incorrect assumption, that the macro _TIME_BITS=64 was always available. It seems like that this is not the case for old systems, causing 32bit builds to break there. Lets completely rework 32bit time support, by actually detecting the hosts size for the time. This will break cross-compilation, as the configure script is run on the host, but since we do not seem to support cross-builds anyway (all archs are build on emulated or native targets), this should be acceptable. Fixes fe47ecb5504a ("Fix time for 32bit systems again") Signed-off-by: Olliver Schinagl --- diff --git a/configure b/configure index 82c0efb60..3a4eb39aa 100755 --- a/configure +++ b/configure @@ -279,6 +279,42 @@ int test(void) } ' +check_cc_snippet time_ld ' +#define _FILE_OFFSET_BITS 64 +#define _TIME_BITS 64 +#include +#include +#include +#define TEST test +int test(void) +{ + printf("%ld", (time_t)1); + return 0; +} +' -Werror + +check_cc_snippet time_lld ' +#define _FILE_OFFSET_BITS 64 +#define _TIME_BITS 64 +#include +#include +#include +#define TEST test +int test(void) +{ + printf("%lld", (time_t)1); + return 0; +} +' -Werror + +if enabled time_lld; then + printf " ^ using time_t format 'lld'\n" +elif enabled time_ld; then + printf " ^ using time_t format 'ld'\n" +else + die 'Unable to determine size of "time_t"' +fi + check_cc_snippet stime ' #include #define TEST test diff --git a/src/tvheadend.h b/src/tvheadend.h index c2fcee716..7a6aa820b 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -334,12 +334,12 @@ void tvh_qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void # endif /* ULONG_MAX */ #endif /* __WORDSIZE */ -#if __WORDSIZE == 32 +#if CONFIG_TIME_LLD == 1 # define PRItime_t "lld" -#elif __WORDSIZE == 64 +#elif CONFIG_TIME_LD == 1 # define PRItime_t "ld" #else -# error "__WORDSIZE not properly defined" +# error "CONFIG_TIME not properly defined" #endif /* transcoding */