--- mstools/posix/h/sys/wait.h 2018/08/09 18:22:18 1.1.1.1 +++ mstools/posix/h/sys/wait.h 2018/08/09 18:24:38 1.1.1.2 @@ -11,17 +11,15 @@ Abstract: This module contains the symbolic constants, macros, and structures needed to support wait, waitpid, and _exit in in IEEE P1003.1/Draft 13. -Author: - - Mark Lucovsky 21-Feb-1989 - -Revision History: - --*/ #ifndef _SYS_WAIT_ #define _SYS_WAIT_ +#ifdef __cplusplus +extern "C" { +#endif + /* * wait options */ @@ -43,46 +41,50 @@ Revision History: * Evaluate to non-zero if process terminated normally (by calling _exit) */ -#define WIFEXITED(stat_val) (\ - ((int)(stat_val) >= 0 ? 1 : 0 )) +#define WIFEXITED(stat_val) \ + (((stat_val) & 0xff) == 0) /* * Returns the low-order 8 bits of the status argument passed to _exit */ -#define WEXITSTATUS(stat_val) (\ - ((int)(stat_val) & 0x000000ff )) +#define WEXITSTATUS(stat_val) \ + (((stat_val) & 0xff00) >> 8) /* * Evaluate to non-zero if process terminated due to receipt of a signal * that was not caught */ -#define WIFSIGNALED(stat_val) (\ - ((int)(stat_val) < 0 ? 1 : 0 )) +#define WIFSIGNALED(stat_val) \ + (!WIFSTOPPED(stat_val) && !WIFEXITED(stat_val)) /* * Returns the signal number of the signal that caused the process to terminate */ -#define WTERMSIG(stat_val) (\ - ((int)(stat_val) & 0x000000ff )) +#define WTERMSIG(stat_val) \ + ((stat_val) & 0xff) /* * Evaluate to non-zero if process is currently stopped */ -#define WIFSTOPPED(stat_val) (\ - ((int)(((int)stat_val<<1)) < 0 ? 1 : 0 )) +#define WIFSTOPPED(stat_val) \ + (((stat_val) & 0xff) == 0177) /* * Returns the signal number of the signal that caused the process to stop */ -#define WSTOPSIG(stat_val) (\ - ((int)(stat_val) & 0x000000ff )) +#define WSTOPSIG(stat_val) \ + (((stat_val) & 0xff00) >> 8) pid_t _CRTAPI1 wait(int *); pid_t _CRTAPI1 waitpid(pid_t, int *, int); +#ifdef __cplusplus +} +#endif + #endif /* _SYS_WAIT_ */