From: Marcus Hähnel <marcus.haehnel(a)kernkonzept.com>
Clang also supports the gnu_inline attribute and the
__GNUC_STDC_INLINE__ macro (C99 semantics). However, it reports as
GCC 4.2 compatible (__GNUC_MINOR__ / __GNUC__) and thus the current
defines do not think it can support this.
Add clang as an alternative for this support. Documentation shows that
this attribute is supported since at least Clang 8.
Signed-off-by: Marcus Haehnel <marcus.haehnel(a)kernkonzept.com>
---
include/sys/cdefs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index 9b3a02177..656548c52 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -320,7 +320,7 @@
inline semantics, unless -fgnu89-inline is used.
For -std=gnu99, forcing gnu_inline attribute does not change behavior,
but may silence spurious warnings (such as in GCC 4.2). */
-#if !defined __cplusplus || __GNUC_PREREQ (4,3)
+#if !defined __cplusplus || __GNUC_PREREQ (4,3) || __CLANG_PREREQ(8,0)
# if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ || defined __cplusplus
# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
# if __GNUC_PREREQ (4,3)
--
2.45.2
This can be used to guard fatures for specific clang versions.
Signed-off-by: Marcus Haehnel <marcus.haehnel(a)kernkonzept.com>
---
include/features.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/features.h b/include/features.h
index b5d4e79f2..1a4efb9db 100644
--- a/include/features.h
+++ b/include/features.h
@@ -140,6 +140,18 @@
# define __GNUC_PREREQ(maj, min) 0
#endif
+/* Convenience macro to test the version of clang.
+ Use like this:
+ #if __CLANG_PREREQ(3,2)
+ ... code requiring clang 3.2 or later ...
+ #endif */
+#if defined __clang__
+# define __CLANG_PREREQ(maj, min) \
+ ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
+#else
+# define __CLANG_PREREQ(maj, min) 0
+#endif
+
/* Whether to use feature set F. */
#define __GLIBC_USE(F) __GLIBC_USE_ ## F
--
2.45.2
From: Yann Le Du <yann.le.du(a)kernkonzept.com>
The existing limit of 20 was found to be insufficient when moving from
gcc 8 to gcc 9. At the time a test ran already 16 handlers had been
installed leaving only minimal room for application installed handlers.
Musl uses 32, as does newlib. Further, the ISO C standard for C99
specifies that:
The implementation shall support the registration of at least
32 functions.
(7.20.4.2 The atexit function)
Co-authored-by: Yann Le Du <yann.le.du(a)kernkonzept.com>
Signed-off-by: Marcus Haehnel <marcus.haehnel(a)kernkonzept.com>
---
include/stdlib.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/stdlib.h b/include/stdlib.h
index 8b1375184..d4e0b75e7 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -606,7 +606,7 @@ libc_hidden_proto(unsetenv)
#ifdef __UCLIBC_DYNAMIC_ATEXIT__
# define __UCLIBC_MAX_ATEXIT INT_MAX
#else
-# define __UCLIBC_MAX_ATEXIT 20
+# define __UCLIBC_MAX_ATEXIT 32
#endif
--
2.45.2
Make two implicit casts from double to int explicit to silence compiler
warnings about them. The casts are required during the computation of
exponentiation.
Co-authored-by: Sven Linker <sven.linker(a)kernkonzept.com>
Signed-off-by: Marcus Haehnel <marcus.haehnel(a)kernkonzept.com>
---
libm/e_exp.c | 2 +-
libm/s_expm1.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libm/e_exp.c b/libm/e_exp.c
index ffa556120..f694f67d1 100644
--- a/libm/e_exp.c
+++ b/libm/e_exp.c
@@ -126,7 +126,7 @@ double __ieee754_exp(double x) /* default IEEE double exp */
if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
} else {
- k = invln2*x+halF[xsb];
+ k = (int32_t)(invln2*x+halF[xsb]);
t = k;
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
diff --git a/libm/s_expm1.c b/libm/s_expm1.c
index 8e51ae748..85defefa4 100644
--- a/libm/s_expm1.c
+++ b/libm/s_expm1.c
@@ -159,7 +159,7 @@ double expm1(double x)
else
{hi = x + ln2_hi; lo = -ln2_lo; k = -1;}
} else {
- k = invln2*x+((xsb==0)?0.5:-0.5);
+ k = (int32_t)(invln2*x+((xsb==0)?0.5:-0.5));
t = k;
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
lo = t*ln2_lo;
--
2.45.2
From: Marcus Hähnel <marcus.haehnel(a)kernkonzept.com>
Clang also supports the gnu_inline attribute and the
__GNUC_STDC_INLINE__ macro (C99 semantics). However, it reports as
GCC 4.2 compatible (__GNUC_MINOR__ / __GNUC__) and thus the current
defines do not think it can support this.
Add clang as an alternative for this support. Documentation shows that
this attribute is supported since at least Clang 8.
---
Requires the features.h change that introduces the __CLANG_PREREQ macro
include/sys/cdefs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index 9b3a02177..656548c52 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -320,7 +320,7 @@
inline semantics, unless -fgnu89-inline is used.
For -std=gnu99, forcing gnu_inline attribute does not change behavior,
but may silence spurious warnings (such as in GCC 4.2). */
-#if !defined __cplusplus || __GNUC_PREREQ (4,3)
+#if !defined __cplusplus || __GNUC_PREREQ (4,3) || __CLANG_PREREQ(8,0)
# if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ || defined __cplusplus
# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
# if __GNUC_PREREQ (4,3)
--
2.43.0
From: Marcus Hähnel <marcus.haehnel(a)kernkonzept.com>
Clang also supports the gnu_inline attribute and the
__GNUC_STDC_INLINE__ macro (C99 semantics). However, it reports as
GCC 4.2 compatible (__GNUC_MINOR__ / __GNUC__) and thus the current
defines do not think it can support this.
Add clang as an alternative for this support. Documentation shows that
this attribute is supported since at least Clang 8.
---
include/sys/cdefs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index 9b3a02177..656548c52 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -320,7 +320,7 @@
inline semantics, unless -fgnu89-inline is used.
For -std=gnu99, forcing gnu_inline attribute does not change behavior,
but may silence spurious warnings (such as in GCC 4.2). */
-#if !defined __cplusplus || __GNUC_PREREQ (4,3)
+#if !defined __cplusplus || __GNUC_PREREQ (4,3) || __CLANG_PREREQ(8,0)
# if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ || defined __cplusplus
# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
# if __GNUC_PREREQ (4,3)
--
2.43.0
This can be used to guard fatures for specific clang versions.
---
include/features.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/features.h b/include/features.h
index b5d4e79f2..1a4efb9db 100644
--- a/include/features.h
+++ b/include/features.h
@@ -140,6 +140,18 @@
# define __GNUC_PREREQ(maj, min) 0
#endif
+/* Convenience macro to test the version of clang.
+ Use like this:
+ #if __CLANG_PREREQ(3,2)
+ ... code requiring clang 3.2 or later ...
+ #endif */
+#if defined __clang__
+# define __CLANG_PREREQ(maj, min) \
+ ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
+#else
+# define __CLANG_PREREQ(maj, min) 0
+#endif
+
/* Whether to use feature set F. */
#define __GLIBC_USE(F) __GLIBC_USE_ ## F
--
2.43.0