diff --git a/libc/decl/intn_t.h b/libc/decl/intn_t.h
deleted file mode 100644
index 09ac29fd..00000000
--- a/libc/decl/intn_t.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef _INTN_T_DECL
-#define _INTN_T_DECL
-
-/* Define basic signed types. */
-typedef __int8_t int8_t;
-typedef __int16_t int16_t;
-typedef __int32_t int32_t;
-typedef __int64_t int64_t;
-
-/* Define basic unsigned types. */
-typedef __uint8_t uint8_t;
-typedef __uint16_t uint16_t;
-typedef __uint32_t uint32_t;
-typedef __uint64_t uint64_t;
-
-/* The maximum width integers available on this platform. */
-typedef __intmax_t intmax_t;
-typedef __uintmax_t uintmax_t;
-
-/* Define an integer able to hold the size of the largest continious memory */
-/* region and define pointer safe integer types. */
-@include(size_t.h)
-@include(ssize_t.h)
-typedef __intptr_t intptr_t;
-typedef __uintptr_t uintptr_t;
-typedef __ptrdiff_t ptrdiff_t;
-
-#define INT8_MIN __INT8_MIN
-#define INT16_MIN __INT16_MIN
-#define INT32_MIN __INT32_MIN
-#define INT64_MIN __INT64_MIN
-#define INT8_MAX __INT8_MAX
-#define INT16_MAX __INT16_MAX
-#define INT32_MAX __INT32_MAX
-#define INT64_MAX __INT64_MAX
-#define UINT8_MAX __UINT8_MAX
-#define UINT16_MAX __UINT16_MAX
-#define UINT32_MAX __UINT32_MAX
-#define UINT64_MAX __UINT64_MAX
-
-#define INTMAX_MIN __INTMAX_MIN
-#define INTMAX_MAX __INTMAX_MAX
-#define UINTMAX_MAX __UINTMAX_MAX
-
-#define CHAR_BIT __CHAR_BIT
-#define SCHAR_MIN __SCHAR_MIN
-#define SCHAR_MAX __SCHAR_MAX
-#define UCHAR_MAX __UCHAR_MAX
-#define CHAR_MIN __CHAR_MIN
-#define CHAR_MAX __CHAR_MAX
-
-#define WCHAR_MIN __WCHAR_MIN
-#define WCHAR_MAX __WCHAR_MAX
-
-#define SHRT_MIN __SHRT_MIN
-#define SHRT_MAX __SHRT_MAX
-#define USHRT_MAX __USHRT_MAX
-
-#define WORD_BIT __WORD_BIT
-#define INT_MIN __INT_MIN
-#define INT_MAX __INT_MAX
-#define UINT_MAX __UINT_MAX
-
-#define LONG_BIT __LONG_BIT
-#define LONG_MIN __LONG_MIN
-#define LONG_MAX __LONG_MAX
-#define ULONG_MAX __ULONG_MAX
-
-#define LONG_MIN __LONG_MIN
-#define LLONG_MAX __LLONG_MAX
-#define ULLONG_MAX __ULLONG_MAX
-
-#define SSIZE_MIN __SSIZE_MIN
-#define SSIZE_MAX __SSIZE_MAX
-#define SIZE_MAX __SIZE_MAX
-#define INTPTR_MIN __INTPTR_MIN
-#define INTPTR_MAX __INTPTR_MAX
-#define UINTPTR_MAX __UINTPTR_MAX
-
-#endif
diff --git a/libc/decl/locale_t.h b/libc/decl/locale_t.h
index dc1c104e..4a74fa86 100644
--- a/libc/decl/locale_t.h
+++ b/libc/decl/locale_t.h
@@ -1,4 +1,7 @@
#ifndef _LOCALE_T_DECL
#define _LOCALT_T_DECL
+/* TODO: figure out what this does and typedef it properly. This is just a
+ temporary assignment. */
+typedef int __locale_t;
typedef __locale_t locale_t;
#endif
diff --git a/libc/decl/wctrans_t.h b/libc/decl/wctrans_t.h
index 4d19621c..a0b41a76 100644
--- a/libc/decl/wctrans_t.h
+++ b/libc/decl/wctrans_t.h
@@ -1,4 +1,7 @@
#ifndef _WCTRANS_T_DECL
#define _WCTRANS_T_DECL
+/* TODO: figure out what this does and typedef it properly. This is just a
+ temporary assignment. */
+typedef unsigned int __wctrans_t;
typedef __wctrans_t wctrans_t;
#endif
diff --git a/libc/decl/wint_t.h b/libc/decl/wint_t.h
index f47af45e..ffe3fecb 100644
--- a/libc/decl/wint_t.h
+++ b/libc/decl/wint_t.h
@@ -1,4 +1,5 @@
#ifndef _WINT_T_DECL
#define _WINT_T_DECL
+typedef int __wint_t;
typedef __wint_t wint_t;
#endif
diff --git a/libc/include/__/stdint.h b/libc/include/__/stdint.h
new file mode 100644
index 00000000..d62a1f07
--- /dev/null
+++ b/libc/include/__/stdint.h
@@ -0,0 +1,250 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2013.
+
+ This file is part of the Sortix C Library.
+
+ The Sortix C Library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ The Sortix C Library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with the Sortix C Library. If not, see .
+
+ __/stdint.h
+ Integer types.
+
+*******************************************************************************/
+
+#ifndef INCLUDE____STDINT_H
+#define INCLUDE____STDINT_H
+
+#define _LIBC_HACK_FEATURE_NO_DECLARATIONS
+#include
+#include <__/wordsize.h>
+
+__BEGIN_DECLS
+
+/* TODO: Make the compiler provide all this information using __ prefix. */
+/* TODO: Use __XINTXX_TYPE__ constants when switching to gcc 4.7.x or newer. */
+
+/* Signed constants. */
+#define __INT8_C(c) c
+#define __INT16_C(c) c
+#define __INT32_C(c) c
+#if __WORDSIZE == 64
+#define __INT64_C(c) c ## L
+#else
+#define __INT64_C(c) c ## LL
+#endif
+
+/* Unsigned constants. */
+#define __UINT8_C(c) c
+#define __UINT16_C(c) c
+#define __UINT32_C(c) c ## U
+#if __WORDSIZE == 64
+#define __UINT64_C(c) c ## UL
+#else
+#define __UINT64_C(c) c ## ULL
+#endif
+
+/* Maxmimal constants. */
+#if __WORDSIZE == 64
+#define __INTMAX_C(c) c ## L
+#define __UINTMAX_C(c) c ## UL
+#else
+#define __INTMAX_C(c) c ## LL
+#define __UINTMAX_C(c) c ## ULL
+#endif
+
+/* Define basic signed types. */
+typedef signed char __int8_t;
+typedef short int __int16_t;
+typedef int __int32_t;
+#if __WORDSIZE == 64
+typedef long int __int64_t;
+#else
+typedef long long int __int64_t;
+#endif
+
+#define __INT8_MIN (-128)
+#define __INT16_MIN (-32767-1)
+#define __INT32_MIN (-2147483647-1)
+#define __INT64_MIN (-__INT64_C(9223372036854775807)-1)
+
+#define __INT8_MAX (127)
+#define __INT16_MAX (32767)
+#define __INT32_MAX (2147483647)
+#define __INT64_MAX (__INT64_C(9223372036854775807))
+
+/* Define basic unsigned types. */
+typedef unsigned char __uint8_t;
+typedef unsigned short int __uint16_t;
+typedef unsigned int __uint32_t;
+#if __WORDSIZE == 64
+typedef unsigned long int __uint64_t;
+#else
+typedef unsigned long long int __uint64_t;
+#endif
+
+#define __UINT8_MAX (255)
+#define __UINT16_MAX (65535)
+#define __UINT32_MAX (4294967295U)
+#define __UINT64_MAX (__UINT64_C(18446744073709551615))
+
+/* Define small signed types. */
+typedef signed char __int_least8_t;
+typedef short int __int_least16_t;
+typedef int __int_least32_t;
+#if __WORDSIZE == 64
+typedef long int __int_least64_t;
+#else
+typedef long long int __int_least64_t;
+#endif
+
+#define __INT_LEAST8_MIN (-128)
+#define __INT_LEAST16_MIN (-32767-1)
+#define __INT_LEAST32_MIN (-2147483647-1)
+#define __INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
+
+#define __INT_LEAST8_MAX (127)
+#define __INT_LEAST16_MAX (32767)
+#define __INT_LEAST32_MAX (2147483647)
+#define __INT_LEAST64_MAX (__INT64_C(9223372036854775807))
+
+/* Define small unsigned types. */
+typedef unsigned char __uint_least8_t;
+typedef unsigned short int __uint_least16_t;
+typedef unsigned int __uint_least32_t;
+#if __WORDSIZE == 64
+typedef unsigned long int __uint_least64_t;
+#else
+typedef unsigned long long int __uint_least64_t;
+#endif
+
+#define __UINT_LEAST8_MAX (255)
+#define __UINT_LEAST16_MAX (65535)
+#define __UINT_LEAST32_MAX (4294967295U)
+#define __UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
+
+/* Define fast signed types. */
+typedef signed char __int_fast8_t;
+#if __WORDSIZE == 64
+typedef long int __int_fast16_t;
+typedef long int __int_fast32_t;
+typedef long int __int_fast64_t;
+#else
+typedef int __int_fast16_t;
+typedef int __int_fast32_t;
+typedef long long int __int_fast64_t;
+#endif
+
+#define __INT_FAST8_MIN (-128)
+#if __WORDSIZE == 64
+#define __INT_FAST16_MIN (-9223372036854775807L-1)
+#define __INT_FAST32_MIN (-9223372036854775807L-1)
+#else
+#define __INT_FAST16_MIN (-2147483647-1)
+#define __INT_FAST32_MIN (-2147483647-1)
+#endif
+#define __INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
+
+#define __INT_FAST8_MAX (127)
+#if __WORDSIZE == 64
+#define __INT_FAST16_MAX (9223372036854775807L)
+#define __INT_FAST32_MAX (9223372036854775807L)
+#else
+#define __INT_FAST16_MAX (2147483647)
+#define __INT_FAST32_MAX (2147483647)
+#endif
+#define __INT_FAST64_MAX (__INT64_C(9223372036854775807))
+
+/* Define fast unsigned types. */
+typedef unsigned char __uint_fast8_t;
+#if __WORDSIZE == 64
+typedef unsigned long int __uint_fast16_t;
+typedef unsigned long int __uint_fast32_t;
+typedef unsigned long int __uint_fast64_t;
+#else
+typedef unsigned int __uint_fast16_t;
+typedef unsigned int __uint_fast32_t;
+typedef unsigned long long int __uint_fast64_t;
+#endif
+
+#define __UINT_FAST8_MAX (255)
+#if __WORDSIZE == 64
+#define __UINT_FAST16_MAX (18446744073709551615UL)
+#define __UINT_FAST32_MAX (18446744073709551615UL)
+#else
+#define __UINT_FAST16_MAX (4294967295U)
+#define __UINT_FAST32_MAX (4294967295U)
+#endif
+#define __UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
+
+/* Define pointer-safe types. */
+#if __WORDSIZE == 64
+typedef long int __intptr_t;
+typedef unsigned long int __uintptr_t;
+#else
+typedef int __intptr_t;
+typedef unsigned int __uintptr_t;
+#endif
+
+#if __WORDSIZE == 64
+#define __INTPTR_MIN (-9223372036854775807L-1)
+#define __INTPTR_MAX (9223372036854775807L)
+#define __UINTPTR_MAX (18446744073709551615UL)
+#else
+#define __INTPTR_MIN (-2147483647-1)
+#define __INTPTR_MAX (2147483647)
+#define __UINTPTR_MAX (4294967295U)
+#endif
+
+/* Define largest integer types. */
+#if __WORDSIZE == 64
+typedef long int __intmax_t;
+typedef unsigned long int __uintmax_t;
+#else
+typedef long long int __intmax_t;
+typedef long long unsigned int __uintmax_t;
+#endif
+
+#define __INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
+#define __INTMAX_MAX (__INT64_C(9223372036854775807))
+#define __UINTMAX_MAX (__UINT64_C(18446744073709551615))
+
+/* TODO: Should these come from a <__stddef.h>? */
+#if __WORDSIZE == 64
+#define __PTRDIFF_MIN (-9223372036854775807L-1)
+#define __PTRDIFF_MAX (9223372036854775807L)
+#else
+#define __PTRDIFF_MIN (-2147483647-1)
+#define __PTRDIFF_MAX (2147483647)
+#endif
+
+/* Note: The wchar_t related constants comes from another header. */
+
+/* TODO: Should these come from a <__signal.h>? */
+#define __SIG_ATOMIC_MIN (-2147483647-1)
+#define __SIG_ATOMIC_MAX (2147483647)
+
+/* TODO: Should these come from a <__stddef.h>? */
+#if __WORDSIZE == 64
+#define __SIZE_MAX (18446744073709551615UL)
+#define __SSIZE_MIN (-9223372036854775807L-1)
+#define __SSIZE_MAX (9223372036854775807L)
+#else
+#define __SIZE_MAX (4294967295U)
+#define __SSIZE_MIN (-2147483647-1)
+#define __SSIZE_MAX (2147483647)
+#endif
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/features.h b/libc/include/features.h
index 4e624c8c..7871b183 100644
--- a/libc/include/features.h
+++ b/libc/include/features.h
@@ -75,7 +75,13 @@
/* Don't provide things from standard headers that is not implemented. */
/*#define __SORTIX_SHOW_UNIMPLEMENTED*/
-#include
+#if !defined(_LIBC_HACK_FEATURE_NO_DECLARATIONS)
+#include
+#include
+
+#endif
+
+#undef _LIBC_HACK_FEATURE_NO_DECLARATIONS
#endif
diff --git a/libc/include/stdint.h b/libc/include/stdint.h
index 6a5af2ee..437d83a8 100644
--- a/libc/include/stdint.h
+++ b/libc/include/stdint.h
@@ -1,6 +1,6 @@
/*******************************************************************************
- Copyright(C) Jonas 'Sortie' Termansen 2011.
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2013.
This file is part of the Sortix C Library.
@@ -22,16 +22,140 @@
*******************************************************************************/
-/* TODO: POSIX-1.2008 compliance is only partial */
-
#ifndef _STDINT_H
#define _STDINT_H 1
#include
+#include <__/stdint.h>
__BEGIN_DECLS
-@include(intn_t.h)
+/* Only define these constant macros in C++ if requested. */
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) || \
+ defined(LIBC_LIBRARY) || defined(SORTIX_KERNEL) /* TODO: HACK! */
+
+#define INT8_C(c) __INT8_C(c)
+#define INT16_C(c) __INT16_C(c)
+#define INT32_C(c) __INT32_C(c)
+#define INT64_C(c) __INT64_C(c)
+
+#define UINT8_C(c) __UINT8_C(c)
+#define UINT16_C(c) __UINT16_C(c)
+#define UINT32_C(c) __UINT32_C(c)
+#define UINT64_C(c) __UINT64_C(c)
+
+#define INTMAX_C(c) __INTMAX_C(c)
+#define UINTMAX_C(c) __UINTMAX_C(c)
+
+#endif
+
+/* Only define these limit macros in C++ if requested. */
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) || \
+ defined(LIBC_LIBRARY) || defined(SORTIX_KERNEL) /* TODO: HACK! */
+
+#define INT8_MIN __INT8_MIN
+#define INT16_MIN __INT16_MIN
+#define INT32_MIN __INT32_MIN
+#define INT64_MIN __INT64_MIN
+
+#define INT8_MAX __INT8_MAX
+#define INT16_MAX __INT16_MAX
+#define INT32_MAX __INT32_MAX
+#define INT64_MAX __INT64_MAX
+
+#define UINT8_MAX __UINT8_MAX
+#define UINT16_MAX __UINT16_MAX
+#define UINT32_MAX __UINT32_MAX
+#define UINT64_MAX __UINT64_MAX
+
+#define INT_LEAST8_MIN __INT_LEAST8_MIN
+#define INT_LEAST16_MIN __INT_LEAST16_MIN
+#define INT_LEAST32_MIN __INT_LEAST32_MIN
+#define INT_LEAST64_MIN __INT_LEAST64_MIN
+
+#define INT_LEAST8_MAX __INT_LEAST8_MAX
+#define INT_LEAST16_MAX __INT_LEAST16_MAX
+#define INT_LEAST32_MAX __INT_LEAST32_MAX
+#define INT_LEAST64_MAX __INT_LEAST64_MAX
+
+#define UINT_LEAST8_MAX __UINT_LEAST8_MAX
+#define UINT_LEAST16_MAX __UINT_LEAST16_MAX
+#define UINT_LEAST32_MAX __UINT_LEAST32_MAX
+#define UINT_LEAST64_MAX __UINT_LEAST64_MAX
+
+#define INT_FAST8_MIN __INT_FAST8_MIN
+#define INT_FAST16_MIN __INT_FAST16_MIN
+#define INT_FAST32_MIN __INT_FAST32_MIN
+#define INT_FAST64_MIN __INT_FAST64_MIN
+
+#define INT_FAST8_MAX __INT_FAST8_MAX
+#define INT_FAST16_MAX __INT_FAST16_MAX
+#define INT_FAST32_MAX __INT_FAST32_MAX
+#define INT_FAST64_MAX __INT_FAST64_MAX
+
+#define UINT_FAST8_MAX __UINT_FAST8_MAX
+#define UINT_FAST16_MAX __UINT_FAST16_MAX
+#define UINT_FAST32_MAX __UINT_FAST32_MAX
+#define UINT_FAST64_MAX __UINT_FAST64_MAX
+
+#define INTPTR_MIN __INTPTR_MIN
+#define INTPTR_MAX __INTPTR_MAX
+#define UINTPTR_MAX __UINTPTR_MAX
+
+#define INTMAX_MIN __INTMAX_MIN
+#define INTMAX_MAX __INTMAX_MAX
+#define UINTMAX_MAX __UINTMAX_MAX
+
+#define PTRDIFF_MIN __PTRDIFF_MIN
+#define PTRDIFF_MAX __PTRDIFF_MAX
+
+#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX
+
+#define SIZE_MAX __SIZE_MAX
+/* TODO: Should SSIZE_MIN and SSIZE_MAX be declared here? */
+#define SSIZE_MIN __SSIZE_MIN
+#define SSIZE_MAX __SSIZE_MAX
+
+/* TODO: wchar_t related stuff is missing here. */
+
+#endif
+
+typedef __int8_t int8_t;
+typedef __int16_t int16_t;
+typedef __int32_t int32_t;
+typedef __int64_t int64_t;
+
+typedef __uint8_t uint8_t;
+typedef __uint16_t uint16_t;
+typedef __uint32_t uint32_t;
+typedef __uint64_t uint64_t;
+
+typedef __int_least8_t int_least8_t;
+typedef __int_least16_t int_least16_t;
+typedef __int_least32_t int_least32_t;
+typedef __int_least64_t int_least64_t;
+
+typedef __uint_least8_t uint_least8_t;
+typedef __uint_least16_t uint_least16_t;
+typedef __uint_least32_t uint_least32_t;
+typedef __uint_least64_t uint_least64_t;
+
+typedef __int_fast8_t int_fast8_t;
+typedef __int_fast16_t int_fast16_t;
+typedef __int_fast32_t int_fast32_t;
+typedef __int_fast64_t int_fast64_t;
+
+typedef __uint_fast8_t uint_fast8_t;
+typedef __uint_fast16_t uint_fast16_t;
+typedef __uint_fast32_t uint_fast32_t;
+typedef __uint_fast64_t uint_fast64_t;
+
+typedef __intptr_t intptr_t;
+typedef __uintptr_t uintptr_t;
+
+typedef __intmax_t intmax_t;
+typedef __uintmax_t uintmax_t;
__END_DECLS
diff --git a/libc/include/sys/__/types.h b/libc/include/sys/__/types.h
new file mode 100644
index 00000000..bea79e5c
--- /dev/null
+++ b/libc/include/sys/__/types.h
@@ -0,0 +1,31 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
+
+ This file is part of the Sortix C Library.
+
+ The Sortix C Library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ The Sortix C Library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with the Sortix C Library. If not, see .
+
+ sys/__/types.h
+ Data types.
+
+*******************************************************************************/
+
+#ifndef INCLUDE_SYS____TYPES_H
+#define INCLUDE_SYS____TYPES_H
+
+#include
+#include
+
+#endif
diff --git a/libc/include/sys/display.h b/libc/include/sys/display.h
index fa98d2e7..1f197c66 100644
--- a/libc/include/sys/display.h
+++ b/libc/include/sys/display.h
@@ -26,6 +26,7 @@
#define INCLUDE_SYS_DISPLAY_H
#include
+#include
#include
#include
diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h
index 85ba2321..16983ea1 100644
--- a/libc/include/sys/types.h
+++ b/libc/include/sys/types.h
@@ -28,6 +28,7 @@
#define INCLUDE_SYS_TYPES_H
#include
+#include
__BEGIN_DECLS
@@ -46,7 +47,6 @@ __BEGIN_DECLS
@include(nlink_t.h)
@include(off_t.h)
@include(pid_t.h)
-/* TODO: pthread*_t */
@include(size_t.h)
@include(ssize_t.h)
@include(suseconds_t.h)
@@ -56,6 +56,10 @@ __BEGIN_DECLS
@include(uid_t.h)
@include(useconds_t.h)
+#if !defined(SORTIX_KERNEL)
+/* TODO: pthread*_t */
+#endif
+
__END_DECLS
#endif
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 4f624ffb..fc789ae5 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -29,9 +29,10 @@
#define _UNISTD_H 1
#include
+#include <__/stdint.h>
#if defined(_SORTIX_SOURCE)
-#include
#include
+#include
#include
#endif
#include
@@ -77,9 +78,6 @@ __BEGIN_DECLS
@include(off_t.h)
@include(pid_t.h)
@include(useconds_t.h)
-#if defined(_SORTIX_SOURCE) || defined(_SORTIX_ALWAYS_SBRK)
-@include(intn_t.h)
-#endif
#if defined(_WANT_ENVIRON)
extern char** environ;
@@ -195,12 +193,12 @@ size_t readall(int fd, void* buf, size_t count);
size_t readleast(int fd, void* buf, size_t least, size_t max);
pid_t sfork(int flags);
pid_t tfork(int flags, tforkregs_t* regs);
-int uptime(uintmax_t* usecssinceboot);
+int uptime(__uintmax_t* usecssinceboot);
size_t writeall(int fd, const void* buf, size_t count);
size_t writeleast(int fd, const void* buf, size_t least, size_t max);
#endif
#if defined(_SORTIX_SOURCE) || defined(_SORTIX_ALWAYS_SBRK)
-void* sbrk(intptr_t increment);
+void* sbrk(__intptr_t increment);
#endif
__END_DECLS
diff --git a/sortix/dtable.cpp b/sortix/dtable.cpp
index 007324e9..c5ce9ad4 100644
--- a/sortix/dtable.cpp
+++ b/sortix/dtable.cpp
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include
#include "process.h"
diff --git a/sortix/include/sortix/__/types.h b/sortix/include/sortix/__/types.h
new file mode 100644
index 00000000..27510670
--- /dev/null
+++ b/sortix/include/sortix/__/types.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2013.
+
+ This file is part of Sortix.
+
+ Sortix is free software: you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation, either version 3 of the License, or (at your option) any later
+ version.
+
+ Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ Sortix. If not, see .
+
+ sortix/__/types.h
+ Data types.
+
+*******************************************************************************/
+
+#ifndef INCLUDE_SORTIX____TYPES_H
+#define INCLUDE_SORTIX____TYPES_H
+
+#include
+#include <__/stdint.h>
+#include <__/wordsize.h>
+
+__BEGIN_DECLS
+
+typedef int __id_t;
+typedef int __gid_t;
+typedef int __uid_t;
+typedef int __pid_t;
+typedef unsigned int __mode_t;
+typedef __intmax_t __off_t;
+#define __OFF_MIN __INTMAX_MIN
+#define __OFF_MAX __INTMAX_MAX
+typedef unsigned int __useconds_t;
+typedef __intmax_t __blksize_t;
+typedef __intmax_t __blkcnt_t;
+typedef unsigned int __nlink_t;
+typedef __uintmax_t __ino_t;
+typedef __uintptr_t __dev_t;
+typedef __intmax_t __clock_t;
+typedef int __clockid_t;
+typedef long __time_t; /* TODO: Increase on 32-bit systems! */
+typedef long __suseconds_t;
+#if __WORDSIZE == 64
+typedef long int __ssize_t;
+#else
+typedef int __ssize_t;
+#endif
+
+#if defined(SORTIX_KERNEL) || defined(LIBC_LIBRARY)
+#define OFF_MIN __OFF_MIN
+#endif
+#if defined(SORTIX_KERNEL) || defined(LIBC_LIBRARY)
+#define OFF_MAX __OFF_MAX
+#endif
+
+__END_DECLS
+
+#endif
diff --git a/sortix/include/sortix/bits.h b/sortix/include/sortix/bits.h
index 86ce3040..fdbb9dc4 100644
--- a/sortix/include/sortix/bits.h
+++ b/sortix/include/sortix/bits.h
@@ -23,24 +23,9 @@
*******************************************************************************/
#if !defined(PLATFORM_X86) && !defined(PLATFORM_X64)
- #if defined(__LP64__)
+ #if defined(__x86_64__)
#define PLATFORM_X64
#else
#define PLATFORM_X86
#endif
#endif
-
-#if defined(PLATFORM_X86)
-#include "x86/bits.h"
-#elif defined(PLATFORM_X64)
-#include "x64/bits.h"
-#else
-#warning Unsupported platform
-#endif
-
-#if (defined(SORTIX_KERNEL) || defined(LIBC_LIBRARY)) && !defined(OFF_MIN)
-#define OFF_MIN __OFF_MIN
-#endif
-#if (defined(SORTIX_KERNEL) || defined(LIBC_LIBRARY)) && !defined(OFF_MAX)
-#define OFF_MAX __OFF_MAX
-#endif
diff --git a/sortix/include/sortix/types.h b/sortix/include/sortix/types.h
new file mode 100644
index 00000000..c2362c44
--- /dev/null
+++ b/sortix/include/sortix/types.h
@@ -0,0 +1,30 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2013.
+
+ This file is part of Sortix.
+
+ Sortix is free software: you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation, either version 3 of the License, or (at your option) any later
+ version.
+
+ Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ Sortix. If not, see .
+
+ sortix/types.h
+ Data types.
+
+*******************************************************************************/
+
+#ifndef INCLUDE_SORTIX_TYPES_H
+#define INCLUDE_SORTIX_TYPES_H
+
+#include
+
+#endif
diff --git a/utils/uname.cpp b/utils/uname.cpp
index af8bbd4e..552b6815 100644
--- a/utils/uname.cpp
+++ b/utils/uname.cpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#if !defined(VERSIONSTR)
#define VERSIONSTR "unknown version"