Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ HelenOS.config	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -569,4 +569,7 @@
 ! [CONFIG_DSRLNIN=y|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=arm32&MACHINE=integratorcp&CONFIG_PL011_UART=y)|(PLATFORM=arm32&MACHINE=beaglebone&CONFIG_OMAP_UART=y)|(PLATFORM=arm32&MACHINE=beagleboardxm&CONFIG_OMAP_UART=y)|(PLATFORM=arm64&CONFIG_PL011_UART=y)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)|(PLATFORM=arm32&MACHINE=raspberrypi&CONFIG_PL011_UART=y)|(PLATFORM=ia32&CONFIG_NS16550=y)|(PLATFORM=amd64&CONFIG_NS16550=y)|(PLATFORM=mips32&CONFIG_NS16550=y)|(PLATFORM=sparc64&CONFIG_SUN_TTY=y)] CONFIG_SRLN (y)
 
+% L4Re uvmm print hypercall support
+! [PLATFORM=amd64] CONFIG_L4RE_UVMM_EARLY_PRINT (n/y)
+
 % EGA support
 ! [CONFIG_HID_OUT=generic&(PLATFORM=ia32|PLATFORM=amd64)] CONFIG_EGA (y/n)
Index: abi/include/_bits/decls.h
===================================================================
--- abi/include/_bits/decls.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ abi/include/_bits/decls.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2019 Jiří Zárevúcky
+ * 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 bits
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _BITS_DECLS_H_
+#define _BITS_DECLS_H_
+
+#ifdef __cplusplus
+
+#define __HELENOS_DECLS_BEGIN \
+	namespace helenos { \
+	extern "C" {
+
+#define __HELENOS_DECLS_END \
+	} \
+	}
+
+#define __C_DECLS_BEGIN \
+	extern "C" {
+
+#define __C_DECLS_END \
+	}
+
+#else  /* !__cplusplus */
+
+#define __HELENOS_DECLS_BEGIN
+#define __HELENOS_DECLS_END
+#define __C_DECLS_BEGIN
+#define __C_DECLS_END
+
+#endif  /* __cplusplus */
+
+#endif
+
+/** @}
+ */
Index: abi/include/_bits/errno.h
===================================================================
--- abi/include/_bits/errno.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ abi/include/_bits/errno.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -41,14 +41,20 @@
 #define _BITS_ERRNO_H_
 
+#include <_bits/native.h>
+#include <_bits/decls.h>
+
 #ifdef __OPAQUE_ERRNO__
 #include <_bits/__opaque_handle.h>
 
+__HELENOS_DECLS_BEGIN;
 __opaque_handle(errno_t);
 typedef errno_t sys_errno_t;
+__HELENOS_DECLS_END;
+
 #define __errno_t(val) ((errno_t) val)
 
 #else
 
-#include <_bits/native.h>
+__HELENOS_DECLS_BEGIN;
 
 /**
@@ -65,4 +71,6 @@
 typedef sysarg_t sys_errno_t;
 
+__HELENOS_DECLS_END;
+
 /**
  * A C++-style "cast" to `errno_t`.
Index: abi/include/_bits/native.h
===================================================================
--- abi/include/_bits/native.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ abi/include/_bits/native.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -47,4 +47,7 @@
 
 #include <inttypes.h>
+#include <_bits/decls.h>
+
+__HELENOS_DECLS_BEGIN;
 
 typedef uintptr_t pfn_t;
@@ -53,7 +56,5 @@
 typedef intptr_t  native_t;
 
-#define PRIdn  PRIdPTR  /**< Format for native_t. */
-#define PRIun  PRIuPTR  /**< Format for sysarg_t. */
-#define PRIxn  PRIxPTR  /**< Format for hexadecimal sysarg_t. */
+__HELENOS_DECLS_END;
 
 #endif
Index: abi/include/_bits/off64_t.h
===================================================================
--- abi/include/_bits/off64_t.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ abi/include/_bits/off64_t.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019 Jiří Zárevúcky
+ * 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 bits
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _BITS_OFF64_T_H_
+#define _BITS_OFF64_T_H_
+
+#include <stdint.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
+typedef int64_t off64_t;
+__C_DECLS_END;
+
+#endif
+
+/** @}
+ */
Index: abi/include/_bits/ssize_t.h
===================================================================
--- abi/include/_bits/ssize_t.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ abi/include/_bits/ssize_t.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -42,9 +42,9 @@
 
 #include <stdint.h>
+#include <_bits/decls.h>
 
+__C_DECLS_BEGIN;
 typedef intptr_t ssize_t;
-
-#define SSIZE_MIN  INTPTR_MIN
-#define SSIZE_MAX  INTPTR_MAX
+__C_DECLS_END;
 
 #endif
Index: abi/include/inttypes.h
===================================================================
--- abi/include/inttypes.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ abi/include/inttypes.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -43,4 +43,5 @@
 #include <stdint.h>
 #include <_bits/wchar_t.h>
+#include <_bits/decls.h>
 
 /*
@@ -311,11 +312,4 @@
 #endif
 
-#ifdef _HELENOS_SOURCE
-#define UINT8_MIN   0
-#define UINT16_MIN  0
-#define UINT32_MIN  0
-#define UINT64_MIN  0
-#endif
-
 #define PRIdMAX  "lld"
 #define PRIiMAX  "lli"
@@ -330,7 +324,11 @@
 #define SCNxMAX  "llx"
 
-#ifdef __cplusplus
-extern "C" {
+#if defined(_HELENOS_SOURCE) && !defined(__cplusplus)
+#define PRIdn  PRIdPTR  /**< Format for native_t. */
+#define PRIun  PRIuPTR  /**< Format for sysarg_t. */
+#define PRIxn  PRIxPTR  /**< Format for hexadecimal sysarg_t. */
 #endif
+
+__C_DECLS_BEGIN;
 
 typedef struct {
@@ -343,11 +341,11 @@
 intmax_t strtoimax(const char *__restrict__, char **__restrict__, int);
 uintmax_t strtoumax(const char *__restrict__, char **__restrict__, int);
-
-#ifdef __cplusplus
-}
+intmax_t wcstoimax(const wchar_t *__restrict__, wchar_t **__restrict__, int);
+uintmax_t wcstoumax(const wchar_t *__restrict__, wchar_t **__restrict__, int);
+
+__C_DECLS_END;
+
 #endif
 
-#endif
-
 /** @}
  */
Index: abi/include/limits.h
===================================================================
--- abi/include/limits.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ abi/include/limits.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -84,4 +84,5 @@
 #define MB_LEN_MAX 4
 
+#ifdef _HELENOS_SOURCE
 #define UCHAR_MIN   0
 #define USHRT_MIN   0
@@ -89,4 +90,19 @@
 #define ULONG_MIN   (0ul)
 #define ULLONG_MIN  (0ull)
+#define SSIZE_MIN   INTPTR_MIN
+#define UINT8_MIN   0
+#define UINT16_MIN  0
+#define UINT32_MIN  0
+#define UINT64_MIN  0
+#endif
+
+#if defined(_HELENOS_SOURCE) || defined(_POSIX_SOURCE) || \
+    defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
+    defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#define SSIZE_MAX  INTPTR_MAX
+#define NAME_MAX   255
+
+#endif
 
 /* GCC's <limits.h> doesn't define these for C++11, even though it should. */
Index: boot/arch/mips32/include/arch/main.h
===================================================================
--- boot/arch/mips32/include/arch/main.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ boot/arch/mips32/include/arch/main.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,5 +30,5 @@
 #define BOOT_mips32_MAIN_H_
 
-extern void bootstrap(void);
+extern void bootstrap(int, char **);
 
 #endif
Index: boot/arch/mips32/include/arch/types.h
===================================================================
--- boot/arch/mips32/include/arch/types.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ boot/arch/mips32/include/arch/types.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -35,4 +35,5 @@
 #define CPUMAP_MAX_RECORDS         32
 #define BOOTINFO_TASK_NAME_BUFLEN  32
+#define BOOTINFO_BOOTARGS_BUFLEN   256
 
 typedef struct {
@@ -56,4 +57,5 @@
 	uint32_t cpumap;
 	taskmap_t taskmap;
+	char bootargs[BOOTINFO_BOOTARGS_BUFLEN];
 } bootinfo_t;
 
Index: boot/arch/mips32/src/asm.S
===================================================================
--- boot/arch/mips32/src/asm.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ boot/arch/mips32/src/asm.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -36,4 +36,15 @@
 .section BOOTSTRAP
 
+/*
+ * Registers on entry:
+ *
+ *   a0: kernel argument count (kargc)
+ *   a1: kernel argument vector (kargv) of kargc elements
+ *   a2: unused here (kenvp on Malta)
+ *   a3: RAM size on Malta
+ *
+ * This is the case on Malta.
+ * msim clears these registers, so it is de facto correct as well.
+ */
 SYMBOL(start)
 	/*
@@ -43,8 +54,8 @@
 	 *  - Disable 64-bit user addressing mode
 	 */
-	mfc0 $a0, $status
-	la $a1, 0xffffff1f
-	and $a0, $a1, $a0
-	mtc0 $a0, $status
+	mfc0 $t0, $status
+	la $t1, 0xffffff1f
+	and $t0, $t1, $t0
+	mtc0 $t0, $status
 
 #if defined(MACHINE_lmalta) || defined(MACHINE_bmalta)
@@ -52,6 +63,6 @@
 	 * Remember the size of the SDRAM in bootinfo.
 	 */
-	la $a0, PA2KA(BOOTINFO_OFFSET)
-	sw $a3, 0($a0)
+	la $t0, PA2KA(BOOTINFO_OFFSET)
+	sw $a3, 0($t0)
 #endif
 
@@ -61,47 +72,47 @@
 	 * but it not an issue).
 	 */
-	la $a0, PA2KA(CPUMAP_OFFSET)
+	la $t0, PA2KA(CPUMAP_OFFSET)
 
-	sw $zero, 0($a0)
-	sw $zero, 4($a0)
-	sw $zero, 8($a0)
-	sw $zero, 12($a0)
+	sw $zero, 0($t0)
+	sw $zero, 4($t0)
+	sw $zero, 8($t0)
+	sw $zero, 12($t0)
 
-	sw $zero, 16($a0)
-	sw $zero, 20($a0)
-	sw $zero, 24($a0)
-	sw $zero, 28($a0)
+	sw $zero, 16($t0)
+	sw $zero, 20($t0)
+	sw $zero, 24($t0)
+	sw $zero, 28($t0)
 
-	sw $zero, 32($a0)
-	sw $zero, 36($a0)
-	sw $zero, 40($a0)
-	sw $zero, 44($a0)
+	sw $zero, 32($t0)
+	sw $zero, 36($t0)
+	sw $zero, 40($t0)
+	sw $zero, 44($t0)
 
-	sw $zero, 48($a0)
-	sw $zero, 52($a0)
-	sw $zero, 56($a0)
-	sw $zero, 60($a0)
+	sw $zero, 48($t0)
+	sw $zero, 52($t0)
+	sw $zero, 56($t0)
+	sw $zero, 60($t0)
 
-	sw $zero, 64($a0)
-	sw $zero, 68($a0)
-	sw $zero, 72($a0)
-	sw $zero, 76($a0)
+	sw $zero, 64($t0)
+	sw $zero, 68($t0)
+	sw $zero, 72($t0)
+	sw $zero, 76($t0)
 
-	sw $zero, 80($a0)
-	sw $zero, 84($a0)
-	sw $zero, 88($a0)
-	sw $zero, 92($a0)
+	sw $zero, 80($t0)
+	sw $zero, 84($t0)
+	sw $zero, 88($t0)
+	sw $zero, 92($t0)
 
-	sw $zero, 96($a0)
-	sw $zero, 100($a0)
-	sw $zero, 104($a0)
-	sw $zero, 108($a0)
+	sw $zero, 96($t0)
+	sw $zero, 100($t0)
+	sw $zero, 104($t0)
+	sw $zero, 108($t0)
 
-	sw $zero, 112($a0)
-	sw $zero, 116($a0)
-	sw $zero, 120($a0)
-	sw $zero, 124($a0)
+	sw $zero, 112($t0)
+	sw $zero, 116($t0)
+	sw $zero, 120($t0)
+	sw $zero, 124($t0)
 
-	lui $a1, 1
+	lui $t1, 1
 
 #ifdef MACHINE_msim
@@ -119,7 +130,7 @@
 
 	/* Record CPU presence */
-	sll $a2, $k1, 2
-	addu $a2, $a2, $a0
-	sw $a1, ($a2)
+	sll $t2, $k1, 2
+	addu $t2, $t2, $t0
+	sw $t1, ($t2)
 
 	loop:
@@ -131,9 +142,10 @@
 	bsp:
 		/* Record CPU presence */
-		sw $a1, ($a0)
+		sw $t1, ($t0)
 
 		/* Setup initial stack */
 		la $sp, PA2KA(STACK_OFFSET)
 
+		/* a0=kargc, a1=kargv */
 		j bootstrap
 		nop
Index: ot/arch/mips32/src/boot.S
===================================================================
--- boot/arch/mips32/src/boot.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,118 +1,0 @@
-#
-# Copyright (c) 2006 Martin Decky
-# 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.
-#
-
-#include "regname.h"
-#include "main.h"
-
-.set noat
-.set noreorder
-.set nomacro
-
-.section BOOTSTRAP
-
-.global start
-start:
-
-	/* Setup CPU map (on msim this code
-	   is executed in parallel on all CPUs,
-	   but it not an issue) */
-	la $a0, CPUMAP
-
-	sw $zero, 0($a0)
-	sw $zero, 4($a0)
-	sw $zero, 8($a0)
-	sw $zero, 12($a0)
-
-	sw $zero, 16($a0)
-	sw $zero, 20($a0)
-	sw $zero, 24($a0)
-	sw $zero, 28($a0)
-
-	sw $zero, 32($a0)
-	sw $zero, 36($a0)
-	sw $zero, 40($a0)
-	sw $zero, 44($a0)
-
-	sw $zero, 48($a0)
-	sw $zero, 52($a0)
-	sw $zero, 56($a0)
-	sw $zero, 60($a0)
-
-	sw $zero, 64($a0)
-	sw $zero, 68($a0)
-	sw $zero, 72($a0)
-	sw $zero, 76($a0)
-
-	sw $zero, 80($a0)
-	sw $zero, 84($a0)
-	sw $zero, 88($a0)
-	sw $zero, 92($a0)
-
-	sw $zero, 96($a0)
-	sw $zero, 100($a0)
-	sw $zero, 104($a0)
-	sw $zero, 108($a0)
-
-	sw $zero, 112($a0)
-	sw $zero, 116($a0)
-	sw $zero, 120($a0)
-	sw $zero, 124($a0)
-
-	lui $a1, 1
-
-#ifdef MACHINE_msim
-
-	/* Read dorder value */
-	la $k0, MSIM_DORDER_ADDRESS
-	lw $k1, ($k0)
-
-	/* If we are not running on BSP
-	   then end in an infinite loop  */
-	beq $k1, $zero, bsp
-	nop
-
-	/* Record CPU presence */
-	sll $a2, $k1, 2
-	addu $a2, $a2, $a0
-	sw $a1, ($a2)
-
-	loop:
-		j loop
-		nop
-
-#endif
-
-	bsp:
-		/* Record CPU presence */
-		sw $a1, ($a0)
-
-		/* Setup initial stack */
-		la $sp, INITIAL_STACK
-
-		j bootstrap
-		nop
Index: boot/arch/mips32/src/main.c
===================================================================
--- boot/arch/mips32/src/main.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ boot/arch/mips32/src/main.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -45,5 +45,5 @@
 static uint32_t *cpumap = (uint32_t *) PA2KA(CPUMAP_OFFSET);
 
-void bootstrap(void)
+void bootstrap(int kargc, char **kargv)
 {
 	version_print();
@@ -79,4 +79,7 @@
 	}
 
+	str_cpy(bootinfo->bootargs, sizeof(bootinfo->bootargs),
+	    (kargc > 1) ? kargv[1] : "");
+
 	uintptr_t entry = check_kernel(kernel_start);
 
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ kernel/Makefile	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -87,5 +87,5 @@
 INCLUDES_FLAGS = $(addprefix -I,$(INCLUDES))
 
-DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
+DEFS = -D_HELENOS_SOURCE -DKERNEL -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
 
 COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
Index: kernel/arch/amd64/src/asm.S
===================================================================
--- kernel/arch/amd64/src/asm.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ kernel/arch/amd64/src/asm.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -398,8 +398,5 @@
 	.asciz "Invalid instruction pointer."
 
-/** Print Unicode character to EGA display.
- *
- * If CONFIG_EGA is undefined or CONFIG_FB is defined
- * then this function does nothing.
+/** Print Unicode character to an early display device.
  *
  * Since the EGA can only display Extended ASCII (usually
@@ -413,4 +410,11 @@
  */
 FUNCTION_BEGIN(early_putwchar)
+
+#if (defined(CONFIG_L4RE_UVMM_EARLY_PRINT))
+	xorl %eax, %eax  /* RAX==0: uvmm's print hypercall */
+	mov %rdi, %rcx   /* RCX:    printed character */
+	vmcall
+#endif
+
 #if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
 
Index: kernel/arch/mips32/include/arch/arch.h
===================================================================
--- kernel/arch/mips32/include/arch/arch.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ kernel/arch/mips32/include/arch/arch.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -42,4 +42,5 @@
 #define CPUMAP_MAX_RECORDS         32
 #define BOOTINFO_TASK_NAME_BUFLEN  32
+#define BOOTINFO_BOOTARGS_BUFLEN   256
 
 extern size_t cpu_count;
@@ -66,4 +67,5 @@
 	uint32_t cpumap;
 	taskmap_t taskmap;
+	char bootargs[BOOTINFO_BOOTARGS_BUFLEN];
 } bootinfo_t;
 
Index: kernel/arch/mips32/src/mach/malta/malta.c
===================================================================
--- kernel/arch/mips32/src/mach/malta/malta.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ kernel/arch/mips32/src/mach/malta/malta.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -46,5 +46,4 @@
 #include <sysinfo/sysinfo.h>
 #include <log.h>
-#include <str.h>
 
 static void malta_init(void);
@@ -116,7 +115,4 @@
 	    NULL, NULL, tty_out_ptr);
 #endif
-
-	const char *args = "console=devices/\\hw\\pci0\\00:0a.0\\com1\\a";
-	str_ncpy(bargs, CONFIG_BOOT_ARGUMENTS_BUFLEN, args, str_length(args));
 }
 
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ kernel/arch/mips32/src/mips32.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -107,4 +107,6 @@
 #endif
 
