Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/c/Makefile	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -61,4 +61,5 @@
 	generic/bd.c \
 	generic/bd_srv.c \
+	generic/bitops.c \
 	generic/cap.c \
 	generic/cfg.c \
Index: uspace/lib/c/generic/bitops.c
===================================================================
--- uspace/lib/c/generic/bitops.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
+++ uspace/lib/c/generic/bitops.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2013 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+
+#include <bitops.h>
+
+extern int __popcountsi2(int a)
+{
+	return __builtin_popcount(a);
+}
+
+
+/** @}
+ */
Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/c/generic/io/io.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -192,4 +192,18 @@
 }
 
+/** Set stream buffer.
+ *
+ * When @p buf is NULL, the stream is set as unbuffered, otherwise
+ * full buffering is enabled.
+ */
+void setbuf(FILE *stream, void *buf)
+{
+	if (buf == NULL) {
+		setvbuf(stream, NULL, _IONBF, BUFSIZ);
+	} else {
+		setvbuf(stream, buf, _IOFBF, BUFSIZ);
+	}
+}
+
 static void _setvbuf(FILE *stream)
 {
Index: uspace/lib/c/include/bitops.h
===================================================================
--- uspace/lib/c/include/bitops.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/c/include/bitops.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -107,4 +107,6 @@
 }
 
+extern int __popcountsi2(int);
+
 #endif
 
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/c/include/stdio.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -143,4 +143,5 @@
 
 extern void setvbuf(FILE *, void *, int, size_t);
+extern void setbuf(FILE *, void *);
 
 /* Misc file functions */
Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/Makefile	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,6 +37,19 @@
 INCLUDE_LIBC = ./include/libc
 
+LIBC_FILE = $(LIBC_PREFIX)/libc.a
+
+FIXED_POSIX_LIBRARY = libposixaslibc.a
+FIXED_C_LIBRARY = libc4posix.a
+
+REDEFS_HIDE_LIBC = redefs-hide-libc.xargs
+REDEFS_SHOW_LIBPOSIX = redefs-show-posix.xargs
+COLLISIONS_LIST = collisions.list
+
 PRE_DEPEND = $(INCLUDE_LIBC)
-EXTRA_CLEAN = $(INCLUDE_LIBC)
+EXTRA_CLEAN = \
+	$(INCLUDE_LIBC) \
+	$(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX) \
+	$(COLLISIONS_LIST)
+EXTRA_OUTPUT = $(FIXED_C_LIBRARY) $(FIXED_POSIX_LIBRARY)
 
 SOURCES = \
@@ -66,2 +79,23 @@
 $(INCLUDE_LIBC): ../c/include
 	ln -s -f -n ../$^ $@
