[Python-checkins] r45960 - python/trunk/configure python/trunk/configure.in python/trunk/pyconfig.h.in

brett.cannon python-checkins at python.org
Thu May 11 07:11:34 CEST 2006


Author: brett.cannon
Date: Thu May 11 07:11:33 2006
New Revision: 45960

Modified:
   python/trunk/configure
   python/trunk/configure.in
   python/trunk/pyconfig.h.in
Log:
Detect if %zd is supported by printf() during configure and sets
PY_SIZE_FORMAT_T appropriately.  Removes warnings on
OS X under gcc 4.0.1 when PY_SIZE_FORMAT_T is set to "" instead of "z" as is
needed.


Modified: python/trunk/configure
==============================================================================
--- python/trunk/configure	(original)
+++ python/trunk/configure	Thu May 11 07:11:33 2006
@@ -21732,6 +21732,68 @@
 echo "${ECHO_T}no" >&6
 fi
 
+echo "$as_me:$LINENO: checking for %zd printf() format support" >&5
+echo $ECHO_N "checking for %zd printf() format support... $ECHO_C" >&6
+if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+int main()
+{
+    char buffer[4];
+
+    if(sprintf(buffer, "%zd", (size_t)123) < 0)
+       	return 1;
+
+    if (strncmp(buffer, "123", 3))
+	return 1;
+
+    return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define PY_FORMAT_SIZE_T "z"
+_ACEOF
+
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
 echo "$as_me:$LINENO: checking for socklen_t" >&5
 echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6
 if test "${ac_cv_type_socklen_t+set}" = set; then

Modified: python/trunk/configure.in
==============================================================================
--- python/trunk/configure.in	(original)
+++ python/trunk/configure.in	Thu May 11 07:11:33 2006
@@ -3247,6 +3247,27 @@
   AC_MSG_RESULT(no)
 fi
 
+AC_MSG_CHECKING(for %zd printf() format support)
+AC_TRY_RUN([#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+int main()
+{
+    char buffer[4];
+
+    if(sprintf(buffer, "%zd", (size_t)123) < 0)
+       	return 1;
+
+    if (strncmp(buffer, "123", 3))
+	return 1;
+    
+    return 0;
+}],
+[AC_MSG_RESULT(yes)
+ AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
+ AC_MSG_RESULT(no))
+
 AC_CHECK_TYPE(socklen_t,,
   AC_DEFINE(socklen_t,int,
             Define to `int' if <sys/socket.h> does not define.),[

Modified: python/trunk/pyconfig.h.in
==============================================================================
--- python/trunk/pyconfig.h.in	(original)
+++ python/trunk/pyconfig.h.in	Thu May 11 07:11:33 2006
@@ -727,6 +727,9 @@
 /* Defined if PTHREAD_SCOPE_SYSTEM supported. */
 #undef PTHREAD_SYSTEM_SCHED_SUPPORTED
 
+/* Define to printf format modifier for Py_ssize_t */
+#undef PY_FORMAT_SIZE_T
+
 /* Define as the integral type used for Unicode representation. */
 #undef PY_UNICODE_TYPE
 


More information about the Python-checkins mailing list