diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2022-01-23 14:58:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-23 14:58:28 -0700 |
commit | 72a27ad2798575fa5dce9046815597b3a63109a2 (patch) | |
tree | 44363be0aad5a8818c8a76eba8eb008f1d04cbfa | |
parent | 85518d6f34f4bdf1a81eecebf261fa71422197eb (diff) | |
parent | 50d69741cb35db1a535282060c51e536a863ce99 (diff) | |
download | numpy-72a27ad2798575fa5dce9046815597b3a63109a2.tar.gz |
Merge pull request #20866 from bashtage/port-clang-cl-changes
ENH: Add changes that allow NumPy to compile with clang-cl
-rw-r--r-- | numpy/core/include/numpy/ndarraytypes.h | 2 | ||||
-rw-r--r-- | numpy/core/include/numpy/npy_common.h | 7 | ||||
-rw-r--r-- | numpy/core/src/common/simd/intdiv.h | 2 | ||||
-rw-r--r-- | numpy/core/src/multiarray/common_dtype.c | 2 | ||||
-rw-r--r-- | numpy/core/src/umath/loops_unary_fp.dispatch.c.src | 3 |
5 files changed, 10 insertions, 6 deletions
diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h index 47d063178..35d82ec03 100644 --- a/numpy/core/include/numpy/ndarraytypes.h +++ b/numpy/core/include/numpy/ndarraytypes.h @@ -87,7 +87,7 @@ enum NPY_TYPES { NPY_BOOL=0, /* The number of types not including the new 1.6 types */ NPY_NTYPES_ABI_COMPATIBLE=21 }; -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #pragma deprecated(NPY_CHAR) #endif diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h index 1d6234e20..2bcc45e4f 100644 --- a/numpy/core/include/numpy/npy_common.h +++ b/numpy/core/include/numpy/npy_common.h @@ -131,9 +131,10 @@ #endif #endif -#if defined(_MSC_VER) - #define NPY_INLINE __inline -#elif defined(__GNUC__) +#if defined(_MSC_VER) && !defined(__clang__) + #define NPY_INLINE __inline +/* clang included here to handle clang-cl on Windows */ +#elif defined(__GNUC__) || defined(__clang__) #if defined(__STRICT_ANSI__) #define NPY_INLINE __inline__ #else diff --git a/numpy/core/src/common/simd/intdiv.h b/numpy/core/src/common/simd/intdiv.h index a7a461721..42f022c55 100644 --- a/numpy/core/src/common/simd/intdiv.h +++ b/numpy/core/src/common/simd/intdiv.h @@ -136,7 +136,7 @@ NPY_FINLINE npy_uint64 npyv__divh128_u64(npy_uint64 high, npy_uint64 divisor) { assert(divisor > 1); npy_uint64 quotient; -#if defined(_M_X64) && defined(_MSC_VER) && _MSC_VER >= 1920 +#if defined(_M_X64) && defined(_MSC_VER) && _MSC_VER >= 1920 && !defined(__clang__) npy_uint64 remainder; quotient = _udiv128(high, 0, divisor, &remainder); (void)remainder; diff --git a/numpy/core/src/multiarray/common_dtype.c b/numpy/core/src/multiarray/common_dtype.c index ca80b1ed7..3561a905a 100644 --- a/numpy/core/src/multiarray/common_dtype.c +++ b/numpy/core/src/multiarray/common_dtype.c @@ -41,7 +41,7 @@ * @param dtype2 Second DType class. * @return The common DType or NULL with an error set */ -NPY_NO_EXPORT NPY_INLINE PyArray_DTypeMeta * +NPY_NO_EXPORT PyArray_DTypeMeta * PyArray_CommonDType(PyArray_DTypeMeta *dtype1, PyArray_DTypeMeta *dtype2) { if (dtype1 == dtype2) { diff --git a/numpy/core/src/umath/loops_unary_fp.dispatch.c.src b/numpy/core/src/umath/loops_unary_fp.dispatch.c.src index 5817cf500..78e231965 100644 --- a/numpy/core/src/umath/loops_unary_fp.dispatch.c.src +++ b/numpy/core/src/umath/loops_unary_fp.dispatch.c.src @@ -128,6 +128,9 @@ NPY_FINLINE double c_square_f64(double a) #if __clang_major__ < 10 // Clang before v10 #define WORKAROUND_CLANG_RECIPROCAL_BUG 1 + #elif defined(_MSC_VER) + // clang-cl has the same bug + #define WORKAROUND_CLANG_RECIPROCAL_BUG 1 #elif defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64) // Clang v10+, targeting i386 or x86_64 #define WORKAROUND_CLANG_RECIPROCAL_BUG 0 |