Skip to content

Commit

Permalink
TASK: rename macros (from review)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Aug 21, 2022
1 parent d1cbf3f commit 25629dd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
2 changes: 0 additions & 2 deletions numpy/core/setup_common.py
Expand Up @@ -142,8 +142,6 @@ def set_sig(sig):
"ftello", "fseeko"
]

# TODO: make these mandatory and use BLOCK_ macros rather than HAVE_ macros
# in npy_config.h and throughout the code
C99_COMPLEX_TYPES = [
'complex double', 'complex float', 'complex long double'
]
Expand Down
28 changes: 14 additions & 14 deletions numpy/core/src/common/npy_config.h
Expand Up @@ -11,22 +11,22 @@
/* Disable broken functions on z/OS */
#if defined (__MVS__)

#define BLOCK_POWF
#define BLOCK_EXPF
#define NPY_BLOCK_POWF
#define NPY_BLOCK_EXPF
#undef HAVE___THREAD

#endif

/* Disable broken MS math functions */
#if defined(__MINGW32_VERSION)

#define BLOCK_ATAN2
#define BLOCK_ATAN2F
#define BLOCK_ATAN2L
#define NPY_BLOCK_ATAN2
#define NPY_BLOCK_ATAN2F
#define NPY_BLOCK_ATAN2L

#define BLOCK_HYPOT
#define BLOCK_HYPOTF
#define BLOCK_HYPOTL
#define NPY_BLOCK_HYPOT
#define NPY_BLOCK_HYPOTF
#define NPY_BLOCK_HYPOTL

#endif

Expand Down Expand Up @@ -66,23 +66,23 @@
#undef HAVE_CABSF
#undef HAVE_CABSL

#define BLOCK_HYPOT
#define BLOCK_HYPOTF
#define BLOCK_HYPOTL
#define NPY_BLOCK_HYPOT
#define NPY_BLOCK_HYPOTF
#define NPY_BLOCK_HYPOTL

#endif


/* Intel C for Windows uses POW for 64 bits longdouble*/
#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
#if NPY_SIZEOF_LONGDOUBLE == 8
#define BLOCK_POWL
#define NPY_BLOCK_POWL
#endif
#endif /* defined(_MSC_VER) && defined(__INTEL_COMPILER) */

/* powl gives zero division warning on OS X, see gh-8307 */
#if defined(NPY_OS_DARWIN)
#define BLOCK_POWL
#define NPY_BLOCK_POWL
#endif

#ifdef __CYGWIN__
Expand Down Expand Up @@ -119,7 +119,7 @@
#undef HAVE_CACOS

/* log2(exp2(i)) off by a few eps */
#define BLOCK_LOG2
#define NPY_BLOCK_LOG2

/* np.power(..., dtype=np.complex256) doesn't report overflow */
#undef HAVE_CPOWL
Expand Down
18 changes: 9 additions & 9 deletions numpy/core/src/npymath/npy_math_internal.h.src
Expand Up @@ -119,7 +119,7 @@ NPY_INPLACE double npy_modf(double x, double *iptr)
*/
NPY_INPLACE double npy_log2(double x)
{
#ifndef BLOCK_LOG2
#ifndef NPY_BLOCK_LOG2
return log2(x);
#else
if (!npy_isfinite(x) || x <= 0.) {
Expand Down Expand Up @@ -159,7 +159,7 @@ NPY_INPLACE double npy_log2(double x)
#define NPY_DBL_EPSILON 1.2246467991473531772E-16
NPY_INPLACE double npy_atan2(double y, double x)
{
#ifndef BLOCK_ATAN2
#ifndef NPY_BLOCK_ATAN2
return atan2(y, x);
#else
npy_int32 k, m, iy, ix, hx, hy;
Expand Down Expand Up @@ -243,7 +243,7 @@ NPY_INPLACE double npy_atan2(double y, double x)

NPY_INPLACE double npy_hypot(double x, double y)
{
#ifndef BLOCK_HYPOT
#ifndef NPY_BLOCK_HYPOT
return hypot(x, y);
#else
double yx;
Expand Down Expand Up @@ -390,14 +390,14 @@ NPY_INPLACE @type@ npy_cbrt@c@(@type@ x)
#ifdef @kind@@c@
#undef @kind@@c@
#endif
#ifdef BLOCK_@KIND@@C@
#ifdef NPY_BLOCK_@KIND@@C@
NPY_INPLACE @type@ npy_@kind@@c@(@type@ x)
{
return (@type@) npy_@kind@((double)x);
}
#endif

#ifndef BLOCK_@KIND@@C@
#ifndef NPY_BLOCK_@KIND@@C@
NPY_INPLACE @type@ npy_@kind@@c@(@type@ x)
{
return NPY__FP_SFX(@kind@)(x);
Expand All @@ -414,14 +414,14 @@ NPY_INPLACE @type@ npy_@kind@@c@(@type@ x)
#ifdef @kind@@c@
#undef @kind@@c@
#endif
#ifdef BLOCK_@KIND@@C@
#ifdef NPY_BLOCK_@KIND@@C@
NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y)
{
return (@type@) npy_@kind@((double)x, (double) y);
}
#endif

#ifndef BLOCK_@KIND@@C@
#ifndef NPY_BLOCK_@KIND@@C@
NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y)
{
return NPY__FP_SFX(@kind@)(x, y);
Expand All @@ -432,7 +432,7 @@ NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y)
#ifdef modf@c@
#undef modf@c@
#endif
#ifdef BLOCK_MODF@C@
#ifdef NPY_BLOCK_MODF@C@
NPY_INPLACE @type@ npy_modf@c@(@type@ x, @type@ *iptr)
{
double niptr;
Expand All @@ -442,7 +442,7 @@ NPY_INPLACE @type@ npy_modf@c@(@type@ x, @type@ *iptr)
}
#endif

#ifndef BLOCK_MODF@C@
#ifndef NPY_BLOCK_MODF@C@
NPY_INPLACE @type@ npy_modf@c@(@type@ x, @type@ *iptr)
{
return NPY__FP_SFX(modf)(x, iptr);
Expand Down

0 comments on commit 25629dd

Please sign in to comment.