From c253db68caea45ee56b7d35e93bb2945b98ddf5b Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sat, 10 Jan 2015 09:57:33 +0100 Subject: [PATCH] Add a new compilation flag: OPENLIBM_ONLY_THREAD_SAFE. The global signgam variable is only part of the X/Open System Interfaces. It is not part of the POSIX base definitions nor the C standard. I'd rather have it disabled for my specific use-case, so introduce a new compilation flag that we can use to disable it. --- src/e_gamma.c | 6 ++++-- src/e_gammaf.c | 6 ++++-- src/e_lgamma.c | 6 ++++-- src/e_lgammaf.c | 6 ++++-- src/e_lgammal.c | 5 +++-- src/openlibm.h | 3 +++ src/s_signgam.c | 2 ++ 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/e_gamma.c b/src/e_gamma.c index ff7b257..3c3e97c 100644 --- a/src/e_gamma.c +++ b/src/e_gamma.c @@ -25,10 +25,12 @@ #include "math_private.h" -extern int signgam; - DLLEXPORT double __ieee754_gamma(double x) { +#ifdef OPENLIBM_ONLY_THREAD_SAFE + int signgam; +#endif + return __ieee754_gamma_r(x,&signgam); } diff --git a/src/e_gammaf.c b/src/e_gammaf.c index 465efb4..1cb2c74 100644 --- a/src/e_gammaf.c +++ b/src/e_gammaf.c @@ -26,10 +26,12 @@ #include "math_private.h" -extern int signgam; - DLLEXPORT float __ieee754_gammaf(float x) { +#ifdef OPENLIBM_ONLY_THREAD_SAFE + int signgam; +#endif + return __ieee754_gammaf_r(x,&signgam); } diff --git a/src/e_lgamma.c b/src/e_lgamma.c index da25f44..4dd5a0d 100644 --- a/src/e_lgamma.c +++ b/src/e_lgamma.c @@ -25,10 +25,12 @@ #include "math_private.h" -extern int signgam; - DLLEXPORT double __ieee754_lgamma(double x) { +#ifdef OPENLIBM_ONLY_THREAD_SAFE + int signgam; +#endif + return __ieee754_lgamma_r(x,&signgam); } diff --git a/src/e_lgammaf.c b/src/e_lgammaf.c index 922be5a..40e7059 100644 --- a/src/e_lgammaf.c +++ b/src/e_lgammaf.c @@ -26,10 +26,12 @@ #include "math_private.h" -extern int signgam; - DLLEXPORT float __ieee754_lgammaf(float x) { +#ifdef OPENLIBM_ONLY_THREAD_SAFE + int signgam; +#endif + return __ieee754_lgammaf_r(x,&signgam); } diff --git a/src/e_lgammal.c b/src/e_lgammal.c index 2e68630..5ae5761 100644 --- a/src/e_lgammal.c +++ b/src/e_lgammal.c @@ -4,11 +4,12 @@ #include "math_private.h" -extern int signgam; - DLLEXPORT long double lgammal(long double x) { +#ifdef OPENLIBM_ONLY_THREAD_SAFE + int signgam; +#endif return (lgammal_r(x, &signgam)); } diff --git a/src/openlibm.h b/src/openlibm.h index 513ad4d..ca704c7 100644 --- a/src/openlibm.h +++ b/src/openlibm.h @@ -170,7 +170,10 @@ extern const union __nan_un { #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #define MAXFLOAT ((float)3.40282346638528860e+38) + +#ifndef OPENLIBM_ONLY_THREAD_SAFE extern int signgam; +#endif #endif /* __BSD_VISIBLE || __XSI_VISIBLE */ #if __BSD_VISIBLE diff --git a/src/s_signgam.c b/src/s_signgam.c index 7e197a0..1557899 100644 --- a/src/s_signgam.c +++ b/src/s_signgam.c @@ -2,4 +2,6 @@ #include "math_private.h" +#ifndef OPENLIBM_ONLY_THREAD_SAFE int signgam = 0; +#endif