[Python-checkins] r70584 - in python/branches/multiprocessing-autoconf: Lib/test/test_multiprocessing.py configure configure.in pyconfig.h.in setup.py
christian.heimes
python-checkins at python.org
Tue Mar 24 22:11:11 CET 2009
Author: christian.heimes
Date: Tue Mar 24 22:11:10 2009
New Revision: 70584
Log:
Replaced hard coded values with autoconf rules.
Modified:
python/branches/multiprocessing-autoconf/Lib/test/test_multiprocessing.py
python/branches/multiprocessing-autoconf/configure
python/branches/multiprocessing-autoconf/configure.in
python/branches/multiprocessing-autoconf/pyconfig.h.in
python/branches/multiprocessing-autoconf/setup.py
Modified: python/branches/multiprocessing-autoconf/Lib/test/test_multiprocessing.py
==============================================================================
--- python/branches/multiprocessing-autoconf/Lib/test/test_multiprocessing.py (original)
+++ python/branches/multiprocessing-autoconf/Lib/test/test_multiprocessing.py Tue Mar 24 22:11:10 2009
@@ -1801,6 +1801,58 @@
multiprocessing.connection.answer_challenge,
_FakeConnection(), b'abc')
+ def test_macros(self):
+ platform = sys.platform
+ if platform == "win32":
+ macros = dict(
+ )
+ elif platform == 'darwin': # Mac OSX
+ macros = dict(
+ HAVE_SEM_OPEN=1,
+ HAVE_SEM_TIMEDWAIT=0,
+ HAVE_FD_TRANSFER=1,
+ HAVE_BROKEN_SEM_GETVALUE=1
+ )
+ elif platform == 'cygwin': # Cygwin
+ macros = dict(
+ HAVE_SEM_OPEN=1,
+ HAVE_SEM_TIMEDWAIT=1,
+ HAVE_FD_TRANSFER=0,
+ HAVE_BROKEN_SEM_UNLINK=1
+ )
+ elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
+ # FreeBSD's P1003.1b semaphore support is very experimental
+ # and has many known problems. (as of June 2008)
+ macros = dict( # FreeBSD
+ HAVE_SEM_OPEN=0,
+ HAVE_SEM_TIMEDWAIT=0,
+ HAVE_FD_TRANSFER=1,
+ )
+ elif platform.startswith('openbsd'):
+ macros = dict( # OpenBSD
+ HAVE_SEM_OPEN=0, # Not implemented
+ HAVE_SEM_TIMEDWAIT=0,
+ HAVE_FD_TRANSFER=1,
+ )
+ else: # Linux and other unices
+ macros = dict(
+ HAVE_SEM_OPEN=1,
+ HAVE_SEM_TIMEDWAIT=1,
+ HAVE_FD_TRANSFER=1
+ )
+ flags = ['HAVE_SEM_OPEN', 'HAVE_BROKEN_SEM_GETVALUE',
+ 'HAVE_FD_TRANSFER', 'HAVE_BROKEN_SEM_UNLINK',
+ 'HAVE_SEM_TIMEDWAIT']
+
+ for name in flags:
+ mp_flag = _multiprocessing.flags.get(name, 0)
+ plat_flag = macros.get(name, 0)
+ self.assertEqual(mp_flag, plat_flag,
+ "%s: expected %i, got %i" %
+ (name, mp_flag, plat_flag)
+ )
+
+
testcases_other = [OtherTest, TestInvalidHandle]
#
Modified: python/branches/multiprocessing-autoconf/configure
==============================================================================
--- python/branches/multiprocessing-autoconf/configure (original)
+++ python/branches/multiprocessing-autoconf/configure Tue Mar 24 22:11:10 2009
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 68312 .
+# From configure.in Revision: 70479 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 2.7.
#
@@ -25187,6 +25187,224 @@
fi
+###
+# multiprocessing specific tests
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BROKEN_SEM_UNLINK 0
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BROKEN_SEM_GETVALUE 0
+_ACEOF
+
+
+{ echo "$as_me:$LINENO: checking for sem_open" >&5
+echo $ECHO_N "checking for sem_open... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <semaphore.h>
+int
+main ()
+{
+void *x=sem_open
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SEM_OPEN 1
+_ACEOF
+
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_SEM_OPEN 0
+_ACEOF
+
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ echo "$as_me:$LINENO: checking for sem_timedwait" >&5
+echo $ECHO_N "checking for sem_timedwait... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <semaphore.h>
+int
+main ()
+{
+void *x=sem_timedwait
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SEM_TIMEDWAIT 1
+_ACEOF
+
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_SEM_TIMEDWAIT 0
+_ACEOF
+
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ echo "$as_me:$LINENO: checking for sendmsg (fd transfer)" >&5
+echo $ECHO_N "checking for sendmsg (fd transfer)... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/socket.h>
+int
+main ()
+{
+void *x; size_t s; struct msghdr msg; struct cmsghdr *cmsg;
+ x=sendmsg;
+ s = CMSG_SPACE(CMSG_LEN(sizeof(int)));
+ cmsg = CMSG_FIRSTHDR(&msg);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FD_TRANSFER 1
+_ACEOF
+
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_FD_TRANSFER 0.
+_ACEOF
+
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+case $ac_sys_system/$ac_sys_release in
+ FreeBSD/4.*|FreeBSD/5.*|FreeBSD/6.*|FreeBSD/7.*|FreeBSD/8.*)
+ # FreeBSD's P1003.1b semaphore support is very experimental
+ # and has many known problems. (as of June 2008)
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_SEM_OPEN 0
+_ACEOF
+
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_SEM_TIMEDWAIT 0
+_ACEOF
+
+ ;;
+esac
+
+case $ac_sys_system in
+ CYGWIN*)
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_BROKEN_SEM_UNLINK 1
+_ACEOF
+
+ ;;
+ Darwin*)
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_BROKEN_SEM_GETVALUE 1
+_ACEOF
+
+ ;;
+esac
+
+# end of multiprocessing
+###
+
for h in `(cd $srcdir;echo Python/thread_*.h)`
Modified: python/branches/multiprocessing-autoconf/configure.in
==============================================================================
--- python/branches/multiprocessing-autoconf/configure.in (original)
+++ python/branches/multiprocessing-autoconf/configure.in Tue Mar 24 22:11:10 2009
@@ -3766,6 +3766,61 @@
#endif
])
+###
+# multiprocessing specific tests
+AC_DEFINE(HAVE_BROKEN_SEM_UNLINK, 0, Define if 'sem_unlink' is broken on your platform)
+AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 0, Define if 'sem_getvalue' is broken on your platform)
+
+AC_MSG_CHECKING(for sem_open)
+AC_TRY_COMPILE([#include <semaphore.h>], void *x=sem_open,
+ AC_DEFINE(HAVE_SEM_OPEN, 1, Define if you have the 'sem_open' function.)
+ AC_MSG_RESULT(yes),
+ AC_DEFINE(HAVE_SEM_OPEN, 0)
+ AC_MSG_RESULT(no)
+)
+
+AC_MSG_CHECKING(for sem_timedwait)
+AC_TRY_COMPILE([#include <semaphore.h>], void *x=sem_timedwait,
+ AC_DEFINE(HAVE_SEM_TIMEDWAIT, 1, Define if you have the 'sem_timedwait' function.)
+ AC_MSG_RESULT(yes),
+ AC_DEFINE(HAVE_SEM_TIMEDWAIT, 0)
+ AC_MSG_RESULT(no)
+)
+
+AC_MSG_CHECKING(for sendmsg (fd transfer))
+AC_TRY_COMPILE([#include <sys/socket.h>],
+ void *x; size_t s; struct msghdr msg; struct cmsghdr *cmsg;
+ x=sendmsg;
+ s = CMSG_SPACE(CMSG_LEN(sizeof(int)));
+ cmsg = CMSG_FIRSTHDR(&msg);
+ ,
+ AC_DEFINE(HAVE_FD_TRANSFER, 1, Define if you have the 'sendmsg' function for fd transfer.)
+ AC_MSG_RESULT(yes),
+ AC_DEFINE(HAVE_FD_TRANSFER, 0.)
+ AC_MSG_RESULT(no)
+)
+
+case $ac_sys_system/$ac_sys_release in
+ FreeBSD/4.*|FreeBSD/5.*|FreeBSD/6.*|FreeBSD/7.*|FreeBSD/8.*)
+ # FreeBSD's P1003.1b semaphore support is very experimental
+ # and has many known problems. (as of June 2008)
+ AC_DEFINE(HAVE_SEM_OPEN, 0)
+ AC_DEFINE(HAVE_SEM_TIMEDWAIT, 0)
+ ;;
+esac
+
+case $ac_sys_system in
+ CYGWIN*)
+ AC_DEFINE(HAVE_BROKEN_SEM_UNLINK, 1)
+ ;;
+ Darwin*)
+ AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1)
+ ;;
+esac
+
+# end of multiprocessing
+###
+
AC_SUBST(THREADHEADERS)
for h in `(cd $srcdir;echo Python/thread_*.h)`
Modified: python/branches/multiprocessing-autoconf/pyconfig.h.in
==============================================================================
--- python/branches/multiprocessing-autoconf/pyconfig.h.in (original)
+++ python/branches/multiprocessing-autoconf/pyconfig.h.in Tue Mar 24 22:11:10 2009
@@ -73,6 +73,12 @@
/* Define if pthread_sigmask() does not work on your system. */
#undef HAVE_BROKEN_PTHREAD_SIGMASK
+/* Define if 'sem_getvalue' is broken on your platform */
+#undef HAVE_BROKEN_SEM_GETVALUE
+
+/* Define if 'sem_unlink' is broken on your platform */
+#undef HAVE_BROKEN_SEM_UNLINK
+
/* Define this if you have the type _Bool. */
#undef HAVE_C99_BOOL
@@ -186,6 +192,9 @@
/* Define if you have the 'fdatasync' function. */
#undef HAVE_FDATASYNC
+/* Define if you have the 'sendmsg' function for fd transfer. */
+#undef HAVE_FD_TRANSFER
+
/* Define to 1 if you have the `finite' function. */
#undef HAVE_FINITE
@@ -504,6 +513,12 @@
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
+/* Define if you have the 'sem_open' function. */
+#undef HAVE_SEM_OPEN
+
+/* Define if you have the 'sem_timedwait' function. */
+#undef HAVE_SEM_TIMEDWAIT
+
/* Define to 1 if you have the `setegid' function. */
#undef HAVE_SETEGID
Modified: python/branches/multiprocessing-autoconf/setup.py
==============================================================================
--- python/branches/multiprocessing-autoconf/setup.py (original)
+++ python/branches/multiprocessing-autoconf/setup.py Tue Mar 24 22:11:10 2009
@@ -1240,55 +1240,11 @@
self.detect_ctypes(inc_dirs, lib_dirs)
# Richard Oudkerk's multiprocessing module
- if platform == 'win32': # Windows
- macros = dict()
- libraries = ['ws2_32']
-
- elif platform == 'darwin': # Mac OSX
- macros = dict(
- HAVE_SEM_OPEN=1,
- HAVE_SEM_TIMEDWAIT=0,
- HAVE_FD_TRANSFER=1,
- HAVE_BROKEN_SEM_GETVALUE=1
- )
- libraries = []
-
- elif platform == 'cygwin': # Cygwin
- macros = dict(
- HAVE_SEM_OPEN=1,
- HAVE_SEM_TIMEDWAIT=1,
- HAVE_FD_TRANSFER=0,
- HAVE_BROKEN_SEM_UNLINK=1
- )
- libraries = []
-
- elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
- # FreeBSD's P1003.1b semaphore support is very experimental
- # and has many known problems. (as of June 2008)
- macros = dict( # FreeBSD
- HAVE_SEM_OPEN=0,
- HAVE_SEM_TIMEDWAIT=0,
- HAVE_FD_TRANSFER=1,
- )
- libraries = []
-
- elif platform.startswith('openbsd'):
- macros = dict( # OpenBSD
- HAVE_SEM_OPEN=0, # Not implemented
- HAVE_SEM_TIMEDWAIT=0,
- HAVE_FD_TRANSFER=1,
- )
- libraries = []
-
- else: # Linux and other unices
- macros = dict(
- HAVE_SEM_OPEN=1,
- HAVE_SEM_TIMEDWAIT=1,
- HAVE_FD_TRANSFER=1
- )
- libraries = ['rt']
+ macros = {}
+ libraries = [] # some platforms may require 'rt'
if platform == 'win32':
+ libraries = ['ws2_32']
multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
'_multiprocessing/semaphore.c',
'_multiprocessing/pipe_connection.c',
@@ -1301,7 +1257,7 @@
'_multiprocessing/socket_connection.c'
]
- if macros.get('HAVE_SEM_OPEN', False):
+ if sysconfig.get_config_var("HAVE_SEM_OPEN"):
multiprocessing_srcs.append('_multiprocessing/semaphore.c')
if sysconfig.get_config_var('WITH_THREAD'):
More information about the Python-checkins
mailing list