+	str_cpy(bargs, CONFIG_BOOT_ARGUMENTS_BUFLEN, bootinfo->bootargs);
+
 	/* Initialize machine_ops pointer. */
 	machine_ops_init();
Index: tools/ew.py
===================================================================
--- tools/ew.py	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ tools/ew.py	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -87,5 +87,5 @@
 
 def malta_options():
-	return '-cpu 4Kc'
+	return '-cpu 4Kc -append "console=devices/\\hw\\pci0\\00:0a.0\\com1\\a"'
 
 def find_firmware(name, environ_var, default_paths, extra_info=None):
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/Makefile	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -223,12 +223,9 @@
 #
 
-BASE_LIBS = \
+DIRS += \
+	lib/fs \
+	lib/block \
 	lib/c \
 	lib/cpp \
-	lib/untar
-
-LIBS = \
-	lib/fs \
-	lib/block \
 	lib/crypto \
 	lib/clui \
@@ -253,4 +250,5 @@
 	lib/ext4 \
 	lib/trackmod \
+	lib/untar \
 	lib/uri \
 	lib/usb \
@@ -266,15 +264,14 @@
 	lib/virtio
 
-BASE_BUILDS := $(addsuffix .build,$(BASE_LIBS))
-BUILDS := $(addsuffix .build,$(DIRS) $(LIBS))
-BUILDS_TESTS := $(addsuffix .build-test,$(DIRS) $(LIBS) $(BASE_LIBS))
-DEPS = $(addsuffix /deps.mk,$(DIRS) $(LIBS))
-CLEANS := $(addsuffix .clean,$(DIRS) $(LIBS) $(BASE_LIBS))
-
-.PHONY: all $(BASE_BUILDS) $(BUILDS) $(BUILDS_TESTS) $(CLEANS) clean export
+BUILDS := $(addsuffix .build,$(DIRS))
+BUILDS_TESTS := $(addsuffix .build-test,$(DIRS))
+DEPS = $(addsuffix /deps.mk,$(DIRS))
+CLEANS := $(addsuffix .clean,$(DIRS))
+
+.PHONY: all $(BUILDS) $(BUILDS_TESTS) $(CLEANS) clean export
 
 all: $(BUILDS) $(BUILDS_TESTS)
 
-$(BUILDS_TESTS): $(BASE_BUILDS) $(BUILDS)
+$(BUILDS_TESTS): $(BUILDS)
 	$(MAKE) -r -C $(basename $@) all-test PRECHECK=$(PRECHECK)
 
@@ -292,5 +289,5 @@
 	-$(MAKE) -r -C $(basename $@) fasterclean
 
-$(BASE_BUILDS) $(BUILDS):
+$(BUILDS):
 	$(MAKE) -r -C $(basename $@) all PRECHECK=$(PRECHECK)
 
@@ -298,5 +295,3 @@
 	$(MAKE) -r -C $(@D) deps.mk SELF_TARGET="$(@D).build"
 
-$(BUILDS): $(BASE_BUILDS)
-
 -include $(DEPS)
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/Makefile.common	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -46,6 +46,4 @@
 #   STATIC_NEEDED      set to 'y' for init binaries, will build statically
 #                      linked version
-#   STATIC_ONLY        set to 'y' if binary cannot be linked dynamically
-#                      (e.g. uses thread-local variables)
 #
 # Optionally, for a library:
@@ -114,28 +112,22 @@
 LDFLAGS = -Wl,--fatal-warnings,--warn-common
 
+STATIC_BUILD = n
+
 ifeq ($(STATIC_NEEDED),y)
 	STATIC_BUILD = y
-else
-	ifeq ($(STATIC_ONLY),y)
+endif
+
+ifneq ($(CONFIG_BUILD_SHARED_LIBS),y)
+	STATIC_BUILD = y
+endif
+
+ifneq ($(CONFIG_USE_SHARED_LIBS),y)
+	ifeq ($(LIBRARY),)
 		STATIC_BUILD = y
-	else
-		ifeq ($(CONFIG_BUILD_SHARED_LIBS),y)
-			ifeq ($(CONFIG_USE_SHARED_LIBS),y)
-				STATIC_BUILD = n
-			else
-				ifeq ($(LIBRARY),)
-					STATIC_BUILD = y
-				else
-					STATIC_BUILD = n
-				endif
-			endif
-		else
-			STATIC_BUILD = y
-		endif
 	endif
 endif
 
-ifneq ($(STATIC_BUILD),y)
-	LINK_DYNAMIC = y
+ifeq ($(STATIC_BUILD),y)
+	LDFLAGS += -static
 endif
 
@@ -152,8 +144,4 @@
 BASE_LIBS += -lgcc
 
-ifneq ($(LINK_DYNAMIC),y)
-	LDFLAGS += -static
-endif
-
 INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS)
 
@@ -164,7 +152,14 @@
 INCLUDES_FLAGS += $(foreach lib,$(LIBS), -I$(LIB_PREFIX)/$(lib) -I$(LIB_PREFIX)/$(lib)/include)
 
-# TODO: get rid of this special case
-ifneq ($(filter math, $(LIBS)),)
-	INCLUDES_FLAGS += $(LIBMATH_INCLUDES_FLAGS)
+DEPLIBS := $(LIBS)
+
+ifneq ($(filter %.cpp %.cc %.cxx, $(SOURCES)),)
+	ifneq ($(LIBRARY),libcpp)
+		DEPLIBS += cpp
+	endif
+endif
+
+ifneq ($(LIBRARY),libc)
+	DEPLIBS += c
 endif
 
@@ -305,10 +300,6 @@
 DEPENDS := $(addsuffix .d,$(basename $(SOURCES))) $(addsuffix .test.d,$(basename $(TEST_SOURCES)))
 
-LIBTAGS := $(foreach lib,$(LIBS), $(USPACE_PREFIX)/lib/$(lib)/tag)
+LIBTAGS := $(foreach lib,$(DEPLIBS), $(USPACE_PREFIX)/lib/$(lib)/tag)
 LIBARGS := $(addprefix -L$(USPACE_PREFIX)/lib/, $(LIBS)) $(addprefix -l, $(LIBS))
-
-ifneq ($(LIBRARY),libc)
-	LIBTAGS := $(LIBC_PREFIX)/tag $(LIBTAGS)
-endif
 
 .PHONY: all all-test clean fasterclean depend
@@ -339,5 +330,5 @@
 deps.mk: Makefile
 	echo > $@.new
-	for lib in $(LIBS); do \
+	for lib in $(DEPLIBS); do \
 		echo "$(SELF_TARGET): lib/$$lib.build" >> $@.new; \
 	done
Index: uspace/app/bdsh/cmds/modules/ls/ls.c
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/app/bdsh/cmds/modules/ls/ls.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -42,4 +42,5 @@
 #include <vfs/vfs.h>
 #include <str.h>
+#include <cap.h>
 
 #include "ls.h"
@@ -58,4 +59,6 @@
 	{ "unsort", no_argument, 0, 'u' },
 	{ "recursive", no_argument, 0, 'r' },
+	{ "exact-size", no_argument, 0, 'e' },
+	{ "single-column", no_argument, 0, '1' },
 	{ 0, 0, 0, 0 }
 };
@@ -63,6 +66,8 @@
 /* Prototypes for the ls command, excluding entry points. */
 static unsigned int ls_start(ls_job_t *);
-static void ls_print(struct dir_elem_t *);
-static int ls_cmp(const void *, const void *);
+static errno_t ls_print(struct dir_elem_t *);
+static errno_t ls_print_single_column(struct dir_elem_t *);
+static int ls_cmp_type_name(const void *, const void *);
+static int ls_cmp_name(const void *, const void *);
 static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **);
 static unsigned int ls_recursive(const char *, DIR *);
@@ -74,4 +79,7 @@
 	ls->sort = 1;
 
+	ls->exact_size = false;
+	ls->single_column = false;
+	ls->printer = ls_print;
 	return 1;
 }
@@ -88,12 +96,51 @@
  * @param de		Directory element.
  */
-static void ls_print(struct dir_elem_t *de)
-{
-	if (de->s.is_file)
-		printf("%-40s\t%llu\n", de->name, (long long) de->s.size);
-	else if (de->s.is_directory)
-		printf("%-40s\t<dir>\n", de->name);
+static errno_t ls_print(struct dir_elem_t *de)
+{
+	int width = 13;
+
+	if (de->s.is_file) {
+		if (ls.exact_size) {
+			printf("%-40s\t%*llu\n", de->name, width, (long long) de->s.size);
+			return EOK;
+		}
+
+		cap_spec_t cap;
+		cap_from_blocks(de->s.size, 1, &cap);
+		cap_simplify(&cap);
+
+		char *rptr;
+		errno_t rc = cap_format(&cap, &rptr);
+		if (rc != EOK) {
+			return rc;
+		}
+
+		char *sep = str_rchr(rptr, ' ');
+		if (sep == NULL) {
+			free(rptr);
+			return ENOENT;
+		}
+
+		*sep = '\0';
+
+		printf("%-40s\t%*s %2s\n", de->name, width - 3, rptr, sep + 1);
+		free(rptr);
+	} else if (de->s.is_directory)
+		printf("%-40s\t%*s\n", de->name, width, "<dir>");
 	else
 		printf("%-40s\n", de->name);
+
+	return EOK;
+}
+
+static errno_t ls_print_single_column(struct dir_elem_t *de)
+{
+	if (de->s.is_file) {
+		printf("%s\n", de->name);
+	} else {
+		printf("%s/\n", de->name);
+	}
+
+	return EOK;
 }
 
@@ -109,5 +156,5 @@
  * @return		-1 if a < b, 1 otherwise.
  */
-static int ls_cmp(const void *a, const void *b)
+static int ls_cmp_type_name(const void *a, const void *b)
 {
 	struct dir_elem_t const *da = a;
@@ -120,4 +167,18 @@
 	else
 		return 1;
+}
+
+/** Compare directories/files per name
+ *
+ * This comparision ignores the type of
+ * the node. Sorted will strictly by name.
+ *
+ */
+static int ls_cmp_name(const void *a, const void *b)
+{
+	struct dir_elem_t const *da = a;
+	struct dir_elem_t const *db = b;
+
+	return str_cmp(da->name, db->name);
 }
 
@@ -192,9 +253,16 @@
 	}
 
-	if (ls.sort)
-		qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), ls_cmp);
-
-	for (i = 0; i < nbdirs; i++)
-		ls_print(&tosort[i]);
+	if (ls.sort) {
+		int (*compar)(const void *, const void *);
+		compar = ls.single_column ? ls_cmp_name : ls_cmp_type_name;
+		qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), compar);
+	}
+
+	for (i = 0; i < nbdirs; i++) {
+		if (ls.printer(&tosort[i]) != EOK) {
+			cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
+			goto out;
+		}
+	}
 
 	/* Populate the directory list. */
@@ -333,7 +401,9 @@
 		    "If not path is given, the current working directory is used.\n"
 		    "Options:\n"
-		    "  -h, --help       A short option summary\n"
-		    "  -u, --unsort     Do not sort directory entries\n"
-		    "  -r, --recursive  List subdirectories recursively\n",
+		    "  -h, --help            A short option summary\n"
+		    "  -u, --unsort          Do not sort directory entries\n"
+		    "  -r, --recursive       List subdirectories recursively\n"
+		    "  -e, --exact-size      File sizes will be unformatted (raw bytes count)\n"
+		    "  -1, --single-column   Only the names will be returned\n",
 		    cmdname);
 	}
@@ -364,5 +434,5 @@
 
 	while (c != -1) {
-		c = getopt_long(argc, argv, "hur", long_options, &opt_ind);
+		c = getopt_long(argc, argv, "hure1", long_options, &opt_ind);
 		switch (c) {
 		case 'h':
@@ -375,4 +445,11 @@
 			ls.recursive = 1;
 			break;
+		case 'e':
+			ls.exact_size = true;
+			break;
+		case '1':
+			ls.single_column = true;
+			ls.printer = ls_print_single_column;
+			break;
 		}
 	}
@@ -400,5 +477,8 @@
 	switch (scope) {
 	case LS_FILE:
-		ls_print(&de);
+		if (ls.printer(&de) != EOK) {
+			cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
+			return CMD_FAILURE;
+		}
 		break;
 	case LS_DIR:
Index: uspace/app/bdsh/cmds/modules/ls/ls.h
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/app/bdsh/cmds/modules/ls/ls.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -8,11 +8,4 @@
 #define LS_FILE  1
 #define LS_DIR   2
-
-typedef struct {
-	/* Options set at runtime. */
-	unsigned int recursive;
-	unsigned int sort;
-
-} ls_job_t;
 
 /** Structure to represent a directory entry.
@@ -26,3 +19,14 @@
 };
 
+typedef struct {
+	/* Options set at runtime. */
+	unsigned int recursive;
+	unsigned int sort;
+
+	bool single_column;
+	bool exact_size;
+
+	errno_t (*printer)(struct dir_elem_t *);
+} ls_job_t;
+
 #endif
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/Makefile	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -217,8 +217,8 @@
 include $(USPACE_PREFIX)/Makefile.common
 
-$(LIBC_PREFIX)/crt0.o: $(LIBC_PREFIX)/arch/$(UARCH)/src/entry.o
+$(LIBC_PREFIX)/crt0.o: $(LIBC_PREFIX)/arch/$(UARCH)/src/crt0.o
 	cp $< $@
 
-$(LIBC_PREFIX)/crt1.o: $(LIBC_PREFIX)/generic/crt/entry.o
+$(LIBC_PREFIX)/crt1.o: $(LIBC_PREFIX)/generic/crt/crt1.o
 	cp $< $@
 
