/*
 * $Id: wait.h,v 1.4 2000/09/22 22:05:18 k-abe Exp $
 *
 * This file is part of PTL, Portable Thread Library.
 *
 * Copyright (C) 1999-2000 Kota Abe
 */

#ifndef __PTL_SYS_WAIT_H__
#define __PTL_SYS_WAIT_H__

#include <sys/pthread-init.h>

/* ---------------------------------------------------------------- */
#ifdef __PTL_RENAMED__
#define __PTL_ALREADY_RENAMED_SYS_WAIT_H
#else
#include <sys/pthread-before.h>
#endif

#ifdef __GNUC__
#include <00root-gcc/sys/wait.h>
#else
#include <00root-system/sys/wait.h>
#endif

#include <sys/pthread-after.h>
/* ---------------------------------------------------------------- */

#include <sys/pthread-cdecl.h>

#undef WIFEXITED
#undef WIFSIGNALED
#undef WIFSTOPPED
#undef WEXITSTATUS
#undef WTERMSIG
#undef WSTOPSIG

#define WIFEXITED(s)	((int)((s)&0xff) == 0)
#define WIFSIGNALED(s)	((int)((s)&0xff) > 0 && (int)((s)&0xff00) == 0)
#define WIFSTOPPED(s)	((int)((s)&0xff) == 0177 && (int)((s)&0xff00) != 0)
#define WEXITSTATUS(s)	((int)(((s)>>8)&0xff))
#define WTERMSIG(s)	((int)((s)&0x7f))
#define WSTOPSIG(s)	((int)(((s)>>8)&0xff))

__PTL_BEGIN_DECLS

extern pid_t wait __PTL_P((int*));
extern pid_t waitpid __PTL_P((pid_t, int*, int));
extern pid_t wait3 __PTL_P((int*, int, struct rusage*));
extern pid_t wait4 __PTL_P((pid_t, int*, int, struct rusage*));

__PTL_END_DECLS

/* ---------------------------------------------------------------- */
#ifdef __PTL_ALREADY_RENAMED_SYS_WAIT_H
#include <sys/pthread-before.h>
#undef __PTL_ALREADY_RENAMED_SYS_WAIT_H
#else
#include <sys/pthread-after.h>
#endif
/* ---------------------------------------------------------------- */

#endif /* __PTL_SYS_TYPES_H__ */
