[Numpy-svn] r5608 - in trunk/numpy/core: . include/numpy

numpy-svn@scip... numpy-svn@scip...
Mon Aug 4 23:11:17 CDT 2008


Author: cdavid
Date: 2008-08-04 23:11:11 -0500 (Mon, 04 Aug 2008)
New Revision: 5608

Modified:
   trunk/numpy/core/SConscript
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/include/numpy/numpyconfig.h.in
   trunk/numpy/core/setup.py
Log:
Use C99 print formatting if available for NPY_INTP.

Modified: trunk/numpy/core/SConscript
===================================================================
--- trunk/numpy/core/SConscript	2008-08-04 20:16:48 UTC (rev 5607)
+++ trunk/numpy/core/SConscript	2008-08-05 04:11:11 UTC (rev 5608)
@@ -1,4 +1,4 @@
-# Last Change: Mon Jul 28 03:00 PM 2008 J
+# Last Change: Tue Aug 05 12:00 PM 2008 J
 # vim:syntax=python
 import os
 import sys
@@ -98,6 +98,15 @@
     nosmp = 0
 numpyconfig_sym.append(('NPY_NO_SMP', nosmp))
 
+#----------------------------------------------
+# Check whether we can use C99 printing formats
+#----------------------------------------------
+if config.CheckDeclaration(('PRIdPTR'), includes  = '#include <inttypes.h>'):
+    usec99 = 1
+else:
+    usec99 = 0
+numpyconfig_sym.append(('USE_C99_FORMATS', usec99))
+    
 #----------------------
 # Checking the mathlib
 #----------------------

Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2008-08-04 20:16:48 UTC (rev 5607)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2008-08-05 04:11:11 UTC (rev 5608)
@@ -971,6 +971,13 @@
         #define NPY_INTP_FMT "Ld"
 #endif
 
+/* We can only use C99 formats for npy_int_p if it is the same as intp_t, hence
+ * the condition on HAVE_UNITPTR_T */
+#if NPY_USE_C99_FORMATS == 1 && HAVE_UINTPRT_T
+        #undef NPY_INTP_FMT
+        #define NPY_INTP_FMT PRIdPTR
+#endif
+
 #define NPY_ERR(str) fprintf(stderr, #str); fflush(stderr);
 #define NPY_ERR2(str) fprintf(stderr, str); fflush(stderr);
 

Modified: trunk/numpy/core/include/numpy/numpyconfig.h.in
===================================================================
--- trunk/numpy/core/include/numpy/numpyconfig.h.in	2008-08-04 20:16:48 UTC (rev 5607)
+++ trunk/numpy/core/include/numpy/numpyconfig.h.in	2008-08-05 04:11:11 UTC (rev 5608)
@@ -14,3 +14,5 @@
 
 @DEFINE_NPY_SIZEOF_LONGLONG@
 @DEFINE_NPY_SIZEOF_PY_LONG_LONG@
+
+#define NPY_USE_C99_FORMATS @USE_C99_FORMATS@

Modified: trunk/numpy/core/setup.py
===================================================================
--- trunk/numpy/core/setup.py	2008-08-04 20:16:48 UTC (rev 5607)
+++ trunk/numpy/core/setup.py	2008-08-05 04:11:11 UTC (rev 5608)
@@ -189,6 +189,24 @@
                 raise SystemError,"Failed to generate numpy configuration. "\
                       "See previous error messages for more information."
 
+            moredefs = []
+            
+            # Check wether we can use inttypes (C99) formats
+            if config_cmd.check_decl('PRIdPTR', headers = ['inttypes.h']):
+                moredefs.append(('NPY_USE_C99_FORMATS', 1))
+            else:
+                moredefs.append(('NPY_USE_C99_FORMATS', 0))
+
+            # Add moredefs to header
+            target_f = open(target,'a')
+            for d in moredefs:
+                if isinstance(d,str):
+                    target_f.write('#define %s\n' % (d))
+                else:
+                    target_f.write('#define %s %s\n' % (d[0],d[1]))
+            target_f.close()
+
+            # Dump the numpyconfig.h header to stdout
             print 'File: %s' % target
             target_f = open(target)
             print target_f.read()



More information about the Numpy-svn mailing list