[Numpy-svn] r5101 - trunk/numpy/core/include/numpy

numpy-svn@scip... numpy-svn@scip...
Sat Apr 26 18:36:58 CDT 2008


Author: charris
Date: 2008-04-26 18:36:55 -0500 (Sat, 26 Apr 2008)
New Revision: 5101

Modified:
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/include/numpy/ufuncobject.h
Log:
Enclose macros with ifs in do {} while (0).
Lets try this again with clean files.


Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2008-04-26 23:29:01 UTC (rev 5100)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2008-04-26 23:36:55 UTC (rev 5101)
@@ -1137,25 +1137,22 @@
         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 @@
 #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();

Modified: trunk/numpy/core/include/numpy/ufuncobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ufuncobject.h	2008-04-26 23:29:01 UTC (rev 5100)
+++ trunk/numpy/core/include/numpy/ufuncobject.h	2008-04-26 23:36:55 UTC (rev 5101)
@@ -174,8 +174,8 @@
 
 
 #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 @@
 #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  */



More information about the Numpy-svn mailing list