From a181adcebca4b9bc079cd04c42c95cdc88dc57f2 Mon Sep 17 00:00:00 2001 From: David Bar-On Date: Sat, 20 Jan 2024 12:47:47 +0200 Subject: [PATCH] Define SIZE_OF_LONG_INT to replace sizeof(long) in #if --- configure.ac | 10 ++++++++++ src/cjson.c | 4 ++-- src/iperf.h | 2 +- src/iperf_locale.c | 2 +- src/iperf_udp.c | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 192ab16cf..796e5cf3b 100644 --- a/configure.ac +++ b/configure.ac @@ -180,6 +180,16 @@ else fi fi +# Get the size of long int +AC_CACHE_CHECK([Size of long int], +[iperf3_cv_sizeof_long], +AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[fprintf(stderr, "%d", sizeof(long)); return(0)]])], + [iperf3_cv_sizeof_long=`./conftest$EXEEXT 2>&1`], + [AC_MSG_ERROR(Failed to compile and run size of long test)])) +AC_DEFINE_UNQUOTED([SIZE_OF_LONG_INT], $iperf3_cv_sizeof_long, [Size of long int.]) + # Check for TCP_CONGESTION sockopt (believed to be Linux and FreeBSD only) AC_CACHE_CHECK([TCP_CONGESTION socket option], [iperf3_cv_header_tcp_congestion], diff --git a/src/cjson.c b/src/cjson.c index 02d8d6001..249259709 100644 --- a/src/cjson.c +++ b/src/cjson.c @@ -94,13 +94,13 @@ # include #else # ifndef PRIu64 -# if sizeof(long) == 8 +# if SIZE_OF_LONG_INT == 8 # define PRIu64 "lu" # else # define PRIu64 "llu" # endif # ifndef PRId64 -# if sizeof(long) == 8 +# if SIZE_OF_LONG_INT == 8 # define PRId64 "ld" # else # define PRId64 "lld" diff --git a/src/iperf.h b/src/iperf.h index a5eea4237..57e5df7e3 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -55,7 +55,7 @@ # include #else # ifndef PRIu64 -# if sizeof(long) == 8 +# if SIZE_OF_LONG_INT == 8 # define PRIu64 "lu" # else # define PRIu64 "llu" diff --git a/src/iperf_locale.c b/src/iperf_locale.c index 41d78cb5c..0457d3171 100644 --- a/src/iperf_locale.c +++ b/src/iperf_locale.c @@ -85,7 +85,7 @@ # include #else # ifndef PRId64 -# if sizeof(long) == 8 +# if SIZE_OF_LONG_INT == 8 # define PRId64 "ld" # else # define PRId64 "lld" diff --git a/src/iperf_udp.c b/src/iperf_udp.c index 5f69ee366..3f1cf46ee 100644 --- a/src/iperf_udp.c +++ b/src/iperf_udp.c @@ -52,7 +52,7 @@ # include #else # ifndef PRIu64 -# if sizeof(long) == 8 +# if SIZE_OF_LONG_INT == 8 # define PRIu64 "lu" # else # define PRIu64 "llu"