Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea0d5fc

Browse files
author
Charles-François Natali
committed
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.
1 parent e0afb16 commit ea0d5fc

5 files changed

Lines changed: 299 additions & 309 deletions

File tree

Lib/test/test_posix.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ def test_sched_yield(self):
840840
posix.sched_yield()
841841

842842
@requires_sched_h
843+
@unittest.skipUnless(hasattr(posix, 'sched_get_priority_max'),
844+
"requires sched_get_priority_max()")
843845
def test_sched_priority(self):
844846
# Round-robin usually has interesting priorities.
845847
pol = posix.SCHED_RR

Modules/posixmodule.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4555,6 +4555,8 @@ posix_fork(PyObject *self, PyObject *noargs)
45554555

45564556
#ifdef HAVE_SCHED_H
45574557

4558+
#ifdef HAVE_SCHED_GET_PRIORITY_MAX
4559+
45584560
PyDoc_STRVAR(posix_sched_get_priority_max__doc__,
45594561
"sched_get_priority_max(policy)\n\n\
45604562
Get the maximum scheduling priority for *policy*.");
@@ -4589,6 +4591,8 @@ posix_sched_get_priority_min(PyObject *self, PyObject *args)
45894591
return PyLong_FromLong(min);
45904592
}
45914593

4594+
#endif /* HAVE_SCHED_GET_PRIORITY_MAX */
4595+
45924596
#ifdef HAVE_SCHED_SETSCHEDULER
45934597

45944598
PyDoc_STRVAR(posix_sched_getscheduler__doc__,
@@ -10452,8 +10456,10 @@ static PyMethodDef posix_methods[] = {
1045210456
{"fork", posix_fork, METH_NOARGS, posix_fork__doc__},
1045310457
#endif /* HAVE_FORK */
1045410458
#ifdef HAVE_SCHED_H
10459+
#ifdef HAVE_SCHED_GET_PRIORITY_MAX
1045510460
{"sched_get_priority_max", posix_sched_get_priority_max, METH_VARARGS, posix_sched_get_priority_max__doc__},
1045610461
{"sched_get_priority_min", posix_sched_get_priority_min, METH_VARARGS, posix_sched_get_priority_min__doc__},
10462+
#endif
1045710463
#ifdef HAVE_SCHED_SETPARAM
1045810464
{"sched_getparam", posix_sched_getparam, METH_VARARGS, posix_sched_getparam__doc__},
1045910465
#endif
@@ -10474,7 +10480,7 @@ static PyMethodDef posix_methods[] = {
1047410480
{"sched_setaffinity", posix_sched_setaffinity, METH_VARARGS, posix_sched_setaffinity__doc__},
1047510481
{"sched_getaffinity", posix_sched_getaffinity, METH_VARARGS, posix_sched_getaffinity__doc__},
1047610482
#endif
10477-
#endif
10483+
#endif /* HAVE_SCHED_H */
1047810484
#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)
1047910485
{"openpty", posix_openpty, METH_NOARGS, posix_openpty__doc__},
1048010486
#endif /* HAVE_OPENPTY || HAVE__GETPTY || HAVE_DEV_PTMX */

0 commit comments

Comments
 (0)