mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-25 20:21:07 +00:00
aa0235dfde
All representations of floating-point numbers in types with IEC 60559 binary exchange format are canonical. On the other hand, types with IEC 60559 extended formats, such as those implemented under ldbl-96 and ldbl-128ibm, contain representations that are not canonical. TS 18661-1 introduced the type-generic macro iscanonical, which returns whether a floating-point value is canonical or not. In Glibc, this type-generic macro is implemented using the macro __MATH_TG, which, when support for float128 is enabled, relies on __builtin_types_compatible_p to select between floating-point types. However, this use of iscanonical breaks C++ applications, because the builtin is only available in C mode. This patch provides a C++ implementation of iscanonical that relies on function overloading, rather than builtins, to select between floating-point types. Unlike the C++ implementations for iszero and issignaling, this implementation ignores __NO_LONG_DOUBLE_MATH. The double type always matches IEC 60559 double format, which is always canonical. Thus, when double and long double are the same (__NO_LONG_DOUBLE_MATH), iscanonical always returns 1 and is not implemented with __MATH_TG. Tested for powerpc64, powerpc64le and x86_64. [BZ #22235] * math/math.h: Trivial fix for unbalanced parentheses in comment. * math/Makefile [CXX] (tests): Add test-math-iscanonical.cc. (CFLAGS-test-math-iscanonical.cc): New variable. * math/test-math-iscanonical.cc: New file. * sysdeps/ieee754/ldbl-96/bits/iscanonical.h (iscanonical): Provide a C++ implementation based on function overloading, rather than using __MATH_TG, which uses C-only builtins. * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h (iscanonical): Likewise. * sysdeps/powerpc/powerpc64le/Makefile (CFLAGS-test-math-iscanonical.cc): New variable.
68 lines
3.0 KiB
Makefile
68 lines
3.0 KiB
Makefile
# When building float128 we need to ensure -mfloat128 is
|
|
# passed to all such object files.
|
|
|
|
# libgcc requires __tcb_parse_hwcap_and_convert_at_platform when built with
|
|
# a binary128 type. That symbol is provided by the loader on dynamically
|
|
# linked executables, forcing to link the loader after libgcc link.
|
|
f128-loader-link = $(as-needed) $(elf-objpfx)ld.so $(no-as-needed)
|
|
|
|
ifeq ($(subdir),math)
|
|
# sqrtf128 requires emulation before POWER9.
|
|
CPPFLAGS += -I../soft-fp
|
|
|
|
# float128 requires adding a handful of extra flags.
|
|
$(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += -mfloat128
|
|
$(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += -mfloat128
|
|
$(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += -mfloat128
|
|
$(foreach suf,$(all-object-suffixes),$(objpfx)test-ifloat128%$(suf)): CFLAGS += -mfloat128
|
|
CFLAGS-libm-test-support-float128.c += -mfloat128
|
|
CFLAGS-test-math-iscanonical.cc += -mfloat128
|
|
CFLAGS-test-math-issignaling.cc += -mfloat128
|
|
CFLAGS-test-math-iszero.cc += -mfloat128
|
|
$(objpfx)test-float128% $(objpfx)test-ifloat128% $(objpfx)test-math-iszero: \
|
|
gnulib-tests += $(f128-loader-link)
|
|
endif
|
|
|
|
# Append flags to string <-> _Float128 routines.
|
|
ifneq ($(filter $(subdir),wcsmbs stdlib),)
|
|
$(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += -mfloat128
|
|
$(foreach suf,$(all-object-suffixes),%f128_l$(suf)): CFLAGS += -mfloat128
|
|
$(foreach suf,$(all-object-suffixes),%f128_nan$(suf)): CFLAGS += -mfloat128
|
|
$(foreach suf,$(all-object-suffixes),%float1282mpn$(suf)): CFLAGS += -mfloat128
|
|
$(foreach suf,$(all-object-suffixes),%mpn2float128$(suf)): CFLAGS += -mfloat128
|
|
CFLAGS-bug-strtod.c += -mfloat128
|
|
CFLAGS-bug-strtod2.c += -mfloat128
|
|
CFLAGS-tst-strtod-round.c += -mfloat128
|
|
CFLAGS-tst-wcstod-round.c += -mfloat128
|
|
CFLAGS-tst-strtod-nan-locale.c += -mfloat128
|
|
CFLAGS-tst-wcstod-nan-locale.c += -mfloat128
|
|
CFLAGS-tst-strtod6.c += -mfloat128
|
|
CFLAGS-tst-strfrom.c += -mfloat128
|
|
CFLAGS-tst-strfrom-locale.c += -mfloat128
|
|
CFLAGS-strfrom-skeleton.c += -mfloat128
|
|
$(foreach test,bug-strtod bug-strtod2 bug-strtod2 tst-strtod-round \
|
|
tst-wcstod-round tst-strtod6 tst-strrom tst-strfrom-locale \
|
|
tst-strtod-nan-locale tst-wcstod-nan-locale \
|
|
strfrom-skeleton,$(objpfx)$(test)): gnulib-tests += $(f128-loader-link)
|
|
|
|
# When building glibc with support for _Float128, the powers of ten tables in
|
|
# fpioconst.c and in the string conversion functions must be extended. Some
|
|
# Makefiles (e.g.: wcsmbs/Makefile) override CFLAGS defined by the Makefiles in
|
|
# sysdeps. This is avoided with the use sysdep-CFLAGS instead of CFLAGS.
|
|
sysdep-CFLAGS += $(sysdep-CFLAGS-$(<F))
|
|
sysdep-CFLAGS-fpioconst.c += -mfloat128
|
|
sysdep-CFLAGS-strtod_l.c += -mfloat128
|
|
sysdep-CFLAGS-strtof_l.c += -mfloat128
|
|
sysdep-CFLAGS-strtold_l.c += -mfloat128
|
|
sysdep-CFLAGS-wcstod_l.c += -mfloat128
|
|
sysdep-CFLAGS-wcstof_l.c += -mfloat128
|
|
sysdep-CFLAGS-wcstold_l.c += -mfloat128
|
|
endif
|
|
|
|
# Append flags to printf routines.
|
|
ifeq ($(subdir),stdio-common)
|
|
CFLAGS-printf_fp.c = -mfloat128
|
|
CFLAGS-printf_fphex.c = -mfloat128
|
|
CFLAGS-printf_size.c = -mfloat128
|
|
endif
|