Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2740af8c
Commit
2740af8c
authored
Aug 02, 2011
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sched.h can exist without sched affinity support
parent
94b580d4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
4 deletions
+19
-4
Lib/test/test_posix.py
Lib/test/test_posix.py
+6
-4
Modules/posixmodule.c
Modules/posixmodule.c
+8
-0
configure
configure
+1
-0
configure.in
configure.in
+1
-0
pyconfig.h.in
pyconfig.h.in
+3
-0
No files found.
Lib/test/test_posix.py
View file @
2740af8c
...
...
@@ -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
)
...
...
Modules/posixmodule.c
View file @
2740af8c
...
...
@@ -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
)
...
...
configure
View file @
2740af8c
...
...
@@ -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
\
...
...
configure.in
View file @
2740af8c
...
...
@@ -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 \
...
...
pyconfig.h.in
View file @
2740af8c
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment