File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed
quaddtype/numpy_quaddtype/src Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -30,22 +30,18 @@ py_is_longdouble_128(PyObject *self, PyObject *args)
30
30
}
31
31
}
32
32
33
- #ifndef SLEEF_QUAD_C
33
+ #ifdef SLEEF_QUAD_C
34
+ // Native __float128 support
35
+ static const Sleef_quad SMALLEST_SUBNORMAL_VALUE = SLEEF_QUAD_DENORM_MIN ;
36
+ #else
37
+ // Use static union for thread-safe initialization
34
38
static const union {
35
39
struct {
36
- #if defined(__BYTE_ORDER__ ) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ )
37
- uint64_t h , l ;
38
- #else
39
40
uint64_t l , h ;
40
- #endif
41
41
} parts ;
42
- Sleef_quad quad_value ;
43
- long double alignment_dummy __attribute__((aligned (16 )));
44
- } SMALLEST_SUBNORMAL_CONST = {
45
- .parts = {
46
- .h = 0x0000000000000000ULL , // exponent = 0 (subnormal), mantissa high = 0
47
- .l = 0x0000000000000001ULL // mantissa low = 1 (smallest possible)
48
- }};
42
+ Sleef_quad value ;
43
+ } smallest_subnormal_const = {.parts = {.l = 0x0000000000000001ULL , .h = 0x0000000000000000ULL }};
44
+ #define SMALLEST_SUBNORMAL_VALUE (smallest_subnormal_const.value)
49
45
#endif
50
46
51
47
static PyObject *
@@ -93,7 +89,7 @@ get_sleef_constant(PyObject *self, PyObject *args)
93
89
// On platforms with native __float128 support, use the correct literal
94
90
result -> value .sleef_value = SLEEF_QUAD_DENORM_MIN ;
95
91
#else
96
- result -> value .sleef_value = SMALLEST_SUBNORMAL_CONST . quad_value ;
92
+ result -> value .sleef_value = SMALLEST_SUBNORMAL_VALUE ;
97
93
#endif
98
94
}
99
95
else if (strcmp (constant_name , "bits" ) == 0 ) {
You can’t perform that action at this time.
0 commit comments