public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] Fortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h. Date: Fri, 17 Sep 2021 14:13:46 +0000 (GMT) [thread overview] Message-ID: <20210917141346.7E4E13858D29@sourceware.org> (raw) https://gcc.gnu.org/g:4f2ec425c9d09b7d763f89173ee6f36ededa63af commit 4f2ec425c9d09b7d763f89173ee6f36ededa63af Author: Sandra Loosemore <sandra@codesourcery.com> Date: Fri Sep 17 16:13:29 2021 +0200 Fortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h. 2021-09-17 Sandra Loosemore <sandra@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> 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. (cherry picked from commit 654187d05376f08667c8ba88309073e0345431c2) Diff: --- libgfortran/ChangeLog.omp | 10 ++++++ libgfortran/ISO_Fortran_binding.h | 75 ++++++++++++++++++++++++++++++--------- 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/libgfortran/ChangeLog.omp b/libgfortran/ChangeLog.omp index a97a9c96254..7ddd61a127b 100644 --- a/libgfortran/ChangeLog.omp +++ b/libgfortran/ChangeLog.omp @@ -1,3 +1,13 @@ +2021-09-17 Tobias Burnus <tobias@codesourcery.com> + + Backported from master: + 2021-09-17 Sandra Loosemore <sandra@codesourcery.com> + Tobias Burnus <tobias@codesourcery.com> + + * 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. + 2021-09-13 Tobias Burnus <tobias@codesourcery.com> Backported from master: 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 <stddef.h> /* Standard ptrdiff_t tand size_t. */ #include <stdint.h> /* Integer types. */ -#include <float.h> /* 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 <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 +#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
reply other threads:[~2021-09-17 14:13 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210917141346.7E4E13858D29@sourceware.org \ --to=burnus@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).