commit: cc38ae078fc7a256d1486e0900afc7771b6ba723
parent c5a61c5054fc50d257c5d3e808a3dcebb8647581
Author: Michael Forney <mforney@mforney.org>
Date: Sun, 24 Jan 2021 01:03:55 -0800
musl: use _Generic selection for type-generic math macros
This way cproc can better handle programs that include math.h, since
it doesn't have to generate code involving long double.
Diffstat:
3 files changed, 101 insertions(+), 1 deletion(-)
diff --git a/.gitmodules b/.gitmodules
@@ -198,6 +198,7 @@
[submodule "pkg/musl/src"]
path = pkg/musl/src
url = git://git.musl-libc.org/musl
+ ignore = all
[submodule "pkg/ncompress/src"]
path = pkg/ncompress/src
url = https://github.com/vapier/ncompress.git
diff --git a/pkg/musl/patch/0001-use-_Generic-selection-for-type-generic-math-macros.patch b/pkg/musl/patch/0001-use-_Generic-selection-for-type-generic-math-macros.patch
@@ -0,0 +1,99 @@
+From 5db27a0021348fa0520b958d5361884046a53fa9 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Sat, 23 Jan 2021 19:59:55 -0800
+Subject: [PATCH] use _Generic selection for type-generic math macros
+
+---
+ include/math.h | 64 +++++++++++++++++++++++++-------------------------
+ 1 file changed, 32 insertions(+), 32 deletions(-)
+
+diff --git a/include/math.h b/include/math.h
+index 14f28ec8..8f18254c 100644
+--- a/include/math.h
++++ b/include/math.h
+@@ -65,39 +65,39 @@ static __inline unsigned long long __DOUBLE_BITS(double __f)
+ return __u.__i;
+ }
+
+-#define fpclassify(x) ( \
+- sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
+- sizeof(x) == sizeof(double) ? __fpclassify(x) : \
+- __fpclassifyl(x) )
+-
+-#define isinf(x) ( \
+- sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 : \
+- sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52 : \
+- __fpclassifyl(x) == FP_INFINITE)
+-
+-#define isnan(x) ( \
+- sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \
+- sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \
+- __fpclassifyl(x) == FP_NAN)
+-
+-#define isnormal(x) ( \
+- sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x)+0x00800000) & 0x7fffffff) >= 0x01000000 : \
+- sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53 : \
+- __fpclassifyl(x) == FP_NORMAL)
+-
+-#define isfinite(x) ( \
+- sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 : \
+- sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52 : \
+- __fpclassifyl(x) > FP_INFINITE)
++#define fpclassify(x) _Generic((x), \
++ float: __fpclassifyf(x), \
++ double: __fpclassify(x), \
++ long double: __fpclassifyl(x))
++
++#define isinf(x) _Generic((x), \
++ float: (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000, \
++ double: (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52, \
++ long double: __fpclassifyl(x) == FP_INFINITE)
++
++#define isnan(x) _Generic((x), \
++ float: (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000, \
++ double: (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52, \
++ long double: __fpclassifyl(x) == FP_NAN)
++
++#define isnormal(x) _Generic((x), \
++ float: ((__FLOAT_BITS(x)+0x00800000) & 0x7fffffff) >= 0x01000000, \
++ double: ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53, \
++ long double: __fpclassifyl(x) == FP_NORMAL)
++
++#define isfinite(x) _Generic((x), \
++ float: (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000, \
++ double: (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52, \
++ long double: __fpclassifyl(x) > FP_INFINITE)
+
+ int __signbit(double);
+ int __signbitf(float);
+ int __signbitl(long double);
+
+-#define signbit(x) ( \
+- sizeof(x) == sizeof(float) ? (int)(__FLOAT_BITS(x)>>31) : \
+- sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x)>>63) : \
+- __signbitl(x) )
++#define signbit(x) _Generic((x), \
++ float: (int)(__FLOAT_BITS(x)>>31), \
++ double: (int)(__DOUBLE_BITS(x)>>63), \
++ long double: __signbitl(x))
+
+ #define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y)))
+
+@@ -121,10 +121,10 @@ __ISREL_DEF(greaterequalf, >=, float_t)
+ __ISREL_DEF(greaterequal, >=, double_t)
+ __ISREL_DEF(greaterequall, >=, long double)
+
+-#define __tg_pred_2(x, y, p) ( \
+- sizeof((x)+(y)) == sizeof(float) ? p##f(x, y) : \
+- sizeof((x)+(y)) == sizeof(double) ? p(x, y) : \
+- p##l(x, y) )
++#define __tg_pred_2(x, y, p) _Generic((x)+(y), \
++ float: p##f(x, y), \
++ double: p(x, y), \
++ long double: p##l(x, y))
+
+ #define isless(x, y) __tg_pred_2(x, y, __isless)
+ #define islessequal(x, y) __tg_pred_2(x, y, __islessequal)
+--
+2.30.0
+
diff --git a/pkg/musl/ver b/pkg/musl/ver
@@ -1 +1 @@
-1.2.2 r0
+1.2.2 r1