Skip to content

Commit c253db6

Browse files
committed
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.
1 parent 9fdc4f9 commit c253db6

7 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/e_gamma.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525

2626
#include "math_private.h"
2727

28-
extern int signgam;
29-
3028
DLLEXPORT double
3129
__ieee754_gamma(double x)
3230
{
31+
#ifdef OPENLIBM_ONLY_THREAD_SAFE
32+
int signgam;
33+
#endif
34+
3335
return __ieee754_gamma_r(x,&signgam);
3436
}

src/e_gammaf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626

2727
#include "math_private.h"
2828

29-
extern int signgam;
30-
3129
DLLEXPORT float
3230
__ieee754_gammaf(float x)
3331
{
32+
#ifdef OPENLIBM_ONLY_THREAD_SAFE
33+
int signgam;
34+
#endif
35+
3436
return __ieee754_gammaf_r(x,&signgam);
3537
}

src/e_lgamma.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525

2626
#include "math_private.h"
2727

28-
extern int signgam;
29-
3028
DLLEXPORT double
3129
__ieee754_lgamma(double x)
3230
{
31+
#ifdef OPENLIBM_ONLY_THREAD_SAFE
32+
int signgam;
33+
#endif
34+
3335
return __ieee754_lgamma_r(x,&signgam);
3436
}

src/e_lgammaf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626

2727
#include "math_private.h"
2828

29-
extern int signgam;
30-
3129
DLLEXPORT float
3230
__ieee754_lgammaf(float x)
3331
{
32+
#ifdef OPENLIBM_ONLY_THREAD_SAFE
33+
int signgam;
34+
#endif
35+
3436
return __ieee754_lgammaf_r(x,&signgam);
3537
}

src/e_lgammal.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
#include "math_private.h"
66

7-
extern int signgam;
8-
97
DLLEXPORT long double
108
lgammal(long double x)
119
{
10+
#ifdef OPENLIBM_ONLY_THREAD_SAFE
11+
int signgam;
12+
#endif
1213

1314
return (lgammal_r(x, &signgam));
1415
}

src/openlibm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ extern const union __nan_un {
170170
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
171171

172172
#define MAXFLOAT ((float)3.40282346638528860e+38)
173+
174+
#ifndef OPENLIBM_ONLY_THREAD_SAFE
173175
extern int signgam;
176+
#endif
174177
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
175178

176179
#if __BSD_VISIBLE

src/s_signgam.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
#include "math_private.h"
44

5+
#ifndef OPENLIBM_ONLY_THREAD_SAFE
56
int signgam = 0;
7+
#endif

0 commit comments

Comments
 (0)