diff mbox

use __SIZEOF_LONG_LONG__ when compiling libgcc

Message ID 20101009033249.GX17388@nightcrawler
State New
Headers show

Commit Message

Nathan Froyd Oct. 9, 2010, 3:32 a.m. UTC
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.

Comments

Richard Henderson Oct. 9, 2010, 6:47 p.m. UTC | #1
On 10/08/2010 08:32 PM, Nathan Froyd wrote:
> 	* libgcc2.h: Use __SIZEOF_LONG_LONG__ instead of LONG_LONG_TYPE_SIZE.
> 	* libgcc2.c: Likewise.

Ok.


r~
diff mbox

Patch

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