Update headers to fix problems with integer types, wait() and access()

diff --git a/include/stdint.h b/include/stdint.h
index 2022a30..47fec18 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -110,4 +110,7 @@
 
 #endif
 
+/* Keep the kernel from trying to define these types... */
+#define __BIT_TYPES_DEFINED__
+
 #endif /* _STDINT_H */
diff --git a/include/sys/time.h b/include/sys/time.h
index 4eccf82..b503d21 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -6,6 +6,7 @@
 #define _SYS_TIME_H
 
 #include <klibc/extern.h>
+#include <sys/types.h>
 #include <linux/time.h>
 
 __extern int gettimeofday(struct timeval *, struct timezone *);
diff --git a/include/sys/types.h b/include/sys/types.h
index a25873c..88523da 100644
--- a/include/sys/types.h
+++ b/include/sys/types.h
@@ -1,8 +1,5 @@
 /*
  * sys/types.h
- *
- * This is a bastardized version of linux/types.h, since that file
- * is broken w.r.t. <stdint.h> definitions.
  */
 
 #ifndef _SYS_TYPES_H
@@ -25,7 +22,7 @@
 typedef __kernel_ino_t		ino_t;
 typedef __kernel_mode_t		mode_t;
 typedef __kernel_nlink_t	nlink_t;
-typedef __kernel_off_t		off_t;
+typedef __kernel_off_t		off_t; /* Should become __kernel_loff_t... */
 typedef __kernel_pid_t		pid_t;
 typedef __kernel_daddr_t	daddr_t;
 typedef __kernel_key_t		key_t;
@@ -83,15 +80,11 @@
 typedef unsigned int		uint;
 typedef unsigned long		ulong;
 
-#ifndef __BIT_TYPES_DEFINED__
-#define __BIT_TYPES_DEFINED__
-
-typedef		__u8		u_int8_t;
-typedef		__u16		u_int16_t;
-typedef		__u32		u_int32_t;
-typedef		__u64		u_int64_t;
-
-#endif /* !(__BIT_TYPES_DEFINED__) */
+/* Linux-specific? */
+typedef uint8_t			u_int8_t;
+typedef uint16_t		u_int16_t;
+typedef uint32_t 		u_int32_t;
+typedef uint64_t		u_int64_t;
 
 /*
  * transition to 64-bit sector_t, possibly making it an option...
diff --git a/include/sys/wait.h b/include/sys/wait.h
index cad6989..4cfafc9 100644
--- a/include/sys/wait.h
+++ b/include/sys/wait.h
@@ -11,6 +11,15 @@
 
 #include <linux/wait.h>
 
+#define WEXITSTATUS(s)	(((s) & 0xff00) >> 8)
+#define WTERMSIG(s)	((s) & 0x7f)
+#define WIFEXITED(s)	(WTERMSIG(s) == 0)
+#define WIFSTOPPED(s)	(WTERMSIG(s) == 0x7f)
+/* Ugly hack to avoid multiple evaluation of "s" */
+#define WIFSIGNALED(s)	(WTERMSIG((s)+1) >= 2)
+#define WCOREDUMP(s)	((s) & 0x80)
+#define WSTOPSIG(s)	WEXITSTATUS(s)
+
 __extern pid_t wait(int *);
 __extern pid_t waitpid(pid_t, int *, int);
 __extern pid_t wait3(int *, int, struct rusage *);
diff --git a/include/unistd.h b/include/unistd.h
index 3d5c688..f1cde23 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -49,6 +49,12 @@
 __extern int getfsuid(uid_t);
 __extern int setfsuid(uid_t);
 
+/* Macros for access() */
+#define R_OK	4		/* Read */
+#define W_OK	2		/* Write */
+#define X_OK	1		/* Execute */
+#define F_OK	0		/* Existence */
+
 __extern int access(const char *, int);
 __extern int link(const char *, const char *);
 __extern int unlink(const char *);
diff --git a/klibc/include/stdint.h b/klibc/include/stdint.h
index 2022a30..47fec18 100644
--- a/klibc/include/stdint.h
+++ b/klibc/include/stdint.h
@@ -110,4 +110,7 @@
 
 #endif
 
