Commit Graph

905 Commits

Author SHA1 Message Date
riastradh 70dffce551 riscv: Make feraiseexcept actually raise the given exceptions.
Doing

	fexcept_t ex = 0;
	fesetexceptflag(&ex, excepts);

has the effect of _clearing_ all the exceptions in excepts.  Using
fesetexceptflag doesn't make this easier, because we would have to
record which exceptions were already raised.  So just set the fflags
bits in the fcsr register directly.
2024-05-17 02:11:07 +00:00
riastradh 906e271cb3 modfl(3): Fix conversion from FreeBSD.
LDBL_MANL_SIZE is spelled EXT_FRACLBITS -- and not EXT_FRACHBITS.

PR lib/58237: modfl returns wrong answers on ld128 architectures
2024-05-15 00:02:56 +00:00
riastradh 26e8a868b4 libm: Fix powerpc64 build.
- Include fenv.c and fma(3) symbols (which just use the FMADD
  instruction).
- Note the .FN symbols in libm for the asm functions.  The FN symbols
  point at the function _descriptors_; the .FN symbols point at the
  first instruction of the function.

XXX Unclear why we have the .FN symbols for asm functions but not for
C functions.  I'm not sure we should be exporting them.
2024-05-14 14:34:35 +00:00
riastradh 806be69ba7 hypotl(3): Fix includes and macros.
1. Need <math.h> for __HAVE_LONG_DOUBLE.
2. Need <machine/ieee.h> for struct ieee_ext_u &c.
3. EXT_FRACLBITS, not LDBL_MANL_SIZE.

PR lib/58245: hypotl is broken on ld128 ports
2024-05-11 20:09:47 +00:00
riastradh bcaa0f35c3 nexttoward(3): Fix high-word test on small positive subnormals.
By this point in the logic, x can't be zero, so it's either positive
or negative.

The high word hx, however, can be zero, when x is a small positive
subnormal.  This means x is a small positive subnormal, so if x > y
we are computing nextDown, and if x < y we are computing nextUp.

hx is a (signed 32-bit) integer, not a double floating-point number,
so it's a little silly to compare hx > 0.0.  But that on its own
isn't enough to trigger the bug because all signed 32-bit integers
can be represented by double on all NetBSD architectures.

PR lib/58236
2024-05-11 02:07:53 +00:00
riastradh 9aa4064b35 libm: No divtc3.c or multc3.c in sparc64's compat sparc library.
compat/sparc64/sparc/bsd.sparc.mk doesn't define LIBC_MACHINE_CPU,
only LIBC_MACHINE_ARCH, so when the compat build gets to this
conditional, LIBC_MACHINE_CPU is just MACHINE_CPU, i.e., sparc64.

