NetBSD Problem Report #59336
From www@netbsd.org Sun Apr 20 21:59:43 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id EF8901A9239
for <gnats-bugs@gnats.NetBSD.org>; Sun, 20 Apr 2025 21:59:42 +0000 (UTC)
Message-Id: <20250420215941.9F7A61A923D@mollari.NetBSD.org>
Date: Sun, 20 Apr 2025 21:59:41 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: C23: Annex F and math.h extensions
X-Send-Pr-Version: www-1.0
>Number: 59336
>Category: standards
>Synopsis: C23: Annex F and math.h extensions
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: standards-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Apr 20 22:00:00 +0000 2025
>Last-Modified: Tue Dec 23 17:15:01 +0000 2025
>Originator: Taylor R Campbell
>Release: current
>Organization:
The FloatBSD23 Extensions
>Environment:
>Description:
We should consider whether to define __STDC_IEC_559__ or __STDC_IEC_60559_BFP__ (on appropriate architectures -- that is, not vax) to indicate support for IEEE 754 floating-point as in Annex F, which is inexplicably referred to by its little-known IEC number IEC 60559 in the C standard. And similarly for __STDC_IEC_559_COMPLEX__ or __STDC_IEC_60559_COMPLEX__ for Annex G, IEEE 754 complex arithmetic.
It appears gcc defines __GCC_IEC_559=2 and __GCC_IEC_559_COMPLEX=2, but clang does not. Need to do some research to figure out what to do here.
Additionally, if these macros are defined, and the _user_ defines __STDC_WANT_IEC_60559_EXT__, math.h should expose the following additional operations for access to various operations on IEEE 754 values such as total ordering and access to the payloads (see C23, Annex F, F.10.12 and F.10.13):
int totalorder(const double *, const double *);
int totalorderf(const float *, const float *);
int totalorderl(const long double *, const long double *);
int totalordermag(const double *, const double *);
int totalordermagf(const float *, const float *);
int totalordermagl(const long double *, const long double *);
double getpayload(const double *);
float getpayloadf(const float *);
long double getpayloadl(const long double *);
int setpayload(double *, double);
int setpayloadf(float *, float);
int setpayloadl(long double *, long double);
int setpayloadsig(double *, double);
int setpayloadsigf(float *, float);
int setpayloadsigl(long double *, long double);
And, we are also missing from math.h:
double fmaximum(double, double);
float fmaximumf(float, float);
long double fmaximuml(long double, long double);
double fminimum(double, double);
float fminimumf(float, float);
long double fminimuml(long double, long double);
double fmaximum_mag(double, double);
float fmaximum_magf(float, float);
long double fmaximum_magl(long double, long double);
double fminimum_mag(double, double);
float fminimum_magf(float, float);
long double fminimum_magl(long double, long double
double fmaximum_num(double, double);
float fmaximumf_num(float, float);
long double fmaximuml_numl(long double, long double);
double fminimum_num(double, double);
float fminimum_numf(float, float);
long double fminimum_numl(long double, long double);
double fmaximum_mag_num(double, double);
float fmaximum_mag_numf(float, float);
long double fmaximum_mag_numl(long double, long double);
double fminimum_mag_num(double, double);
float fminimum_mag_numf(float, float);
long double fminimum_mag_numl(long double, long double);
And some more round-to-narrower-result functions:
float fadd(double, double);
float faddl(long double, long double);
double daddl(long double, long double);
float fsub(double, double);
float fsubl(long double, long double);
double dsubl(long double, long double);
float fmul(double, double);
float fmull(long double, long double);
double dmull(long double, long double);
float fdiv(double, double);
float fdivl(long double, long double);
double ddivl(long double, long double);
float ffma(double, double, double);
float ffmal(long double, long double, long double);
double dfmal(long double, long double, long double);
float fsqrt(double);
float fsqrtl(long double);
double dsqrtl(long double);
And some explicit-direction, explicit-width rounding functions --
fromfp* to signed, ufromfp* to unsigned, *fromfpx* with the possibility
of raising the inexact exception:
double fromfp(double, int, unsigned);
float fromfpf(float, int, unsigned);
long double fromfpl(long double, int, unsigned);
double ufromfp(double, int, unsigned);
float ufromfpf(float, int, unsigned);
long double ufromfpl(long double, int, unsigned);
...and more: powr, rootn, rsqrt, compoundn, log2p1, logp1 (alias for log1p), log10p1, llogb, exp2m1, exp10m1, exp10, asinpi, acospi, atanpi, atan2pi, issignalling, iscanonical, FP_FAST_* macros, FP_ILOGB0 and FP_ILOGBNAN, roundeven, iseqsig, etc. (XXX Need to go through these systematically to make sure I didn't miss any, which I alm
>How-To-Repeat:
standards inspection
>Fix:
Yes, please!
>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59336 CVS commit: src/tests/lib/libc/gen
Date: Thu, 18 Dec 2025 05:28:22 +0000
Module Name: src
Committed By: riastradh
Date: Thu Dec 18 05:28:22 UTC 2025
Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c
Log Message:
t_fpclassify: Test the is* classification functions too.
Also test the upcoming C23 functions (iszero, issubnormal,
issignalling), so the tests will be there when we implement them, and
test the floating-point exceptions all the functions involved raise
(which should be none).
PR standards/59336: C23: Annex F and math.h extensions
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/gen/t_fpclassify.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59336 CVS commit: src/tests/lib/libc/gen
Date: Sun, 21 Dec 2025 19:07:50 +0000
Module Name: src
Committed By: riastradh
Date: Sun Dec 21 19:07:49 UTC 2025
Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c
Log Message:
t_fpclassify: Fix long double mistakes.
1. Handle >64-bit long double with `union ieee_ext_u'.
2. Operationally verify the quiet vs signalling NaN bits.
3. xfail for softfloat and softfloat-long-double bugs on clang.
4. Print NaN encodings in hexadecimal to make diagnostics easier.
5. Add RCS id.
PR standards/59336: C23: Annex F and math.h extensions
PR lib/59853: compiler-rt softfloat lacks floating-point exceptions
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/gen/t_fpclassify.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59336 CVS commit: src/tests/lib/libc/gen
Date: Tue, 23 Dec 2025 17:11:42 +0000
Module Name: src
Committed By: riastradh
Date: Tue Dec 23 17:11:42 UTC 2025
Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c
Log Message:
t_fpclassify: Fix build properly without __HAVE_LONG_DOUBLE.
Centralize use of union ieee_ext_u, used on machines where double is
not the same as long double, so most of the long double code doesn't
need __HAVE_LONG_DOUBLE conditionals (reminder: __HAVE_LONG_DOUBLE
means long double is _larger_ than double, not just that long double
exists; long double always exists and should work either way).
PR standards/59336: C23: Annex F and math.h extensions
PR lib/59853: compiler-rt softfloat lacks floating-point exceptions
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/gen/t_fpclassify.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.49 2026/05/14 01:52:41 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.