| 39 | } |
| 40 | |
| 41 | NPY_VISIBILITY_HIDDEN int |
| 42 | npy_cpu_init(void) |
| 43 | { |
| 44 | npy__cpu_init_features(); |
| 45 | if (npy__cpu_validate_baseline() < 0) { |
| 46 | return -1; |
| 47 | } |
| 48 | char *enable_env = getenv("NPY_ENABLE_CPU_FEATURES"); |
| 49 | char *disable_env = getenv("NPY_DISABLE_CPU_FEATURES"); |
| 50 | int is_enable = enable_env && enable_env[0]; |
| 51 | int is_disable = disable_env && disable_env[0]; |
| 52 | if (is_enable & is_disable) { |
| 53 | PyErr_Format(PyExc_ImportError, |
| 54 | "Both NPY_DISABLE_CPU_FEATURES and NPY_ENABLE_CPU_FEATURES " |
| 55 | "environment variables cannot be set simultaneously." |
| 56 | ); |
| 57 | return -1; |
| 58 | } |
| 59 | if (is_enable | is_disable) { |
| 60 | if (npy__cpu_check_env(is_disable, is_disable ? disable_env : enable_env) < 0) { |
| 61 | return -1; |
| 62 | } |
| 63 | } |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | static struct { |
| 68 | enum npy_cpu_features feature; |
no test coverage detected