summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2008-04-26 18:36:35 +0000
committerCharles Harris <charlesr.harris@gmail.com>2008-04-26 18:36:35 +0000
commit97f7b55e469c0e3792b602f5d00ab15ad16f00dc (patch)
tree632dce9e7f61da0e3e97338537a6f7110b8cf0f0 /numpy/core
parent76d1305986ddcc07aad6bb38550fb06b1ca70be0 (diff)
downloadnumpy-97f7b55e469c0e3792b602f5d00ab15ad16f00dc.tar.gz
Sprinkle some do {} while (0) magic around macros with if statements. They
should lose the semi-colons too, but I don't want to risk breaking out of tree code.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/include/numpy/ndarrayobject.h45
-rw-r--r--numpy/core/include/numpy/ufuncobject.h8
2 files changed, 25 insertions, 28 deletions
diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h
index 72e15a52d..387d090ec 100644
--- a/numpy/core/include/numpy/ndarrayobject.h
+++ b/numpy/core/include/numpy/ndarrayobject.h
@@ -1137,25 +1137,22 @@ typedef struct {
PyArray_FastTakeFunc *fasttake;
} PyArray_ArrFuncs;
-#define NPY_ITEM_REFCOUNT 0x01 /* The item must be reference counted
- when it is inserted or extracted. */
-#define NPY_ITEM_HASOBJECT 0x01 /* Same as needing REFCOUNT */
-
-#define NPY_LIST_PICKLE 0x02 /* Convert to list for pickling */
-#define NPY_ITEM_IS_POINTER 0x04 /* The item is a POINTER */
-
-#define NPY_NEEDS_INIT 0x08 /* memory needs to be initialized
- for this data-type */
-
-#define NPY_NEEDS_PYAPI 0x10 /* operations need Python C-API
- so don't give-up thread. */
-
-#define NPY_USE_GETITEM 0x20 /* Use f.getitem when extracting elements
- of this data-type */
-
-#define NPY_USE_SETITEM 0x40 /* Use f.setitem when setting creating
- 0-d array from this data-type.
- */
+/* The item must be reference counted when it is inserted or extracted. */
+#define NPY_ITEM_REFCOUNT 0x01
+/* Same as needing REFCOUNT */
+#define NPY_ITEM_HASOBJECT 0x01
+/* Convert to list for pickling */
+#define NPY_LIST_PICKLE 0x02
+/* The item is a POINTER */
+#define NPY_ITEM_IS_POINTER 0x04
+/* memory needs to be initialized for this data-type */
+#define NPY_NEEDS_INIT 0x08
+/* operations need Python C-API so don't give-up thread. */
+#define NPY_NEEDS_PYAPI 0x10
+/* Use f.getitem when extracting elements of this data-type */
+#define NPY_USE_GETITEM 0x20
+/* Use f.setitem when setting creating 0-d array from this data-type.*/
+#define NPY_USE_SETITEM 0x40
/* define NPY_IS_COMPLEX */
/* These are inherited for global data-type if any data-types in the field
@@ -1372,15 +1369,15 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
#define NPY_END_ALLOW_THREADS Py_END_ALLOW_THREADS
#define NPY_BEGIN_THREADS_DEF PyThreadState *_save=NULL;
#define NPY_BEGIN_THREADS _save = PyEval_SaveThread();
-#define NPY_END_THREADS if (_save) PyEval_RestoreThread(_save);
+#define NPY_END_THREADS do {if (_save) PyEval_RestoreThread(_save);} while (0);
#define NPY_BEGIN_THREADS_DESCR(dtype) \
- if (!(PyDataType_FLAGCHK(dtype, NPY_NEEDS_PYAPI))) \
- NPY_BEGIN_THREADS
+ do {if (!(PyDataType_FLAGCHK(dtype, NPY_NEEDS_PYAPI))) \
+ NPY_BEGIN_THREADS;} while (0);
#define NPY_END_THREADS_DESCR(dtype) \
- if (!(PyDataType_FLAGCHK(dtype, NPY_NEEDS_PYAPI))) \
- NPY_END_THREADS
+ do {if (!(PyDataType_FLAGCHK(dtype, NPY_NEEDS_PYAPI))) \
+ NPY_END_THREADS; } while (0);
#define NPY_ALLOW_C_API_DEF PyGILState_STATE __save__;
#define NPY_ALLOW_C_API __save__ = PyGILState_Ensure();
diff --git a/numpy/core/include/numpy/ufuncobject.h b/numpy/core/include/numpy/ufuncobject.h
index cf868446b..91f37f99c 100644
--- a/numpy/core/include/numpy/ufuncobject.h
+++ b/numpy/core/include/numpy/ufuncobject.h
@@ -174,8 +174,8 @@ typedef struct {
#if NPY_ALLOW_THREADS
-#define NPY_LOOP_BEGIN_THREADS if (!(loop->obj)) {_save = PyEval_SaveThread();}
-#define NPY_LOOP_END_THREADS if (!(loop->obj)) {PyEval_RestoreThread(_save);}
+#define NPY_LOOP_BEGIN_THREADS do {if (!(loop->obj)) _save = PyEval_SaveThread();} while (0)
+#define NPY_LOOP_END_THREADS do {if (!(loop->obj)) PyEval_RestoreThread(_save);} while (0)
#else
#define NPY_LOOP_BEGIN_THREADS
#define NPY_LOOP_END_THREADS
@@ -213,12 +213,12 @@ typedef struct _loop1d_info {
#define UFUNC_PYVALS_NAME "UFUNC_PYVALS"
#define UFUNC_CHECK_ERROR(arg) \
- if (((arg)->obj && PyErr_Occurred()) || \
+ do {if (((arg)->obj && PyErr_Occurred()) || \
((arg)->errormask && \
PyUFunc_checkfperr((arg)->errormask, \
(arg)->errobj, \
&(arg)->first))) \
- goto fail
+ goto fail;} while (0)
/* This code checks the IEEE status flags in a platform-dependent way */
/* Adapted from Numarray */