Since there's no `sparc64el' or `sparc64hf-el' that we need to
canonicalize by MACHINE_ARCH -> MACHINE_CPU, just use
LIBC_MACHINE_ARCH here.
2024-05-09 19:54:38 +00:00
riastradh 210c9d72b1 libm: Add frexpf and frexpl on VAX.
These are trivial subroutines, not symbol aliases, for separate
reasons:

- frexpf has a different ABI from frexp (float vs double argument)

- frexp is defined in libc, not libm, so although long double is the
  same as double, frexpl can't be an alias in libm of a symbol
  defined in libc
2024-05-09 14:42:09 +00:00
riastradh 08858db306 libm: Define ilogbl as alias for ilogb on vax.
PR 57881
2024-05-09 12:18:48 +00:00
riastradh 5499b93eb2 libm: Split expected symbols in mips further by 32-bit vs 64-bit.
32-bit has binary64 long double, same as double; 64-bit has binary128
long double, which is implemented with a few more symbols in libm
(which should maybe be hidden internal symbols, but let's get this
diagnostic measure in the build working before we think about
possibly deleting private symbols).
2024-05-09 00:04:23 +00:00
riastradh 8e8afff063 libm: Record expected symbols for sh3. 2024-05-08 23:28:31 +00:00
riastradh c0a4905dd8 libm: Split expected symbols on arm and mips by hard/soft float. 2024-05-08 23:28:07 +00:00
riastradh 078777ba38 libm: Add rintl, rintf to non-IEEE754 architectures.
While here, delete #ifdef to handle ns32k -- I don't think that's
gonna be relevant any time soon; in case you hadn't noticed, the
world has moved on from ns32k to vax by now.

PR 57881
2024-05-08 02:08:11 +00:00
riastradh 51f70d1537 libm: ldbl_dummy.c is no longer needed -- nix it. 2024-05-08 01:58:52 +00:00
riastradh 81421ada3b libm: Don't export symbol `pio4' from s_cosl.c.
This appears to have been added unintentionally in the recent FreeBSD
long double update, and never went out in a release.
2024-05-08 01:42:23 +00:00
riastradh 9ff0c4291d libm: Do the weak alias dance for sin/cos/tan/finite{,f}.
tan isn't used internally, but it's confusing for it to be treated
differently from sin and cos, and there's no harm in doing the dance
unnecessarily.
2024-05-08 01:40:26 +00:00
riastradh b6653282bf libm/arch/m68k: Do the weak alias dance for finite.
This is used internally.
2024-05-08 01:05:25 +00:00
riastradh 62e6bb72de libm/arch/mc68881: Do the weak alias dance for sin, cos, tan.
These are used internally.
2024-05-08 01:04:40 +00:00
riastradh 62841561df libm/arch/vax: Do the weak alias dance for finite, finitef.
These are used internally.
2024-05-08 01:04:24 +00:00
riastradh 89f1761863 libm/arch/i387: Do the weak alias dance for finite and finitef.
These are used internally by some things.
2024-05-08 01:04:03 +00:00
riastradh 06a9ffe262 libm: Add expected symbols for m68k.
Not sure if this'll work for all ports -- we might need to split it
up finer-grained by different m68k flavours -- but let's give it a
try and see what breaks.
2024-05-07 23:13:32 +00:00
riastradh 5f4c33f35e lib/libm/arch/m68060: regen 2024-05-07 22:51:19 +00:00
riastradh f349ddea9b lib/libm/m68060/makeas.sh: Delimit symbols with END.
This way we get symbol sizes in the ELF output.
2024-05-07 22:30:16 +00:00
riastradh 9750c027c7 lib/libm/arch/m68060/makeas.sh: Create public weak aliases.
Use _foo for internal names, and weak alias foo when it's public like
sin/cos/tan.
2024-05-07 22:29:53 +00:00
riastradh 2e8caa3647 lib/libm/m68060/makeas.sh: Use `set -eu' to detect script mistakes.
No functional change intended.
2024-05-07 22:19:42 +00:00
riastradh b1bc5af1e1 lib/libm/m68060/makeas.sh: Pass arguments to dummy more idiomatically.
No functional change intended.
2024-05-07 22:18:19 +00:00
riastradh 150c79c867 lib/libm/m68060/makeas.sh: Use local for shell functions.
No functional change intended.
2024-05-07 22:17:24 +00:00
riastradh a45e4331c1 lib/libm/arch/m68060/makeas.sh: Indent sh blocks.
No functional change intended.
2024-05-07 22:17:08 +00:00
riastradh 5bc608efaf lib/libm/arch/m68060: regen 2024-05-07 21:18:47 +00:00
riastradh bd91cc76f2 lib/libm/arch/m68060/makeas.sh: Strip the $ when emitting RCS id. 2024-05-07 21:14:12 +00:00
riastradh 8383bd5dda libm/arch/m68060/Makefile: bsd.sys.mk -> bsd.host.mk
Somewhat belatedly, after bsd.sys.mk was forbidden to use directly
from Makefiles back in 2014.
2024-05-07 21:11:24 +00:00
riastradh 7065ff01cd libm/arch/m68060/makeas.sh: Tag output with makeas.sh RCS id.
No functional change intended to the output -- only changes are to
comments.
2024-05-07 21:05:47 +00:00
riastradh cd9dfcd0c5 libm: Memorialize expected symbols on various architectures.
This will reduce the risk of accidentally adding or deleting the
wrong symbols while fixing the aliases.

(This is all the architectures I have a build tree for handy; can add
other architectures like m68k later.)
2024-05-07 20:58:33 +00:00
riastradh 13d778abc5 libm/arch/vax: Expose atan2l.
PR port-vax/57881: vax libm is missing various symbols
2024-05-07 15:49:33 +00:00
riastradh 4336c6aedd libm/arch/vax: Use STRONG_ALIAS, not ALTENTRY.
STRONG_ALIAS copies the symbol size and type, so it avoids warnings
like this:

/home/riastradh/netbsd/10/obj.vax/tooldir/bin/../lib/gcc/vax--netbsdelf/10.5.0/../../../../vax--netbsdelf/bin/ld: warning: type and size of dynamic symbol `ldexpl' are not defined
2024-05-07 15:15:31 +00:00
riastradh 2a580023ad libm/arch/vax: Use END to delimit symbol definitions.
This way we get sizes and, likely, slightly better debug info about
PCs inside these symbols.
2024-05-07 15:15:09 +00:00
skrll 8c835d3895 Trailing whitespace 2024-05-06 15:59:53 +00:00
riastradh 18bbefc87a libm: Expose sincosl on vax.
PR 57881
2024-05-06 15:52:52 +00:00
riastradh bfbeee7805 libm: Expose sinl, cosl, tanl on vax.
While here, make sin, cos, and tan be weak aliases for internal
symbols _sin, _cos, and _tan; likewise sinf, cosf, tanf.

