From patchwork Sat Oct 9 03:32:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 67313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id EB906B70F5 for ; Sat, 9 Oct 2010 14:33:00 +1100 (EST) Received: (qmail 2525 invoked by alias); 9 Oct 2010 03:32:58 -0000 Received: (qmail 2517 invoked by uid 22791); 9 Oct 2010 03:32:57 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_UC, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Oct 2010 03:32:53 +0000 Received: (qmail 1244 invoked from network); 9 Oct 2010 03:32:51 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Oct 2010 03:32:51 -0000 Date: Fri, 8 Oct 2010 23:32:49 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] use __SIZEOF_LONG_LONG__ when compiling libgcc Message-ID: <20101009033249.GX17388@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list 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