[Numpy-svn] r4212 - in branches/cleanconfig/numpy/core: . include/numpy

numpy-svn@scip... numpy-svn@scip...
Wed Oct 17 21:57:33 CDT 2007


Author: cdavid
Date: 2007-10-17 21:57:25 -0500 (Wed, 17 Oct 2007)
New Revision: 4212

Modified:
   branches/cleanconfig/numpy/core/include/numpy/ndarrayobject.h
   branches/cleanconfig/numpy/core/setup.py
Log:

Refactor the NPY_ALLOW_THREAD logic outside config.h generation, and put it inside numpy headers

Modified: branches/cleanconfig/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- branches/cleanconfig/numpy/core/include/numpy/ndarrayobject.h	2007-10-18 02:46:56 UTC (rev 4211)
+++ branches/cleanconfig/numpy/core/include/numpy/ndarrayobject.h	2007-10-18 02:57:25 UTC (rev 4212)
@@ -15,6 +15,14 @@
 /* This is auto-generated by the installer */
 #include "config.h"
 
+/* Only use thread if configured in config and python supports it */
+#if defined WITH_THREAD && !NPY_NOSMP
+        #define NPY_ALLOW_THREADS 1
+#else
+        #define NPY_ALLOW_THREADS 0
+        #error FLOUPI
+#endif
+
 /* There are several places in the code where an array of dimensions is
  * allocated statically.  This is the size of that static allocation.
  *

Modified: branches/cleanconfig/numpy/core/setup.py
===================================================================
--- branches/cleanconfig/numpy/core/setup.py	2007-10-18 02:46:56 UTC (rev 4211)
+++ branches/cleanconfig/numpy/core/setup.py	2007-10-18 02:57:25 UTC (rev 4212)
@@ -73,8 +73,7 @@
                     nosmp = 1
                 except KeyError:
                     nosmp = 0
-            if nosmp: moredefs = [('NPY_ALLOW_THREADS', '0')]
-            else: moredefs = []
+            moredefs = []
             #
             mathlibs = []
             tc = testcode_mathlib()
@@ -123,8 +122,12 @@
                     target_f.write('#define %s\n' % (d))
                 else:
                     target_f.write('#define %s %s\n' % (d[0],d[1]))
-            if not nosmp:  # default is to use WITH_THREAD
-                target_f.write('#ifdef WITH_THREAD\n#define NPY_ALLOW_THREADS 1\n#else\n#define NPY_ALLOW_THREADS 0\n#endif\n')
+            # Define NPY_NOSMP to 1 if explicitely requested, or if we cannot
+            # support thread support reliably
+            if nosmp:
+                target_f.write('#define NPY_NOSMP 1\n')
+            else:
+                target_f.write('#define NPY_NOSMP 0\n')
             target_f.close()
             print 'File:',target
             target_f = open(target)



More information about the Numpy-svn mailing list