File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
quaddtype/numpy_quaddtype/src Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 18
18
#include "quad_common.h"
19
19
#include "quadblas_interface.h"
20
20
#include "float.h"
21
+ #include <pthread.h>
22
+
23
+ static pthread_mutex_t constant_mutex = PTHREAD_MUTEX_INITIALIZER ;
21
24
22
25
static PyObject *
23
26
py_is_longdouble_128 (PyObject * self , PyObject * args )
@@ -75,6 +78,7 @@ get_sleef_constant(PyObject *self, PyObject *args)
75
78
// On platforms with native __float128 support, use the correct literal
76
79
result -> value .sleef_value = SLEEF_QUAD_DENORM_MIN ;
77
80
#else
81
+ pthread_mutex_lock (& constant_mutex );
78
82
// On platforms without native __float128, SLEEF_QUAD_DENORM_MIN is broken
79
83
// Manually constructing the smallest subnormal: 1 * 2^(-16382-112) = 2^(-16494)
80
84
// This represents 0x0.0000000000000000000000000001p-16382
@@ -90,6 +94,7 @@ get_sleef_constant(PyObject *self, PyObject *args)
90
94
c .h = 0x0000000000000000ULL ; // exponent = 0 (subnormal), mantissa high = 0
91
95
c .l = 0x0000000000000001ULL ; // mantissa low = 1 (smallest possible)
92
96
memcpy (& result -> value .sleef_value , & c , 16 );
97
+ pthread_mutex_unlock (& constant_mutex );
93
98
#endif
94
99
}
95
100
else if (strcmp (constant_name , "bits" ) == 0 ) {
You can’t perform that action at this time.
0 commit comments