Index: uspace/lib/c/arch/abs32le/src/crt0.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/crt0.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/abs32le/src/crt0.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010 Martin Decky
+ * 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.
+ */
+
+/** @file
+ */
+
+#include <stddef.h>
+
+extern void _start(void);
+extern void __c_start(void *);
+
+/* Normally, the entry point is defined in assembly for the architecture. */
+
+void _start(void)
+{
+	__c_start(NULL);
+}
+
+/** @}
+ */
Index: pace/lib/c/arch/abs32le/src/entry.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/entry.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2010 Martin Decky
- * 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.
- */
-
-/** @file
- */
-
-#include <stddef.h>
-
-extern void _start(void);
-extern void __c_start(void *);
-
-/* Normally, the entry point is defined in assembly for the architecture. */
-
-void _start(void)
-{
-	__c_start(NULL);
-}
-
-/** @}
- */
Index: uspace/lib/c/arch/amd64/src/crt0.S
===================================================================
--- uspace/lib/c/arch/amd64/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/amd64/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2006 Ondrej Palkovsky
+# 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+.org 0
+
+## User-space task entry point
+#
+# %rdi contains the PCB pointer
+#
+SYMBOL(_start)
+	#
+	# Create the first stack frame.
+	#
+	pushq $0
+	pushq $0
+	movq %rsp, %rbp
+
+	# %rdi was deliberately chosen as the first argument is also in %rdi
+	# Pass PCB pointer to __c_start (no operation)
+	call FUNCTION_REF(__c_start)
Index: pace/lib/c/arch/amd64/src/entry.S
===================================================================
--- uspace/lib/c/arch/amd64/src/entry.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#
-# Copyright (c) 2006 Ondrej Palkovsky
-# 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.
-#
-
-#include <abi/asmtool.h>
-
-.text
-
-.org 0
-
-## User-space task entry point
-#
-# %rdi contains the PCB pointer
-#
-SYMBOL(_start)
-	#
-	# Create the first stack frame.
-	#
-	pushq $0
-	pushq $0
-	movq %rsp, %rbp
-
-	# %rdi was deliberately chosen as the first argument is also in %rdi
-	# Pass PCB pointer to __c_start (no operation)
-	call FUNCTION_REF(__c_start)
Index: uspace/lib/c/arch/arm32/src/crt0.S
===================================================================
--- uspace/lib/c/arch/arm32/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/arm32/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,57 @@
+#
+# Copyright (c) 2007 Michal Kebrt, Pavel Jancik
+# 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+.org 0
+
+## User-space task entry point
+#
+# r1 contains the PCB pointer
+# r2 contains the RAS page address
+#
+SYMBOL(_start)
+	# Store the RAS page address into the ras_page variable
+	ldr r0, =ras_page
+	str r2, [r0]
+
+	#
+	# Create the first stack frame.
+	#
+	mov fp, #0
+	mov ip, sp
+	push {fp, ip, lr, pc}
+	sub fp, ip, #4
+
+	# Pass pcb_ptr to __c_start as the first argument (in r0)
+	mov r0, r1
+	bl __c_start
+
+.data
Index: pace/lib/c/arch/arm32/src/entry.S
===================================================================
--- uspace/lib/c/arch/arm32/src/entry.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,57 +1,0 @@
-#
-# Copyright (c) 2007 Michal Kebrt, Pavel Jancik
-# 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.
-#
-
-#include <abi/asmtool.h>
-
-.text
-
-.org 0
-
-## User-space task entry point
-#
-# r1 contains the PCB pointer
-# r2 contains the RAS page address
-#
-SYMBOL(_start)
-	# Store the RAS page address into the ras_page variable
-	ldr r0, =ras_page
-	str r2, [r0]
-
-	#
-	# Create the first stack frame.
-	#
-	mov fp, #0
-	mov ip, sp
-	push {fp, ip, lr, pc}
-	sub fp, ip, #4
-
-	# Pass pcb_ptr to __c_start as the first argument (in r0)
-	mov r0, r1
-	bl __c_start
-
-.data
Index: uspace/lib/c/arch/arm64/src/crt0.S
===================================================================
--- uspace/lib/c/arch/arm64/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/arm64/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,48 @@
+#
+# Copyright (c) 2015 Petr Pavlu
+# 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+.org 0
+
+## User-space task entry point
+#
+# x0 contains the PCB pointer
+#
+SYMBOL(_start)
+	#
+	# Create the first stack frame.
+	#
+	mov x29, #0
+	stp x29, x30, [sp, #-16]!
+	mov x29, sp
+
+	# Pass pcb_ptr to __c_start as the first argument (in x0)
+	bl __c_start
Index: pace/lib/c/arch/arm64/src/entry.S
===================================================================
--- uspace/lib/c/arch/arm64/src/entry.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,48 +1,0 @@
-#
-# Copyright (c) 2015 Petr Pavlu
-# 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.
-#
-
-#include <abi/asmtool.h>
-
-.text
-
-.org 0
-
-## User-space task entry point
-#
-# x0 contains the PCB pointer
-#
-SYMBOL(_start)
-	#
-	# Create the first stack frame.
-	#
-	mov x29, #0
-	stp x29, x30, [sp, #-16]!
-	mov x29, sp
-
-	# Pass pcb_ptr to __c_start as the first argument (in x0)
-	bl __c_start
Index: uspace/lib/c/arch/ia32/src/crt0.S
===================================================================
--- uspace/lib/c/arch/ia32/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/ia32/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2005 Martin Decky
+# 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.
+#
+
+#include <abi/asmtool.h>
+
+INTEL_CPUID_STANDARD = 1
+INTEL_SEP = 11
+
+.text
+
+.org 0
+
+## User-space task entry point
+#
+# %edi contains the PCB pointer
+#
+SYMBOL(_start)
+	mov %ss, %ax
+	mov %ax, %ds
+	mov %ax, %es
+	mov %ax, %fs
+	# Do not set %gs, it contains descriptor that can see TLS
+
+#ifndef PROCESSOR_i486
+	# Detect the mechanism used for making syscalls
+	movl $(INTEL_CPUID_STANDARD), %eax
+	cpuid
+	bt $(INTEL_SEP), %edx
+	jnc 0f
+		leal __syscall_fast_func, %eax
+		movl $__syscall_fast, (%eax)
+	0:
+#endif
+
+	#
+	# Create the first stack frame.
+	#
+	pushl $0
+	pushl $0
+	movl %esp, %ebp
+
+	# Pass the PCB pointer to __c_start as the first argument
+	pushl %edi
+	call __c_start
Index: pace/lib/c/arch/ia32/src/entry.S
===================================================================
--- uspace/lib/c/arch/ia32/src/entry.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,69 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# 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.
-#
-
-#include <abi/asmtool.h>
-
-INTEL_CPUID_STANDARD = 1
-INTEL_SEP = 11
-
-.text
-
-.org 0
-
-## User-space task entry point
-#
-# %edi contains the PCB pointer
-#
-SYMBOL(_start)
-	mov %ss, %ax
-	mov %ax, %ds
-	mov %ax, %es
-	mov %ax, %fs
-	# Do not set %gs, it contains descriptor that can see TLS
-
-#ifndef PROCESSOR_i486
-	# Detect the mechanism used for making syscalls
-	movl $(INTEL_CPUID_STANDARD), %eax
-	cpuid
-	bt $(INTEL_SEP), %edx
-	jnc 0f
-		leal __syscall_fast_func, %eax
-		movl $__syscall_fast, (%eax)
-	0:
-#endif
-
-	#
-	# Create the first stack frame.
-	#
-	pushl $0
-	pushl $0
-	movl %esp, %ebp
-
-	# Pass the PCB pointer to __c_start as the first argument
-	pushl %edi
-	call __c_start
Index: uspace/lib/c/arch/ia64/src/crt0.S
===================================================================
--- uspace/lib/c/arch/ia64/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/ia64/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,47 @@
+#
+# Copyright (c) 2006 Jakub Jermar
+# 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+.org 0
+.align 16
+
+## User-space task entry point
+#
+# r2 contains the PCB pointer
+#
+SYMBOL(_start)
+	alloc loc0 = ar.pfs, 0, 1, 2, 0
+	movl gp = __gp
+
+	# Pass PCB pointer as the first argument to __c_start
+	mov out0 = r2 ;;
+	br.call.sptk.many b0 = __c_start
+
Index: pace/lib/c/arch/ia64/src/entry.S
===================================================================
--- uspace/lib/c/arch/ia64/src/entry.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,47 +1,0 @@
-#
-# Copyright (c) 2006 Jakub Jermar
-# 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.
-#
-
-#include <abi/asmtool.h>
-
-.text
-
-.org 0
-.align 16
-
-## User-space task entry point
-#
-# r2 contains the PCB pointer
-#
-SYMBOL(_start)
-	alloc loc0 = ar.pfs, 0, 1, 2, 0
-	movl gp = __gp
-
-	# Pass PCB pointer as the first argument to __c_start
-	mov out0 = r2 ;;
-	br.call.sptk.many b0 = __c_start
-
Index: uspace/lib/c/arch/mips32/src/crt0.S
===================================================================
--- uspace/lib/c/arch/mips32/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/mips32/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,64 @@
+#
+# Copyright (c) 2005 Martin Decky
+# 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.
+#
+
+#include <abi/asmtool.h>
+#include <libarch/stack.h>
+
+.text
+
+.set noreorder
+.option pic2
+
+## User-space task entry point
+#
+# $a0 ($4) contains the PCB pointer
+#
+FUNCTION_BEGIN(__start)
+	.ent __start
+	.frame $sp, ABI_STACK_FRAME, $ra
+	.cpload $t9
+
+	# Allocate the stack frame.
+	addiu $sp, -ABI_STACK_FRAME
+
+	# Allow PIC code
+	.cprestore 16
+
+	# Pass pcb_ptr to __c_start() as the first argument. It is already
+	# in $a0. As the first argument is passed in $a0, no operation
+	# is needed.
+
+	jal __c_start
+	nop
+
+	#
+	# Not reached.
+	#
+	addiu $sp, ABI_STACK_FRAME
+	.end __start
+FUNCTION_END(__start)
Index: pace/lib/c/arch/mips32/src/entry.S
===================================================================
--- uspace/lib/c/arch/mips32/src/entry.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# 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.
-#
-
-#include <abi/asmtool.h>
-#include <libarch/stack.h>
-
-.text
-
-.set noreorder
-.option pic2
-
-## User-space task entry point
-#
-# $a0 ($4) contains the PCB pointer
-#
-FUNCTION_BEGIN(__start)
-	.ent __start
-	.frame $sp, ABI_STACK_FRAME, $ra
-	.cpload $t9
-
-	# Allocate the stack frame.
-	addiu $sp, -ABI_STACK_FRAME
-
-	# Allow PIC code
-	.cprestore 16
-
-	# Pass pcb_ptr to __c_start() as the first argument. It is already
-	# in $a0. As the first argument is passed in $a0, no operation
-	# is needed.
-
-	jal __c_start
-	nop
-
-	#
-	# Not reached.
-	#
-	addiu $sp, ABI_STACK_FRAME
-	.end __start
-FUNCTION_END(__start)
Index: uspace/lib/c/arch/ppc32/src/crt0.S
===================================================================
--- uspace/lib/c/arch/ppc32/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/ppc32/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2006 Martin Decky
+# 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+.org 0
+
+## User-space task entry point
+#
+# r6 contains the PCB pointer
+#
+SYMBOL(_start)
+	#
+	# Create the first stack frame.
+	#
+	li %r3, 0
+	stw %r3, 0(%r1)
+	stwu %r1, -16(%r1)
+
+	# Pass the PCB pointer to __c_start() as the first argument.
+	# The first argument is passed in r3.
+	mr %r3, %r6
+	bl __c_start
Index: pace/lib/c/arch/ppc32/src/entry.S
===================================================================
--- uspace/lib/c/arch/ppc32/src/entry.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,50 +1,0 @@
-#
-# Copyright (c) 2006 Martin Decky
-# 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.
-#
-
-#include <abi/asmtool.h>
-
-.text
-
-.org 0
-
-## User-space task entry point
-#
-# r6 contains the PCB pointer
-#
-SYMBOL(_start)
-	#
-	# Create the first stack frame.
-	#
-	li %r3, 0
-	stw %r3, 0(%r1)
-	stwu %r1, -16(%r1)
-
-	# Pass the PCB pointer to __c_start() as the first argument.
-	# The first argument is passed in r3.
-	mr %r3, %r6
-	bl __c_start
Index: uspace/lib/c/arch/riscv64/src/crt0.c
===================================================================
--- uspace/lib/c/arch/riscv64/src/crt0.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/riscv64/src/crt0.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016 Martin Decky
+ * 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.
+ */
+
+/** @file
+ */
+
+extern void _start(void);
+extern void __c_start(void *);
+
+// FIXME: Implement properly.
+
+void _start(void)
+{
+	__c_start(0);
+}
+
+/** @}
+ */
Index: pace/lib/c/arch/riscv64/src/entry.c
===================================================================
--- uspace/lib/c/arch/riscv64/src/entry.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,43 +1,0 @@
-/*
- * Copyright (c) 2016 Martin Decky
- * 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.
- */
-
-/** @file
- */
-
-extern void _start(void);
-extern void __c_start(void *);
-
-// FIXME: Implement properly.
-
-void _start(void)
-{
-	__c_start(0);
-}
-
-/** @}
- */
Index: uspace/lib/c/arch/sparc64/src/crt0.S
===================================================================
--- uspace/lib/c/arch/sparc64/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/arch/sparc64/src/crt0.S	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2006 Martin Decky
+# 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+.org 0
+
+## User-space task entry point
+#
+# %o0 contains uarg
+# %o1 contains pcb_ptr
+#
+SYMBOL(_start)
+	#
+	# Create the first stack frame.
+	#
+	save %sp, -176, %sp
+	flushw
+	add %g0, -0x7ff, %fp
+
+	# Pass pcb_ptr as the first argument to __c_start()
+	call __c_start
+	mov %i1, %o0
Index: pace/lib/c/arch/sparc64/src/entry.S
===================================================================
--- uspace/lib/c/arch/sparc64/src/entry.S	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,50 +1,0 @@
-#
-# Copyright (c) 2006 Martin Decky
-# 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.
-#
-
-#include <abi/asmtool.h>
-
-.text
-
-.org 0
-
-## User-space task entry point
-#
-# %o0 contains uarg
-# %o1 contains pcb_ptr
-#
-SYMBOL(_start)
-	#
-	# Create the first stack frame.
-	#
-	save %sp, -176, %sp
-	flushw
-	add %g0, -0x7ff, %fp
-
-	# Pass pcb_ptr as the first argument to __c_start()
-	call __c_start
-	mov %i1, %o0
Index: uspace/lib/c/generic/crt/crt1.c
===================================================================
--- uspace/lib/c/generic/crt/crt1.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
+++ uspace/lib/c/generic/crt/crt1.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2018 CZ.NIC, z.s.p.o.
+ * 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.
+ */
+
+#include "../private/libc.h"
+
+/*
+ * We shouldn't be accessing these symbols directly from libc,
+ * since it would create unwanted relocations in shared library
+ * code. Instead, we refer to them here, in a file that's always
+ * statically linked to the main executable, and write their values
+ * to a special structure that resides in libc.
+ */
+
+extern init_array_entry_t __preinit_array_start[] __attribute__((weak));
+extern init_array_entry_t __preinit_array_end[] __attribute__((weak));
+extern init_array_entry_t __init_array_start[] __attribute__((weak));
+extern init_array_entry_t __init_array_end[] __attribute__((weak));
+extern fini_array_entry_t __fini_array_start[] __attribute__((weak));
+extern fini_array_entry_t __fini_array_end[] __attribute__((weak));
+extern int main(int, char *[]);
+extern unsigned char __executable_start[];
+extern unsigned char _end[];
+
+/* __c_start is only called from _start in assembly. */
+void __c_start(void *);
+
+void __c_start(void *pcb)
+{
+	__progsymbols = (progsymbols_t) {
+		.main = main,
+		.elfstart = __executable_start,
+		.end = _end,
+		.preinit_array = __preinit_array_start,
+		.preinit_array_len = __preinit_array_end - __preinit_array_start,
+		.init_array = __init_array_start,
+		.init_array_len = __init_array_end - __init_array_start,
+		.fini_array = __fini_array_start,
+		.fini_array_len = __fini_array_end - __fini_array_start,
+	};
+
+	__libc_main(pcb);
+}
Index: pace/lib/c/generic/crt/entry.c
===================================================================
--- uspace/lib/c/generic/crt/entry.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ 	(revision )
@@ -1,67 +1,0 @@
-/*
- * Copyright (c) 2018 CZ.NIC, z.s.p.o.
- * 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.
- */
-
-#include "../private/libc.h"
-
-/*
- * We shouldn't be accessing these symbols directly from libc,
- * since it would create unwanted relocations in shared library
- * code. Instead, we refer to them here, in a file that's always
- * statically linked to the main executable, and write their values
- * to a special structure that resides in libc.
- */
-
-extern init_array_entry_t __preinit_array_start[] __attribute__((weak));
-extern init_array_entry_t __preinit_array_end[] __attribute__((weak));
-extern init_array_entry_t __init_array_start[] __attribute__((weak));
-extern init_array_entry_t __init_array_end[] __attribute__((weak));
-extern fini_array_entry_t __fini_array_start[] __attribute__((weak));
-extern fini_array_entry_t __fini_array_end[] __attribute__((weak));
-extern int main(int, char *[]);
-extern unsigned char __executable_start[];
-extern unsigned char _end[];
-
-/* __c_start is only called from _start in assembly. */
-void __c_start(void *);
-
-void __c_start(void *pcb)
-{
-	__progsymbols = (progsymbols_t) {
-		.main = main,
-		.elfstart = __executable_start,
-		.end = _end,
-		.preinit_array = __preinit_array_start,
-		.preinit_array_len = __preinit_array_end - __preinit_array_start,
-		.init_array = __init_array_start,
-		.init_array_len = __init_array_end - __init_array_start,
-		.fini_array = __fini_array_start,
-		.fini_array_len = __fini_array_end - __fini_array_start,
-	};
-
-	__libc_main(pcb);
-}
Index: uspace/lib/c/generic/dirent.c
===================================================================
--- uspace/lib/c/generic/dirent.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/generic/dirent.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -39,4 +39,5 @@
 #include <errno.h>
 #include <assert.h>
+#include <string.h>
 
 struct __dirstream {
@@ -92,10 +93,12 @@
 	ssize_t len = 0;
 
-	rc = vfs_read_short(dirp->fd, dirp->pos, &dirp->res.d_name[0],
-	    NAME_MAX + 1, &len);
+	rc = vfs_read_short(dirp->fd, dirp->pos, dirp->res.d_name,
+	    sizeof(dirp->res.d_name), &len);
 	if (rc != EOK) {
 		errno = rc;
 		return NULL;
 	}
+
+	assert(strnlen(dirp->res.d_name, sizeof(dirp->res.d_name)) < sizeof(dirp->res.d_name));
 
 	dirp->pos += len;
Index: uspace/lib/c/generic/private/stdio.h
===================================================================
--- uspace/lib/c/generic/private/stdio.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/generic/private/stdio.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -40,4 +40,5 @@
 #include <async.h>
 #include <stddef.h>
+#include <offset.h>
 
 /** Maximum characters that can be pushed back by ungetc() */
@@ -54,4 +55,15 @@
 	int (*flush)(FILE *stream);
 } __stream_ops_t;
+
+enum __buffer_state {
+	/** Buffer is empty */
+	_bs_empty,
+
+	/** Buffer contains data to be written */
+	_bs_write,
+
+	/** Buffer contains prefetched data for reading */
+	_bs_read
+};
 
 struct _IO_FILE {
@@ -87,5 +99,5 @@
 
 	/** Buffering type */
-	enum _buffer_type btype;
+	enum __buffer_type btype;
 
 	/** Buffer */
@@ -96,5 +108,5 @@
 
 	/** Buffer state */
-	enum _buffer_state buf_state;
+	enum __buffer_state buf_state;
 
 	/** Buffer I/O pointer */
Index: uspace/lib/c/generic/ubsan.c
===================================================================
--- uspace/lib/c/generic/ubsan.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/generic/ubsan.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -35,4 +35,11 @@
 };
 
+struct type_mismatch_data_v1 {
+	struct source_location loc;
+	struct type_descriptor *type;
+	unsigned char log_alignment;
+	unsigned char type_check_kind;
+};
+
 struct overflow_data {
 	struct source_location loc;
@@ -73,4 +80,8 @@
 	struct source_location loc;
 	struct source_location attr_loc;
+};
+
+struct pointer_overflow_data {
+	struct source_location loc;
 };
 
@@ -81,4 +92,5 @@
  */
 void __ubsan_handle_type_mismatch(struct type_mismatch_data *data, unsigned long ptr);
+void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data, unsigned long ptr);
 void __ubsan_handle_add_overflow(struct overflow_data *data, unsigned long lhs, unsigned long rhs);
 void __ubsan_handle_sub_overflow(struct overflow_data *data, unsigned long lhs, unsigned long rhs);
@@ -99,4 +111,6 @@
 void __ubsan_handle_nonnull_return(struct nonnull_return_data *data);
 void __ubsan_handle_builtin_unreachable(struct unreachable_data *data);
+void __ubsan_handle_pointer_overflow(struct pointer_overflow_data *data,
+    unsigned long base, unsigned long result);
 
 static void print_loc(const char *func, struct source_location *loc)
@@ -121,4 +135,13 @@
 }
 
+void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data,
+    unsigned long ptr)
+{
+	print_loc(__func__, &data->loc);
+	PRINTF("Type: %s, alignment: %hhu, type_check_kind: %hhu\n",
+	    data->type->type_name, data->log_alignment, data->type_check_kind);
+	ubsan_panic();
+}
+
 void __ubsan_handle_add_overflow(struct overflow_data *data,
     unsigned long lhs,
@@ -228,2 +251,9 @@
 	ubsan_panic();
 }
+
+void __ubsan_handle_pointer_overflow(struct pointer_overflow_data *data,
+    unsigned long base, unsigned long result)
+{
+	print_loc(__func__, &data->loc);
+	ubsan_panic();
+}
Index: uspace/lib/c/include/adt/list.h
===================================================================
--- uspace/lib/c/include/adt/list.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/adt/list.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -42,19 +42,14 @@
 #include <stdint.h>
 #include <trace.h>
