From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 7609B3858402; Tue, 14 Sep 2021 03:39:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7609B3858402 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: 22txeGsysUvBXg7dcRg+oV6MC78n1OaBwW3bWfKMRNtQ25jPUISYiI6hykBFddKihdcGGKCrfV 8BN5OkuPmLBTmq9Dx4JaLwPkDHIDHBRHwqjXN/fJMQnz/2cZgV/6q8mi0So+dvRJ+YrV/stCuQ OYHLEu+LsMsM4JlA8CGDLeWSuMM1OPuz1pSUT1sYEjqBaLM7e20Lh5Xzmu7YuUCIdzwVd+gqVD ClZ8c3eqBZUdJtpsIb2PWC20DeJBNvClcaniJNzpzcByPfZH2Blt2KfcPWxHL2jRgaY2ZGeQ4e MEbGVu+ZWj3fIF6tru3TiMG8 X-IronPort-AV: E=Sophos;i="5.85,291,1624348800"; d="scan'208";a="68317229" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 13 Sep 2021 19:39:17 -0800 IronPort-SDR: XnVqDjN3kyUV1nwts/BUYNN3pc6V84MR1y3MQby1VJnwcCDJCWGGtT1tQblMEcFkTed/QcFl2A 0mVtHwjHpMWlLhHheyaR5rJYUkDXIKle0STCCQgjUR2S/1f+19/c6GDUNku/HjKO4lvbmEX0gg PevLQypHWT03pWcFXLzjKQOXCsdRtqPnR8XiECoNut1kmiqlyLWawN/rShIhzOfWI110ofY4o7 jeyVyNXNBVps27SIeT8T48wi3JPU+5wgP2aaC2HYtfBOatq0avMhF+R6OYWjcY2uVyMFE9UrFn jQM= Subject: Re: [PATCH, Fortran] Revert to non-multilib-specific ISO_Fortran_binding.h To: Tobias Burnus , Jakub Jelinek CC: Gerald Pfeifer , Andreas Tobler , , References: <4c32e0e7-7156-835a-30b-ada8c4b4482d@pfeifer.com> <20210913165105.GJ304296@tucnak> From: Sandra Loosemore Message-ID: Date: Mon, 13 Sep 2021 21:39:09 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------77E2F7F989052E258E58BAFB" Content-Language: en-US X-ClientProxiedBy: SVR-ORW-MBX-06.mgc.mentorg.com (147.34.90.206) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 03:39:19 -0000 --------------77E2F7F989052E258E58BAFB Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit On 9/13/21 11:07 AM, Tobias Burnus wrote: > On 13.09.21 18:59, Sandra Loosemore wrote: >> On 9/13/21 10:51 AM, Jakub Jelinek wrote: >>> Wouldn't it be better to use the __LDBL_* macros anyway and not rely on >>> float.h?  The header doesn't want to test what float.h tells about the >>> long double type, but what the compiler knows about it. >> I originally wrote the code to use the internal GCC __LDBL_* macros as >> you suggest, but Tobias complained that then the gfortran-provided .h >> file could not be used to compile the C parts of the program with some >> other C compiler. > For instance, clang does not seem to provide those - and in some cases, > it can be useful to mix gfortran code with code complied by other > compilers (icc, clang, ...). >> Maybe it needs to first check the internal macros and then look for >> the float.h versions if it can't find them? > > I think that makes sense. (Adding a comment that #include is > for non-GCC compilers, only.) Here's a patch. Gerald, can you check that this fixes your bootstrap problem on i586-unknown-freebsd11? -Sandra --------------77E2F7F989052E258E58BAFB Content-Type: text/x-patch; charset="UTF-8"; name="ldbl-macro-fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ldbl-macro-fix.patch" commit b8b19bca743ed678ef1b59f1a363c7fa7d155c43 Author: Sandra Loosemore Date: Mon Sep 13 19:48:16 2021 -0700 Fortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h. 2021-09-13 Sandra Loosemore libgfortran/ * ISO_Fortran_binding.h: Only include float.h if the C compiler doesn't have predefined __LDBL_* and __DBL_* macros. diff --git a/libgfortran/ISO_Fortran_binding.h b/libgfortran/ISO_Fortran_binding.h index 9c42464..a3c6f80 100644 --- a/libgfortran/ISO_Fortran_binding.h +++ b/libgfortran/ISO_Fortran_binding.h @@ -32,7 +32,6 @@ extern "C" { #include /* Standard ptrdiff_t tand size_t. */ #include /* Integer types. */ -#include /* Macros for floating-point type characteristics. */ /* Constants, defined as macros. */ #define CFI_VERSION 1 @@ -217,40 +216,82 @@ extern int CFI_setpointer (CFI_cdesc_t *, CFI_cdesc_t *, const CFI_index_t []); #endif /* The situation with long double support is more complicated; we need to - examine the type in more detail to figure out its kind. */ + examine the type in more detail to figure out its kind. + GCC and some other compilers predefine the __LDBL* macros; otherwise + get the parameters we need from float.h. */ + +#if (defined (__LDBL_MANT_DIG__) \ + && defined (__LDBL_MIN_EXP__) \ + && defined (__LDBL_MAX_EXP__) \ + && defined (__DBL_MANT_DIG__) \ + && defined (__DBL_MIN_EXP__) \ + && defined (__DBL_MAX_EXP__)) +#define __CFI_LDBL_MANT_DIG__ __LDBL_MANT_DIG__ +#define __CFI_LDBL_MIN_EXP__ __LDBL_MIN_EXP__ +#define __CFI_LDBL_MAX_EXP__ __LDBL_MAX_EXP__ +#define __CFI_DBL_MANT_DIG__ __DBL_MANT_DIG__ +#define __CFI_DBL_MIN_EXP__ __DBL_MIN_EXP__ +#define __CFI_DBL_MAX_EXP__ __DBL_MAX_EXP__ + +#else +#include + +#if (defined (LDBL_MANT_DIG) \ + && defined (LDBL_MIN_EXP) \ + && defined (LDBL_MAX_EXP) \ + && defined (DBL_MANT_DIG) \ + && defined (DBL_MIN_EXP) \ + && defined (DBL_MAX_EXP)) +#define __CFI_LDBL_MANT_DIG__ LDBL_MANT_DIG +#define __CFI_LDBL_MIN_EXP__ LDBL_MIN_EXP +#define __CFI_LDBL_MAX_EXP__ LDBL_MAX_EXP +#define __CFI_DBL_MANT_DIG__ DBL_MANT_DIG +#define __CFI_DBL_MIN_EXP__ DBL_MIN_EXP +#define __CFI_DBL_MAX_EXP__ DBL_MAX_EXP + +#else +#define CFI_no_long_double 1 + +#endif /* Definitions from float.h. */ +#endif /* Definitions from compiler builtins. */ + +/* Can't determine anything about long double support? */ +#if (defined (CFI_no_long_double)) +#define CFI_type_long_double -2 +#define CFI_type_long_double_Complex -2 /* Long double is the same kind as double. */ -#if (LDBL_MANT_DIG == DBL_MANT_DIG \ - && LDBL_MIN_EXP == DBL_MIN_EXP \ - && LDBL_MAX_EXP == DBL_MAX_EXP) +#elif (__CFI_LDBL_MANT_DIG__ == __CFI_DBL_MANT_DIG__ \ + && __CFI_LDBL_MIN_EXP__ == __CFI_DBL_MIN_EXP__ \ + && __CFI_LDBL_MAX_EXP__ == __CFI_DBL_MAX_EXP__) #define CFI_type_long_double CFI_type_double #define CFI_type_long_double_Complex CFI_type_double_Complex /* This is the 80-bit encoding on x86; Fortran assigns it kind 10. */ -#elif (LDBL_MANT_DIG == 64 \ - && LDBL_MIN_EXP == -16381 \ - && LDBL_MAX_EXP == 16384) +#elif (__CFI_LDBL_MANT_DIG__ == 64 \ + && __CFI_LDBL_MIN_EXP__ == -16381 \ + && __CFI_LDBL_MAX_EXP__ == 16384) #define CFI_type_long_double (CFI_type_Real + (10 << CFI_type_kind_shift)) #define CFI_type_long_double_Complex (CFI_type_Complex + (10 << CFI_type_kind_shift)) /* This is the 96-bit encoding on m68k; Fortran assigns it kind 10. */ -#elif (LDBL_MANT_DIG == 64 \ - && LDBL_MIN_EXP == -16382 \ - && LDBL_MAX_EXP == 16384) +#elif (__CFI_LDBL_MANT_DIG__ == 64 \ + && __CFI_LDBL_MIN_EXP__ == -16382 \ + && __CFI_LDBL_MAX_EXP__ == 16384) #define CFI_type_long_double (CFI_type_Real + (10 << CFI_type_kind_shift)) #define CFI_type_long_double_Complex (CFI_type_Complex + (10 << CFI_type_kind_shift)) /* This is the IEEE 128-bit encoding, same as float128. */ -#elif (LDBL_MANT_DIG == 113 \ - && LDBL_MIN_EXP == -16381 \ - && LDBL_MAX_EXP == 16384) +#elif (__CFI_LDBL_MANT_DIG__ == 113 \ + && __CFI_LDBL_MIN_EXP__ == -16381 \ + && __CFI_LDBL_MAX_EXP__ == 16384) #define CFI_type_long_double (CFI_type_Real + (16 << CFI_type_kind_shift)) #define CFI_type_long_double_Complex (CFI_type_Complex + (16 << CFI_type_kind_shift)) /* This is the IBM128 encoding used on PowerPC; also assigned kind 16. */ -#elif (LDBL_MANT_DIG == 106 \ - && LDBL_MIN_EXP == -968 \ - && LDBL_MAX_EXP == 1024) +#elif (__CFI_LDBL_MANT_DIG__ == 106 \ + && __CFI_LDBL_MIN_EXP__ == -968 \ + && __CFI_LDBL_MAX_EXP__ == 1024) #define CFI_type_long_double (CFI_type_Real + (16 << CFI_type_kind_shift)) #define CFI_type_long_double_Complex (CFI_type_Complex + (16 << CFI_type_kind_shift)) #define CFI_no_float128 1 --------------77E2F7F989052E258E58BAFB--