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
d5a37549
Commit
d5a37549
authored
Mar 20, 2006
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to cleanup a lot of boilerplate #ifdef wrt wait types and make the code
more consistent (and smaller by 85 lines or so).
parent
49c65d02
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
143 deletions
+47
-143
Modules/posixmodule.c
Modules/posixmodule.c
+47
-143
No files found.
Modules/posixmodule.c
View file @
d5a37549
...
@@ -264,6 +264,12 @@ extern int lstat(const char *, struct stat *);
...
@@ -264,6 +264,12 @@ extern int lstat(const char *, struct stat *);
#define WTERMSIG(u_wait) ((u_wait).w_termsig)
#define WTERMSIG(u_wait) ((u_wait).w_termsig)
#endif
#endif
#define WAIT_TYPE union wait
#define WAIT_STATUS_INT(s) (s.w_status)
#else
/* !UNION_WAIT */
#define WAIT_TYPE int
#define WAIT_STATUS_INT(s) (s)
#endif
/* UNION_WAIT */
#endif
/* UNION_WAIT */
/* Don't use the "_r" form if we don't need it (also, won't have a
/* Don't use the "_r" form if we don't need it (also, won't have a
...
@@ -5159,15 +5165,8 @@ posix_wait3(PyObject *self, PyObject *args)
...
@@ -5159,15 +5165,8 @@ posix_wait3(PyObject *self, PyObject *args)
{
{
int
pid
,
options
;
int
pid
,
options
;
struct
rusage
ru
;
struct
rusage
ru
;
WAIT_TYPE
status
;
#ifdef UNION_WAIT
WAIT_STATUS_INT
(
status
)
=
0
;
union
wait
status
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:wait3"
,
&
options
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:wait3"
,
&
options
))
return
NULL
;
return
NULL
;
...
@@ -5176,8 +5175,7 @@ posix_wait3(PyObject *self, PyObject *args)
...
@@ -5176,8 +5175,7 @@ posix_wait3(PyObject *self, PyObject *args)
pid
=
wait3
(
&
status
,
options
,
&
ru
);
pid
=
wait3
(
&
status
,
options
,
&
ru
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
return
wait_helper
(
pid
,
status_i
,
&
ru
);
return
wait_helper
(
pid
,
WAIT_STATUS_INT
(
status
),
&
ru
);
#undef status_i
}
}
#endif
/* HAVE_WAIT3 */
#endif
/* HAVE_WAIT3 */
...
@@ -5191,15 +5189,8 @@ posix_wait4(PyObject *self, PyObject *args)
...
@@ -5191,15 +5189,8 @@ posix_wait4(PyObject *self, PyObject *args)
{
{
int
pid
,
options
;
int
pid
,
options
;
struct
rusage
ru
;
struct
rusage
ru
;
WAIT_TYPE
status
;
#ifdef UNION_WAIT
WAIT_STATUS_INT
(
status
)
=
0
;
union
wait
status
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"ii:wait4"
,
&
pid
,
&
options
))
if
(
!
PyArg_ParseTuple
(
args
,
"ii:wait4"
,
&
pid
,
&
options
))
return
NULL
;
return
NULL
;
...
@@ -5208,8 +5199,7 @@ posix_wait4(PyObject *self, PyObject *args)
...
@@ -5208,8 +5199,7 @@ posix_wait4(PyObject *self, PyObject *args)
pid
=
wait4
(
pid
,
&
status
,
options
,
&
ru
);
pid
=
wait4
(
pid
,
&
status
,
options
,
&
ru
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
return
wait_helper
(
pid
,
status_i
,
&
ru
);
return
wait_helper
(
pid
,
WAIT_STATUS_INT
(
status
),
&
ru
);
#undef status_i
}
}
#endif
/* HAVE_WAIT4 */
#endif
/* HAVE_WAIT4 */
...
@@ -5222,14 +5212,8 @@ static PyObject *
...
@@ -5222,14 +5212,8 @@ static PyObject *
posix_waitpid
(
PyObject
*
self
,
PyObject
*
args
)
posix_waitpid
(
PyObject
*
self
,
PyObject
*
args
)
{
{
int
pid
,
options
;
int
pid
,
options
;
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"ii:waitpid"
,
&
pid
,
&
options
))
if
(
!
PyArg_ParseTuple
(
args
,
"ii:waitpid"
,
&
pid
,
&
options
))
return
NULL
;
return
NULL
;
...
@@ -5238,8 +5222,8 @@ posix_waitpid(PyObject *self, PyObject *args)
...
@@ -5238,8 +5222,8 @@ posix_waitpid(PyObject *self, PyObject *args)
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
if
(
pid
==
-
1
)
if
(
pid
==
-
1
)
return
posix_error
();
return
posix_error
();
else
return
Py_BuildValue
(
"ii"
,
pid
,
status_i
);
return
Py_BuildValue
(
"ii"
,
pid
,
WAIT_STATUS_INT
(
status
)
);
}
}
#elif defined(HAVE_CWAIT)
#elif defined(HAVE_CWAIT)
...
@@ -5262,9 +5246,8 @@ posix_waitpid(PyObject *self, PyObject *args)
...
@@ -5262,9 +5246,8 @@ posix_waitpid(PyObject *self, PyObject *args)
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
if
(
pid
==
-
1
)
if
(
pid
==
-
1
)
return
posix_error
();
return
posix_error
();
else
/* shift the status left a byte so this is more like the
/* shift the status left a byte so this is more like the POSIX waitpid */
POSIX waitpid */
return
Py_BuildValue
(
"ii"
,
pid
,
status
<<
8
);
return
Py_BuildValue
(
"ii"
,
pid
,
status
<<
8
);
}
}
#endif
/* HAVE_WAITPID || HAVE_CWAIT */
#endif
/* HAVE_WAITPID || HAVE_CWAIT */
...
@@ -5278,23 +5261,16 @@ static PyObject *
...
@@ -5278,23 +5261,16 @@ static PyObject *
posix_wait
(
PyObject
*
self
,
PyObject
*
noargs
)
posix_wait
(
PyObject
*
self
,
PyObject
*
noargs
)
{
{
int
pid
;
int
pid
;
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
pid
=
wait
(
&
status
);
pid
=
wait
(
&
status
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
if
(
pid
==
-
1
)
if
(
pid
==
-
1
)
return
posix_error
();
return
posix_error
();
else
return
Py_BuildValue
(
"ii"
,
pid
,
status_i
);
return
Py_BuildValue
(
"ii"
,
pid
,
WAIT_STATUS_INT
(
status
));
#undef status_i
}
}
#endif
#endif
...
@@ -6132,22 +6108,13 @@ Return True if the process returning 'status' was dumped to a core file.");
...
@@ -6132,22 +6108,13 @@ Return True if the process returning 'status' was dumped to a core file.");
static
PyObject
*
static
PyObject
*
posix_WCOREDUMP
(
PyObject
*
self
,
PyObject
*
args
)
posix_WCOREDUMP
(
PyObject
*
self
,
PyObject
*
args
)
{
{
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:WCOREDUMP"
,
&
status_i
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:WCOREDUMP"
,
&
WAIT_STATUS_INT
(
status
)))
{
return
NULL
;
return
NULL
;
}
return
PyBool_FromLong
(
WCOREDUMP
(
status
));
return
PyBool_FromLong
(
WCOREDUMP
(
status
));
#undef status_i
}
}
#endif
/* WCOREDUMP */
#endif
/* WCOREDUMP */
...
@@ -6160,22 +6127,13 @@ job control stop.");
...
@@ -6160,22 +6127,13 @@ job control stop.");
static
PyObject
*
static
PyObject
*
posix_WIFCONTINUED
(
PyObject
*
self
,
PyObject
*
args
)
posix_WIFCONTINUED
(
PyObject
*
self
,
PyObject
*
args
)
{
{
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:WCONTINUED"
,
&
status_i
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:WCONTINUED"
,
&
WAIT_STATUS_INT
(
status
)))
{
return
NULL
;
return
NULL
;
}
return
PyBool_FromLong
(
WIFCONTINUED
(
status
));
return
PyBool_FromLong
(
WIFCONTINUED
(
status
));
#undef status_i
}
}
#endif
/* WIFCONTINUED */
#endif
/* WIFCONTINUED */
...
@@ -6187,22 +6145,13 @@ Return True if the process returning 'status' was stopped.");
...
@@ -6187,22 +6145,13 @@ Return True if the process returning 'status' was stopped.");
static
PyObject
*
static
PyObject
*
posix_WIFSTOPPED
(
PyObject
*
self
,
PyObject
*
args
)
posix_WIFSTOPPED
(
PyObject
*
self
,
PyObject
*
args
)
{
{
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:WIFSTOPPED"
,
&
status_i
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:WIFSTOPPED"
,
&
WAIT_STATUS_INT
(
status
)))
{
return
NULL
;
return
NULL
;
}
return
PyBool_FromLong
(
WIFSTOPPED
(
status
));
return
PyBool_FromLong
(
WIFSTOPPED
(
status
));
#undef status_i
}
}
#endif
/* WIFSTOPPED */
#endif
/* WIFSTOPPED */
...
@@ -6214,22 +6163,13 @@ Return True if the process returning 'status' was terminated by a signal.");
...
@@ -6214,22 +6163,13 @@ Return True if the process returning 'status' was terminated by a signal.");
static
PyObject
*
static
PyObject
*
posix_WIFSIGNALED
(
PyObject
*
self
,
PyObject
*
args
)
posix_WIFSIGNALED
(
PyObject
*
self
,
PyObject
*
args
)
{
{
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:WIFSIGNALED"
,
&
status_i
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:WIFSIGNALED"
,
&
WAIT_STATUS_INT
(
status
)))
{
return
NULL
;
return
NULL
;
}
return
PyBool_FromLong
(
WIFSIGNALED
(
status
));
return
PyBool_FromLong
(
WIFSIGNALED
(
status
));
#undef status_i
}
}
#endif
/* WIFSIGNALED */
#endif
/* WIFSIGNALED */
...
@@ -6242,22 +6182,13 @@ system call.");
...
@@ -6242,22 +6182,13 @@ system call.");
static
PyObject
*
static
PyObject
*
posix_WIFEXITED
(
PyObject
*
self
,
PyObject
*
args
)
posix_WIFEXITED
(
PyObject
*
self
,
PyObject
*
args
)
{
{
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:WIFEXITED"
,
&
status_i
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:WIFEXITED"
,
&
WAIT_STATUS_INT
(
status
)))
{
return
NULL
;
return
NULL
;
}
return
PyBool_FromLong
(
WIFEXITED
(
status
));
return
PyBool_FromLong
(
WIFEXITED
(
status
));
#undef status_i
}
}
#endif
/* WIFEXITED */
#endif
/* WIFEXITED */
...
@@ -6269,22 +6200,13 @@ Return the process return code from 'status'.");
...
@@ -6269,22 +6200,13 @@ Return the process return code from 'status'.");
static
PyObject
*
static
PyObject
*
posix_WEXITSTATUS
(
PyObject
*
self
,
PyObject
*
args
)
posix_WEXITSTATUS
(
PyObject
*
self
,
PyObject
*
args
)
{
{
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:WEXITSTATUS"
,
&
status_i
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:WEXITSTATUS"
,
&
WAIT_STATUS_INT
(
status
)))
{
return
NULL
;
return
NULL
;
}
return
Py_BuildValue
(
"i"
,
WEXITSTATUS
(
status
));
return
Py_BuildValue
(
"i"
,
WEXITSTATUS
(
status
));
#undef status_i
}
}
#endif
/* WEXITSTATUS */
#endif
/* WEXITSTATUS */
...
@@ -6297,22 +6219,13 @@ value.");
...
@@ -6297,22 +6219,13 @@ value.");
static
PyObject
*
static
PyObject
*
posix_WTERMSIG
(
PyObject
*
self
,
PyObject
*
args
)
posix_WTERMSIG
(
PyObject
*
self
,
PyObject
*
args
)
{
{
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:WTERMSIG"
,
&
status_i
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:WTERMSIG"
,
&
WAIT_STATUS_INT
(
status
)))
{
return
NULL
;
return
NULL
;
}
return
Py_BuildValue
(
"i"
,
WTERMSIG
(
status
));
return
Py_BuildValue
(
"i"
,
WTERMSIG
(
status
));
#undef status_i
}
}
#endif
/* WTERMSIG */
#endif
/* WTERMSIG */
...
@@ -6325,22 +6238,13 @@ the 'status' value.");
...
@@ -6325,22 +6238,13 @@ the 'status' value.");
static
PyObject
*
static
PyObject
*
posix_WSTOPSIG
(
PyObject
*
self
,
PyObject
*
args
)
posix_WSTOPSIG
(
PyObject
*
self
,
PyObject
*
args
)
{
{
#ifdef UNION_WAIT
WAIT_TYPE
status
;
union
wait
status
;
WAIT_STATUS_INT
(
status
)
=
0
;
#define status_i (status.w_status)
#else
int
status
;
#define status_i status
#endif
status_i
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:WSTOPSIG"
,
&
status_i
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:WSTOPSIG"
,
&
WAIT_STATUS_INT
(
status
)))
{
return
NULL
;
return
NULL
;
}
return
Py_BuildValue
(
"i"
,
WSTOPSIG
(
status
));
return
Py_BuildValue
(
"i"
,
WSTOPSIG
(
status
));
#undef status_i
}
}
#endif
/* WSTOPSIG */
#endif
/* WSTOPSIG */
...
...
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