-
-/** Doubly linked list link. */
-typedef struct link {
-	struct link *prev;  /**< Pointer to the previous item in the list. */
-	struct link *next;  /**< Pointer to the next item in the list. */
-} link_t;
-
-/** Doubly linked list. */
-typedef struct list {
-	link_t head;  /**< List head. Does not have any data. */
-} list_t;
-
-extern bool list_member(const link_t *, const list_t *);
-extern void list_splice(list_t *, link_t *);
-extern unsigned long list_count(const list_t *);
+#include <_bits/decls.h>
+
+#ifndef __cplusplus
+
+/**
+ * We don't define the macros in C++ to avoid polluting headers with
+ * namespaceless names. We don't actually need them, so this is fine.
+ * We still allow including the rest of the file (in `helenos` namespace)
+ * so that we can expose publicly visible types that have list_t members.
+ */
 
 /** Declare and initialize statically allocated list.
@@ -138,4 +133,27 @@
 	assert(!link_used(link))
 
+#define list_pop(list, type, member) \
+	((type *) list_pop_internal(list, \
+	    (list_link_to_void(&(((type *) NULL)->member)) - NULL)))
+
+#endif  /* !__cplusplus */
+
+__HELENOS_DECLS_BEGIN;
+
+/** Doubly linked list link. */
+typedef struct __adt_list_link {
+	struct __adt_list_link *prev;  /**< Pointer to the previous item in the list. */
+	struct __adt_list_link *next;  /**< Pointer to the next item in the list. */
+} link_t;
+
+/** Doubly linked list. */
+typedef struct {
+	link_t head;  /**< List head. Does not have any data. */
+} list_t;
+
+extern bool list_member(const link_t *, const list_t *);
+extern void list_splice(list_t *, link_t *);
+extern unsigned long list_count(const list_t *);
+
 /** Returns true if the link is definitely part of a list. False if not sure. */
 static inline bool link_in_use(const link_t *link)
@@ -425,7 +443,5 @@
 }
 
-#define list_pop(list, type, member) \
-	((type *) list_pop_internal(list, \
-	    (list_link_to_void(&(((type *) NULL)->member)) - NULL)))
+__HELENOS_DECLS_END;
 
 #endif
Index: uspace/lib/c/include/assert.h
===================================================================
--- uspace/lib/c/include/assert.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/assert.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -41,7 +41,11 @@
 #define _LIBC_ASSERT_H_
 
+#include <_bits/decls.h>
+
 #ifndef __cplusplus
 #define static_assert _Static_assert
 #endif
+
+__C_DECLS_BEGIN;
 
 extern void __helenos_assert_abort(const char *, const char *, unsigned int)
@@ -50,4 +54,6 @@
 extern void __helenos_assert_quick_abort(const char *, const char *, unsigned int)
     __attribute__((noreturn));
+
+__C_DECLS_END;
 
 #endif
Index: uspace/lib/c/include/bsearch.h
===================================================================
--- uspace/lib/c/include/bsearch.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/bsearch.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,7 +37,12 @@
 
 #include <stddef.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 extern void *bsearch(const void *, const void *, size_t, size_t,
     int (*)(const void *, const void *));
+
+__C_DECLS_END;
 
 #endif
Index: uspace/lib/c/include/ctype.h
===================================================================
--- uspace/lib/c/include/ctype.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/ctype.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,4 +30,7 @@
 #define _LIBC_CTYPE_H_
 
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 int islower(int);
 int isupper(int);
@@ -44,4 +47,5 @@
 int tolower(int);
 int toupper(int);
+__C_DECLS_END;
 
 #endif
Index: uspace/lib/c/include/dirent.h
===================================================================
--- uspace/lib/c/include/dirent.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/dirent.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -36,8 +36,10 @@
 #define _LIBC_DIRENT_H_
 
-#define NAME_MAX  256
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 struct dirent {
-	char d_name[NAME_MAX + 1];
+	char d_name[256];
 };
 
@@ -49,4 +51,6 @@
 extern int closedir(DIR *);
 
+__C_DECLS_END;
+
 #endif
 
Index: uspace/lib/c/include/dlfcn.h
===================================================================
--- uspace/lib/c/include/dlfcn.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/dlfcn.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,6 +37,12 @@
 #define _LIBC_DLFCN_H_
 
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
+
 void *dlopen(const char *, int);
 void *dlsym(void *, const char *);
+
+__C_DECLS_END;
 
 #endif
Index: uspace/lib/c/include/errno.h
===================================================================
--- uspace/lib/c/include/errno.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/errno.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -38,8 +38,17 @@
 #include <_bits/errno.h>
 #include <abi/errno.h>
+#include <_bits/decls.h>
 
-#define errno  (*(__errno()))
+__HELENOS_DECLS_BEGIN;
 
 extern errno_t *__errno(void) __attribute__((const));
+
+__HELENOS_DECLS_END;
+
+#ifdef __cplusplus
+#define errno  (*(::helenos::__errno()))
+#else
+#define errno  (*(__errno()))
+#endif
 
 #endif
Index: uspace/lib/c/include/fibril.h
===================================================================
--- uspace/lib/c/include/fibril.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/fibril.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -36,7 +36,10 @@
 #define _LIBC_FIBRIL_H_
 
-#include <types/common.h>
 #include <time.h>
+#include <_bits/errno.h>
 #include <_bits/__noreturn.h>
+#include <_bits/decls.h>
+
+__HELENOS_DECLS_BEGIN;
 
 typedef struct fibril fibril_t;
@@ -71,4 +74,6 @@
 extern __noreturn void fibril_exit(long);
 
+__HELENOS_DECLS_END;
+
 #endif
 
Index: uspace/lib/c/include/fibril_synch.h
===================================================================
--- uspace/lib/c/include/fibril_synch.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/fibril_synch.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -40,10 +40,7 @@
 #include <time.h>
 #include <stdbool.h>
-
-typedef struct {
-	fibril_owner_info_t oi;  /**< Keep this the first thing. */
-	int counter;
-	list_t waiters;
-} fibril_mutex_t;
+#include <_bits/decls.h>
+
+#ifndef __cplusplus
 
 #define FIBRIL_MUTEX_INITIALIZER(name) \
@@ -58,11 +55,4 @@
 #define FIBRIL_MUTEX_INITIALIZE(name) \
 	fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name)
-
-typedef struct {
-	fibril_owner_info_t oi;  /**< Keep this the first thing. */
-	unsigned int writers;
-	unsigned int readers;
-	list_t waiters;
-} fibril_rwlock_t;
 
 #define FIBRIL_RWLOCK_INITIALIZER(name) \
@@ -79,8 +69,4 @@
 	fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name)
 
-typedef struct {
-	list_t waiters;
-} fibril_condvar_t;
-
 #define FIBRIL_CONDVAR_INITIALIZER(name) \
 	{ \
@@ -90,4 +76,34 @@
 #define FIBRIL_CONDVAR_INITIALIZE(name) \
 	fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name)
+
+#define FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) \
+	{ \
+		.count = (cnt), \
+		.waiters = LIST_INITIALIZER((name).waiters), \
+	}
+
+#define FIBRIL_SEMAPHORE_INITIALIZE(name, cnt) \
+	fibril_semaphore_t name = FIBRIL_SEMAPHORE_INITIALIZER(name, cnt)
+
+#endif
+
+__HELENOS_DECLS_BEGIN;
+
+typedef struct {
+	fibril_owner_info_t oi;  /**< Keep this the first thing. */
+	int counter;
+	list_t waiters;
+} fibril_mutex_t;
+
+typedef struct {
+	fibril_owner_info_t oi;  /**< Keep this the first thing. */
+	unsigned int writers;
+	unsigned int readers;
+	list_t waiters;
+} fibril_rwlock_t;
+
+typedef struct {
+	list_t waiters;
+} fibril_condvar_t;
 
 typedef void (*fibril_timer_fun_t)(void *);
@@ -134,13 +150,4 @@
 } fibril_semaphore_t;
 
-#define FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) \
-	{ \
-		.count = (cnt), \
-		.waiters = LIST_INITIALIZER((name).waiters), \
-	}
-
-#define FIBRIL_SEMAPHORE_INITIALIZE(name, cnt) \
-	fibril_semaphore_t name = FIBRIL_SEMAPHORE_INITIALIZER(name, cnt)
-
 extern void __fibril_synch_init(void);
 extern void __fibril_synch_fini(void);
@@ -190,4 +197,6 @@
 extern void mpsc_close(mpsc_t *);
 
+__HELENOS_DECLS_END;
+
 #endif
 
Index: uspace/lib/c/include/malloc.h
===================================================================
--- uspace/lib/c/include/malloc.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/malloc.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,4 +37,7 @@
 
 #include <stddef.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 extern void *malloc(size_t size)
@@ -42,10 +45,19 @@
 extern void *calloc(size_t nmemb, size_t size)
     __attribute__((malloc));
-extern void *memalign(size_t align, size_t size)
-    __attribute__((malloc));
 extern void *realloc(void *addr, size_t size)
     __attribute__((warn_unused_result));
 extern void free(void *addr);
+
+__C_DECLS_END;
+
+#ifdef _HELENOS_SOURCE
+__HELENOS_DECLS_BEGIN;
+
+extern void *memalign(size_t align, size_t size)
+    __attribute__((malloc));
 extern void *heap_check(void);
+
+__HELENOS_DECLS_END;
+#endif
 
 #endif
Index: uspace/lib/c/include/mem.h
===================================================================
--- uspace/lib/c/include/mem.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/mem.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -38,4 +38,7 @@
 
 #include <stddef.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 extern void *memset(void *, int, size_t)
@@ -50,4 +53,6 @@
     __attribute__((nonnull(1)));
 
+__C_DECLS_END;
+
 #endif
 
Index: uspace/lib/c/include/offset.h
===================================================================
--- uspace/lib/c/include/offset.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/offset.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -36,5 +36,11 @@
 #define _LIBC_OFFSET_H_
 
+#ifndef _HELENOS_SOURCE
+#error This file should only be included from HelenOS sources
+#endif
+
 #include <stdint.h>
+#include <_bits/decls.h>
+#include <_bits/off64_t.h>
 
 /* off64_t */
@@ -52,9 +58,10 @@
 #define PRIXOFF64 PRIX64
 
-/** Relative offset */
-typedef int64_t off64_t;
+__HELENOS_DECLS_BEGIN;
 
 /** Absolute offset */
 typedef uint64_t aoff64_t;
+
+__HELENOS_DECLS_END;
 
 #endif
Index: uspace/lib/c/include/qsort.h
===================================================================
--- uspace/lib/c/include/qsort.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/qsort.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,9 +37,17 @@
 
 #include <stddef.h>
+#include <_bits/decls.h>
 
+__C_DECLS_BEGIN;
 extern void qsort(void *, size_t, size_t, int (*)(const void *,
     const void *));
+__C_DECLS_END;
+
+#ifdef _HELENOS_SOURCE
+__HELENOS_DECLS_BEGIN;
 extern void qsort_r(void *, size_t, size_t, int (*)(const void *,
     const void *, void *), void *);
+__HELENOS_DECLS_END;
+#endif
 
 #endif
Index: uspace/lib/c/include/setjmp.h
===================================================================
--- uspace/lib/c/include/setjmp.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/setjmp.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -34,10 +34,9 @@
 #define _LIBC_SETJMP_H_
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <libarch/fibril_context.h>
 #include <_bits/__noreturn.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 typedef __context_t jmp_buf[1];
@@ -46,10 +45,9 @@
 extern __noreturn void __context_restore(__context_t *, int);
 
-#define setjmp __context_save
 extern __noreturn void longjmp(jmp_buf, int);
 
-#ifdef __cplusplus
-}
-#endif
+__C_DECLS_END;
+
+#define setjmp __context_save
 
 #endif
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/stdio.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,9 +37,4 @@
 #define _LIBC_STDIO_H_
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <offset.h>
 #include <stdarg.h>
 #include <io/verify.h>
@@ -48,13 +43,5 @@
 #include <_bits/wchar_t.h>
 #include <_bits/wint_t.h>
-
-/** Forward declaration */
-struct _IO_FILE;
-typedef struct _IO_FILE FILE;
-
-/** File position */
-typedef struct {
-	off64_t pos;
-} fpos_t;
+#include <_bits/decls.h>
 
 #ifndef _HELENOS_SOURCE
@@ -70,5 +57,5 @@
 
 /** Max number of files that is guaranteed to be able to open at the same time */
-#define FOPEN_MAX VFS_MAX_OPEN_FILES
+#define FOPEN_MAX 16
 
 /** Recommended size of fixed-size array for holding file names. */
@@ -92,4 +79,15 @@
 /** Minimum number of unique temporary file names */
 #define TMP_MAX 1000000
+
+__C_DECLS_BEGIN;
+
+/** Forward declaration */
+struct _IO_FILE;
+typedef struct _IO_FILE FILE;
+
+/** File position */
+typedef struct {
+	long long pos;
+} fpos_t;
 
 extern FILE *stdin;
@@ -98,15 +96,23 @@
 
 /* Character and string input functions */
-#define getc fgetc
 extern int fgetc(FILE *);
 extern char *fgets(char *, int, FILE *);
 extern char *gets(char *, size_t) __attribute__((deprecated));
 
+static inline int getc(FILE *f)
+{
+	return fgetc(f);
+}
+
 extern int getchar(void);
 
 /* Character and string output functions */
-#define putc fputc
 extern int fputc(int, FILE *);
 extern int fputs(const char *, FILE *);
+
+static inline int putc(int i, FILE *f)
+{
+	return fputc(i, f);
+}
 
 extern int putchar(int);
@@ -180,9 +186,15 @@
 extern char *tmpnam(char *s);
 
+__C_DECLS_END;
+
 #ifdef _HELENOS_SOURCE
 
+#include <_bits/off64_t.h>
+
+__HELENOS_DECLS_BEGIN;
+
 /* Nonstandard extensions. */
 
-enum _buffer_type {
+enum __buffer_type {
 	/** No buffering */
 	_IONBF,
@@ -193,15 +205,4 @@
 };
 
-enum _buffer_state {
-	/** Buffer is empty */
-	_bs_empty,
-
-	/** Buffer contains data to be written */
-	_bs_write,
-
-	/** Buffer contains prefetched data for reading */
-	_bs_read
-};
-
 extern int vprintf_length(const char *, va_list);
 extern int printf_length(const char *, ...)
@@ -210,13 +211,8 @@
 extern int fileno(FILE *);
 
-#include <offset.h>
-
 extern int fseek64(FILE *, off64_t, int);
 extern off64_t ftell64(FILE *);
 
-#endif
-
-#ifdef __cplusplus
-}
+__HELENOS_DECLS_END;
 #endif
 
Index: uspace/lib/c/include/stdlib.h
===================================================================
--- uspace/lib/c/include/stdlib.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/stdlib.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -36,13 +36,19 @@
 #define _LIBC_STDLIB_H_
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <_bits/size_t.h>
 #include <_bits/wchar_t.h>
+#include <_bits/decls.h>
 #include <bsearch.h>
 #include <malloc.h>
 #include <qsort.h>
+
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+
+#define RAND_MAX  714025
+
+#define MB_CUR_MAX 4
+
+__C_DECLS_BEGIN;
 
 /** Type returned by the div function */
@@ -69,11 +75,4 @@
 	long long rem;
 } lldiv_t;
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-#define RAND_MAX  714025
-
-#define MB_CUR_MAX 4
 
 extern long double strtold(const char *, char **);
@@ -109,7 +108,5 @@
 extern lldiv_t lldiv(long long, long long);
 
-#ifdef __cplusplus
-}
-#endif
+__C_DECLS_END;
 
 #endif
Index: uspace/lib/c/include/str.h
===================================================================
--- uspace/lib/c/include/str.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/str.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -38,8 +38,4 @@
 #define _LIBC_STR_H_
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <errno.h>
 #include <stdbool.h>
@@ -48,4 +44,7 @@
 
 #include <mem.h>
+#include <_bits/decls.h>
+
+#ifndef __cplusplus
 
 /* Common Unicode characters */
@@ -63,4 +62,8 @@
  */
 #define SPASCII_STR_BUFSIZE(spa_size) ((spa_size) + 1)
+
+#endif
+
+__HELENOS_DECLS_BEGIN;
 
 extern wchar_t str_decode(const char *str, size_t *offset, size_t sz);
@@ -147,7 +150,5 @@
 extern unsigned long strtoul(const char *, char **, int);
 
-#ifdef __cplusplus
-}
-#endif
+__HELENOS_DECLS_END;
 
 #endif
Index: uspace/lib/c/include/string.h
===================================================================
--- uspace/lib/c/include/string.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/string.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -41,7 +41,10 @@
 #endif
 
+#include <_bits/decls.h>
 #include <_bits/size_t.h>
 #include <_bits/NULL.h>
 #include <mem.h>
+
+__C_DECLS_BEGIN;
 
 extern char *strcpy(char *, const char *);
@@ -70,4 +73,6 @@
 #endif
 
+__C_DECLS_END;
+
 #endif
 
Index: uspace/lib/c/include/time.h
===================================================================
--- uspace/lib/c/include/time.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/time.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -36,7 +36,5 @@
 #define _LIBC_TIME_H_
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <_bits/decls.h>
 
 /* ISO/IEC 9899:2011 7.27.1 (2) */
@@ -51,4 +49,6 @@
 
 #include <_bits/size_t.h>
+
+__C_DECLS_BEGIN;
 
 /* ISO/IEC 9899:2011 7.27.1 (3), (4) */
@@ -106,4 +106,6 @@
     const struct tm *__restrict__);
 
+__C_DECLS_END;
+
 #ifdef _HELENOS_SOURCE
 
@@ -114,4 +116,6 @@
 #include <stdbool.h>
 #include <_bits/errno.h>
+
+__HELENOS_DECLS_BEGIN;
 
 typedef long long sec_t;
@@ -155,9 +159,7 @@
 extern void udelay(sysarg_t);
 
+__HELENOS_DECLS_END;
+
 #endif /* _HELENOS_SOURCE */
-
-#ifdef __cplusplus
-}
-#endif
 
 #endif
Index: uspace/lib/c/include/vfs/vfs.h
===================================================================
--- uspace/lib/c/include/vfs/vfs.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/c/include/vfs/vfs.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -44,6 +44,4 @@
 #include <async.h>
 #include <offset.h>
