Charles-François Natali <neolo...@free.fr> added the comment:
Here's a patch adding a configure-time check. Since the functions are
checked without being linked explicitely with pthread, it should do
the trick (I couldn't test it on OpenBSD though).
I also added a skipTest to test_posix.test_sched_priority().
----------
keywords: +patch
title: Disable sched_get_priority_min/max if Python is compiled without threads
-> Disable sched_get_priority_min/max if Python is compiled without threads
Added file: http://bugs.python.org/file23097/sched_get_priority.diff
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12871>
_______________________________________
diff -r a29b72950795 Lib/test/test_posix.py
--- a/Lib/test/test_posix.py Thu Sep 01 23:08:21 2011 +0200
+++ b/Lib/test/test_posix.py Sat Sep 03 18:08:01 2011 +0200
@@ -840,6 +840,8 @@
posix.sched_yield()
@requires_sched_h
+ @unittest.skipUnless(hasattr(posix, 'sched_get_priority_max'),
+ "requires sched_get_priority_max()")
def test_sched_priority(self):
# Round-robin usually has interesting priorities.
pol = posix.SCHED_RR
diff -r a29b72950795 Modules/posixmodule.c
--- a/Modules/posixmodule.c Thu Sep 01 23:08:21 2011 +0200
+++ b/Modules/posixmodule.c Sat Sep 03 18:08:01 2011 +0200
@@ -4555,6 +4555,8 @@
#ifdef HAVE_SCHED_H
+#ifdef HAVE_SCHED_GET_PRIORITY_MAX
+
PyDoc_STRVAR(posix_sched_get_priority_max__doc__,
"sched_get_priority_max(policy)\n\n\
Get the maximum scheduling priority for *policy*.");
@@ -4589,6 +4591,8 @@
return PyLong_FromLong(min);
}
+#endif /* HAVE_SCHED_GET_PRIORITY_MAX */
+
#ifdef HAVE_SCHED_SETSCHEDULER
PyDoc_STRVAR(posix_sched_getscheduler__doc__,
@@ -10452,8 +10456,10 @@
{"fork", posix_fork, METH_NOARGS, posix_fork__doc__},
#endif /* HAVE_FORK */
#ifdef HAVE_SCHED_H
+#ifdef HAVE_SCHED_GET_PRIORITY_MAX
{"sched_get_priority_max", posix_sched_get_priority_max, METH_VARARGS,
posix_sched_get_priority_max__doc__},
{"sched_get_priority_min", posix_sched_get_priority_min, METH_VARARGS,
posix_sched_get_priority_min__doc__},
+#endif
#ifdef HAVE_SCHED_SETPARAM
{"sched_getparam", posix_sched_getparam, METH_VARARGS,
posix_sched_getparam__doc__},
#endif
@@ -10474,7 +10480,7 @@
{"sched_setaffinity", posix_sched_setaffinity, METH_VARARGS,
posix_sched_setaffinity__doc__},
{"sched_getaffinity", posix_sched_getaffinity, METH_VARARGS,
posix_sched_getaffinity__doc__},
#endif
-#endif
+#endif /* HAVE_SCHED_H */
#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)
{"openpty", posix_openpty, METH_NOARGS, posix_openpty__doc__},
#endif /* HAVE_OPENPTY || HAVE__GETPTY || HAVE_DEV_PTMX */
diff -r a29b72950795 configure.in
--- a/configure.in Thu Sep 01 23:08:21 2011 +0200
+++ b/configure.in Sat Sep 03 18:08:01 2011 +0200
@@ -2538,7 +2538,8 @@
select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid
seteuid \
setgid sethostname \
setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp
setpriority setuid setvbuf \
- sched_setaffinity sched_setscheduler sched_setparam sched_rr_get_interval \
+ sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
+ sched_rr_get_interval \
sigaction sigaltstack siginterrupt sigpending sigrelse \
sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com