Issue #12871: sched_get_priority_(min|max) might not be defined even though

<sched.h> is available (most notably on OpenBSD when built without pthread):
add an explicit configure check.
This commit is contained in:
Charles-François Natali 2011-09-06 19:03:35 +02:00
parent e0afb16a31
commit ea0d5fcb4a
5 changed files with 299 additions and 309 deletions

View File

@ -840,6 +840,8 @@ class PosixTester(unittest.TestCase):
posix.sched_yield() posix.sched_yield()
@requires_sched_h @requires_sched_h
@unittest.skipUnless(hasattr(posix, 'sched_get_priority_max'),
"requires sched_get_priority_max()")
def test_sched_priority(self): def test_sched_priority(self):
# Round-robin usually has interesting priorities. # Round-robin usually has interesting priorities.
pol = posix.SCHED_RR pol = posix.SCHED_RR

View File

@ -4555,6 +4555,8 @@ posix_fork(PyObject *self, PyObject *noargs)
#ifdef HAVE_SCHED_H #ifdef HAVE_SCHED_H
#ifdef HAVE_SCHED_GET_PRIORITY_MAX
PyDoc_STRVAR(posix_sched_get_priority_max__doc__, PyDoc_STRVAR(posix_sched_get_priority_max__doc__,
"sched_get_priority_max(policy)\n\n\ "sched_get_priority_max(policy)\n\n\
Get the maximum scheduling priority for *policy*."); Get the maximum scheduling priority for *policy*.");
@ -4589,6 +4591,8 @@ posix_sched_get_priority_min(PyObject *self, PyObject *args)
return PyLong_FromLong(min); return PyLong_FromLong(min);
} }
#endif /* HAVE_SCHED_GET_PRIORITY_MAX */
#ifdef HAVE_SCHED_SETSCHEDULER #ifdef HAVE_SCHED_SETSCHEDULER
PyDoc_STRVAR(posix_sched_getscheduler__doc__, PyDoc_STRVAR(posix_sched_getscheduler__doc__,
@ -10452,8 +10456,10 @@ static PyMethodDef posix_methods[] = {
{"fork", posix_fork, METH_NOARGS, posix_fork__doc__}, {"fork", posix_fork, METH_NOARGS, posix_fork__doc__},
#endif /* HAVE_FORK */ #endif /* HAVE_FORK */
#ifdef HAVE_SCHED_H #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_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__}, {"sched_get_priority_min", posix_sched_get_priority_min, METH_VARARGS, posix_sched_get_priority_min__doc__},
#endif
#ifdef HAVE_SCHED_SETPARAM #ifdef HAVE_SCHED_SETPARAM
{"sched_getparam", posix_sched_getparam, METH_VARARGS, posix_sched_getparam__doc__}, {"sched_getparam", posix_sched_getparam, METH_VARARGS, posix_sched_getparam__doc__},
#endif #endif
@ -10474,7 +10480,7 @@ static PyMethodDef posix_methods[] = {
{"sched_setaffinity", posix_sched_setaffinity, METH_VARARGS, posix_sched_setaffinity__doc__}, {"sched_setaffinity", posix_sched_setaffinity, METH_VARARGS, posix_sched_setaffinity__doc__},
{"sched_getaffinity", posix_sched_getaffinity, METH_VARARGS, posix_sched_getaffinity__doc__}, {"sched_getaffinity", posix_sched_getaffinity, METH_VARARGS, posix_sched_getaffinity__doc__},
#endif #endif
#endif #endif /* HAVE_SCHED_H */
#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)
{"openpty", posix_openpty, METH_NOARGS, posix_openpty__doc__}, {"openpty", posix_openpty, METH_NOARGS, posix_openpty__doc__},
#endif /* HAVE_OPENPTY || HAVE__GETPTY || HAVE_DEV_PTMX */ #endif /* HAVE_OPENPTY || HAVE__GETPTY || HAVE_DEV_PTMX */

592
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -2538,7 +2538,8 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \ select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \
setgid sethostname \ setgid sethostname \
setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \ 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 \ sigaction sigaltstack siginterrupt sigpending sigrelse \
sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \ sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \

View File

@ -653,6 +653,9 @@
/* Define to 1 if you have the `round' function. */ /* Define to 1 if you have the `round' function. */
#undef HAVE_ROUND #undef HAVE_ROUND
/* Define to 1 if you have the `sched_get_priority_max' function. */
#undef HAVE_SCHED_GET_PRIORITY_MAX
/* Define to 1 if you have the <sched.h> header file. */ /* Define to 1 if you have the <sched.h> header file. */
#undef HAVE_SCHED_H #undef HAVE_SCHED_H