-
-#define VFS_MAX_OPEN_FILES  128
 
 enum vfs_change_state_type {
Index: uspace/lib/cpp/include/__bits/chrono.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/chrono.hpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/__bits/chrono.hpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -611,6 +611,6 @@
             static time_point now()
             {
-                hel::timespec ts{};
-                hel::getrealtime(&ts);
+                ::std::timespec ts{};
+                ::helenos::getrealtime(&ts);
 
                 rep time = NSEC2USEC(ts.tv_nsec);
@@ -654,6 +654,6 @@
             static time_point now()
             {
-                hel::timespec ts{};
-                hel::getuptime(&ts);
+                ::std::timespec ts{};
+                ::helenos::getuptime(&ts);
 
                 rep time = NSEC2USEC(ts.tv_nsec);
Index: uspace/lib/cpp/include/__bits/io/ios.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/io/ios.hpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/__bits/io/ios.hpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -41,5 +41,5 @@
 {
     using streamoff = long long;
-    using streamsize = hel::ssize_t;
+    using streamsize = ::ssize_t;
 
     /**
Index: uspace/lib/cpp/include/__bits/limits.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/limits.hpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/__bits/limits.hpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -528,5 +528,5 @@
             static constexpr unsigned short min()
             {
-                return USHRT_MIN;
+                return 0;
             }
 
@@ -552,5 +552,5 @@
             static constexpr unsigned int min()
             {
-                return UINT_MIN;
+                return 0;
             }
 
@@ -576,5 +576,5 @@
             static constexpr unsigned long min()
             {
-                return ULONG_MIN;
+                return 0;
             }
 
@@ -600,5 +600,5 @@
             static constexpr unsigned long long min()
             {
-                return ULLONG_MIN;
+                return 0;
             }
 
Index: uspace/lib/cpp/include/__bits/locale/num_get.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/locale/num_get.hpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/__bits/locale/num_get.hpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -301,16 +301,19 @@
                 if (size > 0)
                 {
-                    int ret{};
+                    int olderrno{errno};
+                    errno = EOK;
+                    char *endptr = NULL;
+
                     if constexpr (is_signed<BaseType>::value)
-                        ret = std::hel::str_int64_t(base.buffer_, nullptr, num_base, false, &res);
-                    else
-                        ret = std::hel::str_uint64_t(base.buffer_, nullptr, num_base, false, &res);
-
-                    if (ret != EOK)
-                    {
+                        res = ::strtoll(base.buffer_, &endptr, num_base);
+                    else
+                        res = ::strtoull(base.buffer_, &endptr, num_base);
+
+                    if (errno != EOK || endptr == base.buffer_)
                         err |= ios_base::failbit;
-                        v = 0;
-                    }
-                    else if (res > static_cast<BaseType>(numeric_limits<T>::max()))
+
+                    errno = olderrno;
+
+                    if (res > static_cast<BaseType>(numeric_limits<T>::max()))
                     {
                         err |= ios_base::failbit;
Index: uspace/lib/cpp/include/__bits/random.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/random.hpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/__bits/random.hpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -1030,10 +1030,10 @@
              *       something better.
              */
-            hel::srand(hel::time(nullptr));
+            ::srand(::time(nullptr));
         }
 
         result_type operator()()
         {
-            return hel::rand();
+            return ::rand();
         }
 
Index: uspace/lib/cpp/include/__bits/string/string.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/string/string.hpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/__bits/string/string.hpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -82,10 +82,10 @@
         static int compare(const char_type* s1, const char_type* s2, size_t n)
         {
-            return hel::str_lcmp(s1, s2, n);
+            return ::strncmp(s1, s2, n);
         }
 
         static size_t length(const char_type* s)
         {
-            return hel::str_size(s);
+            return ::strlen(s);
         }
 
@@ -367,5 +367,4 @@
             // TODO: This function does not exits...
             __unimplemented();
-            //return hel::wstr_lcmp(s1, s2, n);
             return 0;
         }
@@ -373,5 +372,8 @@
         static size_t length(const char_type* s)
         {
-            return hel::wstr_size(s);
+            size_t i = 0;
+            while (s[i] != 0)
+                i++;
+            return i;
         }
 
Index: uspace/lib/cpp/include/__bits/thread/condition_variable.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/thread/condition_variable.hpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/__bits/thread/condition_variable.hpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -35,9 +35,4 @@
 namespace std
 {
-    extern "C" {
-        #include <fibril.h>
-        #include <fibril_synch.h>
-    }
-
     enum class cv_status
     {
Index: uspace/lib/cpp/include/__bits/thread/threading.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/thread/threading.hpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/__bits/thread/threading.hpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,13 +30,8 @@
 #define LIBCPP_BITS_THREAD_THREADING
 
-namespace std::hel
-{
-    extern "C" {
-        #include <fibril.h>
-        #include <fibril_synch.h>
-    }
-}
-
 #include <chrono>
+
+#include <fibril.h>
+#include <fibril_synch.h>
 
 namespace std::aux
@@ -54,9 +49,9 @@
     struct threading_policy<fibril_tag>
     {
-        using mutex_type        = hel::fibril_mutex_t;
-        using thread_type       = hel::fid_t;
-        using condvar_type      = hel::fibril_condvar_t;
-        using time_unit         = hel::usec_t;
-        using shared_mutex_type = hel::fibril_rwlock_t;
+        using mutex_type        = ::helenos::fibril_mutex_t;
+        using thread_type       = ::helenos::fid_t;
+        using condvar_type      = ::helenos::fibril_condvar_t;
+        using time_unit         = ::helenos::usec_t;
+        using shared_mutex_type = ::helenos::fibril_rwlock_t;
 
         struct thread
@@ -65,20 +60,20 @@
             static thread_type create(Callable clbl, Payload& pld)
             {
-                return hel::fibril_create(clbl, (void*)&pld);
+                return ::helenos::fibril_create(clbl, (void*)&pld);
             }
 
             static void start(thread_type thr)
             {
-                hel::fibril_add_ready(thr);
+                ::helenos::fibril_add_ready(thr);
             }
 
             static thread_type this_thread()
             {
-                return hel::fibril_get_id();
+                return ::helenos::fibril_get_id();
             }
 
             static void yield()
             {
-                hel::fibril_yield();
+                ::helenos::fibril_yield();
             }
 
@@ -94,20 +89,20 @@
             static void init(mutex_type& mtx)
             {
-                hel::fibril_mutex_initialize(&mtx);
+                ::helenos::fibril_mutex_initialize(&mtx);
             }
 
             static void lock(mutex_type& mtx)
             {
-                hel::fibril_mutex_lock(&mtx);
+                ::helenos::fibril_mutex_lock(&mtx);
             }
 
             static void unlock(mutex_type& mtx)
             {
-                hel::fibril_mutex_unlock(&mtx);
+                ::helenos::fibril_mutex_unlock(&mtx);
             }
 
             static bool try_lock(mutex_type& mtx)
             {
-                return hel::fibril_mutex_trylock(&mtx);
+                return ::helenos::fibril_mutex_trylock(&mtx);
             }
 
@@ -123,25 +118,25 @@
             static void init(condvar_type& cv)
             {
-                hel::fibril_condvar_initialize(&cv);
+                ::helenos::fibril_condvar_initialize(&cv);
             }
 
             static void wait(condvar_type& cv, mutex_type& mtx)
             {
-                hel::fibril_condvar_wait(&cv, &mtx);
+                ::helenos::fibril_condvar_wait(&cv, &mtx);
             }
 
             static int wait_for(condvar_type& cv, mutex_type& mtx, time_unit timeout)
             {
-                return hel::fibril_condvar_wait_timeout(&cv, &mtx, timeout);
+                return ::helenos::fibril_condvar_wait_timeout(&cv, &mtx, timeout);
             }
 
             static void signal(condvar_type& cv)
             {
-                hel::fibril_condvar_signal(&cv);
+                ::helenos::fibril_condvar_signal(&cv);
             }
 
             static void broadcast(condvar_type& cv)
             {
-                hel::fibril_condvar_broadcast(&cv);
+                ::helenos::fibril_condvar_broadcast(&cv);
             }
         };
@@ -157,5 +152,5 @@
             static void sleep(time_unit time)
             {
-                hel::fibril_usleep(time);
+                ::helenos::fibril_usleep(time);
             }
         };
@@ -165,25 +160,25 @@
             static void init(shared_mutex_type& mtx)
             {
-                hel::fibril_rwlock_initialize(&mtx);
+                ::helenos::fibril_rwlock_initialize(&mtx);
             }
 
             static void lock(shared_mutex_type& mtx)
             {
-                hel::fibril_rwlock_write_lock(&mtx);
+                ::helenos::fibril_rwlock_write_lock(&mtx);
             }
 
             static void unlock(shared_mutex_type& mtx)
             {
-                hel::fibril_rwlock_write_unlock(&mtx);
+                ::helenos::fibril_rwlock_write_unlock(&mtx);
             }
 
             static void lock_shared(shared_mutex_type& mtx)
             {
-                hel::fibril_rwlock_read_lock(&mtx);
+                ::helenos::fibril_rwlock_read_lock(&mtx);
             }
 
             static void unlock_shared(shared_mutex_type& mtx)
             {
-                hel::fibril_rwlock_read_unlock(&mtx);
+                ::helenos::fibril_rwlock_read_unlock(&mtx);
             }
 
Index: uspace/lib/cpp/include/cassert
===================================================================
--- uspace/lib/cpp/include/cassert	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cassert	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,14 +30,5 @@
 #define LIBCPP_CASSERT
 
-
-extern "C" {
-    #include <assert.h>
-}
-
-// TODO: For some reason, this function isn't visible (maybe the
-//       noreturn attribute?), adding a redeclaration here for the
-//       time being.
-
-extern void __helenos_assert_abort(const char *, const char *, unsigned int);
+#include <assert.h>
 
 #define __unimplemented() assert(!"Not implemented!")
Index: uspace/lib/cpp/include/cctype
===================================================================
--- uspace/lib/cpp/include/cctype	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cctype	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,28 +30,22 @@
 #define LIBCPP_CCTYPE
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <ctype.h>
-    }
-}
+#include <ctype.h>
 
 namespace std
 {
-    using std::hel::isalnum;
-    using std::hel::isalpha;
-    using std::hel::islower;
-    using std::hel::isupper;
-    using std::hel::isdigit;
-    /* using std::hel::isxdigit; */
-    /* using std::hel::iscntrl; */
-    /* using std::hel::isgraph; */
-    using std::hel::isspace;
-    /* using std::hel::isblank; */
-    /* using std::hel::isprint; */
-    /* using std::hel::ispunct; */
-    using std::hel::tolower;
-    using std::hel::toupper;
+    using ::isalnum;
+    using ::isalpha;
+    using ::islower;
+    using ::isupper;
+    using ::isdigit;
+    using ::isxdigit;
+    using ::iscntrl;
+    using ::isgraph;
+    using ::isspace;
+    using ::isblank;
+    using ::isprint;
+    using ::ispunct;
+    using ::tolower;
+    using ::toupper;
 }
 
Index: uspace/lib/cpp/include/cerrno
===================================================================
--- uspace/lib/cpp/include/cerrno	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cerrno	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,16 +30,5 @@
 #define LIBCPP_CERRNO
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <errno.h>
-    }
-}
-
-namespace std
-{
-    // Note: Only macros are imported here.
-}
+#include <errno.h>
 
 #endif
Index: uspace/lib/cpp/include/cinttypes
===================================================================
--- uspace/lib/cpp/include/cinttypes	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cinttypes	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,36 +30,17 @@
 #define LIBCPP_CINTTYPES
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <inttypes.h>
-    }
-}
+#include <cstdint>
+#include <inttypes.h>
 
 namespace std
 {
-    using std::hel::imaxdiv_t;
-    /* using std::hel::abs; */
-    /* using std::hel::div; */
-    /* using std::hel::imaxabs; */
-    /* using std::hel::imaxdiv; */
-    /* using std::hel::strtoimax; */
-    /* using std::hel::strtoumax; */
-    /* using std::hel::wcstoimax; */
-    /* using std::hel::wcstoumax; */
+    using ::imaxdiv_t;
+    using ::imaxabs;
+    using ::imaxdiv;
+    using ::strtoimax;
+    using ::strtoumax;
+    using ::wcstoimax;
+    using ::wcstoumax;
 }
 
-using std::hel::imaxdiv_t;
-/* using std::hel::abs; */
-/* using std::hel::div; */
-/* using std::hel::imaxabs; */
-/* using std::hel::imaxdiv; */
-/* using std::hel::strtoimax; */
-/* using std::hel::strtoumax; */
-/* using std::hel::wcstoimax; */
-/* using std::hel::wcstoumax; */
-
-#include <cstdint>
-
 #endif
Index: uspace/lib/cpp/include/climits
===================================================================
--- uspace/lib/cpp/include/climits	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/climits	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,16 +30,5 @@
 #define LIBCPP_CLIMITS
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <limits.h>
-    }
-}
-
-namespace std
-{
-    // Note: Only macros imported here.
-}
+#include <limits.h>
 
 #endif
Index: uspace/lib/cpp/include/csetjmp
===================================================================
--- uspace/lib/cpp/include/csetjmp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/csetjmp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,25 +30,11 @@
 #define LIBCPP_CSETJMP
 
-
-/**
- * TODO: Currently the <setjmp.h> header uses
- *       _Noreturn, which is not available in C++.
- */
-
-namespace std::hel
-{
-    extern "C" {
-        //#include <setjmp.h>
-    }
-}
+#include <setjmp.h>
 
 namespace std
 {
-    /* using std::hel::jmp_buf; */
-    /* using std::hel::longjmp; */
+    using ::jmp_buf;
+    using ::longjmp;
 }
 
-/* using std::hel::jmp_buf; */
-/* using std::hel::longjmp; */
-
 #endif
Index: uspace/lib/cpp/include/cstdarg
===================================================================
--- uspace/lib/cpp/include/cstdarg	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cstdarg	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,18 +30,10 @@
 #define LIBCPP_CSTDARG
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <stdarg.h>
-    }
-}
+#include <stdarg.h>
 
 namespace std
 {
-    using std::hel::va_list;
+    using ::va_list;
 }
 
-using std::hel::va_list;
-
 #endif
Index: uspace/lib/cpp/include/cstddef
===================================================================
--- uspace/lib/cpp/include/cstddef	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cstddef	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,26 +30,13 @@
 #define LIBCPP_CSTDDEF
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <stddef.h>
-    }
-}
-
+#include <stddef.h>
 
 namespace std
 {
-    using nullptr_t = decltype(nullptr);
-
-    using std::hel::size_t;
-    using std::hel::ptrdiff_t;
-    /* using std::hel::max_align_t; */
+    using ::nullptr_t;
+    using ::size_t;
+    using ::ptrdiff_t;
+    using ::max_align_t;
 }
 
-using std::nullptr_t;
-using std::hel::size_t;
-using std::hel::ptrdiff_t;
-/* using std::hel::max_align_t; */
-
 #endif
Index: uspace/lib/cpp/include/cstdint
===================================================================
--- uspace/lib/cpp/include/cstdint	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cstdint	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,86 +30,44 @@
 #define LIBCPP_CSTDINT
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <stdint.h>
-    }
-}
+#include <stdint.h>
 
 namespace std
 {
-    using int8_t  = std::hel::int8_t;
-    using int16_t = std::hel::int16_t;
-    using int32_t = std::hel::int32_t;
-    using int64_t = std::hel::int64_t;
+    using ::int8_t;
+    using ::int16_t;
+    using ::int32_t;
+    using ::int64_t;
 
-    using intmax_t = std::hel::intmax_t;
-    using intptr_t = std::hel::intptr_t;
+    using ::intmax_t;
+    using ::intptr_t;
 
-    using int_fast8_t  = std::hel::int_fast8_t;
-    using int_fast16_t = std::hel::int_fast16_t;
-    using int_fast32_t = std::hel::int_fast32_t;
-    using int_fast64_t = std::hel::int_fast64_t;
+    using ::int_fast8_t;
+    using ::int_fast16_t;
+    using ::int_fast32_t;
+    using ::int_fast64_t;
 
-    using int_least8_t  = std::hel::int_least8_t;
-    using int_least16_t = std::hel::int_least16_t;
-    using int_least32_t = std::hel::int_least32_t;
-    using int_least64_t = std::hel::int_least64_t;
+    using ::int_least8_t;
+    using ::int_least16_t;
+    using ::int_least32_t;
+    using ::int_least64_t;
 
-    using uint8_t  = std::hel::uint8_t;
-    using uint16_t = std::hel::uint16_t;
-    using uint32_t = std::hel::uint32_t;
-    using uint64_t = std::hel::uint64_t;
+    using ::uint8_t;
+    using ::uint16_t;
+    using ::uint32_t;
+    using ::uint64_t;
 
-    using uintmax_t = std::hel::uintmax_t;
-    using uintptr_t = std::hel::uintptr_t;
+    using ::uintmax_t;
+    using ::uintptr_t;
 
-    using uint_fast8_t  = std::hel::uint_fast8_t;
-    using uint_fast16_t = std::hel::uint_fast16_t;
-    using uint_fast32_t = std::hel::uint_fast32_t;
-    using uint_fast64_t = std::hel::uint_fast64_t;
+    using ::uint_fast8_t;
+    using ::uint_fast16_t;
+    using ::uint_fast32_t;
+    using ::uint_fast64_t;
 
-    using uint_least8_t  = std::hel::uint_least8_t;
-    using uint_least16_t = std::hel::uint_least16_t;
-    using uint_least32_t = std::hel::uint_least32_t;
-    using uint_least64_t = std::hel::uint_least64_t;
+    using ::uint_least8_t;
+    using ::uint_least16_t;
+    using ::uint_least32_t;
+    using ::uint_least64_t;
 }
 
-using int8_t  = std::hel::int8_t;
-using int16_t = std::hel::int16_t;
-using int32_t = std::hel::int32_t;
-using int64_t = std::hel::int64_t;
-
-using intmax_t = std::hel::intmax_t;
-using intptr_t = std::hel::intptr_t;
-
-using int_fast8_t  = std::hel::int_fast8_t;
-using int_fast16_t = std::hel::int_fast16_t;
-using int_fast32_t = std::hel::int_fast32_t;
-using int_fast64_t = std::hel::int_fast64_t;
-
-using int_least8_t  = std::hel::int_least8_t;
-using int_least16_t = std::hel::int_least16_t;
-using int_least32_t = std::hel::int_least32_t;
-using int_least64_t = std::hel::int_least64_t;
-
-using uint8_t  = std::hel::uint8_t;
-using uint16_t = std::hel::uint16_t;
-using uint32_t = std::hel::uint32_t;
-using uint64_t = std::hel::uint64_t;
-
-using uintmax_t = std::hel::uintmax_t;
-using uintptr_t = std::hel::uintptr_t;
-
-using uint_fast8_t  = std::hel::uint_fast8_t;
-using uint_fast16_t = std::hel::uint_fast16_t;
-using uint_fast32_t = std::hel::uint_fast32_t;
-using uint_fast64_t = std::hel::uint_fast64_t;
-
-using uint_least8_t  = std::hel::uint_least8_t;
-using uint_least16_t = std::hel::uint_least16_t;
-using uint_least32_t = std::hel::uint_least32_t;
-using uint_least64_t = std::hel::uint_least64_t;
-
 #endif
