From patchwork Sat Oct 9 03:32:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: use __SIZEOF_LONG_LONG__ when compiling libgcc Date: Fri, 08 Oct 2010 17:32:49 -0000 From: Nathan Froyd X-Patchwork-Id: 67313 Message-Id: <20101009033249.GX17388@nightcrawler> To: gcc-patches@gcc.gnu.org Attempting to compile libgcc on avr-elf results in error messages: In file included from ../../../../combined-tree/libgcc/../gcc/libgcc2.c:57:0: libgcc2.h:143:5: error: token "." is not valid in preprocessor expressions libgcc2.h:345:5: error: token "." is not valid in preprocessor expressions libgcc2.c:43:38: error: token "." is not valid in preprocessor expressions This is because the avr definition for LONG_LONG_TYPE_SIZE actually depends on target options: #define INT_TYPE_SIZE (TARGET_INT8 ? 8 : 16) #define LONG_LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 32 : 64) which doesn't work so well in preprocessor conditionals. This patch fixes that by using __SIZEOF_LONG_LONG__ instead, which is defined by the compiler. We have to tweak the tests slightly, as LONG_LONG_TYPE_SIZE is expressed in bits, and __SIZEOF_LONG_LONG__ is expressed in bytes. This change also has the benefit of one less dependency on target headers in libgcc. Tested on avr-elf, where it fixes the compile error, and x86_64-unknown-linux-gnu. OK to commit? -Nathan * libgcc2.h: Use __SIZEOF_LONG_LONG__ instead of LONG_LONG_TYPE_SIZE. * libgcc2.c: Likewise. diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index 02828e3..20e7bd2 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -40,7 +40,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #if MIN_UNITS_PER_WORD > 4 # define LIBGCC2_MAX_UNITS_PER_WORD 8 #elif (MIN_UNITS_PER_WORD > 2 \ - || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32)) + || (MIN_UNITS_PER_WORD > 1 && __SIZEOF_LONG_LONG__ > 4)) # define LIBGCC2_MAX_UNITS_PER_WORD 4 #else # define LIBGCC2_MAX_UNITS_PER_WORD MIN_UNITS_PER_WORD diff --git a/gcc/libgcc2.h b/gcc/libgcc2.h index 56dc9f7..f344917 100644 --- a/gcc/libgcc2.h +++ b/gcc/libgcc2.h @@ -140,7 +140,7 @@ typedef unsigned int UHItype __attribute__ ((mode (HI))); /* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1. */ typedef int SItype __attribute__ ((mode (SI))); typedef unsigned int USItype __attribute__ ((mode (SI))); -#if LONG_LONG_TYPE_SIZE > 32 +#if __SIZEOF_LONG_LONG__ > 4 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2. */ typedef int DItype __attribute__ ((mode (DI))); typedef unsigned int UDItype __attribute__ ((mode (DI))); @@ -342,7 +342,7 @@ extern cmp_return_type __ucmpdi2 (DWtype, DWtype); #if MIN_UNITS_PER_WORD > 1 extern SItype __bswapsi2 (SItype); #endif -#if LONG_LONG_TYPE_SIZE > 32 +#if __SIZEOF_LONG_LONG__ > 4 extern DItype __bswapdi2 (DItype); #endif