Skip to content

Commit

Permalink
Configure changes for HAS_NON_INT_BITFIELDS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed Jun 6, 2021
1 parent cd0c6ec commit 8dafde0
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 4 deletions.
33 changes: 33 additions & 0 deletions Configure
Expand Up @@ -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=''
Expand Down Expand Up @@ -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 <stdio.h>
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
Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions Cross/config.sh-arm-linux
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions Cross/config.sh-arm-linux-n770
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions NetWare/config.wc
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions Porting/config.sh
Expand Up @@ -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'
Expand Down
7 changes: 7 additions & 0 deletions config_h.SH
Expand Up @@ -2339,6 +2339,13 @@ sed <<!GROK!THIS! >$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
*/
Expand Down
2 changes: 2 additions & 0 deletions configure.com
Expand Up @@ -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"
Expand Down Expand Up @@ -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 + "'"
Expand Down
3 changes: 1 addition & 2 deletions metaconfig.h
Expand Up @@ -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
*
*/
1 change: 1 addition & 0 deletions plan9/config_sh.sample
Expand Up @@ -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'
Expand Down
11 changes: 9 additions & 2 deletions uconfig.h
Expand Up @@ -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
*/
Expand Down Expand Up @@ -5282,6 +5289,6 @@
#endif

/* Generated from:
* 6edd641b187b02d0daa8cb53f5d22f2dcca115a0d3e744f51b0292d2db484ca5 config_h.SH
* a0fa823df68d3b6a854579e3727e8d354614ad995d17f68b691399261825c2d3 uconfig.sh
* dac70e6e1bbb594cb13128b2271cfd83bc32d4cb1d14179edc6100597299d0bf config_h.SH
* bad73e58d466bfe6befab92731c4d075d5d439b45fd11c20585b3514865093a8 uconfig.sh
* ex: set ro: */
1 change: 1 addition & 0 deletions uconfig.sh
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions uconfig64.sh
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions win32/config.gc
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions win32/config.vc
Expand Up @@ -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'
Expand Down

0 comments on commit 8dafde0

Please sign in to comment.