2011-10-06 Christian Franke <franke@computer.org>
* include/cygwin/wait.h: Use new __wait_status_to_int() macro to access status value in W*() status checks. Fix status description. * include/sys/wait.h: Allow `int' and `union wait' as wait status parameter. Change __wait_status_to_int() macro and wait () prototypes accordingly. Add inline functions for C++. Remove extra `;'.
This commit is contained in:
parent
e402890df2
commit
efe716bb8e
@ -1,3 +1,13 @@
|
||||
2011-10-06 Christian Franke <franke@computer.org>
|
||||
|
||||
* include/cygwin/wait.h: Use new __wait_status_to_int()
|
||||
macro to access status value in W*() status checks.
|
||||
Fix status description.
|
||||
* include/sys/wait.h: Allow `int' and `union wait' as
|
||||
wait status parameter. Change __wait_status_to_int()
|
||||
macro and wait () prototypes accordingly. Add inline
|
||||
functions for C++. Remove extra `;'.
|
||||
|
||||
2011-10-05 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* external.cc (create_winenv): Rename from sync_winenv. Take
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* cygwin/wait.h
|
||||
|
||||
Copyright 2006, 2009 Red Hat, Inc.
|
||||
Copyright 2006, 2009, 2011 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -16,8 +16,11 @@ details. */
|
||||
#define WCONTINUED 8
|
||||
#define __W_CONTINUED 0xffff
|
||||
|
||||
/* A status looks like:
|
||||
<2 bytes info> <2 bytes code>
|
||||
/* Will be redefined in sys/wait.h. */
|
||||
#define __wait_status_to_int(w) (w)
|
||||
|
||||
/* A status is 16 bits, and looks like:
|
||||
<1 byte info> <1 byte code>
|
||||
|
||||
<code> == 0, child has exited, info is the exit value
|
||||
<code> == 1..7e, child has exited, info is the signal number.
|
||||
@ -25,13 +28,14 @@ details. */
|
||||
<code> == 80, there was a core dump.
|
||||
*/
|
||||
|
||||
#define WIFEXITED(w) (((w) & 0xff) == 0)
|
||||
#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
|
||||
#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
|
||||
#define WIFCONTINUED(w) (((w) & 0xffff) == __W_CONTINUED)
|
||||
#define WEXITSTATUS(w) (((w) >> 8) & 0xff)
|
||||
#define WTERMSIG(w) ((w) & 0x7f)
|
||||
#define WIFEXITED(w) ((__wait_status_to_int(w) & 0xff) == 0)
|
||||
#define WIFSIGNALED(w) ((__wait_status_to_int(w) & 0x7f) > 0 \
|
||||
&& ((__wait_status_to_int(w) & 0x7f) < 0x7f))
|
||||
#define WIFSTOPPED(w) ((__wait_status_to_int(w) & 0xff) == 0x7f)
|
||||
#define WIFCONTINUED(w) ((__wait_status_to_int(w) & 0xffff) == __W_CONTINUED)
|
||||
#define WEXITSTATUS(w) ((__wait_status_to_int(w) >> 8) & 0xff)
|
||||
#define WTERMSIG(w) (__wait_status_to_int(w) & 0x7f)
|
||||
#define WSTOPSIG WEXITSTATUS
|
||||
#define WCOREDUMP(w) (WIFSIGNALED(w) && (w & 0x80))
|
||||
#define WCOREDUMP(w) (WIFSIGNALED(w) && (__wait_status_to_int(w) & 0x80))
|
||||
|
||||
#endif /* _CYGWIN_WAIT_H */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* sys/wait.h
|
||||
|
||||
Copyright 1997, 1998, 2001, 2002, 2003, 2004, 2006 Red Hat, Inc.
|
||||
Copyright 1997, 1998, 2001, 2002, 2003, 2004, 2006, 2011 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -19,10 +19,25 @@ details. */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
pid_t wait (int *);
|
||||
pid_t waitpid (pid_t, int *, int);
|
||||
pid_t wait3 (int *__status, int __options, struct rusage *__rusage);
|
||||
pid_t wait4 (pid_t __pid, int *__status, int __options, struct rusage *__rusage);
|
||||
#ifdef __cplusplus
|
||||
|
||||
typedef int *__wait_status_ptr_t;
|
||||
|
||||
#else /* !__cplusplus */
|
||||
|
||||
/* Allow `int' and `union wait' for the status. */
|
||||
typedef union
|
||||
{
|
||||
int *__int_ptr;
|
||||
union wait *__union_wait_ptr;
|
||||
} __wait_status_ptr_t __attribute__ ((__transparent_union__));
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
pid_t wait (__wait_status_ptr_t __status);
|
||||
pid_t waitpid (pid_t __pid, __wait_status_ptr_t __status, int __options);
|
||||
pid_t wait3 (__wait_status_ptr_t __status, int __options, struct rusage *__rusage);
|
||||
pid_t wait4 (pid_t __pid, __wait_status_ptr_t __status, int __options, struct rusage *__rusage);
|
||||
|
||||
union wait
|
||||
{
|
||||
@ -49,7 +64,34 @@ union wait
|
||||
#define w_stopval __wait_stopped.__w_stopval
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* Used in cygwin/wait.h, redefine to accept `int' and `union wait'. */
|
||||
#undef __wait_status_to_int
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline int __wait_status_to_int (int __status)
|
||||
{ return __status; }
|
||||
inline int __wait_status_to_int (const union wait & __status)
|
||||
{ return __status.w_status; }
|
||||
|
||||
/* C++ wait() variants for `union wait'. */
|
||||
inline pid_t wait (union wait *__status)
|
||||
{ return wait ((int *) __status); }
|
||||
inline pid_t waitpid (pid_t __pid, union wait *__status, int __options)
|
||||
{ return waitpid(__pid, (int *) __status, __options); }
|
||||
inline pid_t wait3 (union wait *__status, int __options, struct rusage *__rusage)
|
||||
{ return wait3 ((int *) __status, __options, __rusage); }
|
||||
inline pid_t wait4 (pid_t __pid, union wait *__status, int __options, struct rusage *__rusage)
|
||||
{ return wait4 (__pid, (int *) __status, __options, __rusage); }
|
||||
|
||||
#else /* !__cplusplus */
|
||||
|
||||
#define __wait_status_to_int(__status) (__extension__ \
|
||||
(((union { __typeof(__status) __in; int __out; }) { .__in = (__status) }).__out))
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _SYS_WAIT_H */
|
||||
|
Loading…
Reference in New Issue
Block a user