diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2023-10-25 11:04:12 +0100 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2023-10-25 11:04:12 +0100 |
commit | 8bb655d0c56502798d664ab0c1685bbab4aaa454 (patch) | |
tree | 1a17f28cb30e33a3a10fed058a2a8359a5627922 /libgm2/libm2pim | |
parent | cfb7755d107beed8f79b7f31046f57bd84a8e43a (diff) | |
download | gcc-8bb655d0c56502798d664ab0c1685bbab4aaa454.zip gcc-8bb655d0c56502798d664ab0c1685bbab4aaa454.tar.gz gcc-8bb655d0c56502798d664ab0c1685bbab4aaa454.tar.bz2 |
PR modula2/111955 introduce isnan support to Builtins.def
This patch introduces isnan, isnanf and isnanl to Builtins.def.
It requires fallback functions isnan, isnanf, isnanl to be implemented in
libgm2/libm2pim/wrapc.cc and gm2-libs-ch/wrapc.c.
Access to the GCC builtin isnan tree is provided by adding
an isnan definition and support functions to gm2-gcc/m2builtins.cc.
gcc/m2/ChangeLog:
PR modula2/111955
* gm2-gcc/m2builtins.cc (gm2_isnan_node): New tree.
(DoBuiltinIsnan): New function.
(m2builtins_BuiltInIsnan): New function.
(m2builtins_init): Initialize gm2_isnan_node.
(list_of_builtins): Add define for __builtin_isnan.
* gm2-libs-ch/wrapc.c (wrapc_isnan): New function.
(wrapc_isnanf): New function.
(wrapc_isnanl): New function.
* gm2-libs/Builtins.def (isnanf): New procedure function.
(isnan): New procedure function.
(isnanl): New procedure function.
* gm2-libs/Builtins.mod:
* gm2-libs/wrapc.def (isnan): New function.
(isnanf): New function.
(isnanl): New function.
libgm2/ChangeLog:
PR modula2/111955
* libm2pim/wrapc.cc (isnan): Export new function.
(isnanf): Export new function.
(isnanl): Export new function.
gcc/testsuite/ChangeLog:
PR modula2/111955
* gm2/pimlib/run/pass/testnan.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'libgm2/libm2pim')
-rw-r--r-- | libgm2/libm2pim/wrapc.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libgm2/libm2pim/wrapc.cc b/libgm2/libm2pim/wrapc.cc index c24d214..4d93050 100644 --- a/libgm2/libm2pim/wrapc.cc +++ b/libgm2/libm2pim/wrapc.cc @@ -277,6 +277,45 @@ EXPORT(isfinitef) (float x) #endif } +/* isnan - provide non builtin alternative to the gcc builtin isnan. + Returns 1 if x is a NaN otherwise return 0. */ + +extern "C" int +EXPORT(isnan) (double x) +{ +#if defined(FP_NAN) + return fpclassify (x) == FP_NAN; +#else + return x != x; +#endif +} + +/* isnanf - provide non builtin alternative to the gcc builtin isnanf. + Returns 1 if x is a NaN otherwise return 0. */ + +extern "C" int +EXPORT(isnanf) (float x) +{ +#if defined(FP_NAN) + return fpclassify (x) == FP_NAN; +#else + return x != x; +#endif +} + +/* isnanl - provide non builtin alternative to the gcc builtin isnanl. + Returns 1 if x is a NaN otherwise return 0. */ + +extern "C" int +EXPORT(isnanl) (long double x) +{ +#if defined(FP_NAN) + return fpclassify (x) == FP_NAN; +#else + return x != x; +#endif +} + /* GNU Modula-2 linking hooks. */ extern "C" void |