Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a4127b

Browse files
committed
BUG: Disable broken complex trig functions for early linux glibc.
The library functions casin, casinh, catan, catanh are inaccurate in glibc version < 2.16, so use the numpy fallback functions for those.
1 parent 44d0c52 commit 3a4127b

2 files changed

Lines changed: 48 additions & 6 deletions

File tree

numpy/core/setup_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def check_api_version(apiversion, codegen_dir):
107107
# sse headers only enabled automatically on amd64/x32 builds
108108
"xmmintrin.h", # SSE
109109
"emmintrin.h", # SSE2
110+
"features.h", # for glibc version linux
110111
]
111112

112113
# optional gcc compiler builtins and their call arguments and optional a

numpy/core/src/private/npy_config.h

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
#include "config.h"
55
#include "numpy/numpyconfig.h"
66

7-
/* Disable broken MS math functions */
8-
#if defined(_MSC_VER) || defined(__MINGW32_VERSION)
9-
#undef HAVE_ATAN2
10-
#undef HAVE_HYPOT
11-
#endif
12-
137
/*
148
* largest alignment the copy loops might require
159
* required as string, void and complex types might get copied using larger
@@ -21,9 +15,56 @@
2115
*/
2216
#define NPY_MAX_COPY_ALIGNMENT 16
2317

18+
/* blacklist */
19+
2420
/* Disable broken Sun Workshop Pro math functions */
2521
#ifdef __SUNPRO_C
22+
23+
#undef HAVE_ATAN2
24+
#undef HAVE_ATAN2F
25+
#undef HAVE_ATAN2L
26+
27+
#endif
28+
29+
/* Disable broken MS math functions */
30+
#if defined(_MSC_VER) || defined(__MINGW32_VERSION)
31+
2632
#undef HAVE_ATAN2
33+
#undef HAVE_ATAN2F
34+
#undef HAVE_ATAN2L
35+
36+
#undef HAVE_HYPOT
37+
#undef HAVE_HYPOTF
38+
#undef HAVE_HYPOTL
39+
2740
#endif
2841

42+
/* Disable broken gnu trig functions on linux */
43+
#if defined(__linux__) && defined(__GNUC__)
44+
45+
#if defined(HAVE_FEATURES_H)
46+
#include <features.h>
47+
#define TRIG_OK __GLIBC_PREREQ(2, 16)
48+
#else
49+
#define TRIG_OK 0
50+
#endif
51+
52+
#if !TRIG_OK
53+
#undef HAVE_CASIN
54+
#undef HAVE_CASINF
55+
#undef HAVE_CASINL
56+
#undef HAVE_CASINH
57+
#undef HAVE_CASINHF
58+
#undef HAVE_CASINHL
59+
#undef HAVE_CATAN
60+
#undef HAVE_CATANF
61+
#undef HAVE_CATANL
62+
#undef HAVE_CATANH
63+
#undef HAVE_CATANHF
64+
#undef HAVE_CATANHL
65+
#endif
66+
#undef TRIG_OK
67+
68+
#endif /* defined(__linux__) && defined(__GNUC__) */
69+
2970
#endif

0 commit comments

Comments
 (0)