From 6f68e10fd7c5e52ea20e6a93c09a1dd271204856 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 5 Jun 2021 07:33:13 -0600 Subject: [PATCH] Configure changes for HAS_NON_INT_BITFIELDS This probe has been available without my realizing it had been merged. Some compilers, chiefly IBM, use only integer-size bitfields, warning when presented with other-sized ones. Allowing other-sized fields is an extension to the C standard. These warnings don't affect the correctness of the code generated, but very many are generated per run, potentially overwhelming the reader into not noticing warnings that are important. --- Configure | 33 +++++++++++++++++++++++++++++++++ Cross/config.sh-arm-linux | 1 + Cross/config.sh-arm-linux-n770 | 1 + NetWare/config.wc | 1 + Porting/config.sh | 1 + config_h.SH | 7 +++++++ configure.com | 2 ++ metaconfig.h | 3 +-- plan9/config_sh.sample | 1 + uconfig.h | 11 +++++++++-- uconfig.sh | 1 + uconfig64.sh | 1 + win32/config.gc | 1 + win32/config.vc | 1 + 14 files changed, 61 insertions(+), 4 deletions(-) diff --git a/Configure b/Configure index 6f8ae66f61f8..9097172dd53b 100755 --- a/Configure +++ b/Configure @@ -394,6 +394,7 @@ d_attribute_unused='' d_attribute_warn_unused_result='' d_printf_format_null='' d_backtrace='' +d_non_int_bitfields='' d_builtin_choose_expr='' d_builtin_expect='' d_builtin_add_overflow='' @@ -16541,6 +16542,37 @@ eval $inhdr set nl_langinfo d_nl_langinfo eval $inlibc +: Look for non 'int'-sized bitfields +case "$d_non_int_bitfields" in +'') +echo " " >&4 +echo "Checking whether your compiler can handle struct bitfields that aren't 'int' or 'unsigned int' ..." >&4 +$cat >try.c <<'EOCP' +#include +struct foo { + unsigned char byte:1; + unsigned short halfword:1; +} bar; +EOCP +if $cc $ccflags -c try.c >try.out 2>&1 ; then + if $compiler_warning try.out >/dev/null 2>&1; then + echo "Your C compiler doesn't support struct bitfields that aren't 'int' or 'unsigned int'." >&4 + val="$undef" + else + echo "Your C compiler supports struct bitfields besides 'int' and 'unsigned int'." >&4 + val="$define" + fi +else + echo "Your C compiler doesn't seem to understand struct bitfields that aren't 'int' or 'unsigned int' at all." >&4 + val="$undef" +fi +;; +*) val="$d_non_int_bitfields" ;; +esac +set d_non_int_bitfields +eval $setvar +$rm_try + : see if this is a quadmath.h system set quadmath.h i_quadmath eval $inhdr @@ -24527,6 +24559,7 @@ d_nextafter='$d_nextafter' d_nexttoward='$d_nexttoward' d_nice='$d_nice' d_nl_langinfo='$d_nl_langinfo' +d_non_int_bitfields='$d_non_int_bitfields' d_nv_preserves_uv='$d_nv_preserves_uv' d_nv_zero_is_allbits_zero='$d_nv_zero_is_allbits_zero' d_off64_t='$d_off64_t' diff --git a/Cross/config.sh-arm-linux b/Cross/config.sh-arm-linux index 2c6db13a1210..18caa12d3847 100644 --- a/Cross/config.sh-arm-linux +++ b/Cross/config.sh-arm-linux @@ -418,6 +418,7 @@ d_nextafter='undef' d_nexttoward='undef' d_nice='define' d_nl_langinfo='define' +d_non_int_bitfields='define' d_nv_preserves_uv='define' d_nv_zero_is_allbits_zero='undef' d_off64_t='undef' diff --git a/Cross/config.sh-arm-linux-n770 b/Cross/config.sh-arm-linux-n770 index 020843665ecd..a1dcf247140b 100644 --- a/Cross/config.sh-arm-linux-n770 +++ b/Cross/config.sh-arm-linux-n770 @@ -417,6 +417,7 @@ d_nextafter='undef' d_nexttoward='undef' d_nice='define' d_nl_langinfo='define' +d_non_int_bitfields='define' d_nv_preserves_uv='define' d_nv_zero_is_allbits_zero='undef' d_off64_t='undef' diff --git a/NetWare/config.wc b/NetWare/config.wc index 26c1755798ed..ef9fb5ee009f 100644 --- a/NetWare/config.wc +++ b/NetWare/config.wc @@ -407,6 +407,7 @@ d_nextafter='undef' d_nexttoward='undef' d_nice='undef' d_nl_langinfo='undef' +d_non_int_bitfields='define' d_nv_preserves_uv='define' d_nv_zero_is_allbits_zero='undef' d_off64_t='undef' diff --git a/Porting/config.sh b/Porting/config.sh index 391415d5e60e..5fc8ccce18e4 100644 --- a/Porting/config.sh +++ b/Porting/config.sh @@ -436,6 +436,7 @@ d_nextafter='define' d_nexttoward='define' d_nice='define' d_nl_langinfo='define' +d_non_int_bitfields='define' d_nv_preserves_uv='define' d_nv_zero_is_allbits_zero='undef' d_off64_t='define' diff --git a/config_h.SH b/config_h.SH index 8264f91dce8b..69103e419585 100755 --- a/config_h.SH +++ b/config_h.SH @@ -2339,6 +2339,13 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un */ #$d_atanh HAS_ATANH /**/ +/* HAS_NON_INT_BITFIELDS: + * This symbol, if defined, indicates that the C compiler accepts, without + * error or warning, struct bitfields that are declared with sizes other + * than plain 'int'; for example 'unsigned char' is accepted. + */ +#$d_non_int_bitfields HAS_NON_INT_BITFIELDS /**/ + /* HAS_BUILTIN_CHOOSE_EXPR: * Can we handle GCC builtin for compile-time ternary-like expressions */ diff --git a/configure.com b/configure.com index df2958201e5e..2dbb4fba78c0 100644 --- a/configure.com +++ b/configure.com @@ -5610,6 +5610,7 @@ $ d_mbstowcs="define" $ d_mbtowc="define" $ d_mktime="define" $ d_nl_langinfo="define" +$ d_non_int_bitfields="define" $ d_setlocale="define" $ d_setlocale_accepts_any_locale_name="undef" $ d_stdiobase="define" @@ -6399,6 +6400,7 @@ $ WC "d_nextafter='" + d_nextafter + "'" $ WC "d_nexttoward='" + d_nexttoward + "'" $ WC "d_nice='define'" $ WC "d_nl_langinfo='" + d_nl_langinfo + "'" +$ WC "d_non_int_bitfields='define'" $ WC "d_getenv_preserves_other_thread='" + d_getenv_preserves_other_thread + "'" $ WC "d_nv_preserves_uv='" + d_nv_preserves_uv + "'" $ WC "nv_overflows_integers_at='" + nv_overflows_integers_at + "'" diff --git a/metaconfig.h b/metaconfig.h index ae0093afd420..c2a4650d12e4 100644 --- a/metaconfig.h +++ b/metaconfig.h @@ -13,7 +13,6 @@ * Symbols should only be here temporarily. Once they are actually used, * they should be removed from here. * - * HAS_WCRTOMB - * GETENV_PRESERVES_OTHER_THREAD + * HAS_NON_INT_BITFIELDS * */ diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample index 63073397e160..2b8e88e80a82 100644 --- a/plan9/config_sh.sample +++ b/plan9/config_sh.sample @@ -418,6 +418,7 @@ d_nextafter='undef' d_nexttoward='undef' d_nice='undef' d_nl_langinfo='undef' +d_non_int_bitfields='define' d_nv_preserves_uv='undef' d_nv_zero_is_allbits_zero='undef' d_off64_t='undef' diff --git a/uconfig.h b/uconfig.h index 94bd2a1e04e0..27d88d39dbe2 100644 --- a/uconfig.h +++ b/uconfig.h @@ -2304,6 +2304,13 @@ */ /*#define HAS_ATANH / **/ +/* HAS_NON_INT_BITFIELDS: + * This symbol, if defined, indicates that the C compiler accepts, without + * error or warning, struct bitfields that are declared with sizes other + * than plain 'int'; for example 'unsigned char' is accepted. + */ +#define HAS_NON_INT_BITFIELDS /**/ + /* HAS_BUILTIN_CHOOSE_EXPR: * Can we handle GCC builtin for compile-time ternary-like expressions */ @@ -5282,6 +5289,6 @@ #endif /* Generated from: - * 6edd641b187b02d0daa8cb53f5d22f2dcca115a0d3e744f51b0292d2db484ca5 config_h.SH - * a0fa823df68d3b6a854579e3727e8d354614ad995d17f68b691399261825c2d3 uconfig.sh + * dac70e6e1bbb594cb13128b2271cfd83bc32d4cb1d14179edc6100597299d0bf config_h.SH + * bad73e58d466bfe6befab92731c4d075d5d439b45fd11c20585b3514865093a8 uconfig.sh * ex: set ro: */ diff --git a/uconfig.sh b/uconfig.sh index b38db79b74e8..7888ca4b4b10 100644 --- a/uconfig.sh +++ b/uconfig.sh @@ -358,6 +358,7 @@ d_nextafter='undef' d_nexttoward='undef' d_nice='undef' d_nl_langinfo='undef' +d_non_int_bitfields='define' d_nv_preserves_uv='undef' d_nv_zero_is_allbits_zero='undef' d_off64_t='undef' diff --git a/uconfig64.sh b/uconfig64.sh index a0e3a5bfa783..c4649e2d1061 100644 --- a/uconfig64.sh +++ b/uconfig64.sh @@ -358,6 +358,7 @@ d_nextafter='undef' d_nexttoward='undef' d_nice='undef' d_nl_langinfo='undef' +d_non_int_bitfields='define' d_nv_preserves_uv='undef' d_nv_zero_is_allbits_zero='undef' d_off64_t='undef' diff --git a/win32/config.gc b/win32/config.gc index af6fed92fbea..5ea0e48faa91 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -407,6 +407,7 @@ d_nextafter='define' d_nexttoward='define' d_nice='undef' d_nl_langinfo='undef' +d_non_int_bitfields='define' d_nv_preserves_uv='define' d_nv_zero_is_allbits_zero='define' d_off64_t='undef' diff --git a/win32/config.vc b/win32/config.vc index f4625bf2a4b9..e76ba4365a64 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -407,6 +407,7 @@ d_nextafter='undef' d_nexttoward='undef' d_nice='undef' d_nl_langinfo='undef' +d_non_int_bitfields='define' d_nv_preserves_uv='define' d_nv_zero_is_allbits_zero='define' d_off64_t='undef'