This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: x-files must die: rather too much at once


On Fri, Mar 09, 2001 at 11:15:17PM -0800, Zack Weinberg wrote:
> +#ifdef HAVE_LIMITS_H
> +#include <limits.h>
> +#else
> +#define CHAR_BIT 8
> +#endif

Consider 

----
i=1
type='char'
while test $i -lt 65; do
  echo "char test[($type)(($type)1 << $i)
		  ? ($type)(($type)1 << $i) == 1 ? -1 : 1
		  : -1];" > conftest.c
  if ! cc -c conftest.c > /dev/null 2>&1 ; then
    ac_bits_per=$i
    break
  fi
  i=`expr $i + 1`
done
if test -z "$ac_bits_per" -o "$ac_bits_per" = 1; then
  echo test failed
else
  echo $ac_bits_per
fi
----

> +struct {
> +  char h[2];
> +  short two;
> +  char e[2];
> +} s = { { 'a', 'b' },
> +        ('C' << CHAR_BIT) | 'D',
> +        { 'e', '\0' } };

I meant this as an example only.  You ought to be more clever than
that, and consider sizeof short.  This could be done as a later change,
since no current hosts require it.  But e.g. Cray T3 uses 32-bit shorts
and someone sent mail recently about porting gcc to that target.



r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]