__float128: how to use f128 functions with clang?


glibc provides a set of APIs for __float128 math, e.g. nextafterf128, ldexpf128, etc, but they are only enabled under the following check (glibc/math/math.h):

#if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)

E.g. for x86-64 glibc has this header code (glibc/sysdeps/x86/bits/floatn.h):

#if (defined __x86_64__                                                 \
     ? __GNUC_PREREQ (4, 3)                                             \
     : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
# define __HAVE_FLOAT128 1
# define __HAVE_FLOAT128 0

It seems convenient to me that I can use the glibc “standard” methods for __float128 math (e.g. vs using GCC’s quadmath.h), but as you can see they are not enabled for clang compilations.

So my questions are:

  • What is the recommended way of calculating such math functions with clang?
  • Is it possible/reasonable to add declarations of these methods into clang header files (e.g. for targets where glibc supports them)?
  • OR, is it reasonable to create glibc feature request to enable __HAVE_FLOAT128 with clang for some targets?