Browse Source

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.
Ed Schouten 10 years ago
parent
commit
c253db68ca
7 changed files with 24 additions and 10 deletions
  1. 4 2
      src/e_gamma.c
  2. 4 2
      src/e_gammaf.c
  3. 4 2
      src/e_lgamma.c
  4. 4 2
      src/e_lgammaf.c
  5. 3 2
      src/e_lgammal.c
  6. 3 0
      src/openlibm.h
  7. 2 0
      src/s_signgam.c

+ 4 - 2
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);
 }

+ 4 - 2
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);
 }

+ 4 - 2
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);
 }

+ 4 - 2
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);
 }

+ 3 - 2
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));
 }

+ 3 - 0
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

+ 2 - 0
src/s_signgam.c

@@ -2,4 +2,6 @@
 
 #include "math_private.h"
 
+#ifndef OPENLIBM_ONLY_THREAD_SAFE
 int signgam = 0;
+#endif