diff --git a/configure b/configure index e05fad61044..6297d9f1c66 100755 --- a/configure +++ b/configure @@ -21732,6 +21732,68 @@ else 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 +#include +#include + +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 diff --git a/configure.in b/configure.in index e2dae9d4843..168c621aeb7 100644 --- a/configure.in +++ b/configure.in @@ -3247,6 +3247,27 @@ else AC_MSG_RESULT(no) fi +AC_MSG_CHECKING(for %zd printf() format support) +AC_TRY_RUN([#include +#include +#include + +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 does not define.),[ diff --git a/pyconfig.h.in b/pyconfig.h.in index 886b3368660..acbbd8d23f9 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -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