sched.h can exist without sched affinity support
This commit is contained in:
parent
94b580d423
commit
2740af8cc4
|
@ -831,6 +831,8 @@ class PosixTester(unittest.TestCase):
|
|||
|
||||
requires_sched_h = unittest.skipUnless(hasattr(posix, 'sched_yield'),
|
||||
"don't have scheduling support")
|
||||
requires_sched_affinity = unittest.skipUnless(hasattr(posix, 'cpu_set'),
|
||||
"dont' have sched affinity support")
|
||||
|
||||
@requires_sched_h
|
||||
def test_sched_yield(self):
|
||||
|
@ -888,7 +890,7 @@ class PosixTester(unittest.TestCase):
|
|||
self.assertGreaterEqual(interval, 0.)
|
||||
self.assertLess(interval, 1.)
|
||||
|
||||
@requires_sched_h
|
||||
@requires_sched_affinity
|
||||
def test_sched_affinity(self):
|
||||
mask = posix.sched_getaffinity(0, 1024)
|
||||
self.assertGreaterEqual(mask.count(), 1)
|
||||
|
@ -899,7 +901,7 @@ class PosixTester(unittest.TestCase):
|
|||
self.assertRaises(OSError, posix.sched_setaffinity, 0, empty)
|
||||
self.assertRaises(OSError, posix.sched_setaffinity, -1, mask)
|
||||
|
||||
@requires_sched_h
|
||||
@requires_sched_affinity
|
||||
def test_cpu_set_basic(self):
|
||||
s = posix.cpu_set(10)
|
||||
self.assertEqual(len(s), 10)
|
||||
|
@ -924,7 +926,7 @@ class PosixTester(unittest.TestCase):
|
|||
self.assertRaises(ValueError, s.isset, -1)
|
||||
self.assertRaises(ValueError, s.isset, 10)
|
||||
|
||||
@requires_sched_h
|
||||
@requires_sched_affinity
|
||||
def test_cpu_set_cmp(self):
|
||||
self.assertNotEqual(posix.cpu_set(11), posix.cpu_set(12))
|
||||
l = posix.cpu_set(10)
|
||||
|
@ -935,7 +937,7 @@ class PosixTester(unittest.TestCase):
|
|||
r.set(1)
|
||||
self.assertEqual(l, r)
|
||||
|
||||
@requires_sched_h
|
||||
@requires_sched_affinity
|
||||
def test_cpu_set_bitwise(self):
|
||||
l = posix.cpu_set(5)
|
||||
l.set(0)
|
||||
|
|
|
@ -4753,6 +4753,8 @@ posix_sched_yield(PyObject *self, PyObject *noargs)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SCHED_SETAFFINITY
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD;
|
||||
Py_ssize_t size;
|
||||
|
@ -5083,6 +5085,8 @@ posix_sched_getaffinity(PyObject *self, PyObject *args)
|
|||
return (PyObject *)res;
|
||||
}
|
||||
|
||||
#endif /* HAVE_SCHED_SETAFFINITY */
|
||||
|
||||
#endif /* HAVE_SCHED_H */
|
||||
|
||||
/* AIX uses /dev/ptc but is otherwise the same as /dev/ptmx */
|
||||
|
@ -10056,9 +10060,11 @@ static PyMethodDef posix_methods[] = {
|
|||
{"sched_setparam", posix_sched_setparam, METH_VARARGS, posix_sched_setparam__doc__},
|
||||
{"sched_setscheduler", posix_sched_setscheduler, METH_VARARGS, posix_sched_setscheduler__doc__},
|
||||
{"sched_yield", posix_sched_yield, METH_NOARGS, posix_sched_yield__doc__},
|
||||
#ifdef HAVE_SCHED_SETAFFINITY
|
||||
{"sched_setaffinity", posix_sched_setaffinity, METH_VARARGS, posix_sched_setaffinity__doc__},
|
||||
{"sched_getaffinity", posix_sched_getaffinity, METH_VARARGS, posix_sched_getaffinity__doc__},
|
||||
#endif
|
||||
#endif
|
||||
#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 */
|
||||
|
@ -10876,10 +10882,12 @@ INITFUNC(void)
|
|||
Py_INCREF(PyExc_OSError);
|
||||
PyModule_AddObject(m, "error", PyExc_OSError);
|
||||
|
||||
#ifdef HAVE_SCHED_SETAFFINITY
|
||||
if (PyType_Ready(&cpu_set_type) < 0)
|
||||
return NULL;
|
||||
Py_INCREF(&cpu_set_type);
|
||||
PyModule_AddObject(m, "cpu_set", (PyObject *)&cpu_set_type);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PUTENV
|
||||
if (posix_putenv_garbage == NULL)
|
||||
|
|
|
@ -9339,6 +9339,7 @@ for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
|
|||
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 \
|
||||
sigaction sigaltstack siginterrupt sigpending sigrelse \
|
||||
sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
|
||||
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
|
||||
|
|
|
@ -2537,6 +2537,7 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
|
|||
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 \
|
||||
sigaction sigaltstack siginterrupt sigpending sigrelse \
|
||||
sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
|
||||
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
|
||||
|
|
|
@ -653,6 +653,9 @@
|
|||
/* Define to 1 if you have the <sched.h> header file. */
|
||||
#undef HAVE_SCHED_H
|
||||
|
||||
/* Define to 1 if you have the `sched_setaffinity' function. */
|
||||
#undef HAVE_SCHED_SETAFFINITY
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
|
|
Loading…
Reference in New Issue