From patchwork Fri Sep 17 14:10:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 45128 X-Patchwork-Delegate: jwakely.gcc@gmail.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB56A3857023 for ; Fri, 17 Sep 2021 14:11:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id D3D163858D29; Fri, 17 Sep 2021 14:10:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3D163858D29 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: cz/k4vz2tAXqknNTgpD+rLBieUi64aO8r8dvKMvVfMYUxZ/jmDcBs76c6G/qqD0BM5jncovYVm clLGa2cbD5fmi7ltGL5jyKSjIrPzHnWmmRmQOZ7wUHLeYTlVhmacJDFWM+aIoYy1L4itXohhH3 FFHLilZ5mjfd55I1nbhfNf8Q69d0WHns0SO3qMIATEz5quhKGuWr2YYw/foqvsCTb+9iwNxQXs YMM/Okxnz4SvlIAtEYzmNxlAUL1LmY73fn3WzC3J/cWZ1qxK8CzpAN1b29wUgio0L06H+H0Yyg 52TvfIwcavULOxft+vpTStvO X-IronPort-AV: E=Sophos;i="5.85,301,1624348800"; d="diff'?scan'208";a="65980894" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 17 Sep 2021 06:10:45 -0800 IronPort-SDR: S1HvQKESmDN1+Zu2PP1AY3mRGNGxpWDh4WsYhYt9wnLxYZVhMv9X9/lhR1HO8g4BidRULhXd21 zex0D9yfRWxNEiMEs1cNTLKwk3pGF2in+0/xQp8Unna/WmruJovMEahF9kyFuiBmnHLxXV/i24 8TRyLJSyoT+zx2BlMzU1Tn1+kUkO5KXam2wosWAFAYyg7nKa1O3CmdnSzqSVkn78FG0mXKZ9aN 8yXtFQSl1hJd1oFknZO3RLLv2Qa+G97ipMWnS+ciC0W7CDi7KJUEGyjd1Dj+F7PbnBeuaGuoER 85c= Subject: [committed] Fortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h (was: [PATCH, Fortran] Revert to non-multilib-specific ISO_Fortran_binding.h) To: Gerald Pfeifer , Jakub Jelinek , Sandra Loosemore References: <4c32e0e7-7156-835a-30b-ada8c4b4482d@pfeifer.com> <2de2f2b0-d221-acc1-79d4-554ee480c62@pfeifer.com> <87r1drkwzz.fsf@igel.home> <20210914152312.GX304296@tucnak> <97733d30-6d1f-e39d-1c3-b5bd63c35ee9@pfeifer.com> <6fb03844-e472-a95-2d0-df485bd4ab7@pfeifer.com> From: Tobias Burnus Message-ID: <846a6c47-e9b8-ee36-5d31-43244665ecae@codesourcery.com> Date: Fri, 17 Sep 2021 16:10:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <6fb03844-e472-a95-2d0-df485bd4ab7@pfeifer.com> Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, 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: , Cc: gcc-patches@gcc.gnu.org, Andreas Schwab , Andreas Tobler , fortran@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" On 17.09.21 08:03, Gerald Pfeifer wrote: > On Tue, 14 Sep 2021, Gerald Pfeifer wrote: >>> And, related, does the following make sense and fixes the issue? >>> >>> --- a/libgfortran/ISO_Fortran_binding.h >>> +++ b/libgfortran/ISO_Fortran_binding.h >>> @@ -228,5 +228,5 @@ extern int CFI_setpointer (CFI_cdesc_t *, CFI_cdesc_t *, >>> const CFI_index_t []); >>> >>> /* This is the 80-bit encoding on x86; Fortran assigns it kind 10. */ >>> -#elif (LDBL_MANT_DIG == 64 \ >>> +#elif ((LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 53) \ >>> && LDBL_MIN_EXP == -16381 \ >>> && LDBL_MAX_EXP == 16384) >> Yes, with this patch (on top of current trunk) i586-freebsd-* is back >> in bootstrap land. :) > Neither this (which fixes the bootstrap) nor Sandra's rewrite (which > does not, but seemed generally liked) has been committed. I have now committed the attached patch as r12-3621. It includes the patch by Sandra https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579372.html (approved 3 days ago) plus adding the "== 53" similar to above. Hopefully, we can now close this issue. Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 commit 654187d05376f08667c8ba88309073e0345431c2 Author: Tobias Burnus Date: Fri Sep 17 15:43:30 2021 +0200 Fortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h. 2021-09-17 Sandra Loosemore Tobias Burnus libgfortran/ * ISO_Fortran_binding.h: Only include float.h if the C compiler doesn't have predefined __LDBL_* and __DBL_* macros. Handle LDBL_MANT_DIG == 53 for FreeBSD. diff --git a/libgfortran/ISO_Fortran_binding.h b/libgfortran/ISO_Fortran_binding.h index 9c42464affa..50b02d27c9c 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_MANT_DIG__ == 53) \ + && __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