PR 57881
2024-05-06 15:33:04 +00:00
riastradh 3822903a53 libm: long double is just double on hppa, so don't use s_rintl.c.
PR misc/58054
2024-05-05 22:52:19 +00:00
riastradh 47b5b183dd libm: If long double is double, nexttowardl is nextafter.
long double nexttowardl(long double, long double);
double nextafter(double, double);
2024-05-05 22:10:06 +00:00
riastradh 17f9eb725b libm: No s_rintl.c on mips32.
This is only for machines where long double is not double.

Not 100% sure this is the right criterion, but there's a good chance
it is.
2024-05-05 14:53:22 +00:00
riastradh 55bbe7aeb3 libm/s_nexttowardf.c: Handle __HAVE_LONG_DOUBLE, LDBL_IMPLICIT_NBIT.
We should arrange to just have LDBL_NBIT unconditionally defined in the
appropriate MD header file, and make LDBL_IMPLICIT_NBIT an alias for
LDBL_NBIT==0.  But for now this will do.
2024-05-05 14:06:47 +00:00
riastradh f8bd6e11b1 libm: Make s_nexttowardf.c work when long double is double.
Seems likely that there are other parts of libm which would benefit
from being defined unconditionally in terms of ieee_ext_u, with
ieee_ext_u as an alias for ieee_double_u, in this scenario.  But I
haven't gone looking yet.
2024-05-05 11:38:03 +00:00
riastradh 816699395b libm: long double is just double on arm, so don't use s_rintl.c.
PR misc/58054
2024-05-05 11:07:49 +00:00
riastradh 8f27842e48 libm: New s_rintl.S for x86.
Prompted by PR lib/58054.
2024-05-05 02:50:11 +00:00
riastradh ebb5e1cc01 s_rintl.c: Reduce FreeBSD diff and fix on ld128 platforms.
EXT_FRACBITS, the number of bits in the _binary encoding_ that stores
the trailing significand field, is never 113.  In IEEE 754 binary128,
it is 112, even though there are 113 bits of precision in the set of
floating-point numbers -- the leading 1 bit is implicit in binary128.
So ld128 platforms like aarch64 and sparc64 were skipping the real
definition and just defining rintl as an alias for rint, which is
wrong.

In contrast, LDBL_MANT_DIG, the number of bits of precision in the set
of floating-point numbers (p, in IEEE 754 parlance), is 113 in IEEE 754
binary128.  This is also the constant used in FreeBSD libm anyway.  So
let's just use that instead of trying to translate it to our private
EXT_FRACBITS (not defined in FreeBSD) with a fencepos terror.  And
delete the buggy rintl=rint alias.

PR lib/58054
2024-05-04 19:21:51 +00:00
christos b0c6c15390 remove #include <ieeefp.h> for i386 now that it is included in math_private.h 2024-04-03 18:53:41 +00:00
christos b3579e8037 need <ieeefp.h> for i386. 2024-04-03 14:54:50 +00:00
kre 0e71e5a0d1 For i386, if ft[sg]etprec() are to be used, ensure there's a
prototype for them in scope (so include <ieeefp.h>)

Might fix the i386 build.
2024-04-03 04:40:23 +00:00
christos d89d80aaff reduce diff with FreeBSD 2024-04-03 01:51:01 +00:00