Index: uspace/lib/cpp/include/cstdio
===================================================================
--- uspace/lib/cpp/include/cstdio	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cstdio	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,115 +30,60 @@
 #define LIBCPP_CSTDIO
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <stdio.h>
-    }
-}
+#include <stdio.h>
 
 namespace std
 {
-    using std::hel::FILE;
-    using std::hel::stdin;
-    using std::hel::stdout;
-    using std::hel::stderr;
-    /* using std::hel::fpos_t */
-    using std::hel::size_t;
+    using ::FILE;
+    using ::stdin;
+    using ::stdout;
+    using ::stderr;
+    using ::fpos_t;
+    using ::size_t;
 
-    using std::hel::clearerr;
-    using std::hel::fclose;
-    using std::hel::feof;
-    using std::hel::ferror;
-    using std::hel::fflush;
-    using std::hel::fgetc;
-    /* using std::hel::fgetpos; */
-    using std::hel::fgets;
-    using std::hel::fopen;
-    using std::hel::fprintf;
-    using std::hel::fputc;
-    using std::hel::fputs;
-    using std::hel::fread;
-    using std::hel::freopen;
-    /* using std::hel::fscanf; */
-    using std::hel::fseek;
-    /* using std::hel::fsetpos; */
-    using std::hel::ftell;
-    using std::hel::fwrite;
-    /* using std::hel::getc; */
-    using std::hel::getchar;
-    /* using std::hel::perror; */
-    using std::hel::printf;
-    /* using std::hel::putc; */
-    using std::hel::putchar;
-    using std::hel::puts;
-    using std::hel::remove;
-    using std::hel::rename;
-    using std::hel::rewind;
-    /* using std::hel::scanf; */
-    using std::hel::setbuf;
-    using std::hel::setvbuf;
-    using std::hel::snprintf;
-    /* using std::hel::sprintf; */
-    /* using std::hel::sscanf; */
-    /* using std::hel::tmpfile; */
-    /* using std::hel::tmpnam; */
-    using std::hel::ungetc;
-    using std::hel::vfprintf;
-    using std::hel::vprintf;
-    /* using std::hel::vscanf; */
-    using std::hel::vsnprintf;
-    /* using std::hel::vsprintf; */
-    /* using std::hel::vsscanf; */
+    using ::clearerr;
+    using ::fclose;
+    using ::feof;
+    using ::ferror;
+    using ::fflush;
+    using ::fgetc;
+    using ::fgetpos;
+    using ::fgets;
+    using ::fopen;
+    using ::fprintf;
+    using ::fputc;
+    using ::fputs;
+    using ::fread;
+    using ::freopen;
+    using ::fscanf;
+    using ::fseek;
+    using ::fsetpos;
+    using ::ftell;
+    using ::fwrite;
+    using ::getc;
+    using ::getchar;
+    using ::perror;
+    using ::printf;
+    using ::putc;
+    using ::putchar;
+    using ::puts;
+    using ::remove;
+    using ::rename;
+    using ::rewind;
+    using ::scanf;
+    using ::setbuf;
+    using ::setvbuf;
+    using ::snprintf;
+    /* using ::sprintf; */
+    /* using ::sscanf; */
+    /* using ::tmpfile; */
+    /* using ::tmpnam; */
+    using ::ungetc;
+    using ::vfprintf;
+    using ::vprintf;
+    /* using ::vscanf; */
+    using ::vsnprintf;
+    /* using ::vsprintf; */
+    /* using ::vsscanf; */
 }
 
-using std::hel::FILE;
-/* using std::hel::fpos_t */
-using std::hel::size_t;
-
-using std::hel::clearerr;
-using std::hel::fclose;
-using std::hel::feof;
-using std::hel::ferror;
-using std::hel::fflush;
-using std::hel::fgetc;
-/* using std::hel::fgetpos; */
-using std::hel::fgets;
-using std::hel::fopen;
-using std::hel::fprintf;
-using std::hel::fputc;
-using std::hel::fputs;
-using std::hel::fread;
-using std::hel::freopen;
-/* using std::hel::fscanf; */
-using std::hel::fseek;
-/* using std::hel::fsetpos; */
-using std::hel::ftell;
-using std::hel::fwrite;
-/* using std::hel::getc; */
-using std::hel::getchar;
-/* using std::hel::perror; */
-using std::hel::printf;
-/* using std::hel::putc; */
-using std::hel::putchar;
-using std::hel::puts;
-using std::hel::remove;
-using std::hel::rename;
-using std::hel::rewind;
-/* using std::hel::scanf; */
-using std::hel::setbuf;
-using std::hel::setvbuf;
-using std::hel::snprintf;
-/* using std::hel::sprintf; */
-/* using std::hel::sscanf; */
-/* using std::hel::tmpfile; */
-/* using std::hel::tmpnam; */
-using std::hel::ungetc;
-using std::hel::vfprintf;
-using std::hel::vprintf;
-/* using std::hel::vscanf; */
-using std::hel::vsnprintf;
-/* using std::hel::vsprintf; */
-/* using std::hel::vsscanf; */
-
 #endif
Index: uspace/lib/cpp/include/cstdlib
===================================================================
--- uspace/lib/cpp/include/cstdlib	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cstdlib	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,111 +30,57 @@
 #define LIBCPP_CSTDLIB
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <stdlib.h>
-        #include <_bits/ssize_t.h>
-    }
-}
+#include <stdlib.h>
+#include <_bits/ssize_t.h>
 
 namespace std
 {
-    /* using std::hel::div_t; */
-    /* using std::hel::ldiv_t; */
-    /* using std::hel::lldiv_t; */
-    using std::hel::size_t;
+    /* using ::div_t; */
+    /* using ::ldiv_t; */
+    /* using ::lldiv_t; */
+    using ::size_t;
 
-    using std::hel::abort;
-    using std::hel::exit;
-    /* using std::hel::quick_exit; */
-    /* using std::hel::_Exit; */
-    using std::hel::atexit;
-    /* using std::hel::at_quick_exit; */
-    /* using std::hel::system; */
-    /* using std::hel::getenv; */
+    using ::abort;
+    using ::exit;
+    /* using ::quick_exit; */
+    /* using ::_Exit; */
+    using ::atexit;
+    /* using ::at_quick_exit; */
+    /* using ::system; */
+    /* using ::getenv; */
 
-    using std::hel::malloc;
-    using std::hel::calloc;
-    using std::hel::realloc;
-    using std::hel::free;
+    using ::malloc;
+    using ::calloc;
+    using ::realloc;
+    using ::free;
 
-    /* using std::hel::atof; */
-    /* using std::hel::atoi; */
-    /* using std::hel::atol; */
-    /* using std::hel::atoll; */
-    /* using std::hel::strtol; */
-    /* using std::hel::strtoll; */
-    /* using std::hel::strtoul; */
-    /* using std::hel::strtoull; */
-    /* using std::hel::strtof; */
-    /* using std::hel::strtod; */
-    /* using std::hel::strtold; */
+    /* using ::atof; */
+    /* using ::atoi; */
+    /* using ::atol; */
+    /* using ::atoll; */
+    /* using ::strtol; */
+    /* using ::strtoll; */
+    /* using ::strtoul; */
+    /* using ::strtoull; */
+    /* using ::strtof; */
+    /* using ::strtod; */
+    /* using ::strtold; */
 
-    /* using std::hel::mblen; */
-    /* using std::hel::mbtowc; */
-    /* using std::hel::wctomb; */
-    /* using std::hel::mbstowcs; */
-    /* using std::hel::wcstombs; */
+    /* using ::mblen; */
+    /* using ::mbtowc; */
+    /* using ::wctomb; */
+    /* using ::mbstowcs; */
+    /* using ::wcstombs; */
 
-    using std::hel::rand;
-    using std::hel::srand;
-    using std::hel::qsort;
-    /* using std::hel::bsearch; */
-    /* using std::hel::abs; */
-    /* using std::hel::labs; */
-    /* using std::hel::llabs; */
-    /* using std::hel::div; */
-    /* using std::hel::ldiv; */
-    /* using std::hel::lldiv; */
+    using ::rand;
+    using ::srand;
+    using ::qsort;
+    /* using ::bsearch; */
+    /* using ::abs; */
+    /* using ::labs; */
+    /* using ::llabs; */
+    /* using ::div; */
+    /* using ::ldiv; */
+    /* using ::lldiv; */
 }
 
-/* using std::hel::div_t; */
-/* using std::hel::ldiv_t; */
-/* using std::hel::lldiv_t; */
-using std::hel::size_t;
-
-using std::hel::abort;
-using std::hel::exit;
-/* using std::hel::quick_exit; */
-/* using std::hel::_Exit; */
-using std::hel::atexit;
-/* using std::hel::at_quick_exit; */
-/* using std::hel::system; */
-/* using std::hel::getenv; */
-
-using std::hel::malloc;
-using std::hel::calloc;
-using std::hel::realloc;
-using std::hel::free;
-
-/* using std::hel::atof; */
-/* using std::hel::atoi; */
-/* using std::hel::atol; */
-/* using std::hel::atoll; */
-/* using std::hel::strtol; */
-/* using std::hel::strtoll; */
-/* using std::hel::strtoul; */
-/* using std::hel::strtoull; */
-/* using std::hel::strtof; */
-/* using std::hel::strtod; */
-/* using std::hel::strtold; */
-
-/* using std::hel::mblen; */
-/* using std::hel::mbtowc; */
-/* using std::hel::wctomb; */
-/* using std::hel::mbstowcs; */
-/* using std::hel::wcstombs; */
-
-using std::hel::rand;
-using std::hel::srand;
-using std::hel::qsort;
-/* using std::hel::bsearch; */
-/* using std::hel::abs; */
-/* using std::hel::labs; */
-/* using std::hel::llabs; */
-/* using std::hel::div; */
-/* using std::hel::ldiv; */
-/* using std::hel::lldiv; */
-
 #endif
Index: uspace/lib/cpp/include/cstring
===================================================================
--- uspace/lib/cpp/include/cstring	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cstring	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,70 +30,37 @@
 #define LIBCPP_CSTRING
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <str.h>
-    }
-}
+#define _REALLY_WANT_STRING_H
+#include <string.h>
 
 namespace std
 {
-    using std::hel::size_t;
+    using ::size_t;
 
-    /* using std::hel::strcpy; */
-    /* using std::hel::strncpy; */
-    /* using std::hel::strcat; */
-    /* using std::hel::strncat; */
-    /* using std::hel::strxfrm; */
+    using ::strcpy;
+    using ::strncpy;
+    using ::strcat;
+    using ::strncat;
+    using ::strxfrm;
 
-    /* using std::hel::strlen; */
-    /* using std::hel::strcmp; */
-    /* using std::hel::strncmp; */
-    /* using std::hel::strcoll; */
-    /* using std::hel::strchr; */
-    /* using std::hel::strrchr; */
-    /* using std::hel::strspn; */
-    /* using std::hel::strcspn; */
-    /* using std::hel::strpbrk; */
-    /* using std::hel::strstr; */
-    /* using std::hel::strok; */
+    using ::strlen;
+    using ::strcmp;
+    using ::strncmp;
+    using ::strcoll;
+    using ::strchr;
+    using ::strrchr;
+    using ::strspn;
+    using ::strcspn;
+    using ::strpbrk;
+    using ::strstr;
+    using ::strtok;
 
-    /* using std::hel::memchr; */
-    using std::hel::memcmp;
-    using std::hel::memset;
-    using std::hel::memcpy;
-    using std::hel::memmove;
+    using ::memchr;
+    using ::memcmp;
+    using ::memset;
+    using ::memcpy;
+    using ::memmove;
 
-    /* using std::hel::strerror; */
+    using ::strerror;
 }
 
-using std::hel::size_t;
-
-/* using std::hel::strcpy; */
-/* using std::hel::strncpy; */
-/* using std::hel::strcat; */
-/* using std::hel::strncat; */
-/* using std::hel::strxfrm; */
-
-/* using std::hel::strlen; */
-/* using std::hel::strcmp; */
-/* using std::hel::strncmp; */
-/* using std::hel::strcoll; */
-/* using std::hel::strchr; */
-/* using std::hel::strrchr; */
-/* using std::hel::strspn; */
-/* using std::hel::strcspn; */
-/* using std::hel::strpbrk; */
-/* using std::hel::strstr; */
-/* using std::hel::strok; */
-
-/* using std::hel::memchr; */
-using std::hel::memcmp;
-using std::hel::memset;
-using std::hel::memcpy;
-using std::hel::memmove;
-
-/* using std::hel::strerror; */
-
 #endif
Index: uspace/lib/cpp/include/ctime
===================================================================
--- uspace/lib/cpp/include/ctime	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/ctime	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,50 +30,26 @@
 #define LIBCPP_CTIME
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <time.h>
-    }
-}
+#include <time.h>
 
 namespace std
 {
-    /* using std::hel::clock_t; */
-    using std::hel::size_t;
-    using std::hel::time_t;
-    using std::hel::tm;
-    /* using std::hel::timespec; */
+    using ::clock_t;
+    using ::size_t;
+    using ::time_t;
+    using ::tm;
+    using ::timespec;
 
-    /* using std::hel::clock; */
-    using std::hel::time;
-    using std::hel::difftime;
+    using ::clock;
+    using ::time;
+    using ::difftime;
 
-    /* using std::hel::ctime; */
-    /* using std::hel::asctime; */
-    using std::hel::strftime;
-    /* using std::hel::wcsftime; */
-    /* using std::hel::gmtime; */
-    /* using std::hel::localtime; */
-    using std::hel::mktime;
+    using ::ctime;
+    using ::asctime;
+    using ::strftime;
+    /* using ::wcsftime; */
+    /* using ::gmtime; */
+    /* using ::localtime; */
+    using ::mktime;
 }
 
-/* using std::hel::clock_t; */
-using std::hel::size_t;
-using std::hel::time_t;
-using std::hel::tm;
-/* using std::hel::timespec; */
-
-/* using std::hel::clock; */
-using std::hel::time;
-using std::hel::difftime;
-
-/* using std::hel::ctime; */
-/* using std::hel::asctime; */
-using std::hel::strftime;
-/* using std::hel::wcsftime; */
-/* using std::hel::gmtime; */
-/* using std::hel::localtime; */
-using std::hel::mktime;
-
 #endif
Index: uspace/lib/cpp/include/cwchar
===================================================================
--- uspace/lib/cpp/include/cwchar	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/include/cwchar	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -30,149 +30,76 @@
 #define LIBCPP_WCHAR
 
-
-namespace std::hel
-{
-    extern "C" {
-        #include <wchar.h>
-        #include <time.h>
-    }
-}
+#include <wchar.h>
+#include <time.h>
 
 namespace std
 {
-    /* using std::hel::mbstate_t; */
-    using std::hel::size_t;
-    using std::hel::wint_t;
-    using std::hel::tm;
+    /* using ::mbstate_t; */
+    using ::size_t;
+    using ::wint_t;
+    using ::tm;
 
-    /* using std::hel::wcscpy; */
-    /* using std::hel::wcsncpy; */
-    /* using std::hel::wcscat; */
-    /* using std::hel::wcsncat; */
-    /* using std::hel::wcsnxfrm; */
+    /* using ::wcscpy; */
+    /* using ::wcsncpy; */
+    /* using ::wcscat; */
+    /* using ::wcsncat; */
+    /* using ::wcsnxfrm; */
 
-    /* using std::hel::wcslen; */
-    /* using std::hel::wcscmp; */
-    /* using std::hel::wcsncmp; */
-    /* using std::hel::wcscoll; */
-    /* using std::hel::wcschr; */
-    /* using std::hel::wcsrchr; */
-    /* using std::hel::wcsspn; */
-    /* using std::hel::wcscspn; */
-    /* using std::hel::wcspbrk; */
-    /* using std::hel::wcsstr; */
-    /* using std::hel::wcstok; */
+    /* using ::wcslen; */
+    /* using ::wcscmp; */
+    /* using ::wcsncmp; */
+    /* using ::wcscoll; */
+    /* using ::wcschr; */
+    /* using ::wcsrchr; */
+    /* using ::wcsspn; */
+    /* using ::wcscspn; */
+    /* using ::wcspbrk; */
+    /* using ::wcsstr; */
+    /* using ::wcstok; */
 
-    /* using std::hel::wmemcpy; */
-    /* using std::hel::wmemmove; */
-    /* using std::hel::wmemcmp; */
-    /* using std::hel::wmemchr; */
-    /* using std::hel::wmemset; */
+    /* using ::wmemcpy; */
+    /* using ::wmemmove; */
+    /* using ::wmemcmp; */
+    /* using ::wmemchr; */
+    /* using ::wmemset; */
 
-    /* using std::hel::msbinit; */
-    /* using std::hel::btowc; */
-    /* using std::hel::wctob; */
-    /* using std::hel::mbrlen; */
-    /* using std::hel::mbrtowc; */
-    /* using std::hel::wctomb; */
-    /* using std::hel::mbsrtowcs; */
-    /* using std::hel::wcsrtombs; */
+    /* using ::msbinit; */
+    /* using ::btowc; */
+    /* using ::wctob; */
+    /* using ::mbrlen; */
+    /* using ::mbrtowc; */
+    /* using ::wctomb; */
+    /* using ::mbsrtowcs; */
+    /* using ::wcsrtombs; */
 
-    /* using std::hel::fgetwc; */
-    /* using std::hel::getwc; */
-    /* using std::hel::fgetws; */
-    /* using std::hel::fputwc; */
-    /* using std::hel::putwc; */
-    /* using std::hel::fputws; */
-    /* using std::hel::getwchar; */
-    /* using std::hel::putwchar; */
-    /* using std::hel::ungetwc; */
-    /* using std::hel::fwide; */
-    /* using std::hel::wscanf; */
-    /* using std::hel::fwscanf; */
-    /* using std::hel::swscanf; */
-    /* using std::hel::vwscanf; */
-    /* using std::hel::vfwscanf; */
-    /* using std::hel::vswscanf; */
-    /* using std::hel::wprintf; */
-    /* using std::hel::fwprintf; */
-    /* using std::hel::swprintf; */
+    /* using ::fgetwc; */
+    /* using ::getwc; */
+    /* using ::fgetws; */
+    /* using ::fputwc; */
+    /* using ::putwc; */
+    /* using ::fputws; */
+    /* using ::getwchar; */
+    /* using ::putwchar; */
+    /* using ::ungetwc; */
+    /* using ::fwide; */
+    /* using ::wscanf; */
+    /* using ::fwscanf; */
+    /* using ::swscanf; */
+    /* using ::vwscanf; */
+    /* using ::vfwscanf; */
+    /* using ::vswscanf; */
+    /* using ::wprintf; */
+    /* using ::fwprintf; */
+    /* using ::swprintf; */
 
-    /* using std::hel::wcsftime; */
-    /* using std::hel::wcstol; */
-    /* using std::hel::wcstoll; */
-    /* using std::hel::wcstoul; */
-    /* using std::hel::wcstoull; */
-    /* using std::hel::wcstof; */
-    /* using std::hel::wcstod; */
-    /* using std::hel::wcstold; */
+    /* using ::wcsftime; */
+    /* using ::wcstol; */
+    /* using ::wcstoll; */
+    /* using ::wcstoul; */
+    /* using ::wcstoull; */
+    /* using ::wcstof; */
+    /* using ::wcstod; */
+    /* using ::wcstold; */
 }
 
