[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 5c8b6e03ebfe by Charles-François Natali in branch 'default': Issue #12871: sched_get_priority_(min|max) might not be defined even though http://hg.python.org/cpython/rev/5c8b6e03ebfe -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
Changes by Charles-François Natali neolo...@free.fr: -- resolution: - fixed stage: - committed/rejected status: open - closed type: - compile error ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
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.pyThu Sep 01 23:08:21 2011 +0200 +++ b/Lib/test/test_posix.pySat 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
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
Remi Pointel pyt...@xiri.fr added the comment: Hi, it seems to solve the problem (tested on OpenBSD 4.9 and OpenBSD-current). * test_posix.py on OpenBSD 4.9: [...] Ran 79 tests in 0.508s OK (skipped=35) * test_posix.py on OpenBSD-current: it continues to segfault, but I have opened an other ticket for this problem (issue 12852). Thanks a lot, Remi. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
STINNER Victor victor.stin...@haypocalc.com added the comment: It builds correctly with -pthread or -lpthread, but it fails to build without these options. Not on Linux: this is specific to OpenBSD. Oh, I forgot to specify: yes, I tested on OpenBSD (5.0). sched_get_priority_max() and sched_get_priority_min() come from libpthread on OpenBSD, whereas Python only checks for #ifdef HAVE_SCHED_H. That's exactly what I said in my previous message ;-) I'll post a patch later. Yep, it's just that I have the confirmation with my tests. -- 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 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
STINNER Victor victor.stin...@haypocalc.com added the comment: For example, the following snippet builds correctly on Linux It builds correctly with -pthread or -lpthread, but it fails to build without these options. sched_get_priority_max() and sched_get_priority_min() come from libpthread on OpenBSD, whereas Python only checks for #ifdef HAVE_SCHED_H. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
Charles-François Natali neolo...@free.fr added the comment: It builds correctly with -pthread or -lpthread, but it fails to build without these options. Not on Linux: this is specific to OpenBSD. sched_get_priority_max() and sched_get_priority_min() come from libpthread on OpenBSD, whereas Python only checks for #ifdef HAVE_SCHED_H. That's exactly what I said in my previous message ;-) I'll post a patch later. -- title: Disable sched_get_priority_min/max on OpenBSD if Python is compiled without threads - Disable sched_get_priority_min/max if Python is compiled without threads ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
New submission from STINNER Victor victor.stin...@haypocalc.com: If Pyton is configured without thread support (--without-threads), the compilation fails on OpenBSD : $ make [...] ./Modules/posixmodule.c:4582: undefined reference to `sched_get_priority_min' libpython3.3m.a(posixmodule.o)(.text+0x430b): In function `posix_sched_get_priority_max': ./Modules/posixmodule.c:4565: undefined reference to `sched_get_priority_max' collect2: ld returned 1 exit status *** Error code 1 I didn't try on Linux, but I suppose that the issue is not specific to OpenBSD. -- components: Extension Modules messages: 143270 nosy: haypo, rpointel priority: normal severity: normal status: open title: Disable sched_get_priority_min/max if Python is compiled without threads versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
Nadeem Vawda nadeem.va...@gmail.com added the comment: I haven't been able to reproduce this on Linux (2.6.38; Ubuntu 11.04). Some searching around seems to suggest that OpenBSD doesn't provide those functions (or didn't until recently). Modules/posixmodule.c and configure.in seem to assume that these functions are available if sched.h exists. Adding an explicit check for them should solve the problem. -- nosy: +nadeem.vawda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12871] Disable sched_get_priority_min/max if Python is compiled without threads
Charles-François Natali neolo...@free.fr added the comment: There's no reason to disable sched_get_priority_(min|max) when Python is built without threads: those libraries control the scheduling policy, and should be available even without pthread. However, it's really likely that pthread has its own implementation (especially since OpenBSD's threads are implemented in user-space), and it seems that OpenBSD sched_get_priority() is only defined for threads: http://www.openbsd.org/cgi-bin/man.cgi?query=sched_get_priority_maxapropos=0sektion=0manpath=OpenBSD+Currentarch=i386format=html This implementation does not support process scheduling. For example, the following snippet builds correctly on Linux: #include sched.h int main(int argc, char *argv[]) { int (*fp)(int) = sched_get_priority_max; return 0; } So this should be skipped only on OpenBSD, or we should add some checks to the configure script. -- nosy: +neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com