Re: numpy failure on netbsd-9, rintl

2023-11-16 Thread Greg Troxel
It looks like this is more ok than I thought.  I don't find anything
different from 10 to current.   Looking at 9 to current and pruning diff
noise, there are a number of additional aliases in 10.

It seems that there are two strategies for this.Can we pick one
and document it?  It seems like the choices are:

1) ldbl_dummy approach

In ldbl_dummy.c, define a weak_alias from fool to _fool
In namespace.h, define fool to _fool, but only for some

It's not clear how these interact, as namespace.h is included first.


2) per-function alias approach

e.g See s_modf.c,

#ifndef __HAVE_LONG_DOUBLE
__strong_alias(_modfl, modf)
__weak_alias(modfl, modf)
#endif




Index: src/ldbl_dummy.c
===
RCS file: /cvsroot/src/lib/libm/src/ldbl_dummy.c,v
retrieving revision 1.2
retrieving revision 1.2.26.1
diff -u -p -r1.2 -r1.2.26.1
--- src/ldbl_dummy.c13 Nov 2014 21:43:27 -  1.2
+++ src/ldbl_dummy.c11 Aug 2023 14:44:19 -  1.2.26.1
@@ -43,8 +43,11 @@ __weak_alias(atan2l, _atan2l)
 __weak_alias(hypotl, _hypotl)
 __weak_alias(logl, _logl)
 __weak_alias(log10l, _log10l)
+__weak_alias(log2l, _log2l)
+__weak_alias(log1pl, _log1pl)
 __weak_alias(expl, _expl)
 __weak_alias(exp2l, _exp2l)
+__weak_alias(expm1l, _expm1l)
 __weak_alias(powl, _powl)
 __weak_alias(cosl, _cosl)
 __weak_alias(sinl, _sinl)
@@ -60,6 +63,8 @@ __weak_alias(asinhl, _asinhl)
 __weak_alias(atanhl, _atanhl)
 __weak_alias(erfl, _erfl)
 __weak_alias(erfcl, _erfcl)
+__weak_alias(lgammal, _lgammal)
+__weak_alias(tgammal, _tgammal)
 
 long double
 atan2l(long double y, long double x)
@@ -86,6 +91,18 @@ log10l(long double x)
 }
 
 long double
+log2l(long double x)
+{
+   return log2(x);
+}
+
+long double
+log1pl(long double x)
+{
+   return log1p(x);
+}
+
+long double
 expl(long double x)
 {
return exp(x);
@@ -98,6 +115,12 @@ exp2l(long double x)
 }
 
 long double
+expm1l(long double x)
+{
+   return expm1(x);
+}
+
+long double
 powl(long double x, long double y)
 {
return pow(x, y);
@@ -187,3 +210,27 @@ erfcl(long double x)
 {
return erfc(x);
 }
+
+long double
+lgammal(long double x)
+{
+   return lgamma(x);
+}
+
+long double
+tgammal(long double x)
+{
+   return tgamma(x);
+}
+
+long double
+remainderl(long double x, long double y)
+{
+   return remainder(x, y);
+}
+
+long double
+remquol(long double x, long double y, int *quo)
+{
+   return remquo(x, y, quo);
+}
Index: src/namespace.h
===
RCS file: /cvsroot/src/lib/libm/src/namespace.h,v
retrieving revision 1.14
retrieving revision 1.16.2.1
diff -u -p -r1.14 -r1.16.2.1
--- src/namespace.h 22 Mar 2017 23:11:09 -  1.14
+++ src/namespace.h 11 Aug 2023 14:44:19 -  1.16.2.1
@@ -10,6 +10,7 @@
 #define exp _exp
 #define expf _expf
 #define expl _expl
+#define expm1l _expm1l
 #define log _log
 #define logf _logf
 #define logl _logl
@@ -22,6 +23,9 @@
 #define finite _finite
 #define finitef _finitef
 #endif /* notyet */
+#define sincos _sincos
+#define sincosf _sincosf
+#define sincosl _sincosl
 #define sinh _sinh
 #define sinhf _sinhf
 #define sinhl _sinhl
@@ -70,15 +74,17 @@
 #define tanhl _tanhl
 #define atanhl _atanhl
 #define log10l _log10l
+#define log1pl _log1pl
+#define log2l _log2l
 
-#define erfl   _erfl
-#define erfcl  _erfcl
+#define erfl _erfl
+#define erfcl _erfcl
+
+#define lgammal _lgammal
+#define tgammal _tgammal
 
 #define feclearexcept _feclearexcept
-#define fedisableexcept _fedisableexcept
-#define feenableexcept _feenableexcept
 #define fegetenv _fegetenv
-#define fegetexcept _fegetexcept
 #define fegetexceptflag _fegetexceptflag
 #define fegetround _fegetround
 #define feholdexcept _feholdexcept
@@ -88,3 +94,7 @@
 #define fesetround _fesetround
 #define fetestexcept _fetestexcept
 #define feupdateenv _feupdateenv
+
+#define fedisableexcept _fedisableexcept
+#define feenableexcept _feenableexcept
+#define fegetexcept _fegetexcept


Re: numpy failure on netbsd-9, rintl

2023-11-16 Thread Greg Troxel
I extracted defined symbols ending in l from libm.so.


Diffing from netbsd-9 amd64 to netbsd-9 earmv7hf-el

-__ieee754_sqrtl
+_fmal
+_frexpl
+_rintl
-fabsl
-nearbyintl
-nexttowardl


I suspect the + is my local changes and strong vs weak aliases.


Re: numpy failure on netbsd-9, rintl

2023-11-16 Thread Martin Husemann
On Thu, Nov 16, 2023 at 09:03:22AM -0500, Greg Troxel wrote:
> +#ifndef __HAVE_LONG_DOUBLE
> +__strong_alias(_frexpl, frexp)
> +__weak_alias(frexpl, _frexpl)
> +#endif

That is exactly the right thing to do (and we have added such aliases
to several functions already, but not done a systematic sweep).

If double == long double we need an alias to make the long double version
of the function resolve to the plain double one. Many NetBSD architectures
are affected by this, but the libm build system is ... confusing. Would be
a good idea to create an ATF test program that refers to all of them, so
we can easily catch all missing ones at build time (like we did with
several atomics/sync primitives some time ago).

Martin