-/* using std::hel::mbstate_t; */
-using std::hel::size_t;
-using std::hel::wint_t;
-using std::hel::tm;
-
-/* using std::hel::wcscpy; */
-/* using std::hel::wcsncpy; */
-/* using std::hel::wcscat; */
-/* using std::hel::wcsncat; */
-/* using std::hel::wcsnxfrm; */
-
-/* using std::hel::wcslen; */
-/* using std::hel::wcscmp; */
-/* using std::hel::wcsncmp; */
-/* using std::hel::wcscoll; */
-/* using std::hel::wcschr; */
-/* using std::hel::wcsrchr; */
-/* using std::hel::wcsspn; */
-/* using std::hel::wcscspn; */
-/* using std::hel::wcspbrk; */
-/* using std::hel::wcsstr; */
-/* using std::hel::wcstok; */
-
-/* using std::hel::wmemcpy; */
-/* using std::hel::wmemmove; */
-/* using std::hel::wmemcmp; */
-/* using std::hel::wmemchr; */
-/* using std::hel::wmemset; */
-
-/* using std::hel::msbinit; */
-/* using std::hel::btowc; */
-/* using std::hel::wctob; */
-/* using std::hel::mbrlen; */
-/* using std::hel::mbrtowc; */
-/* using std::hel::wctomb; */
-/* using std::hel::mbsrtowcs; */
-/* using std::hel::wcsrtombs; */
-
-/* using std::hel::fgetwc; */
-/* using std::hel::getwc; */
-/* using std::hel::fgetws; */
-/* using std::hel::fputwc; */
-/* using std::hel::putwc; */
-/* using std::hel::fputws; */
-/* using std::hel::getwchar; */
-/* using std::hel::putwchar; */
-/* using std::hel::ungetwc; */
-/* using std::hel::fwide; */
-/* using std::hel::wscanf; */
-/* using std::hel::fwscanf; */
-/* using std::hel::swscanf; */
-/* using std::hel::vwscanf; */
-/* using std::hel::vfwscanf; */
-/* using std::hel::vswscanf; */
-/* using std::hel::wprintf; */
-/* using std::hel::fwprintf; */
-/* using std::hel::swprintf; */
-
-/* using std::hel::wcsftime; */
-/* using std::hel::wcstol; */
-/* using std::hel::wcstoll; */
-/* using std::hel::wcstoul; */
-/* using std::hel::wcstoull; */
-/* using std::hel::wcstof; */
-/* using std::hel::wcstod; */
-/* using std::hel::wcstold; */
-
 #endif
Index: uspace/lib/cpp/src/stdexcept.cpp
===================================================================
--- uspace/lib/cpp/src/stdexcept.cpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/src/stdexcept.cpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -31,17 +31,18 @@
 #include <stdexcept>
 #include <string>