+/* Keep the kernel from trying to define these types... */
+#define __BIT_TYPES_DEFINED__
+
 #endif /* _STDINT_H */
diff --git a/klibc/include/sys/time.h b/klibc/include/sys/time.h
index 4eccf82..b503d21 100644
--- a/klibc/include/sys/time.h
+++ b/klibc/include/sys/time.h
@@ -6,6 +6,7 @@
 #define _SYS_TIME_H
 
 #include <klibc/extern.h>
+#include <sys/types.h>
 #include <linux/time.h>
 
 __extern int gettimeofday(struct timeval *, struct timezone *);
diff --git a/klibc/include/sys/types.h b/klibc/include/sys/types.h
index a25873c..88523da 100644
--- a/klibc/include/sys/types.h
+++ b/klibc/include/sys/types.h
@@ -1,8 +1,5 @@
 /*
  * sys/types.h
- *
- * This is a bastardized version of linux/types.h, since that file
- * is broken w.r.t. <stdint.h> definitions.
  */
 
 #ifndef _SYS_TYPES_H
@@ -25,7 +22,7 @@
 typedef __kernel_ino_t		ino_t;
 typedef __kernel_mode_t		mode_t;
 typedef __kernel_nlink_t	nlink_t;
-typedef __kernel_off_t		off_t;
+typedef __kernel_off_t		off_t; /* Should become __kernel_loff_t... */
 typedef __kernel_pid_t		pid_t;
 typedef __kernel_daddr_t	daddr_t;
 typedef __kernel_key_t		key_t;
@@ -83,15 +80,11 @@
 typedef unsigned int		uint;
 typedef unsigned long		ulong;
 
-#ifndef __BIT_TYPES_DEFINED__
-#define __BIT_TYPES_DEFINED__
-
-typedef		__u8		u_int8_t;
-typedef		__u16		u_int16_t;
-typedef		__u32		u_int32_t;
-typedef		__u64		u_int64_t;
-
-#endif /* !(__BIT_TYPES_DEFINED__) */
+/* Linux-specific? */
+typedef uint8_t			u_int8_t;
+typedef uint16_t		u_int16_t;
+typedef uint32_t 		u_int32_t;
+typedef uint64_t		u_int64_t;
 
 /*
  * transition to 64-bit sector_t, possibly making it an option...
diff --git a/klibc/include/sys/wait.h b/klibc/include/sys/wait.h
index cad6989..4cfafc9 100644
--- a/klibc/include/sys/wait.h
+++ b/klibc/include/sys/wait.h
@@ -11,6 +11,15 @@
 
 #include <linux/wait.h>
 
+#define WEXITSTATUS(s)	(((s) & 0xff00) >> 8)
+#define WTERMSIG(s)	((s) & 0x7f)
+#define WIFEXITED(s)	(WTERMSIG(s) == 0)
+#define WIFSTOPPED(s)	(WTERMSIG(s) == 0x7f)
+/* Ugly hack to avoid multiple evaluation of "s" */
+#define WIFSIGNALED(s)	(WTERMSIG((s)+1) >= 2)
+#define WCOREDUMP(s)	((s) & 0x80)
+#define WSTOPSIG(s)	WEXITSTATUS(s)
+
 __extern pid_t wait(int *);
 __extern pid_t waitpid(pid_t, int *, int);
 __extern pid_t wait3(int *, int, struct rusage *);
diff --git a/klibc/include/unistd.h b/klibc/include/unistd.h
index 3d5c688..f1cde23 100644
--- a/klibc/include/unistd.h
+++ b/klibc/include/unistd.h
@@ -49,6 +49,12 @@
 __extern int getfsuid(uid_t);
 __extern int setfsuid(uid_t);
 
+/* Macros for access() */
+#define R_OK	4		/* Read */
+#define W_OK	2		/* Write */
+#define X_OK	1		/* Execute */
+#define F_OK	0		/* Existence */
+
 __extern int access(const char *, int);
 __extern int link(const char *, const char *);
 __extern int unlink(const char *);