+
+$(FIXED_C_LIBRARY): $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
+	./tools/transform-symbols.sh \
+		$(OBJCOPY) $(AR) echo \
+		$(LIBC_FILE) $@ \
+		$(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
+
+$(FIXED_POSIX_LIBRARY): $(LIBRARY).a $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
+	./tools/transform-symbols.sh \
+		$(OBJCOPY) $(AR) echo \
+		$(LIBRARY).a $@ \
+		$(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
+
+$(REDEFS_HIDE_LIBC): $(COLLISIONS_LIST)
+	./tools/create-redefines.sh "" "__helenos_libc_" <$(COLLISIONS_LIST) >$@
+	
+$(REDEFS_SHOW_LIBPOSIX): $(COLLISIONS_LIST)
+	./tools/create-redefines.sh "posix_" "" <$(COLLISIONS_LIST) >$@
+
+$(COLLISIONS_LIST):
+	./tools/get-collision-list.sh ./include/posix >$@
Index: uspace/lib/posix/include/posix/ctype.h
===================================================================
--- uspace/lib/posix/include/posix/ctype.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/ctype.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,17 +37,21 @@
 #define POSIX_CTYPE_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "libc/ctype.h"
 
 /* Classification of Characters */
-extern int posix_isxdigit(int c);
-extern int posix_isblank(int c);
-extern int posix_iscntrl(int c);
-extern int posix_isgraph(int c);
-extern int posix_isprint(int c);
-extern int posix_ispunct(int c);
+extern int __POSIX_DEF__(isxdigit)(int c);
+extern int __POSIX_DEF__(isblank)(int c);
+extern int __POSIX_DEF__(iscntrl)(int c);
+extern int __POSIX_DEF__(isgraph)(int c);
+extern int __POSIX_DEF__(isprint)(int c);
+extern int __POSIX_DEF__(ispunct)(int c);
 
 /* Obsolete Functions and Macros */
-extern int posix_isascii(int c);
-extern int posix_toascii(int c);
+extern int __POSIX_DEF__(isascii)(int c);
+extern int __POSIX_DEF__(toascii)(int c);
 #undef _tolower
 #define _tolower(c) ((c) - 'A' + 'a')
@@ -56,15 +60,4 @@
 
 
-#ifndef LIBPOSIX_INTERNAL
-	#define isxdigit posix_isxdigit
-	#define isblank posix_isblank
-	#define iscntrl posix_iscntrl
-	#define isgraph posix_isgraph
-	#define isprint posix_isprint
-	#define ispunct posix_ispunct
-	
-	#define isascii posix_isascii
-	#define toascii posix_toascii
-#endif
 
 #endif /* POSIX_CTYPE_H_ */
Index: uspace/lib/posix/include/posix/dirent.h
===================================================================
--- uspace/lib/posix/include/posix/dirent.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
+++ uspace/lib/posix/include/posix/dirent.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libposix
+ * @{
+ */
+/** @file
+ */
+
+#ifndef POSIX_DIRENT_H_
+#define POSIX_DIRENT_H_
+
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
+#include <libc/dirent.h>
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/posix/include/posix/fcntl.h
===================================================================
--- uspace/lib/posix/include/posix/fcntl.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/fcntl.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,8 @@
 #ifndef POSIX_FCNTL_H_
 #define POSIX_FCNTL_H_
+
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
 
 #include "sys/types.h"
@@ -76,11 +80,7 @@
 #define FD_CLOEXEC         1 /* Close on exec. */
 
-extern int posix_open(const char *pathname, int flags, ...);
-extern int posix_fcntl(int fd, int cmd, ...);
+extern int __POSIX_DEF__(open)(const char *pathname, int flags, ...);
+extern int __POSIX_DEF__(fcntl)(int fd, int cmd, ...);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define fcntl posix_fcntl
-	#define open posix_open
-#endif
 
 #endif /* POSIX_FCNTL_H_ */
Index: uspace/lib/posix/include/posix/fenv.h
===================================================================
--- uspace/lib/posix/include/posix/fenv.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
+++ uspace/lib/posix/include/posix/fenv.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libposix
+ * @{
+ */
+/** @file
+ * Floating point related constants.
+ */
+
+#ifndef POSIX_FENV_H_
+#define POSIX_FENV_H_
+
+
+#define FE_DIVBYZERO 1
+#define FE_INEXACT 2
+#define FE_INVALID 4
+#define FE_OVERFLOW 8
+#define FE_UNDERFLOW 16
+#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/posix/include/posix/float.h
===================================================================
--- uspace/lib/posix/include/posix/float.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/float.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -61,5 +61,47 @@
 	#undef FLT_RADIX
 	#define FLT_RADIX __FLT_RADIX__
+#else
+/* For something else than GCC, following definitions are provided.
+ * They are intentionally guarded by the given macro to ensure that anyone
+ * who wants them states this explicitly.
+ *
+ * The values are the ones GCC prints when compiled on i686 Linux.
+ *
+ * WARNING: the values are not accurate (especially the long double ones)!
+ *
+ */
+#ifdef FLOAT_H_YES_I_REALLY_WANT_LIMITS
+/* float limits */
+#define FLT_MIN 1.1754943508222875079687365372222456778186655567720875215087517062784172594547271728515625e-38
+#define FLT_MAX 340282346638528859811704183484516925440
+
+/* double limits */
+#define DBL_MIN 2.2250738585072013830902327173324040642192159804623318305533274168872044348139181958542831590125110205640673397310358110051524341615534601088560123853777188211307779935320023304796101474425836360719216e-308
+#define DBL_MAX 1.7976931348623157081452742373170435679807056752584499659891747680315726078002853876058955863276687817154045895351438246423432132688946418276846754670353751698604991057655128207624549009038932894407587e+308
+
+/* long double limits */
+#define LDBL_MIN 3.3621031431120935062626778173217526025980793448464712401088272298087426993907289670430927063650562228625019066688234732270901114717276781407474941951906317291667263914849985862188944930687409323125832e-4932L
+#define LDBL_MAX 1.1897314953572317650212638530309702051690633222946242004403237338917370055229707226164102903365288828535456978074955773144274431536702884341981255738537436786735932007069732632019159182829615243655295e+4932L
+
+/* epsilons */
+#define FLT_EPSILON 1.1920928955078125e-07
+#define DBL_EPSILON 2.220446049250313080847263336181640625e-16
+#define LDBL_EPSILON 1.08420217248550443400745280086994171142578125e-19L
+
+/* float radix */
+#define FLT_RADIX 2
+
+/* mantisa */
+#define FLT_MANT_DIG 24
+#define DBL_MANT_DIG 53
+#define LDBL_MANT_DIG 64
+
+/* exponents */
+#define DBL_MIN_EXP -1021
+#define DBL_MAX_EXP 1024
+
 #endif
+
+#endif /* __GNUC__ */
 
 #endif /* POSIX_FLOAT_H_ */
Index: uspace/lib/posix/include/posix/fnmatch.h
===================================================================
--- uspace/lib/posix/include/posix/fnmatch.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/fnmatch.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,4 +36,8 @@
 #define POSIX_FNMATCH_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 /* Error Values */
 #undef FNM_NOMATCH
@@ -56,9 +60,6 @@
 #define FNM_CASEFOLD 16
 
-extern int posix_fnmatch(const char *pattern, const char *string, int flags);
+extern int __POSIX_DEF__(fnmatch)(const char *pattern, const char *string, int flags);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define fnmatch posix_fnmatch
-#endif
 
 #endif /* POSIX_FNMATCH_H_ */
Index: uspace/lib/posix/include/posix/getopt.h
===================================================================
--- uspace/lib/posix/include/posix/getopt.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/getopt.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,8 @@
 #define POSIX_GETOPT_H
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "unistd.h"
 
@@ -51,10 +55,5 @@
 #endif
 
-extern int posix_getopt_long(int, char * const [], const char *, const struct option *, int *);
-
-
-#ifndef LIBPOSIX_INTERNAL
-	#define getopt_long posix_getopt_long
-#endif
+extern int __POSIX_DEF__(getopt_long)(int, char * const [], const char *, const struct option *, int *);
 
 
Index: uspace/lib/posix/include/posix/inttypes.h
===================================================================
--- uspace/lib/posix/include/posix/inttypes.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/inttypes.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,16 +36,16 @@
 #define POSIX_INTTYPES_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "stdint.h"
 #include "libc/inttypes.h"
 
-extern posix_intmax_t posix_strtoimax(const char *restrict nptr,
+extern __POSIX_DEF__(intmax_t) __POSIX_DEF__(strtoimax)(const char *restrict nptr,
     char **restrict endptr, int base);
-extern posix_uintmax_t posix_strtoumax(const char *restrict nptr,
+extern __POSIX_DEF__(uintmax_t) __POSIX_DEF__(strtoumax)(const char *restrict nptr,
     char **restrict endptr, int base);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define strtoimax posix_strtoimax
-	#define strtoumax posix_strtoumax
-#endif
 
 #endif /* POSIX_INTTYPES_H_ */
Index: uspace/lib/posix/include/posix/locale.h
===================================================================
--- uspace/lib/posix/include/posix/locale.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/locale.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,4 +36,8 @@
 #define POSIX_LOCALE_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #ifndef NULL
 	#define NULL ((void *) 0)
@@ -42,7 +46,7 @@
 #ifndef __locale_t_defined
 	#define __locale_t_defined
-	typedef struct __posix_locale *posix_locale_t;
+	typedef struct __posix_locale *__POSIX_DEF__(locale_t);
 	#ifndef LIBPOSIX_INTERNAL
-		#define locale_t posix_locale_t
+		#define locale_t __POSIX_DEF__(locale_t)
 	#endif
 #endif
@@ -82,5 +86,5 @@
 #define LC_GLOBAL_LOCALE NULL
 
-struct posix_lconv {
+struct __POSIX_DEF__(lconv) {
 	char *currency_symbol;
 	char *decimal_point;
@@ -109,25 +113,14 @@
 };
 
-extern char *posix_setlocale(int category, const char *locale);
-extern struct posix_lconv *posix_localeconv(void);
+extern char *__POSIX_DEF__(setlocale)(int category, const char *locale);
+extern struct __POSIX_DEF__(lconv) *__POSIX_DEF__(localeconv)(void);
 
 /* POSIX Extensions */
-extern posix_locale_t posix_duplocale(posix_locale_t locobj);
-extern void posix_freelocale(posix_locale_t locobj);
-extern posix_locale_t posix_newlocale(int category_mask, const char *locale,
-    posix_locale_t base);
-extern posix_locale_t posix_uselocale(posix_locale_t newloc);
+extern __POSIX_DEF__(locale_t) __POSIX_DEF__(duplocale)(__POSIX_DEF__(locale_t) locobj);
+extern void __POSIX_DEF__(freelocale)(__POSIX_DEF__(locale_t) locobj);
+extern __POSIX_DEF__(locale_t) __POSIX_DEF__(newlocale)(int category_mask, const char *locale,
+    __POSIX_DEF__(locale_t) base);
+extern __POSIX_DEF__(locale_t) __POSIX_DEF__(uselocale)(__POSIX_DEF__(locale_t) newloc);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define lconv posix_lconv
-
-	#define setlocale posix_setlocale
-	#define localeconv posix_localeconv
-
-	#define newlocale posix_newlocale
-	#define uselocale posix_uselocale
-	#define duplocale posix_duplocale
-	#define freelocale posix_freelocale
-#endif
 
 #endif /* POSIX_LOCALE_H_ */
Index: uspace/lib/posix/include/posix/math.h
===================================================================
--- uspace/lib/posix/include/posix/math.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/math.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,4 +36,8 @@
 #define POSIX_MATH_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #ifdef __GNUC__
 	#define HUGE_VAL (__builtin_huge_val())
@@ -41,35 +45,18 @@
 
 /* Normalization Functions */
-extern double posix_ldexp(double x, int exp);
-extern double posix_frexp(double num, int *exp);
+extern double __POSIX_DEF__(ldexp)(double x, int exp);
+extern double __POSIX_DEF__(frexp)(double num, int *exp);
 
-double posix_fabs(double x);
-double posix_floor(double x);
-double posix_modf(double x, double *iptr);
-double posix_fmod(double x, double y);
-double posix_pow(double x, double y);
-double posix_exp(double x);
-double posix_sqrt(double x);
-double posix_log(double x);
-double posix_sin(double x);
-double posix_cos(double x);
-double posix_atan2(double y, double x);
-
-#ifndef LIBPOSIX_INTERNAL
-	#define ldexp posix_ldexp
-	#define frexp posix_frexp
-
-	#define fabs posix_fabs
-	#define floor posix_floor
-	#define modf posix_modf
-	#define fmod posix_fmod
-	#define pow posix_pow
-	#define exp posix_exp
-	#define sqrt posix_sqrt
-	#define log posix_log
-	#define sin posix_sin
-	#define cos posix_cos
-	#define atan2 posix_atan2
-#endif
+double __POSIX_DEF__(fabs)(double x);
+double __POSIX_DEF__(floor)(double x);
+double __POSIX_DEF__(modf)(double x, double *iptr);
+double __POSIX_DEF__(fmod)(double x, double y);
+double __POSIX_DEF__(pow)(double x, double y);
+double __POSIX_DEF__(exp)(double x);
+double __POSIX_DEF__(sqrt)(double x);
+double __POSIX_DEF__(log)(double x);
+double __POSIX_DEF__(sin)(double x);
+double __POSIX_DEF__(cos)(double x);
+double __POSIX_DEF__(atan2)(double y, double x);
 
 #endif /* POSIX_MATH_H_ */
Index: uspace/lib/posix/include/posix/pwd.h
===================================================================
--- uspace/lib/posix/include/posix/pwd.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/pwd.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,39 +36,30 @@
 #define POSIX_PWD_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "sys/types.h"
 
-struct posix_passwd {
+struct __POSIX_DEF__(passwd) {
 	char *pw_name;
-	posix_uid_t pw_uid;
-	posix_gid_t pw_gid;
+	__POSIX_DEF__(uid_t) pw_uid;
+	__POSIX_DEF__(gid_t) pw_gid;
 	char *pw_dir;
 	char *pw_shell;
 };
 
-extern struct posix_passwd *posix_getpwent(void);
-extern void posix_setpwent(void);
-extern void posix_endpwent(void);
+extern struct __POSIX_DEF__(passwd) *__POSIX_DEF__(getpwent)(void);
+extern void __POSIX_DEF__(setpwent)(void);
+extern void __POSIX_DEF__(endpwent)(void);
 
-extern struct posix_passwd *posix_getpwnam(const char *name);
-extern int posix_getpwnam_r(const char *name, struct posix_passwd *pwd,
-    char *buffer, size_t bufsize, struct posix_passwd **result);
+extern struct __POSIX_DEF__(passwd) *__POSIX_DEF__(getpwnam)(const char *name);
+extern int __POSIX_DEF__(getpwnam_r)(const char *name, struct __POSIX_DEF__(passwd) *pwd,
+    char *buffer, size_t bufsize, struct __POSIX_DEF__(passwd) **result);
 
-extern struct posix_passwd *posix_getpwuid(posix_uid_t uid);
-extern int posix_getpwuid_r(posix_uid_t uid, struct posix_passwd *pwd,
-    char *buffer, size_t bufsize, struct posix_passwd **result);
+extern struct __POSIX_DEF__(passwd) *__POSIX_DEF__(getpwuid)(__POSIX_DEF__(uid_t) uid);
+extern int __POSIX_DEF__(getpwuid_r)(__POSIX_DEF__(uid_t) uid, struct __POSIX_DEF__(passwd) *pwd,
+    char *buffer, size_t bufsize, struct __POSIX_DEF__(passwd) **result);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define passwd posix_passwd
-	
-	#define getpwent posix_getpwent
-	#define setpwent posix_setpwent
-	#define endpwent posix_endpwent
-
-	#define getpwnam posix_getpwnam
-	#define getpwnam_r posix_getpwnam_r
-
-	#define getpwuid posix_getpwuid
-	#define getpwuid_r posix_getpwuid_r
-#endif
 
 #endif /* POSIX_PWD_H_ */
Index: uspace/lib/posix/include/posix/signal.h
===================================================================
--- uspace/lib/posix/include/posix/signal.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/signal.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,5 +36,10 @@
 #define POSIX_SIGNAL_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "sys/types.h"
+#include <posix/ucontext.h>
 
 extern void __posix_default_signal_handler(int signo);
@@ -51,23 +56,4 @@
 #define SIG_IGN ((void (*)(int)) __posix_ignore_signal_handler)
 
-typedef int posix_sig_atomic_t;
-typedef uint32_t posix_sigset_t;
-typedef struct posix_mcontext {
-	/* must not be empty to avoid compiler warnings (-pedantic) */
-	int dummy;
-} posix_mcontext_t;
-
-union posix_sigval {
-	int sival_int;
-	void *sival_ptr;
-};
-
-struct posix_sigevent {
-	int sigev_notify; /* Notification type. */
-	int sigev_signo; /* Signal number. */
-	union posix_sigval sigev_value; /* Signal value. */
-	void (*sigev_notify_function)(union posix_sigval); /* Notification function. */
-	posix_thread_attr_t *sigev_notify_attributes; /* Notification attributes. */
-};
 
 typedef struct {
@@ -77,6 +63,6 @@
 	int si_errno;
 
-	posix_pid_t si_pid;
-	posix_uid_t si_uid;
+	__POSIX_DEF__(pid_t) si_pid;
+	__POSIX_DEF__(uid_t) si_uid;
 	void *si_addr;
 	int si_status;
@@ -84,28 +70,16 @@
 	long si_band;
 
-	union posix_sigval si_value;
-} posix_siginfo_t;
-
-struct posix_sigaction {
+	union __POSIX_DEF__(sigval) si_value;
+} __POSIX_DEF__(siginfo_t);
+
+struct __POSIX_DEF__(sigaction) {
 	void (*sa_handler)(int);
-	posix_sigset_t sa_mask;
+	__POSIX_DEF__(sigset_t) sa_mask;
 	int sa_flags;
-	void (*sa_sigaction)(int, posix_siginfo_t *, void *);
+	void (*sa_sigaction)(int, __POSIX_DEF__(siginfo_t) *, void *);
 };
 
-typedef struct {
-	void *ss_sp;
-	size_t ss_size;
-	int ss_flags;
-} posix_stack_t;
-
-typedef struct posix_ucontext {
-	struct posix_ucontext *uc_link;
-	posix_sigset_t uc_sigmask;
-	posix_stack_t uc_stack;
-	posix_mcontext_t uc_mcontext;
-} posix_ucontext_t;
-
-/* Values of posix_sigevent::sigev_notify */
+
+/* Values of __POSIX_DEF__(sigevent)::sigev_notify */
 #undef SIGEV_NONE
 #undef SIGEV_SIGNAL
@@ -255,57 +229,26 @@
 };
 
-extern int posix_sigaction(int sig, const struct posix_sigaction *restrict act,
-    struct posix_sigaction *restrict oact);
-
-extern void (*posix_signal(int sig, void (*func)(int)))(int);
-extern int posix_raise(int sig);
-extern int posix_kill(posix_pid_t pid, int sig);
-extern int posix_killpg(posix_pid_t pid, int sig);
-
-extern void posix_psiginfo(const posix_siginfo_t *pinfo, const char *message);
-extern void posix_psignal(int signum, const char *message);
-
-extern int posix_sigemptyset(posix_sigset_t *set);
-extern int posix_sigfillset(posix_sigset_t *set);
-extern int posix_sigaddset(posix_sigset_t *set, int signo);
-extern int posix_sigdelset(posix_sigset_t *set, int signo);
-extern int posix_sigismember(const posix_sigset_t *set, int signo);
-
-extern int posix_thread_sigmask(int how, const posix_sigset_t *restrict set,
-    posix_sigset_t *restrict oset);
-extern int posix_sigprocmask(int how, const posix_sigset_t *restrict set,
-    posix_sigset_t *restrict oset);
-
-#ifndef LIBPOSIX_INTERNAL
-	#define sig_atomic_t posix_sig_atomic_t
-	#define sigset_t posix_sigset_t
-	#define sigval posix_sigval
-	#ifndef sigevent
-		#define sigevent posix_sigevent
-	#endif
-	#define mcontext_t posix_mcontext_t
-	#define ucontext_t posix_ucontext_t
-	#define stack_t posix_stack_t
-	#define siginfo_t posix_siginfo_t
-
-	#define sigaction posix_sigaction
-
-	#define signal posix_signal
-	#define raise posix_raise
-	#define kill posix_kill
-	#define killpg posix_killpg
-
-	#define psiginfo posix_psiginfo
-	#define psignal posix_psignal
-
-	#define sigemptyset posix_sigemptyset
-	#define sigfillset posix_sigfillset
-	#define sigaddset posix_sigaddset
-	#define sigdelset posix_sigdelset
-	#define sigismember posix_sigismember
-
-	#define pthread_sigmask posix_thread_sigmask
-	#define sigprocmask posix_sigprocmask
-#endif
+extern int __POSIX_DEF__(sigaction)(int sig, const struct __POSIX_DEF__(sigaction) *restrict act,
+    struct __POSIX_DEF__(sigaction) *restrict oact);
+
+extern void (*__POSIX_DEF__(signal)(int sig, void (*func)(int)))(int);
+extern int __POSIX_DEF__(raise)(int sig);
+extern int __POSIX_DEF__(kill)(__POSIX_DEF__(pid_t) pid, int sig);
+extern int __POSIX_DEF__(killpg)(__POSIX_DEF__(pid_t) pid, int sig);
+
+extern void __POSIX_DEF__(psiginfo)(const __POSIX_DEF__(siginfo_t) *pinfo, const char *message);
+extern void __POSIX_DEF__(psignal)(int signum, const char *message);
+
+extern int __POSIX_DEF__(sigemptyset)(__POSIX_DEF__(sigset_t) *set);
+extern int __POSIX_DEF__(sigfillset)(__POSIX_DEF__(sigset_t) *set);
+extern int __POSIX_DEF__(sigaddset)(__POSIX_DEF__(sigset_t) *set, int signo);
+extern int __POSIX_DEF__(sigdelset)(__POSIX_DEF__(sigset_t) *set, int signo);
+extern int __POSIX_DEF__(sigismember)(const __POSIX_DEF__(sigset_t) *set, int signo);
+
+extern int __POSIX_DEF__(thread_sigmask)(int how, const __POSIX_DEF__(sigset_t) *restrict set,
+    __POSIX_DEF__(sigset_t) *restrict oset);
+extern int __POSIX_DEF__(sigprocmask)(int how, const __POSIX_DEF__(sigset_t) *restrict set,
+    __POSIX_DEF__(sigset_t) *restrict oset);
+
 
 #endif /* POSIX_SIGNAL_H_ */
Index: uspace/lib/posix/include/posix/stddef.h
===================================================================
--- uspace/lib/posix/include/posix/stddef.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/stddef.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,4 +36,8 @@
 #define POSIX_STDDEF_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "sys/types.h"
 
@@ -44,9 +48,6 @@
 #define offsetof(type,member) ((size_t) &(((type *) 0)->member))
 
-typedef ssize_t posix_ptrdiff_t;
+typedef ssize_t __POSIX_DEF__(ptrdiff_t);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define ptrdiff_t posix_ptrdiff_t
-#endif
 
 #endif /* POSIX_STDDEF_H_ */
Index: uspace/lib/posix/include/posix/stdint.h
===================================================================
--- uspace/lib/posix/include/posix/stdint.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/stdint.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,8 @@
 #ifndef POSIX_STDINT_H_
 #define POSIX_STDINT_H_
+
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
 
 #include "libc/stdint.h"
@@ -100,11 +104,7 @@
 #include "libc/sys/types.h"
 
-typedef int64_t posix_intmax_t;
-typedef uint64_t posix_uintmax_t;
+typedef int64_t __POSIX_DEF__(intmax_t);
+typedef uint64_t __POSIX_DEF__(uintmax_t);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define intmax_t posix_intmax_t
-	#define uintmax_t posix_uintmax_t
-#endif
 
 #endif /* POSIX_STDINT_H_ */
Index: uspace/lib/posix/include/posix/stdio.h
===================================================================
--- uspace/lib/posix/include/posix/stdio.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/stdio.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,4 +37,13 @@
 #define POSIX_STDIO_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+/* DEBUG macro does not belong to POSIX stdio.h. Its unconditional
+ * definition in the native stdio.h causes unexpected behaviour of
+ * applications which uses their own DEBUG macro (e.g. debugging
+ * output is printed even if not desirable). */
+#undef DEBUG
+#endif
+
 #include "stddef.h"
 #include "unistd.h"
@@ -108,7 +117,5 @@
 extern size_t fwrite(const void *, size_t, size_t, FILE *);
 
-extern int fseek(FILE *, off64_t, int);
 extern void rewind(FILE *);
-extern off64_t ftell(FILE *);
 extern int feof(FILE *);
 extern int fileno(FILE *);
@@ -126,141 +133,82 @@
 #undef L_ctermid
 #define L_ctermid PATH_MAX
-extern char *posix_ctermid(char *s);
+extern char *__POSIX_DEF__(ctermid)(char *s);
 
 /* Error Recovery */
-extern void posix_clearerr(FILE *stream);
+extern void __POSIX_DEF__(clearerr)(FILE *stream);
 
 /* Input/Output */
 #undef putc
 #define putc fputc
-extern int posix_fputs(const char *restrict s, FILE *restrict stream);
+extern int __POSIX_DEF__(fputs)(const char *restrict s, FILE *restrict stream);
 #undef getc
 #define getc fgetc
-extern int posix_ungetc(int c, FILE *stream);
-extern ssize_t posix_getdelim(char **restrict lineptr, size_t *restrict n,
+extern int __POSIX_DEF__(ungetc)(int c, FILE *stream);
+extern ssize_t __POSIX_DEF__(getdelim)(char **restrict lineptr, size_t *restrict n,
     int delimiter, FILE *restrict stream);
-extern ssize_t posix_getline(char **restrict lineptr, size_t *restrict n,
+extern ssize_t __POSIX_DEF__(getline)(char **restrict lineptr, size_t *restrict n,
     FILE *restrict stream);
 
 /* Opening Streams */
-extern FILE *posix_freopen(const char *restrict filename,
+extern FILE *__POSIX_DEF__(freopen)(const char *restrict filename,
     const char *restrict mode, FILE *restrict stream);
 
 /* Error Messages */
-extern void posix_perror(const char *s);
+extern void __POSIX_DEF__(perror)(const char *s);
 
 /* File Positioning */
-typedef struct _posix_fpos posix_fpos_t;
-extern int posix_fsetpos(FILE *stream, const posix_fpos_t *pos);
-extern int posix_fgetpos(FILE *restrict stream, posix_fpos_t *restrict pos);
-extern int posix_fseek(FILE *stream, long offset, int whence);
-extern int posix_fseeko(FILE *stream, posix_off_t offset, int whence);
-extern long posix_ftell(FILE *stream);
-extern posix_off_t posix_ftello(FILE *stream);
+typedef struct _posix_fpos __POSIX_DEF__(fpos_t);
+extern int __POSIX_DEF__(fsetpos)(FILE *stream, const __POSIX_DEF__(fpos_t) *pos);
+extern int __POSIX_DEF__(fgetpos)(FILE *restrict stream, __POSIX_DEF__(fpos_t) *restrict pos);
+extern int __POSIX_DEF__(fseek)(FILE *stream, long offset, int whence);
+extern int __POSIX_DEF__(fseeko)(FILE *stream, __POSIX_DEF__(off_t) offset, int whence);
+extern long __POSIX_DEF__(ftell)(FILE *stream);
+extern __POSIX_DEF__(off_t) __POSIX_DEF__(ftello)(FILE *stream);
 
 /* Flushing Buffers */
-extern int posix_fflush(FILE *stream);
+extern int __POSIX_DEF__(fflush)(FILE *stream);
 
 /* Formatted Output */
-extern int posix_dprintf(int fildes, const char *restrict format, ...)
+extern int __POSIX_DEF__(dprintf)(int fildes, const char *restrict format, ...)
     PRINTF_ATTRIBUTE(2, 3);
-extern int posix_vdprintf(int fildes, const char *restrict format, va_list ap);
-extern int posix_sprintf(char *restrict s, const char *restrict format, ...)
+extern int __POSIX_DEF__(vdprintf)(int fildes, const char *restrict format, va_list ap);
+extern int __POSIX_DEF__(sprintf)(char *restrict s, const char *restrict format, ...)
     PRINTF_ATTRIBUTE(2, 3);
-extern int posix_vsprintf(char *restrict s, const char *restrict format, va_list ap);
+extern int __POSIX_DEF__(vsprintf)(char *restrict s, const char *restrict format, va_list ap);
 
 /* Formatted Input */
-extern int posix_fscanf(
+extern int __POSIX_DEF__(fscanf)(
     FILE *restrict stream, const char *restrict format, ...);
-extern int posix_vfscanf(
+extern int __POSIX_DEF__(vfscanf)(
     FILE *restrict stream, const char *restrict format, va_list arg);
-extern int posix_scanf(const char *restrict format, ...);
-extern int posix_vscanf(const char *restrict format, va_list arg);
-extern int posix_sscanf(
+extern int __POSIX_DEF__(scanf)(const char *restrict format, ...);
+extern int __POSIX_DEF__(vscanf)(const char *restrict format, va_list arg);
+extern int __POSIX_DEF__(sscanf)(
     const char *restrict s, const char *restrict format, ...);
-extern int posix_vsscanf(
+extern int __POSIX_DEF__(vsscanf)(
     const char *restrict s, const char *restrict format, va_list arg);
 
 /* File Locking */
-extern void posix_flockfile(FILE *file);
-extern int posix_ftrylockfile(FILE *file);
-extern void posix_funlockfile(FILE *file);
-extern int posix_getc_unlocked(FILE *stream);
-extern int posix_getchar_unlocked(void);
-extern int posix_putc_unlocked(int c, FILE *stream);
-extern int posix_putchar_unlocked(int c);
+extern void __POSIX_DEF__(flockfile)(FILE *file);
+extern int __POSIX_DEF__(ftrylockfile)(FILE *file);
+extern void __POSIX_DEF__(funlockfile)(FILE *file);
+extern int __POSIX_DEF__(getc_unlocked)(FILE *stream);
+extern int __POSIX_DEF__(getchar_unlocked)(void);
+extern int __POSIX_DEF__(putc_unlocked)(int c, FILE *stream);
+extern int __POSIX_DEF__(putchar_unlocked)(int c);
 
 /* Deleting Files */
-extern int posix_remove(const char *path);
+extern int __POSIX_DEF__(remove)(const char *path);
 
 /* Renaming Files */
-extern int posix_rename(const char *old, const char *new);
+extern int __POSIX_DEF__(rename)(const char *oldname, const char *newname);
 
 /* Temporary Files */
 #undef L_tmpnam
 #define L_tmpnam PATH_MAX
-extern char *posix_tmpnam(char *s);
-extern char *posix_tempnam(const char *dir, const char *pfx);
-extern FILE *posix_tmpfile(void);
-
-#ifndef LIBPOSIX_INTERNAL
-	/* DEBUG macro does not belong to POSIX stdio.h. Its unconditional
-	 * definition in the native stdio.h causes unexpected behaviour of
-	 * applications which uses their own DEBUG macro (e.g. debugging
-	 * output is printed even if not desirable). */
-	#undef DEBUG
-
-	#define ctermid posix_ctermid
-
-	#define clearerr posix_clearerr
-
-	#define fputs posix_fputs
-	#define ungetc posix_ungetc
-	#define getdelim posix_getdelim
-	#define getline posix_getline
-
-	#define freopen posix_freopen
-
-	#define perror posix_perror
-
-	#define fpos_t posix_fpos_t
-	#define fsetpos posix_fsetpos
-	#define fgetpos posix_fgetpos
-	#define fseek posix_fseek
-	#define fseeko posix_fseeko
-	#define ftell posix_ftell
-	#define ftello posix_ftello
-
-	#define fflush posix_fflush
-
-	#define dprintf posix_dprintf
-	#define vdprintf posix_vdprintf
-	#define sprintf posix_sprintf
-	#define vsprintf posix_vsprintf
-
-	#define fscanf posix_fscanf
-	#define vfscanf posix_vfscanf
-	#define vscanf posix_vscanf
-	#define scanf posix_scanf
-	#define sscanf posix_sscanf
-	#define vsscanf posix_vsscanf
-
-	#define flockfile posix_flockfile
-	#define ftrylockfile posix_ftrylockfile
-	#define funlockfile posix_funlockfile
-
-	#define getc_unlocked posix_getc_unlocked
-	#define getchar_unlocked posix_getchar_unlocked
-	#define putc_unlocked posix_putc_unlocked
-	#define putchar_unlocked posix_putchar_unlocked
-
-	#define remove posix_remove
-
-	#define rename posix_rename
-
-	#define tmpnam posix_tmpnam
-	#define tempnam posix_tempnam
-	#define tmpfile posix_tmpfile
-#endif
+extern char *__POSIX_DEF__(tmpnam)(char *s);
+extern char *__POSIX_DEF__(tempnam)(const char *dir, const char *pfx);
+extern FILE *__POSIX_DEF__(tmpfile)(void);
+
 
 #endif /* POSIX_STDIO_H_ */
Index: uspace/lib/posix/include/posix/stdlib.h
===================================================================
--- uspace/lib/posix/include/posix/stdlib.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/stdlib.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,4 +37,8 @@
 #define POSIX_STDLIB_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "sys/types.h"
 
@@ -49,12 +53,12 @@
 #define EXIT_SUCCESS 0
 #define _Exit exit
-extern int posix_atexit(void (*func)(void));
+extern int __POSIX_DEF__(atexit)(void (*func)(void));
 extern void exit(int status);
 extern void abort(void) __attribute__((noreturn));
 
 /* Absolute Value */
-extern int posix_abs(int i);
-extern long posix_labs(long i);
-extern long long posix_llabs(long long i);
+extern int __POSIX_DEF__(abs)(int i);
+extern long __POSIX_DEF__(labs)(long i);
+extern long long __POSIX_DEF__(llabs)(long long i);
 
 /* Integer Division */
@@ -62,110 +66,63 @@
 typedef struct {
 	int quot, rem;
-} posix_div_t;
+} __POSIX_DEF__(div_t);
 
 typedef struct {
 	long quot, rem;
-} posix_ldiv_t;
+} __POSIX_DEF__(ldiv_t);
 
 typedef struct {
 	long long quot, rem;
-} posix_lldiv_t;
+} __POSIX_DEF__(lldiv_t);
 
-extern posix_div_t posix_div(int numer, int denom);
-extern posix_ldiv_t posix_ldiv(long numer, long denom);
-extern posix_lldiv_t posix_lldiv(long long numer, long long denom);
+extern __POSIX_DEF__(div_t) __POSIX_DEF__(div)(int numer, int denom);
+extern __POSIX_DEF__(ldiv_t) __POSIX_DEF__(ldiv)(long numer, long denom);
+extern __POSIX_DEF__(lldiv_t) __POSIX_DEF__(lldiv)(long long numer, long long denom);
 
 /* Array Functions */
-extern void posix_qsort(void *array, size_t count, size_t size,
+extern void __POSIX_DEF__(qsort)(void *array, size_t count, size_t size,
     int (*compare)(const void *, const void *));
-extern void *posix_bsearch(const void *key, const void *base,
+extern void *__POSIX_DEF__(bsearch)(const void *key, const void *base,
     size_t nmemb, size_t size, int (*compar)(const void *, const void *));
 
 /* Environment Access */
-extern char *posix_getenv(const char *name);
-extern int posix_putenv(char *string);
-extern int posix_system(const char *string);
+extern char *__POSIX_DEF__(getenv)(const char *name);
+extern int __POSIX_DEF__(putenv)(char *string);
+extern int __POSIX_DEF__(system)(const char *string);
 
 /* Symbolic Links */
-extern char *posix_realpath(const char *restrict name, char *restrict resolved);
+extern char *__POSIX_DEF__(realpath)(const char *restrict name, char *restrict resolved);
 
 /* Floating Point Conversion */
-extern double posix_atof(const char *nptr);
-extern float posix_strtof(const char *restrict nptr, char **restrict endptr);
-extern double posix_strtod(const char *restrict nptr, char **restrict endptr);
-extern long double posix_strtold(const char *restrict nptr, char **restrict endptr);
+extern double __POSIX_DEF__(atof)(const char *nptr);
+extern float __POSIX_DEF__(strtof)(const char *restrict nptr, char **restrict endptr);
+extern double __POSIX_DEF__(strtod)(const char *restrict nptr, char **restrict endptr);
+extern long double __POSIX_DEF__(strtold)(const char *restrict nptr, char **restrict endptr);
 
 /* Integer Conversion */
-extern int posix_atoi(const char *nptr);
-extern long int posix_atol(const char *nptr);
-extern long long int posix_atoll(const char *nptr);
-extern long int posix_strtol(const char *restrict nptr,
+extern int __POSIX_DEF__(atoi)(const char *nptr);
+extern long int __POSIX_DEF__(atol)(const char *nptr);
+extern long long int __POSIX_DEF__(atoll)(const char *nptr);
+extern long int __POSIX_DEF__(strtol)(const char *restrict nptr,
     char **restrict endptr, int base);
-extern long long int posix_strtoll(const char *restrict nptr,
+extern long long int __POSIX_DEF__(strtoll)(const char *restrict nptr,
     char **restrict endptr, int base);
-extern unsigned long int posix_strtoul(const char *restrict nptr,
+extern unsigned long int __POSIX_DEF__(strtoul)(const char *restrict nptr,
     char **restrict endptr, int base);
-extern unsigned long long int posix_strtoull(
+extern unsigned long long int __POSIX_DEF__(strtoull)(
     const char *restrict nptr, char **restrict endptr, int base);
 
 /* Memory Allocation */
-extern void *posix_malloc(size_t size);
-extern void *posix_calloc(size_t nelem, size_t elsize);
-extern void *posix_realloc(void *ptr, size_t size);
-extern void posix_free(void *ptr);
+extern void *__POSIX_DEF__(malloc)(size_t size);
+extern void *__POSIX_DEF__(calloc)(size_t nelem, size_t elsize);
+extern void *__POSIX_DEF__(realloc)(void *ptr, size_t size);
+extern void __POSIX_DEF__(free)(void *ptr);
 
 /* Temporary Files */
-extern int posix_mkstemp(char *tmpl);
+extern int __POSIX_DEF__(mkstemp)(char *tmpl);
 
 /* Legacy Declarations */
-extern char *posix_mktemp(char *tmpl);
+extern char *__POSIX_DEF__(mktemp)(char *tmpl);
 extern int bsd_getloadavg(double loadavg[], int nelem);
-
-#ifndef LIBPOSIX_INTERNAL
-	#define atexit posix_atexit
-
-	#define abs posix_abs
-	#define labs posix_labs
-	#define llabs posix_llabs
-
-	#define div_t posix_div_t
-	#define ldiv_t posix_ldiv_t
-	#define lldiv_t posix_lldiv_t
-	#define div posix_div
-	#define ldiv posix_ldiv
-	#define lldiv posix_lldiv
-
-	#define qsort posix_qsort
-	#define bsearch posix_bsearch
-
-	#define getenv posix_getenv
-	#define putenv posix_putenv
-	#define system posix_system
-
-	#define realpath posix_realpath
-	
-	#define atof posix_atof
-	#define strtof posix_strtof
-	#define strtod posix_strtod
-	#define strtold posix_strtold
-	
-	#define atoi posix_atoi
-	#define atol posix_atol
-	#define atoll posix_atoll
-	#define strtol posix_strtol
-	#define strtoll posix_strtoll
-	#define strtoul posix_strtoul
-	#define strtoull posix_strtoull
-
-	#define malloc posix_malloc
-	#define calloc posix_calloc
-	#define realloc posix_realloc
-	#define free posix_free
-
-	#define mkstemp posix_mkstemp
-
-	#define mktemp posix_mktemp
-	#define getloadavg bsd_getloadavg
-#endif
 
 #endif  // POSIX_STDLIB_H_
Index: uspace/lib/posix/include/posix/string.h
===================================================================
--- uspace/lib/posix/include/posix/string.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/string.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,4 +37,8 @@
 #define POSIX_STRING_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "sys/types.h"
 
@@ -65,5 +69,5 @@
 
 /* From mem.h */
-#define bzero(ptr, len)  memset((ptr), 0, (len))
+// #define bzero(ptr, len)  memset((ptr), 0, (len))
 extern void *memset(void *, int, size_t);
 extern void *memcpy(void *, const void *, size_t);
@@ -72,90 +76,51 @@
 
 /* Copying and Concatenation */
-extern char *posix_strcpy(char *restrict dest, const char *restrict src);
-extern char *posix_strncpy(char *restrict dest, const char *restrict src, size_t n);
-extern char *posix_stpcpy(char *restrict dest, const char *restrict src);
-extern char *posix_stpncpy(char *restrict dest, const char *restrict src, size_t n);
-extern char *posix_strcat(char *restrict dest, const char *restrict src);
-extern char *posix_strncat(char *restrict dest, const char *restrict src, size_t n);
-extern void *posix_memccpy(void *restrict dest, const void *restrict src, int c, size_t n);
-extern char *posix_strdup(const char *s);
-extern char *posix_strndup(const char *s, size_t n);
+extern char *__POSIX_DEF__(strcpy)(char *restrict dest, const char *restrict src);
+extern char *__POSIX_DEF__(strncpy)(char *restrict dest, const char *restrict src, size_t n);
+extern char *__POSIX_DEF__(stpcpy)(char *restrict dest, const char *restrict src);
+extern char *__POSIX_DEF__(stpncpy)(char *restrict dest, const char *restrict src, size_t n);
+extern char *__POSIX_DEF__(strcat)(char *restrict dest, const char *restrict src);
+extern char *__POSIX_DEF__(strncat)(char *restrict dest, const char *restrict src, size_t n);
+extern void *__POSIX_DEF__(memccpy)(void *restrict dest, const void *restrict src, int c, size_t n);
+extern char *__POSIX_DEF__(strdup)(const char *s);
+extern char *__POSIX_DEF__(strndup)(const char *s, size_t n);
 
 /* String/Array Comparison */
-extern int posix_memcmp(const void *mem1, const void *mem2, size_t n);
-extern int posix_strcmp(const char *s1, const char *s2);
-extern int posix_strncmp(const char *s1, const char *s2, size_t n);
+extern int __POSIX_DEF__(memcmp)(const void *mem1, const void *mem2, size_t n);
+extern int __POSIX_DEF__(strcmp)(const char *s1, const char *s2);
+extern int __POSIX_DEF__(strncmp)(const char *s1, const char *s2, size_t n);
 
 /* Search Functions */
-extern void *posix_memchr(const void *mem, int c, size_t n);
-extern char *posix_strchr(const char *s, int c);
-extern char *posix_strrchr(const char *s, int c);
+extern void *__POSIX_DEF__(memchr)(const void *mem, int c, size_t n);
+extern char *__POSIX_DEF__(strchr)(const char *s, int c);
+extern char *__POSIX_DEF__(strrchr)(const char *s, int c);
 extern char *gnu_strchrnul(const char *s, int c);
-extern char *posix_strpbrk(const char *s1, const char *s2);
-extern size_t posix_strcspn(const char *s1, const char *s2);
-extern size_t posix_strspn(const char *s1, const char *s2);
-extern char *posix_strstr(const char *haystack, const char *needle);
+extern char *__POSIX_DEF__(strpbrk)(const char *s1, const char *s2);
+extern size_t __POSIX_DEF__(strcspn)(const char *s1, const char *s2);
+extern size_t __POSIX_DEF__(strspn)(const char *s1, const char *s2);
+extern char *__POSIX_DEF__(strstr)(const char *haystack, const char *needle);
 
 /* Collation Functions */
-extern int posix_strcoll(const char *s1, const char *s2);
-extern size_t posix_strxfrm(char *restrict s1, const char *restrict s2, size_t n);
+extern int __POSIX_DEF__(strcoll)(const char *s1, const char *s2);
+extern size_t __POSIX_DEF__(strxfrm)(char *restrict s1, const char *restrict s2, size_t n);
 
 /* Error Messages */
-extern char *posix_strerror(int errnum);
-extern int posix_strerror_r(int errnum, char *buf, size_t bufsz);
+extern char *__POSIX_DEF__(strerror)(int errnum);
+extern int __POSIX_DEF__(strerror_r)(int errnum, char *buf, size_t bufsz);
 
 /* String Length */
-extern size_t posix_strlen(const char *s);
-extern size_t posix_strnlen(const char *s, size_t n);
+extern size_t __POSIX_DEF__(strlen)(const char *s);
+extern size_t __POSIX_DEF__(strnlen)(const char *s, size_t n);
 
 /* Signal Messages */
-extern char *posix_strsignal(int signum);
+extern char *__POSIX_DEF__(strsignal)(int signum);
 
 /* Legacy Declarations */
 #ifndef POSIX_STRINGS_H_
-extern int posix_ffs(int i);
-extern int posix_strcasecmp(const char *s1, const char *s2);
-extern int posix_strncasecmp(const char *s1, const char *s2, size_t n);
+extern int __POSIX_DEF__(ffs)(int i);
+extern int __POSIX_DEF__(strcasecmp)(const char *s1, const char *s2);
+extern int __POSIX_DEF__(strncasecmp)(const char *s1, const char *s2, size_t n);
 #endif
 
-#ifndef LIBPOSIX_INTERNAL
-	#define strcpy posix_strcpy
-	#define strncpy posix_strncpy
-	#define stpcpy posix_stpcpy
-	#define stpncpy posix_stpncpy
-	#define strcat posix_strcat
-	#define strncat posix_strncat
-	#define memccpy posix_memccpy
-	#define strdup posix_strdup
-	#define strndup posix_strndup
-
-	#define memcmp posix_memcmp
-	#define strcmp posix_strcmp
-	#define strncmp posix_strncmp
-
-	#define memchr posix_memchr
-	#define strchr posix_strchr
-	#define strrchr posix_strrchr
-	#define strchrnul gnu_strchrnul
-	#define strpbrk posix_strpbrk
-	#define strcspn posix_strcspn
-	#define strspn posix_strspn
-	#define strstr posix_strstr
-
-	#define strcoll posix_strcoll
-	#define strxfrm posix_strxfrm
-
-	#define strerror posix_strerror
-	#define strerror_r posix_strerror_r
-
-	#define strlen posix_strlen
-	#define strnlen posix_strnlen
-
-	#define strsignal posix_strsignal
-
-	#define ffs posix_ffs
-	#define strcasecmp posix_strcasecmp
-	#define strncasecmp posix_strncasecmp
-#endif
 
 #endif  // POSIX_STRING_H_
Index: uspace/lib/posix/include/posix/strings.h
===================================================================
--- uspace/lib/posix/include/posix/strings.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/strings.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,13 +37,20 @@
 #define POSIX_STRINGS_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
+
+#include <libarch/types.h>
+
 /* Search Functions */
 #ifndef POSIX_STRING_H_
-extern int posix_ffs(int i);
+extern int __POSIX_DEF__(ffs)(int i);
 #endif
 
 /* String/Array Comparison */
 #ifndef POSIX_STRING_H_
-extern int posix_strcasecmp(const char *s1, const char *s2);
-extern int posix_strncasecmp(const char *s1, const char *s2, size_t n);
+extern int __POSIX_DEF__(strcasecmp)(const char *s1, const char *s2);
+extern int __POSIX_DEF__(strncasecmp)(const char *s1, const char *s2, size_t n);
 #endif
 
@@ -55,23 +62,10 @@
 
 /* Legacy Functions */
-extern int posix_bcmp(const void *mem1, const void *mem2, size_t n);
-extern void posix_bcopy(const void *src, void *dest, size_t n);
-extern void posix_bzero(void *mem, size_t n);
-extern char *posix_index(const char *s, int c);
-extern char *posix_rindex(const char *s, int c);
+extern int __POSIX_DEF__(bcmp)(const void *mem1, const void *mem2, size_t n);
+extern void __POSIX_DEF__(bcopy)(const void *src, void *dest, size_t n);
+extern void __POSIX_DEF__(bzero)(void *mem, size_t n);
+extern char *__POSIX_DEF__(index)(const char *s, int c);
+extern char *__POSIX_DEF__(rindex)(const char *s, int c);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define ffs posix_ffs
-
-	#define strcasecmp posix_strcasecmp
-	#define strncasecmp posix_strncasecmp
-
-	#define bcmp posix_bcmp
-	#define bcopy posix_bcopy
-	#undef bzero
-	#define bzero posix_bzero
-	#define index posix_index
-	#define rindex posix_rindex
-#endif
 
 #endif  // POSIX_STRINGS_H_
Index: uspace/lib/posix/include/posix/sys/mman.h
===================================================================
--- uspace/lib/posix/include/posix/sys/mman.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/sys/mman.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,4 +36,8 @@
 #define POSIX_SYS_MMAN_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "sys/types.h"
 #include <abi/mm/as.h>
@@ -45,4 +49,5 @@
 #define MAP_FIXED      (1 << 2)
 #define MAP_ANONYMOUS  (1 << 3)
+#define MAP_ANON MAP_ANONYMOUS
 
 #undef PROT_NONE
@@ -56,6 +61,7 @@
 
 extern void *mmap(void *start, size_t length, int prot, int flags, int fd,
-    posix_off_t offset);
+    __POSIX_DEF__(off_t) offset);
 extern int munmap(void *start, size_t length);
+
 
 #endif /* POSIX_SYS_MMAN_H_ */
Index: uspace/lib/posix/include/posix/sys/stat.h
===================================================================
--- uspace/lib/posix/include/posix/sys/stat.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/sys/stat.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -39,4 +39,8 @@
 #include "types.h"
 #include "../time.h"
+
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
 
 /* values are the same as on Linux */
@@ -108,15 +112,15 @@
 #define S_ISSOCK(m) ((m & S_IFSOCK) != 0) /* socket? (Not in POSIX.1-1996.) */
 
-struct posix_stat {
-	posix_dev_t     st_dev;     /* ID of device containing file */
-	posix_ino_t     st_ino;     /* inode number */
+struct __POSIX_DEF__(stat) {
+	__POSIX_DEF__(dev_t)     st_dev;     /* ID of device containing file */
+	__POSIX_DEF__(ino_t)     st_ino;     /* inode number */
 	mode_t          st_mode;    /* protection */
-	posix_nlink_t   st_nlink;   /* number of hard links */
-	posix_uid_t     st_uid;     /* user ID of owner */
-	posix_gid_t     st_gid;     /* group ID of owner */
-	posix_dev_t     st_rdev;    /* device ID (if special file) */
-	posix_off_t     st_size;    /* total size, in bytes */
-	posix_blksize_t st_blksize; /* blocksize for file system I/O */
-	posix_blkcnt_t  st_blocks;  /* number of 512B blocks allocated */
+	__POSIX_DEF__(nlink_t)   st_nlink;   /* number of hard links */
+	__POSIX_DEF__(uid_t)     st_uid;     /* user ID of owner */
+	__POSIX_DEF__(gid_t)     st_gid;     /* group ID of owner */
+	__POSIX_DEF__(dev_t)     st_rdev;    /* device ID (if special file) */
+	__POSIX_DEF__(off_t)     st_size;    /* total size, in bytes */
+	__POSIX_DEF__(blksize_t) st_blksize; /* blocksize for file system I/O */
+	__POSIX_DEF__(blkcnt_t)  st_blocks;  /* number of 512B blocks allocated */
 	time_t          st_atime;   /* time of last access */
 	time_t          st_mtime;   /* time of last modification */
@@ -124,18 +128,11 @@
 };
 
-extern int posix_fstat(int fd, struct posix_stat *st);
-extern int posix_lstat(const char *restrict path, struct posix_stat *restrict st);
-extern int posix_stat(const char *restrict path, struct posix_stat *restrict st);
-extern int posix_chmod(const char *path, mode_t mode);
-extern mode_t posix_umask(mode_t mask);
+extern int __POSIX_DEF__(fstat)(int fd, struct __POSIX_DEF__(stat) *st);
+extern int __POSIX_DEF__(lstat)(const char *restrict path, struct __POSIX_DEF__(stat) *restrict st);
+extern int __POSIX_DEF__(stat)(const char *restrict path, struct __POSIX_DEF__(stat) *restrict st);
+extern int __POSIX_DEF__(chmod)(const char *path, mode_t mode);
+extern mode_t __POSIX_DEF__(umask)(mode_t mask);
 extern int mkdir(const char *, mode_t);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define fstat posix_fstat
-	#define lstat posix_lstat
-	#define stat posix_stat
-	#define chmod posix_chmod
-	#define umask posix_umask
-#endif
 
 #endif /* POSIX_SYS_STAT_H */
Index: uspace/lib/posix/include/posix/sys/types.h
===================================================================
--- uspace/lib/posix/include/posix/sys/types.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/sys/types.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,40 +37,28 @@
 #define POSIX_SYS_TYPES_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "libc/sys/types.h"
 #include "libc/sys/time.h"
 
-typedef unsigned int posix_ino_t;
-typedef unsigned int posix_nlink_t;
-typedef unsigned int posix_uid_t;
-typedef unsigned int posix_gid_t;
-typedef off64_t posix_off_t;
-typedef long posix_blksize_t;
-typedef long posix_blkcnt_t;
-typedef int64_t posix_pid_t;
-typedef sysarg_t posix_dev_t;
+typedef unsigned int __POSIX_DEF__(ino_t);
+typedef unsigned int __POSIX_DEF__(nlink_t);
+typedef unsigned int __POSIX_DEF__(uid_t);
+typedef unsigned int __POSIX_DEF__(gid_t);
+typedef off64_t __POSIX_DEF__(off_t);
+typedef long __POSIX_DEF__(blksize_t);
+typedef long __POSIX_DEF__(blkcnt_t);
+typedef int64_t __POSIX_DEF__(pid_t);
+typedef sysarg_t __POSIX_DEF__(dev_t);
 
 /* PThread Types */
-typedef struct posix_thread_attr posix_thread_attr_t;
+typedef struct __POSIX_DEF__(thread_attr) __POSIX_DEF__(thread_attr_t);
 
 /* Clock Types */
-typedef long posix_clock_t;
-typedef int posix_clockid_t;
+typedef long __POSIX_DEF__(clock_t);
+typedef int __POSIX_DEF__(clockid_t);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define ino_t posix_ino_t
-	#define nlink_t posix_nlink_t
-	#define uid_t posix_uid_t
-	#define gid_t posix_gid_t
-	#define off_t posix_off_t
-	#define blksize_t posix_blksize_t
-	#define blkcnt_t posix_blkcnt_t
-	#define pid_t posix_pid_t
-	#define dev_t posix_dev_t
-	
-	#define pthread_attr_t posix_thread_attr_t
-	
-	#define clock_t posix_clock_t
-	#define clockid_t posix_clockid_t
-#endif
 
 #endif /* POSIX_SYS_TYPES_H_ */
Index: uspace/lib/posix/include/posix/sys/wait.h
===================================================================
--- uspace/lib/posix/include/posix/sys/wait.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/sys/wait.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -36,4 +36,8 @@
 #define POSIX_SYS_WAIT_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "types.h"
 
@@ -52,11 +56,7 @@
 extern int __posix_wtermsig(int status);
 
-extern posix_pid_t posix_wait(int *stat_ptr);
-extern posix_pid_t posix_waitpid(posix_pid_t pid, int *stat_ptr, int options);
+extern __POSIX_DEF__(pid_t) __POSIX_DEF__(wait)(int *stat_ptr);
+extern __POSIX_DEF__(pid_t) __POSIX_DEF__(waitpid)(__POSIX_DEF__(pid_t) pid, int *stat_ptr, int options);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define wait posix_wait
-	#define waitpid posix_waitpid
-#endif
 
 #endif /* POSIX_SYS_WAIT_H_ */
Index: uspace/lib/posix/include/posix/time.h
===================================================================
--- uspace/lib/posix/include/posix/time.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/time.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,4 +37,8 @@
 #define POSIX_TIME_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "sys/types.h"
 
@@ -49,93 +53,66 @@
 #ifndef __locale_t_defined
 	#define __locale_t_defined
-	typedef struct __posix_locale *posix_locale_t;
+	typedef struct __posix_locale *__POSIX_DEF__(locale_t);
 	#ifndef LIBPOSIX_INTERNAL
-		#define locale_t posix_locale_t
+		#define locale_t __POSIX_DEF__(locale_t)
 	#endif
 #endif
 
 #ifndef POSIX_SIGNAL_H_
-	struct posix_sigevent;
+	struct __POSIX_DEF__(sigevent);
 	#ifndef LIBPOSIX_INTERNAL
-		#define sigevent posix_sigevent
+		#define sigevent __POSIX_DEF__(sigevent)
 	#endif
 #endif
 
 #undef CLOCK_REALTIME
-#define CLOCK_REALTIME ((posix_clockid_t) 0)
+#define CLOCK_REALTIME ((__POSIX_DEF__(clockid_t)) 0)
 
-struct posix_timespec {
+struct __POSIX_DEF__(timespec) {
 	time_t tv_sec; /* Seconds. */
 	long tv_nsec; /* Nanoseconds. */
 };
 
-struct posix_itimerspec {
-	struct posix_timespec it_interval; /* Timer period. */
-	struct posix_timespec it_value; /* Timer expiration. */
+struct __POSIX_DEF__(itimerspec) {
+	struct __POSIX_DEF__(timespec) it_interval; /* Timer period. */
+	struct __POSIX_DEF__(timespec) it_value; /* Timer expiration. */
 };
 
-typedef struct __posix_timer *posix_timer_t;
+typedef struct __posix_timer *__POSIX_DEF__(timer_t);
 
 /* Timezones */
-extern int posix_daylight;
-extern long posix_timezone;
-extern char *posix_tzname[2];
-extern void posix_tzset(void);
+extern int __POSIX_DEF__(daylight);
+extern long __POSIX_DEF__(timezone);
+extern char *__POSIX_DEF__(tzname)[2];
+extern void __POSIX_DEF__(tzset)(void);
 
 /* Broken-down Time */
-extern struct tm *posix_gmtime_r(const time_t *restrict timer,
+extern struct tm *__POSIX_DEF__(gmtime_r)(const time_t *restrict timer,
     struct tm *restrict result);
-extern struct tm *posix_gmtime(const time_t *restrict timep);
-extern struct tm *posix_localtime_r(const time_t *restrict timer,
+extern struct tm *__POSIX_DEF__(gmtime)(const time_t *restrict timep);
+extern struct tm *__POSIX_DEF__(localtime_r)(const time_t *restrict timer,
     struct tm *restrict result);
-extern struct tm *posix_localtime(const time_t *restrict timep);
+extern struct tm *__POSIX_DEF__(localtime)(const time_t *restrict timep);
 
 /* Formatting Calendar Time */
-extern char *posix_asctime_r(const struct tm *restrict timeptr,
+extern char *__POSIX_DEF__(asctime_r)(const struct tm *restrict timeptr,
     char *restrict buf);
-extern char *posix_asctime(const struct tm *restrict timeptr);
-extern char *posix_ctime_r(const time_t *timer, char *buf);
-extern char *posix_ctime(const time_t *timer);
+extern char *__POSIX_DEF__(asctime)(const struct tm *restrict timeptr);
+extern char *__POSIX_DEF__(ctime_r)(const time_t *timer, char *buf);
+extern char *__POSIX_DEF__(ctime)(const time_t *timer);
 
 /* Clocks */
-extern int posix_clock_getres(posix_clockid_t clock_id,
-    struct posix_timespec *res);
-extern int posix_clock_gettime(posix_clockid_t clock_id,
-    struct posix_timespec *tp);
-extern int posix_clock_settime(posix_clockid_t clock_id,
-    const struct posix_timespec *tp); 
-extern int posix_clock_nanosleep(posix_clockid_t clock_id, int flags,
-    const struct posix_timespec *rqtp, struct posix_timespec *rmtp);
+extern int __POSIX_DEF__(clock_getres)(__POSIX_DEF__(clockid_t) clock_id,
+    struct __POSIX_DEF__(timespec) *res);
+extern int __POSIX_DEF__(clock_gettime)(__POSIX_DEF__(clockid_t) clock_id,
+    struct __POSIX_DEF__(timespec) *tp);
+extern int __POSIX_DEF__(clock_settime)(__POSIX_DEF__(clockid_t) clock_id,
+    const struct __POSIX_DEF__(timespec) *tp); 
+extern int __POSIX_DEF__(clock_nanosleep)(__POSIX_DEF__(clockid_t) clock_id, int flags,
+    const struct __POSIX_DEF__(timespec) *rqtp, struct __POSIX_DEF__(timespec) *rmtp);
 
 /* CPU Time */
-extern posix_clock_t posix_clock(void);
+extern __POSIX_DEF__(clock_t) __POSIX_DEF__(clock)(void);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define timespec    posix_timespec
-	#define itimerspec  posix_itimerspec
-	#define timer_t     posix_timer_t
-
-	#define daylight    posix_daylight
-	#define timezone    posix_timezone
-	#define tzname      posix_tzname
-	#define tzset       posix_tzset
-
-	#define gmtime_r    posix_gmtime_r
-	#define gmtime      posix_gmtime
-	#define localtime_r posix_localtime_r
-	#define localtime   posix_localtime
-
-	#define asctime_r   posix_asctime_r
-	#define asctime     posix_asctime
-	#define ctime_r     posix_ctime_r
-	#define ctime       posix_ctime
-
-	#define clock_getres posix_clock_getres
-	#define clock_gettime posix_clock_gettime
-	#define clock_settime posix_clock_settime
-	#define clock_nanosleep posix_clock_nanosleep
-
-	#define clock posix_clock
-#endif
 
 #endif  // POSIX_TIME_H_
Index: uspace/lib/posix/include/posix/ucontext.h
===================================================================
--- uspace/lib/posix/include/posix/ucontext.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
+++ uspace/lib/posix/include/posix/ucontext.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011 Jiri Zarevucky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libposix
+ * @{
+ */
+/** @file Userspace context handling.
+ */
+
+#ifndef POSIX_UCONTEXT_H_
+#define POSIX_UCONTEXT_H_
+
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
+#include "sys/types.h"
+
+typedef int __POSIX_DEF__(sig_atomic_t);
+typedef uint32_t __POSIX_DEF__(sigset_t);
+typedef struct __POSIX_DEF__(mcontext) {
+	/* must not be empty to avoid compiler warnings (-pedantic) */
+	int dummy;
+} __POSIX_DEF__(mcontext_t);
+
+union __POSIX_DEF__(sigval) {
+	int sival_int;
+	void *sival_ptr;
+};
+
+struct __POSIX_DEF__(sigevent) {
+	int sigev_notify; /* Notification type. */
+	int sigev_signo; /* Signal number. */
+	union __POSIX_DEF__(sigval) sigev_value; /* Signal value. */
+	void (*sigev_notify_function)(union __POSIX_DEF__(sigval)); /* Notification function. */
+	__POSIX_DEF__(thread_attr_t) *sigev_notify_attributes; /* Notification attributes. */
+};
+
+typedef struct {
+	void *ss_sp;
+	size_t ss_size;
+	int ss_flags;
+} __POSIX_DEF__(stack_t);
+
+typedef struct __POSIX_DEF__(ucontext) {
+	struct __POSIX_DEF__(ucontext) *uc_link;
+	__POSIX_DEF__(sigset_t) uc_sigmask;
+	__POSIX_DEF__(stack_t) uc_stack;
+	__POSIX_DEF__(mcontext_t) uc_mcontext;
+} __POSIX_DEF__(ucontext_t);
+
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/posix/include/posix/unistd.h
===================================================================
--- uspace/lib/posix/include/posix/unistd.h	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/include/posix/unistd.h	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -37,4 +37,8 @@
 #define POSIX_UNISTD_H_
 
+#ifndef __POSIX_DEF__
+#define __POSIX_DEF__(x) x
+#endif
+
 #include "sys/types.h"
 #include "stddef.h"
@@ -43,40 +47,40 @@
 #define _exit exit
 
-extern char *posix_optarg;
+extern char *__POSIX_DEF__(optarg);
 extern int optind, opterr, optopt;
-extern int posix_getopt(int, char * const [], const char *);
+extern int __POSIX_DEF__(getopt)(int, char * const [], const char *);
 
 /* Environment */
-extern char **posix_environ;
+extern char **__POSIX_DEF__(environ);
 
 /* Login Information */
-extern char *posix_getlogin(void);
-extern int posix_getlogin_r(char *name, size_t namesize);
+extern char *__POSIX_DEF__(getlogin)(void);
+extern int __POSIX_DEF__(getlogin_r)(char *name, size_t namesize);
 
 /* Identifying Terminals */
-extern int posix_isatty(int fd);
+extern int __POSIX_DEF__(isatty)(int fd);
 
 /* Working Directory */
-extern char *posix_getcwd(char *buf, size_t size);
-extern int posix_chdir(const char *path);
+extern char *__POSIX_DEF__(getcwd)(char *buf, size_t size);
+extern int __POSIX_DEF__(chdir)(const char *path);
 
 /* Query Memory Parameters */
-extern int posix_getpagesize(void);
+extern int __POSIX_DEF__(getpagesize)(void);
 
 /* Process Identification */
-extern posix_pid_t posix_getpid(void);
-extern posix_uid_t posix_getuid(void);
-extern posix_gid_t posix_getgid(void);
+extern __POSIX_DEF__(pid_t) __POSIX_DEF__(getpid)(void);
+extern __POSIX_DEF__(uid_t) __POSIX_DEF__(getuid)(void);
+extern __POSIX_DEF__(gid_t) __POSIX_DEF__(getgid)(void);
 
 /* File Manipulation */
-extern int posix_close(int fildes);
-extern ssize_t posix_read(int fildes, void *buf, size_t nbyte);
-extern ssize_t posix_write(int fildes, const void *buf, size_t nbyte);
-extern int posix_fsync(int fildes);
-extern int posix_ftruncate(int fildes, posix_off_t length);
-extern int posix_rmdir(const char *path);
-extern int posix_unlink(const char *path);
-extern int posix_dup(int fildes);
-extern int posix_dup2(int fildes, int fildes2);
+extern int __POSIX_DEF__(close)(int fildes);
+extern ssize_t __POSIX_DEF__(read)(int fildes, void *buf, size_t nbyte);
+extern ssize_t __POSIX_DEF__(write)(int fildes, const void *buf, size_t nbyte);
+extern int __POSIX_DEF__(fsync)(int fildes);
+extern int __POSIX_DEF__(ftruncate)(int fildes, __POSIX_DEF__(off_t) length);
+extern int __POSIX_DEF__(rmdir)(const char *path);
+extern int __POSIX_DEF__(unlink)(const char *path);
+extern int __POSIX_DEF__(dup)(int fildes);
+extern int __POSIX_DEF__(dup2)(int fildes, int fildes2);
 
 /* Standard Streams */
@@ -97,5 +101,5 @@
 #define	W_OK 2 /* Test for write permission. */
 #define	R_OK 4 /* Test for read permission. */
-extern int posix_access(const char *path, int amode);
+extern int __POSIX_DEF__(access)(const char *path, int amode);
 
 /* System Parameters */
@@ -106,5 +110,5 @@
 	_SC_CLK_TCK
 };
-extern long posix_sysconf(int name);
+extern long __POSIX_DEF__(sysconf)(int name);
 
 /* Path Configuration Parameters */
@@ -130,60 +134,18 @@
 	_PC_VDISABLE
 };
-extern long posix_pathconf(const char *path, int name);
+extern long __POSIX_DEF__(pathconf)(const char *path, int name);
 
 /* Creating a Process */
-extern posix_pid_t posix_fork(void);
+extern __POSIX_DEF__(pid_t) __POSIX_DEF__(fork)(void);
 
 /* Executing a File */
-extern int posix_execv(const char *path, char *const argv[]);
-extern int posix_execvp(const char *file, char *const argv[]);
+extern int __POSIX_DEF__(execv)(const char *path, char *const argv[]);
+extern int __POSIX_DEF__(execvp)(const char *file, char *const argv[]);
 
 /* Creating a Pipe */
-extern int posix_pipe(int fildes[2]);
+extern int __POSIX_DEF__(pipe)(int fildes[2]);
 
-#ifndef LIBPOSIX_INTERNAL
-	#define getopt posix_getopt
-	#define optarg posix_optarg
-
-	#define environ posix_environ
-
-	#define getlogin posix_getlogin
-	#define getlogin_r posix_getlogin_r
-
-	#define getcwd posix_getcwd
-	#define chdir posix_chdir
-
-	#define isatty posix_isatty
-
-	#undef getpagesize
-	#define getpagesize posix_getpagesize
-
-	#define getpid posix_getpid
-	#define getuid posix_getuid
-	#define getgid posix_getgid
-
-	#define close posix_close
-	#define read posix_read
-	#define write posix_write
-	#define fsync posix_fsync
-	#define ftruncate posix_ftruncate
-	#define rmdir posix_rmdir
-	#define unlink posix_unlink
-	#define dup posix_dup
-	#define dup2 posix_dup2
-
-	#define access posix_access
-
-	#define sysconf posix_sysconf
-
-	#define pathconf posix_pathconf
-
-	#define fork posix_fork
-
-	#define execv posix_execv
-	#define execvp posix_execvp
-
-	#define pipe posix_pipe
-#endif
+/* Issue alarm signal. */
+extern unsigned int __POSIX_DEF__(alarm)(unsigned int);
 
 #endif /* POSIX_UNISTD_H_ */
Index: uspace/lib/posix/source/ctype.c
===================================================================
--- uspace/lib/posix/source/ctype.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/ctype.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "posix/ctype.h"
Index: uspace/lib/posix/source/errno.c
===================================================================
--- uspace/lib/posix/source/errno.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/errno.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -32,4 +32,6 @@
 /** @file System error numbers.
  */
+#define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "posix/errno.h"
@@ -43,5 +45,5 @@
 {
 	if (*__errno() != 0) {
-		_posix_errno = abs(*__errno());
+		_posix_errno = posix_abs(*__errno());
 		*__errno() = 0;
 	}
Index: uspace/lib/posix/source/fcntl.c
===================================================================
--- uspace/lib/posix/source/fcntl.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/fcntl.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -34,4 +34,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
Index: uspace/lib/posix/source/fnmatch.c
===================================================================
--- uspace/lib/posix/source/fnmatch.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/fnmatch.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -43,4 +43,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "libc/stdbool.h"
Index: uspace/lib/posix/source/getopt.c
===================================================================
--- uspace/lib/posix/source/getopt.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/getopt.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -33,4 +33,5 @@
  */
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
Index: uspace/lib/posix/source/locale.c
===================================================================
--- uspace/lib/posix/source/locale.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/locale.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -34,4 +34,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
Index: uspace/lib/posix/source/math.c
===================================================================
--- uspace/lib/posix/source/math.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/math.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -34,4 +34,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
Index: uspace/lib/posix/source/pwd.c
===================================================================
--- uspace/lib/posix/source/pwd.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/pwd.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -34,4 +34,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "libc/stdbool.h"
Index: uspace/lib/posix/source/signal.c
===================================================================
--- uspace/lib/posix/source/signal.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/signal.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -34,4 +34,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "posix/signal.h"
Index: uspace/lib/posix/source/stdio.c
===================================================================
--- uspace/lib/posix/source/stdio.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/stdio.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
Index: uspace/lib/posix/source/stdio/scanf.c
===================================================================
--- uspace/lib/posix/source/stdio/scanf.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/stdio/scanf.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -34,4 +34,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "posix/assert.h"
Index: uspace/lib/posix/source/stdlib.c
===================================================================
--- uspace/lib/posix/source/stdlib.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/stdlib.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
@@ -62,4 +63,5 @@
 	// TODO: low priority, just a compile-time dependency of binutils
 	not_implemented();
+	return 1;
 }
 
@@ -231,4 +233,5 @@
 	// TODO: low priority, just a compile-time dependency of binutils
 	not_implemented();
+	return 0;
 }
 
@@ -243,4 +246,5 @@
 int posix_system(const char *string) {
 	// TODO: does nothing at the moment
+	not_implemented();
 	return 0;
 }
Index: uspace/lib/posix/source/stdlib/strtol.c
===================================================================
--- uspace/lib/posix/source/stdlib/strtol.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/stdlib/strtol.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -34,4 +34,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "../internal/common.h"
Index: uspace/lib/posix/source/stdlib/strtold.c
===================================================================
--- uspace/lib/posix/source/stdlib/strtold.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/stdlib/strtold.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -34,4 +34,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "../internal/common.h"
Index: uspace/lib/posix/source/string.c
===================================================================
--- uspace/lib/posix/source/string.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/string.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
Index: uspace/lib/posix/source/strings.c
===================================================================
--- uspace/lib/posix/source/strings.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/strings.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
Index: uspace/lib/posix/source/sys/stat.c
===================================================================
--- uspace/lib/posix/source/sys/stat.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/sys/stat.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "../internal/common.h"
Index: uspace/lib/posix/source/sys/wait.c
===================================================================
--- uspace/lib/posix/source/sys/wait.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/sys/wait.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "../internal/common.h"
Index: uspace/lib/posix/source/time.c
===================================================================
--- uspace/lib/posix/source/time.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/time.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
Index: uspace/lib/posix/source/unistd.c
===================================================================
--- uspace/lib/posix/source/unistd.c	(revision d8b47eca6f42cb0337bbfbbd1fcd114ae523a897)
+++ uspace/lib/posix/source/unistd.c	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -35,4 +35,5 @@
 
 #define LIBPOSIX_INTERNAL
+#define __POSIX_DEF__(x) posix_##x
 
 #include "internal/common.h"
@@ -421,4 +422,10 @@
 }
 
+unsigned int posix_alarm(unsigned int seconds)
+{
+	not_implemented();
+	return 0;
+}
+
 /** @}
  */
Index: uspace/lib/posix/tools/create-redefines.sh
===================================================================
--- uspace/lib/posix/tools/create-redefines.sh	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
+++ uspace/lib/posix/tools/create-redefines.sh	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+while read symbolname; do
+	echo "--redefine-sym=$1$symbolname=$2$symbolname"
+done
Index: uspace/lib/posix/tools/get-collision-list.sh
===================================================================
--- uspace/lib/posix/tools/get-collision-list.sh	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
+++ uspace/lib/posix/tools/get-collision-list.sh	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+find "$1" -name '*.h' -exec \
+	sed -n -e '/^#/d' -e 's/__POSIX_DEF__/\n&/gp' {} \; | \
+	sed -n -e 's/__POSIX_DEF__(\([^)]*\)).*/\1/p' | \
+	sort -u
Index: uspace/lib/posix/tools/transform-symbols.sh
===================================================================
--- uspace/lib/posix/tools/transform-symbols.sh	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
+++ uspace/lib/posix/tools/transform-symbols.sh	(revision 08ed1377c1cf36aaa5a0cc9311ce8b841365d06e)
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+OBJCOPY="$1"
+AR="$2"
+ECHO="$3"
+LIB_SOURCE="$4"
+LIB_RESULT="$5"
+REDEFS_FIRST="$6"
+REDEFS_SECOND="$7"
+
+set -e
+
+rm -f "$LIB_RESULT"
+
+$ECHO -n "$LIB_RESULT:"
+
+$AR t "$LIB_SOURCE" | sort | uniq -c | while read count filename; do
+	rm -f "$filename"
+	$ECHO -n " $filename"
+	for idx in `seq 1 $count`; do
+		$AR xN $idx "$LIB_SOURCE" "$filename"
+		xargs "$OBJCOPY" "$filename" "$filename" <"$REDEFS_FIRST"
+		xargs "$OBJCOPY" "$filename" "$filename" <"$REDEFS_SECOND"
+		$AR qc "$LIB_RESULT" "$filename"
+		rm -f "$filename"
+	done
+done
+
+$AR s "$LIB_RESULT"
+
+$ECHO ""
