diff options
author | Jaehyun Kim <jeik01.kim@samsung.com> | 2024-06-07 18:11:13 +0900 |
---|---|---|
committer | Jaehyun Kim <jeik01.kim@samsung.com> | 2024-06-07 18:12:26 +0900 |
commit | ef7e2e6361b2deb5ef8c0a62e1b88f3263798a2c (patch) | |
tree | 4391a851ecd85deaa7b11a866a28519dafd3cde8 /configure.ac | |
parent | 9dff09857ab05c287e95170ce39f7605ea1a42c0 (diff) | |
download | tcpdump-tizen.tar.gz tcpdump-tizen.tar.bz2 tcpdump-tizen.zip |
Fix the build error for gcc-14HEADtizen_9.0_m2_releaseaccepted/tizen/unified/x/asan/20240625.092733accepted/tizen/unified/x/20240610.223526accepted/tizen/unified/toolchain/20240610.172956accepted/tizen/unified/dev/20240620.011133accepted/tizen/unified/20240611.123341accepted/tizen/9.0/unified/20241030.233333tizen_9.0tizenaccepted/tizen_unified_x_asanaccepted/tizen_unified_xaccepted/tizen_unified_toolchainaccepted/tizen_unified_devaccepted/tizen_unifiedaccepted/tizen_9.0_unified
Change-Id: I9dca705f49f9c4a993bccc3911db6f527cd99c8e
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 123 |
1 files changed, 67 insertions, 56 deletions
diff --git a/configure.ac b/configure.ac index 56e2a62..e077285 100644 --- a/configure.ac +++ b/configure.ac @@ -783,63 +783,74 @@ AC_CHECK_TYPE([u_int64_t], , ]) # -# Check for <inttypes.h> -# -AC_CHECK_HEADERS(inttypes.h, - [ - # - # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros? - # Some systems have an inttypes.h that doesn't define all of them. - # - AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]]) - AC_COMPILE_IFELSE( - [ - AC_LANG_SOURCE( - [[ - #include <inttypes.h> - #include <stdio.h> - #include <sys/types.h> - - main() - { - printf("%" PRId64 "\n", (uint64_t)1); - printf("%" PRIo64 "\n", (uint64_t)1); - printf("%" PRIx64 "\n", (uint64_t)1); - printf("%" PRIu64 "\n", (uint64_t)1); - } - ]]) - ], - [ - AC_MSG_RESULT(yes) - ac_lbl_inttypes_h_defines_formats=yes - ], - [ - AC_MSG_RESULT(no) - ac_lbl_inttypes_h_defines_formats=no - ]) - ], - [ - # - # We don't have inttypes.h, so it obviously can't define those - # macros. - # - ac_lbl_inttypes_h_defines_formats=no - ]) -if test "$ac_lbl_inttypes_h_defines_formats" = no; then - AC_LBL_CHECK_64BIT_FORMAT(l, +# It became apparent at some point that using a suitable C99 compiler does not +# automatically mean snprintf(3) implementation in the libc supports all the +# modifiers and specifiers used in the project, so let's test that before the +# build, not after. +# +# Testing the sizeof_t length modifier takes making an snprintf() call and +# comparing the actual result with the expected result. If this fails, it will +# most likely happen at run time, not compile time. +# +# Testing the 64-bit conversion specifiers in addition to that requires the +# <inttypes.h> header to be present and the macros to be defined, so if this +# fails, it will more likely happen at compile time. +# +AC_MSG_CHECKING([whether snprintf is suitable]) +AC_RUN_IFELSE( [ - AC_LBL_CHECK_64BIT_FORMAT(ll, - [ - AC_LBL_CHECK_64BIT_FORMAT(L, - [ - AC_LBL_CHECK_64BIT_FORMAT(q, - [ - AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer]) - ]) - ]) - ]) - ]) -fi + AC_LANG_SOURCE([[ +#include <stdio.h> +#include <string.h> +#include <inttypes.h> +#include <sys/types.h> + +int main() +{ + char buf[100]; + uint64_t t = (uint64_t)1 << 32; + + snprintf(buf, sizeof(buf), "%zu", sizeof(buf)); + if (strncmp(buf, "100", sizeof(buf))) + return 1; + + snprintf(buf, sizeof(buf), "%zd", -sizeof(buf)); + if (strncmp(buf, "-100", sizeof(buf))) + return 2; + + snprintf(buf, sizeof(buf), "%" PRId64, -t); + if (strncmp(buf, "-4294967296", sizeof(buf))) + return 3; + + snprintf(buf, sizeof(buf), "0o%" PRIo64, t); + if (strncmp(buf, "0o40000000000", sizeof(buf))) + return 4; + + snprintf(buf, sizeof(buf), "0x%" PRIx64, t); + if (strncmp(buf, "0x100000000", sizeof(buf))) + return 5; + + snprintf(buf, sizeof(buf), "%" PRIu64, t); + if (strncmp(buf, "4294967296", sizeof(buf))) + return 6; + + return 0; +} + ]]) + ], + [ + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + AC_MSG_ERROR( +[The snprintf(3) implementation in this libc is not suitable, +tcpdump would not work correctly even if it managed to compile.]) + ], + [ + AC_MSG_RESULT(not while cross-compiling) + ] +) # # Check for some headers introduced in later versions of libpcap |