+#include <str.h>
 
 namespace std
 {
     logic_error::logic_error(const string& what)
-        : what_{hel::str_dup(what.c_str())}
+        : what_{::helenos::str_dup(what.c_str())}
     { /* DUMMY BODY */ }
 
     logic_error::logic_error(const char* what)
-        : what_{hel::str_dup(what)}
+        : what_{::helenos::str_dup(what)}
     { /* DUMMY BODY */ }
 
     logic_error::logic_error(const logic_error& other) noexcept
-        : exception{other}, what_{hel::str_dup(other.what_)}
+        : exception{other}, what_{::helenos::str_dup(other.what_)}
     { /* DUMMY BODY */ }
 
@@ -50,5 +51,5 @@
         if (what_)
             free(what_);
-        what_ = hel::str_dup(other.what_);
+        what_ = ::helenos::str_dup(other.what_);
 
         return *this;
@@ -114,13 +115,13 @@
 
     runtime_error::runtime_error(const string& what)
-        : what_{hel::str_dup(what.c_str())}
+        : what_{::helenos::str_dup(what.c_str())}
     { /* DUMMY BODY */ }
 
     runtime_error::runtime_error(const char* what)
-        : what_{hel::str_dup(what)}
+        : what_{::helenos::str_dup(what)}
     { /* DUMMY BODY */ }
 
     runtime_error::runtime_error(const runtime_error& other) noexcept
-        : exception{other}, what_{hel::str_dup(other.what_)}
+        : exception{other}, what_{::helenos::str_dup(other.what_)}
     { /* DUMMY BODY */ }
 
@@ -129,5 +130,5 @@
         if (what_)
             free(what_);
-        what_ = hel::str_dup(other.what_);
+        what_ = ::helenos::str_dup(other.what_);
 
         return *this;
Index: uspace/lib/cpp/src/string.cpp
===================================================================
--- uspace/lib/cpp/src/string.cpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/src/string.cpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -42,5 +42,5 @@
     {
         char* end;
-        long result = hel::strtol(str.c_str(), &end, base);
+        long result = ::strtol(str.c_str(), &end, base);
 
         if (end != str.c_str())
@@ -58,5 +58,5 @@
     {
         char* end;
-        unsigned long result = hel::strtoul(str.c_str(), &end, base);
+        unsigned long result = ::strtoul(str.c_str(), &end, base);
 
         if (end != str.c_str())
@@ -106,13 +106,8 @@
     }
 
-    namespace hel
-    {
-        extern "C" int asprintf(char**, const char*, ...);
-    }
-
     string to_string(int val)
     {
         char* tmp;
-        hel::asprintf(&tmp, "%d", val);
+        ::asprintf(&tmp, "%d", val);
 
         std::string res{tmp};
@@ -125,5 +120,5 @@
     {
         char* tmp;
-        hel::asprintf(&tmp, "%u", val);
+        ::asprintf(&tmp, "%u", val);
 
         std::string res{tmp};
@@ -136,5 +131,5 @@
     {
         char* tmp;
-        hel::asprintf(&tmp, "%ld", val);
+        ::asprintf(&tmp, "%ld", val);
 
         std::string res{tmp};
@@ -147,5 +142,5 @@
     {
         char* tmp;
-        hel::asprintf(&tmp, "%lu", val);
+        ::asprintf(&tmp, "%lu", val);
 
         std::string res{tmp};
@@ -158,5 +153,5 @@
     {
         char* tmp;
-        hel::asprintf(&tmp, "%lld", val);
+        ::asprintf(&tmp, "%lld", val);
 
         std::string res{tmp};
@@ -169,5 +164,5 @@
     {
         char* tmp;
-        hel::asprintf(&tmp, "%llu", val);
+        ::asprintf(&tmp, "%llu", val);
 
         std::string res{tmp};
@@ -180,5 +175,5 @@
     {
         char* tmp;
-        hel::asprintf(&tmp, "%f", val);
+        ::asprintf(&tmp, "%f", val);
 
         std::string res{tmp};
@@ -191,5 +186,5 @@
     {
         char* tmp;
-        hel::asprintf(&tmp, "%f", val);
+        ::asprintf(&tmp, "%f", val);
 
         std::string res{tmp};
@@ -202,5 +197,5 @@
     {
         char* tmp;
-        hel::asprintf(&tmp, "%Lf", val);
+        ::asprintf(&tmp, "%Lf", val);
 
         std::string res{tmp};
Index: uspace/lib/cpp/src/typeinfo.cpp
===================================================================
--- uspace/lib/cpp/src/typeinfo.cpp	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/cpp/src/typeinfo.cpp	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -38,6 +38,5 @@
     bool type_info::operator==(const type_info& other) const noexcept
     {
-        return (this == &other) ||
-               std::hel::str_cmp(name(), other.name());
+        return (this == &other) || ::strcmp(name(), other.name()) == 0;
     }
 
Index: uspace/lib/crypto/crypto.c
===================================================================
--- uspace/lib/crypto/crypto.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/crypto/crypto.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -32,8 +32,10 @@
  */
 
+#include <assert.h>
 #include <str.h>
 #include <macros.h>
 #include <errno.h>
 #include <byteorder.h>
+#include <limits.h>
 #include "crypto.h"
 
@@ -197,4 +199,6 @@
     hash_func_t hash_sel)
 {
+	assert(input_size < SSIZE_MAX);
+
 	if (!input)
 		return EINVAL;
Index: uspace/lib/pcm/src/format.c
===================================================================
--- uspace/lib/pcm/src/format.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/pcm/src/format.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -40,4 +40,5 @@
 #include <stdio.h>
 #include <inttypes.h>
+#include <limits.h>
 
 #include "format.h"
Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/Makefile	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -41,11 +41,9 @@
 	../hound/libhound.a \
 	../pcm/libpcm.a \
+	../cpp/libcpp.a \
 	$(LIBC_PREFIX)/libc.a \
 	$(LIBC_PREFIX)/crt0.o \
 	$(LIBC_PREFIX)/crt1.o \
 	$(LIBRARY).a
-
-PRE_DEPEND = $(INCLUDE_LIBC)
-EXTRA_CLEAN = $(INCLUDE_LIBC)
 
 SOURCES = \
@@ -96,4 +94,7 @@
 	$(COMMON_CFLAGS)
 
+EXPORT_CXXFLAGS = \
+	$(COMMON_CXXFLAGS)
+
 include $(USPACE_PREFIX)/Makefile.common
 
@@ -109,5 +110,5 @@
 	echo 'HELENOS_CPPFLAGS="$(EXPORT_CPPFLAGS)"' >> $@.new
 	echo 'HELENOS_CFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
-	echo 'HELENOS_CXXFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
+	echo 'HELENOS_CXXFLAGS="$(EXPORT_CXXFLAGS)"' >> $@.new
 	echo 'HELENOS_LDFLAGS="$(EXPORT_LDFLAGS)"' >> $@.new
 	echo 'HELENOS_LDLIBS="$(EXPORT_LDLIBS)"' >> $@.new
@@ -127,5 +128,5 @@
 	cp -L $(EXPORT_FILES) $(EXPORT_DIR)/lib
 
-export-includes: $(INCLUDE_LIBC) $(shell find ./include ../c/arch/$(UARCH)/include $(ROOT_PATH)/abi/include -name '*.h')
+export-includes: $(shell find ./include ../c/arch/$(UARCH)/include $(ROOT_PATH)/abi/include -name '*.h')
 	mkdir -p $(EXPORT_DIR)/include
 	rm -rf $(EXPORT_DIR)/include.new
@@ -146,3 +147,5 @@
 	mkdir -p $(EXPORT_DIR)/include.new/libpcm
 	cp -r -L -t $(EXPORT_DIR)/include.new/libpcm ../pcm/include/*
+	mkdir -p $(EXPORT_DIR)/include.new/libcpp
+	cp -r -L -t $(EXPORT_DIR)/include.new/libcpp ../cpp/include/*
 	mv $(EXPORT_DIR)/include.new $(EXPORT_DIR)/include
Index: uspace/lib/posix/include/posix/ctype.h
===================================================================
--- uspace/lib/posix/include/posix/ctype.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/ctype.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -39,4 +39,6 @@
 #include <libc/ctype.h>
 
+__C_DECLS_BEGIN;
+
 /* Obsolete Functions and Macros */
 extern int isascii(int c);
@@ -46,4 +48,6 @@
 #define _toupper(c) ((c) - 'a' + 'A')
 
+__C_DECLS_END;
+
 #endif /* POSIX_CTYPE_H_ */
 
Index: uspace/lib/posix/include/posix/dlfcn.h
===================================================================
--- uspace/lib/posix/include/posix/dlfcn.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/dlfcn.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -41,8 +41,12 @@
 #define RTLD_LOCAL 0
 
+__C_DECLS_BEGIN;
+
 extern void *dlopen(const char *, int);
 extern void *dlsym(void *, const char *);
 extern int dlclose(void *);
 extern char *dlerror(void);
+
+__C_DECLS_END;
 
 #endif
Index: uspace/lib/posix/include/posix/fcntl.h
===================================================================
--- uspace/lib/posix/include/posix/fcntl.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/fcntl.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -38,11 +38,4 @@
 #include <sys/types.h>
 
-#undef O_CREAT
-#undef O_EXCL
-#undef O_TRUNC
-#undef O_APPEND
-#undef O_RDONLY
-#undef O_RDWR
-#undef O_WRONLY
 #define O_CREAT   1
 #define O_EXCL    2
@@ -54,23 +47,10 @@
 
 /* Mask for file access modes. */
-#undef O_ACCMODE
 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
 
 /* Dummy compatibility flag */
-#undef O_NOCTTY
 #define O_NOCTTY 0
 
 /* fcntl commands */
-#undef F_DUPFD
-#undef F_DUPFD_CLOEXEC
-#undef F_GETFD
-#undef F_SETFD
-#undef F_GETFL
-#undef F_SETFL
-#undef F_GETOWN
-#undef F_SETOWN
-#undef F_GETLK
-#undef F_SETLK
-#undef F_SETLKW
 #define F_DUPFD            0 /* Duplicate file descriptor. */
 #define F_DUPFD_CLOEXEC    1 /* Same as F_DUPFD but with FD_CLOEXEC flag set. */
@@ -86,9 +66,12 @@
 
 /* File descriptor flags used with F_GETFD and F_SETFD. */
-#undef FD_CLOEXEC
 #define FD_CLOEXEC         1 /* Close on exec. */
+
+__C_DECLS_BEGIN;
 
 extern int open(const char *pathname, int flags, ...);
 extern int fcntl(int fd, int cmd, ...);
+
+__C_DECLS_END;
 
 #endif /* POSIX_FCNTL_H_ */
Index: uspace/lib/posix/include/posix/fnmatch.h
===================================================================
--- uspace/lib/posix/include/posix/fnmatch.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/fnmatch.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -36,12 +36,10 @@
 #define POSIX_FNMATCH_H_
 
+#include <_bits/decls.h>
+
 /* Error Values */
-#undef FNM_NOMATCH
 #define FNM_NOMATCH 1
 
 /* Flags */
-#undef FNM_PATHNAME
-#undef FNM_PERIOD
-#undef FNM_NOESCAPE
 #define FNM_PATHNAME 1
 #define FNM_PERIOD 2
@@ -49,12 +47,13 @@
 
 /* GNU Extensions */
-#undef FNM_FILE_NAME
-#undef FNM_LEADING_DIR
-#undef FNM_CASEFOLD
 #define FNM_FILE_NAME FNM_PATHNAME
 #define FNM_LEADING_DIR 8
 #define FNM_CASEFOLD 16
 
+__C_DECLS_BEGIN;
+
 extern int fnmatch(const char *pattern, const char *string, int flags);
+
+__C_DECLS_END;
 
 #endif /* POSIX_FNMATCH_H_ */
Index: uspace/lib/posix/include/posix/locale.h
===================================================================
--- uspace/lib/posix/include/posix/locale.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/locale.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,17 +37,6 @@
 
 #include <stddef.h>
+#include <_bits/decls.h>
 
-#ifndef __locale_t_defined
-#define __locale_t_defined
-typedef struct __posix_locale *locale_t;
-#endif
-
-#undef LC_ALL
-#undef LC_COLLATE
-#undef LC_CTYPE
-#undef LC_MESSAGES
-#undef LC_MONETARY
-#undef LC_NUMERIC
-#undef LC_TIME
 #define LC_ALL 0
 #define LC_COLLATE 1
@@ -58,11 +47,4 @@
 #define LC_TIME 6
 
-#undef LC_COLLATE_MASK
-#undef LC_CTYPE_MASK
-#undef LC_MESSAGES_MASK
-#undef LC_MONETARY_MASK
-#undef LC_NUMERIC_MASK
-#undef LC_TIME_MASK
-#undef LC_ALL_MASK
 #define LC_COLLATE_MASK (1 << 0)
 #define LC_CTYPE_MASK (1 << 1)
@@ -74,6 +56,12 @@
     LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
 
-#undef LC_GLOBAL_LOCALE
 #define LC_GLOBAL_LOCALE NULL
+
+__C_DECLS_BEGIN;
+
+#ifndef __locale_t_defined
+#define __locale_t_defined
+typedef struct __posix_locale *locale_t;
+#endif
 
 struct lconv {
@@ -114,4 +102,6 @@
 extern locale_t uselocale(locale_t newloc);
 
+__C_DECLS_END;
+
 #endif /* POSIX_LOCALE_H_ */
 
Index: uspace/lib/posix/include/posix/pthread.h
===================================================================
--- uspace/lib/posix/include/posix/pthread.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/pthread.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -34,4 +34,13 @@
 
 #include <time.h>
+#include <_bits/decls.h>
+
+#define PTHREAD_MUTEX_RECURSIVE 1
+
+#define PTHREAD_MUTEX_INITIALIZER { 0 }
+
+#define PTHREAD_COND_INITIALIZER { 0 }
+
+__C_DECLS_BEGIN;
 
 typedef void *pthread_t;
@@ -43,11 +52,7 @@
 typedef int pthread_key_t;
 
-#define PTHREAD_MUTEX_RECURSIVE 1
-
 typedef struct pthread_mutex {
 	int dummy;
 } pthread_mutex_t;
-
-#define PTHREAD_MUTEX_INITIALIZER { 0 }
 
 typedef struct {
@@ -62,6 +67,4 @@
 	int dummy;
 } pthread_cond_t;
-
-#define PTHREAD_COND_INITIALIZER { 0 }
 
 extern pthread_t pthread_self(void);
@@ -106,4 +109,6 @@
 extern int pthread_key_create(pthread_key_t *, void (*)(void *));
 
+__C_DECLS_END;
+
 #endif
 
Index: uspace/lib/posix/include/posix/pwd.h
===================================================================
--- uspace/lib/posix/include/posix/pwd.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/pwd.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,4 +37,7 @@
 
 #include <sys/types.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 struct passwd {
@@ -58,4 +61,6 @@
     char *buffer, size_t bufsize, struct passwd **result);
 
+__C_DECLS_END;
+
 #endif /* POSIX_PWD_H_ */
 
Index: uspace/lib/posix/include/posix/signal.h
===================================================================
--- uspace/lib/posix/include/posix/signal.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/signal.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -39,67 +39,21 @@
 #include <ucontext.h>
 
-extern void __posix_default_signal_handler(int signo);
-extern void __posix_hold_signal_handler(int signo);
-extern void __posix_ignore_signal_handler(int signo);
-
-#undef SIG_DFL
 #define SIG_DFL ((void (*)(int)) __posix_default_signal_handler)
-#undef SIG_ERR
 #define SIG_ERR ((void (*)(int)) NULL)
-#undef SIG_HOLD
 #define SIG_HOLD ((void (*)(int)) __posix_hold_signal_handler)
-#undef SIG_IGN
 #define SIG_IGN ((void (*)(int)) __posix_ignore_signal_handler)
 
-typedef struct {
-	int si_signo;
-	int si_code;
-
-	int si_errno;
-
-	pid_t si_pid;
-	uid_t si_uid;
-	void *si_addr;
-	int si_status;
-
-	long si_band;
-
-	union sigval si_value;
-} siginfo_t;
-
-struct sigaction {
-	void (*sa_handler)(int);
-	sigset_t sa_mask;
-	int sa_flags;
-	void (*sa_sigaction)(int, siginfo_t *, void *);
-};
-
 /* Values of sigevent::sigev_notify */
-#undef SIGEV_NONE
-#undef SIGEV_SIGNAL
-#undef SIGEV_THREAD
 #define SIGEV_NONE 0
 #define SIGEV_SIGNAL 0
 #define SIGEV_THREAD 0
 
-#undef SIGRT_MIN
-#undef SIGRT_MAX
 #define SIGRT_MIN 0
 #define SIGRT_MAX 0
 
-#undef SIG_BLOCK
-#undef SIG_UNBLOCK
-#undef SIG_SETMASK
 #define SIG_BLOCK 0
 #define SIG_UNBLOCK 1
 #define SIG_SETMASK 2
 
-#undef SA_NOCLDSTOP
-#undef SA_ONSTACK
-#undef SA_RESETHAND
-#undef SA_RESTART
-#undef SA_SIGINFO
-#undef SA_NOCLDWAIT
-#undef SA_NODEFER
 #define SA_NOCLDSTOP (1 << 0)
 #define SA_ONSTACK (1 << 1)
@@ -110,13 +64,38 @@
 #define SA_NODEFER (1 << 6)
 
-#undef SS_ONSTACK
-#undef SS_DISABLE
 #define SS_ONSTACK 0
 #define SS_DISABLE 0
 
-#undef MINSIGSTKSZ
-#undef SIGSTKSZ
 #define MINSIGSTKSZ 0
 #define SIGSTKSZ 0
+
+__C_DECLS_BEGIN;
+
+extern void __posix_default_signal_handler(int signo);
+extern void __posix_hold_signal_handler(int signo);
+extern void __posix_ignore_signal_handler(int signo);
+
+typedef struct {
+	int si_signo;
+	int si_code;
+
+	int si_errno;
+
+	pid_t si_pid;
+	uid_t si_uid;
+	void *si_addr;
+	int si_status;
+
+	long si_band;
+
+	union sigval si_value;
+} siginfo_t;
+
+struct sigaction {
+	void (*sa_handler)(int);
+	sigset_t sa_mask;
+	int sa_flags;
+	void (*sa_sigaction)(int, siginfo_t *, void *);
+};
 
 /* Full POSIX set */
@@ -245,4 +224,6 @@
     sigset_t *__restrict__ oset);
 
+__C_DECLS_END;
+
 #endif /* POSIX_SIGNAL_H_ */
 
Index: uspace/lib/posix/include/posix/stdio.h
===================================================================
--- uspace/lib/posix/include/posix/stdio.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/stdio.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -45,12 +45,14 @@
 #include <limits.h>
 
+#define P_tmpdir "/tmp"
+
+#define L_ctermid PATH_MAX
+
+__C_DECLS_BEGIN;
+
 extern FILE *fdopen(int, const char *);
 extern int fileno(FILE *);
 
-#define P_tmpdir "/tmp"
-
 /* Identifying the Terminal */
-#undef L_ctermid
-#define L_ctermid PATH_MAX
 extern char *ctermid(char *s);
 
@@ -98,4 +100,6 @@
 extern char *tempnam(const char *dir, const char *pfx);
 
+__C_DECLS_END;
+
 #endif /* POSIX_STDIO_H_ */
 
Index: uspace/lib/posix/include/posix/stdlib.h
===================================================================
--- uspace/lib/posix/include/posix/stdlib.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/stdlib.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -42,4 +42,6 @@
 #include <stddef.h>
 
+__C_DECLS_BEGIN;
+
 /* Environment Access */
 extern int putenv(char *string);
@@ -60,4 +62,6 @@
 extern int bsd_getloadavg(double loadavg[], int nelem);
 
+__C_DECLS_END;
+
 #endif  // POSIX_STDLIB_H_
 
Index: uspace/lib/posix/include/posix/string.h
===================================================================
--- uspace/lib/posix/include/posix/string.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/string.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -47,11 +47,9 @@
 
 #include <libc/mem.h>
-#ifdef _HELENOS_SOURCE
-#undef _HELENOS_SOURCE
+
+#define _REALLY_WANT_STRING_H
 #include <libc/string.h>
-#define _HELENOS_SOURCE
-#else
-#include <libc/string.h>
-#endif
+
+__C_DECLS_BEGIN;
 
 /* Copying and Concatenation */
@@ -73,9 +71,9 @@
 
 /* Legacy Declarations */
-#ifndef POSIX_STRINGS_H_
 extern int ffs(int i);
 extern int strcasecmp(const char *s1, const char *s2);
 extern int strncasecmp(const char *s1, const char *s2, size_t n);
-#endif
+
+__C_DECLS_END;
 
 #endif  // POSIX_STRING_H_
Index: uspace/lib/posix/include/posix/strings.h
===================================================================
--- uspace/lib/posix/include/posix/strings.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/strings.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -39,14 +39,12 @@
 #include <types/common.h>
 
+__C_DECLS_BEGIN;
+
 /* Search Functions */
-#ifndef POSIX_STRING_H_
 extern int ffs(int i);
-#endif
 
 /* String/Array Comparison */
-#ifndef POSIX_STRING_H_
 extern int strcasecmp(const char *s1, const char *s2);
 extern int strncasecmp(const char *s1, const char *s2, size_t n);
-#endif
 
 /*
@@ -64,4 +62,6 @@
 extern char *rindex(const char *s, int c);
 
+__C_DECLS_END;
+
 #endif  // POSIX_STRINGS_H_
 
Index: uspace/lib/posix/include/posix/sys/mman.h
===================================================================
--- uspace/lib/posix/include/posix/sys/mman.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/sys/mman.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,7 +37,7 @@
 
 #include <sys/types.h>
-#include <abi/mm/as.h>
+#include <_bits/decls.h>
 
-#define MAP_FAILED ((void *) -1)
+#define MAP_FAILED  ((void *) -1)
 
 #define MAP_SHARED     (1 << 0)
@@ -45,14 +45,12 @@
 #define MAP_FIXED      (1 << 2)
 #define MAP_ANONYMOUS  (1 << 3)
-#define MAP_ANON MAP_ANONYMOUS
+#define MAP_ANON       MAP_ANONYMOUS
 
-#undef PROT_NONE
-#undef PROT_READ
-#undef PROT_WRITE
-#undef PROT_EXEC
-#define PROT_NONE  0
-#define PROT_READ  AS_AREA_READ
-#define PROT_WRITE AS_AREA_WRITE
-#define PROT_EXEC  AS_AREA_EXEC
+#define PROT_NONE   0
+#define PROT_READ   1
+#define PROT_WRITE  2
+#define PROT_EXEC   4
+
+__C_DECLS_BEGIN;
 
 extern void *mmap(void *start, size_t length, int prot, int flags, int fd,
@@ -60,4 +58,6 @@
 extern int munmap(void *start, size_t length);
 
+__C_DECLS_END;
+
 #endif /* POSIX_SYS_MMAN_H_ */
 
Index: uspace/lib/posix/include/posix/sys/stat.h
===================================================================
--- uspace/lib/posix/include/posix/sys/stat.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/sys/stat.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -39,15 +39,8 @@
 #include <sys/types.h>
 #include <time.h>
+#include <_bits/decls.h>
 
 /* values are the same as on Linux */
 
-#undef S_IFMT
-#undef S_IFSOCK
-#undef S_IFLNK
-#undef S_IFREG
-#undef S_IFBLK
-#undef S_IFDIR
-#undef S_IFCHR
-#undef S_IFIFO
 #define S_IFMT     0170000   /* all file types */
 #define S_IFSOCK   0140000   /* socket */
@@ -59,15 +52,8 @@
 #define S_IFIFO    0010000   /* FIFO */
 
-#undef S_ISUID
-#undef S_ISGID
-#undef S_ISVTX
 #define S_ISUID    0004000   /* SUID */
 #define S_ISGID    0002000   /* SGID */
 #define S_ISVTX    0001000   /* sticky */
 
-#undef S_IRWXU
-#undef S_IRUSR
-#undef S_IWUSR
-#undef S_IXUSR
 #define S_IRWXU    00700     /* owner permissions */
 #define S_IRUSR    00400
@@ -75,8 +61,4 @@
 #define S_IXUSR    00100
 
-#undef S_IRWXG
-#undef S_IRGRP
-#undef S_IWGRP
-#undef S_IXGRP
 #define S_IRWXG    00070     /* group permissions */
 #define S_IRGRP    00040
@@ -84,8 +66,4 @@
 #define S_IXGRP    00010
 
-#undef S_IRWXO
-#undef S_IROTH
-#undef S_IWOTH
-#undef S_IXOTH
 #define S_IRWXO    00007     /* other permissions */
 #define S_IROTH    00004
@@ -93,11 +71,4 @@
 #define S_IXOTH    00001
 
-#undef S_ISREG
-#undef S_ISDIR
-#undef S_ISCHR
-#undef S_ISBLK
-#undef S_ISFIFO
-#undef S_ISLNK
-#undef S_ISSOCK
 #define S_ISREG(m) ((m & S_IFREG) != 0)
 #define S_ISDIR(m) ((m & S_IFDIR) != 0)
@@ -107,4 +78,6 @@
 #define S_ISLNK(m) ((m & S_IFLNK) != 0) /* symbolic link? (Not in POSIX.1-1996.) */
 #define S_ISSOCK(m) ((m & S_IFSOCK) != 0) /* socket? (Not in POSIX.1-1996.) */
+
+__C_DECLS_BEGIN;
 
 struct stat {
@@ -131,4 +104,6 @@
 extern int mkdir(const char *path, mode_t mode);
 
+__C_DECLS_END;
+
 #endif /* POSIX_SYS_STAT_H */
 
Index: uspace/lib/posix/include/posix/sys/time.h
===================================================================
--- uspace/lib/posix/include/posix/sys/time.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/sys/time.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -35,4 +35,7 @@
 
 #include <time.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 struct timeval {
@@ -43,4 +46,6 @@
 extern int gettimeofday(struct timeval *, void *);
 
+__C_DECLS_END;
+
 #endif
 
Index: uspace/lib/posix/include/posix/sys/types.h
===================================================================
--- uspace/lib/posix/include/posix/sys/types.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/sys/types.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,5 +37,10 @@
 #define POSIX_SYS_TYPES_H_
 
-#include <types/common.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <_bits/ssize_t.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 typedef unsigned int ino_t;
@@ -46,5 +51,5 @@
 typedef long blkcnt_t;
 typedef int pid_t;
-typedef sysarg_t dev_t;
+typedef unsigned long dev_t;
 typedef unsigned int mode_t;
 
@@ -67,4 +72,6 @@
 typedef long suseconds_t;
 
+__C_DECLS_END;
+
 #endif /* POSIX_SYS_TYPES_H_ */
 
Index: uspace/lib/posix/include/posix/sys/wait.h
===================================================================
--- uspace/lib/posix/include/posix/sys/wait.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/sys/wait.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,13 +37,12 @@
 
 #include <sys/types.h>
+#include <_bits/decls.h>
 
-#undef WIFEXITED
-#undef WEXITSTATUS
-#undef WIFSIGNALED
-#undef WTERMSIG
 #define WIFEXITED(status) __posix_wifexited(status)
 #define WEXITSTATUS(status) __posix_wexitstatus(status)
 #define WIFSIGNALED(status) __posix_wifsignaled(status)
 #define WTERMSIG(status) __posix_wtermsig(status)
+
+__C_DECLS_BEGIN;
 
 extern int __posix_wifexited(int status);
@@ -55,4 +54,6 @@
 extern pid_t waitpid(pid_t pid, int *stat_ptr, int options);
 
+__C_DECLS_END;
+
 #endif /* POSIX_SYS_WAIT_H_ */
 
Index: uspace/lib/posix/include/posix/time.h
===================================================================
--- uspace/lib/posix/include/posix/time.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/time.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -41,4 +41,10 @@
 #include <libc/time.h>
 
+#define CLOCK_REALTIME ((clockid_t) 0)
+
+#define ASCTIME_BUF_LEN  26
+
+__C_DECLS_BEGIN;
+
 #ifndef __locale_t_defined
 #define __locale_t_defined
@@ -46,12 +52,5 @@
 #endif
 
-#ifndef POSIX_SIGNAL_H_
 struct sigevent;
-#endif
-
-#undef CLOCK_REALTIME
-#define CLOCK_REALTIME ((clockid_t) 0)
-
-#define ASCTIME_BUF_LEN  26
 
 struct itimerspec {
@@ -97,4 +96,6 @@
     const struct timespec *rqtp, struct timespec *rmtp);
 
+__C_DECLS_END;
+
 #endif  // POSIX_TIME_H_
 
Index: uspace/lib/posix/include/posix/ucontext.h
===================================================================
--- uspace/lib/posix/include/posix/ucontext.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/ucontext.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -37,4 +37,7 @@
 
 #include <sys/types.h>
+#include <_bits/decls.h>
+
+__C_DECLS_BEGIN;
 
 typedef int sig_atomic_t;
@@ -71,4 +74,6 @@
 } ucontext_t;
 
+__C_DECLS_END;
+
 #endif
 
Index: uspace/lib/posix/include/posix/unistd.h
===================================================================
--- uspace/lib/posix/include/posix/unistd.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/include/posix/unistd.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -47,4 +47,16 @@
 #define _exit exit
 
+/* Standard Streams */
+#define STDIN_FILENO (fileno(stdin))
+#define STDOUT_FILENO (fileno(stdout))
+#define STDERR_FILENO (fileno(stderr))
+
+#define	F_OK 0 /* Test for existence. */
+#define	X_OK 1 /* Test for execute permission. */
+#define	W_OK 2 /* Test for write permission. */
+#define	R_OK 4 /* Test for read permission. */
+
+__C_DECLS_BEGIN;
+
 extern char *optarg;
 extern int optind, opterr, optopt;
@@ -87,4 +99,8 @@
 
 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+// FIXME: this should just be defined in <sys/types.h>, but for some reason
+//        build of coastline binutils on mips32 doesn't see the definition there
+typedef int64_t off64_t;
+
 extern off64_t lseek64(int fildes, off64_t offset, int whence);
 extern int ftruncate64(int fildes, off64_t length);
@@ -106,21 +122,5 @@
 #endif
 
-/* Standard Streams */
-#undef STDIN_FILENO
-#define STDIN_FILENO (fileno(stdin))
-#undef STDOUT_FILENO
-#define STDOUT_FILENO (fileno(stdout))
-#undef STDERR_FILENO
-#define STDERR_FILENO (fileno(stderr))
-
 /* File Accessibility */
-#undef F_OK
-#undef X_OK
-#undef W_OK
-#undef R_OK
-#define	F_OK 0 /* Test for existence. */
-#define	X_OK 1 /* Test for execute permission. */
-#define	W_OK 2 /* Test for write permission. */
-#define	R_OK 4 /* Test for read permission. */
 extern int access(const char *path, int amode);
 
@@ -171,4 +171,6 @@
 extern unsigned int alarm(unsigned int);
 
+__C_DECLS_END;
+
 #endif /* POSIX_UNISTD_H_ */
 
Index: uspace/lib/posix/src/internal/common.h
===================================================================
--- uspace/lib/posix/src/internal/common.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/src/internal/common.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -67,4 +67,7 @@
 }
 
+// TODO: Remove this arbitrary limit.
+#define VFS_MAX_OPEN_FILES 128
+
 extern aoff64_t posix_pos[VFS_MAX_OPEN_FILES];
 
Index: uspace/lib/posix/src/sys/mman.c
===================================================================
--- uspace/lib/posix/src/sys/mman.c	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/lib/posix/src/sys/mman.c	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -39,4 +39,20 @@
 #include <unistd.h>
 
+static int _prot_to_as(int prot)
+{
+	int ret = 0;
+
+	if (prot & PROT_READ)
+		ret |= AS_AREA_READ;
+
+	if (prot & PROT_WRITE)
+		ret |= AS_AREA_WRITE;
+
+	if (prot & PROT_EXEC)
+		ret |= AS_AREA_EXEC;
+
+	return ret;
+}
+
 void *mmap(void *start, size_t length, int prot, int flags, int fd,
     off_t offset)
@@ -53,5 +69,5 @@
 		return MAP_FAILED;
 
-	return as_area_create(start, length, prot, AS_AREA_UNPAGED);
+	return as_area_create(start, length, _prot_to_as(prot), AS_AREA_UNPAGED);
 }
 
Index: uspace/srv/loader/Makefile
===================================================================
--- uspace/srv/loader/Makefile	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/srv/loader/Makefile	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -46,5 +46,5 @@
 
 BINARY = loader
-STATIC_ONLY = y
+STATIC_NEEDED = y
 
 GENERIC_SOURCES = \
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision 42e91ae287bf1525ef41e4cc821ffb99f0562d68)
+++ uspace/srv/vfs/vfs.h	(revision b401b3322a451446f62c081f02087ec8f1c2f07e)
@@ -49,4 +49,8 @@
 #define dprintf(...)
 #endif
+
+// TODO: Remove this arbitrary limit.
+/** Maximum number of open files per client. */
+#define VFS_MAX_OPEN_FILES  128
 
 /**
