summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/include/sys/wait.h
diff options
context:
space:
mode:
authorChristian Franke <franke@computer.org>2011-10-06 16:02:37 +0000
committerChristian Franke <franke@computer.org>2011-10-06 16:02:37 +0000
commitefe716bb8eb2a8e34c4b5e5df658221778b4312e (patch)
tree5dcd7501c76f24e76cd0ea6448fa977d0d1e3f38 /winsup/cygwin/include/sys/wait.h
parente402890df25a0ed1047e24e70830489c17d20895 (diff)
downloadcygnal-efe716bb8eb2a8e34c4b5e5df658221778b4312e.tar.gz
cygnal-efe716bb8eb2a8e34c4b5e5df658221778b4312e.tar.bz2
cygnal-efe716bb8eb2a8e34c4b5e5df658221778b4312e.zip
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 `;'.
Diffstat (limited to 'winsup/cygwin/include/sys/wait.h')
-rw-r--r--winsup/cygwin/include/sys/wait.h56
1 files changed, 49 insertions, 7 deletions
diff --git a/winsup/cygwin/include/sys/wait.h b/winsup/cygwin/include/sys/wait.h
index 04bbae7f5..4341f6970 100644
--- a/winsup/cygwin/include/sys/wait.h
+++ b/winsup/cygwin/include/sys/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 */