Index: uspace/lib/libc/Makefile
===================================================================
--- uspace/lib/libc/Makefile	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/Makefile	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -50,4 +50,5 @@
 	generic/devmap.c \
 	generic/event.c \
+	generic/errno.c \
 	generic/mem.c \
 	generic/string.c \
@@ -69,5 +70,5 @@
 	generic/io/printf_core.c \
 	generic/io/console.c \
-	malloc/malloc.c \
+	generic/malloc.c \
 	generic/sysinfo.c \
 	generic/ipc.c \
@@ -106,5 +107,5 @@
 clean:
 	-rm -f include/kernel include/arch include/libarch libc.a arch/$(UARCH)/_link.ld Makefile.depend
-	find generic/ arch/$(UARCH)/ malloc -name '*.o' -follow -exec rm \{\} \;
+	find generic/ arch/$(UARCH)/ -name '*.o' -follow -exec rm \{\} \;
 
 depend: kerninc
Index: uspace/lib/libc/arch/ia64/Makefile.inc
===================================================================
--- uspace/lib/libc/arch/ia64/Makefile.inc	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/arch/ia64/Makefile.inc	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -38,5 +38,5 @@
 	arch/$(UARCH)/src/ddi.c
 
-CFLAGS += -fno-unwind-tables -DMALLOC_ALIGNMENT_16
+CFLAGS += -fno-unwind-tables
 LFLAGS += -N $(SOFTINT_PREFIX)/libsoftint.a
 
Index: uspace/lib/libc/generic/as.c
===================================================================
--- uspace/lib/libc/generic/as.c	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/generic/as.c	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -39,21 +39,21 @@
 #include <sys/types.h>
 #include <bitops.h>
+#include <malloc.h>
 
-/**
- * Either 4*256M on 32-bit architecures or 16*256M on 64-bit architectures.
- */
-#define MAX_HEAP_SIZE	(sizeof(uintptr_t)<<28)
+/** Last position allocated by as_get_mappable_page */
+static uintptr_t last_allocated = 0;
 
 /** Create address space area.
  *
  * @param address Virtual address where to place new address space area.
- * @param size Size of the area.
- * @param flags Flags describing type of the area.
+ * @param size    Size of the area.
+ * @param flags   Flags describing type of the area.
  *
  * @return address on success, (void *) -1 otherwise.
+ *
  */
 void *as_area_create(void *address, size_t size, int flags)
 {
-	return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address,
+	return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t) address,
 	    (sysarg_t) size, (sysarg_t) flags);
 }
@@ -62,13 +62,14 @@
  *
  * @param address Virtual address pointing into already existing address space
- * 	area.
- * @param size New requested size of the area.
- * @param flags Currently unused.
+ *                area.
+ * @param size    New requested size of the area.
+ * @param flags   Currently unused.
  *
- * @return Zero on success or a code from @ref errno.h on failure.
+ * @return zero on success or a code from @ref errno.h on failure.
+ *
  */
 int as_area_resize(void *address, size_t size, int flags)
 {
-	return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address,
+	return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t) address,
 	    (sysarg_t) size, (sysarg_t) flags);
 }
@@ -77,11 +78,12 @@
  *
  * @param address Virtual address pointing into the address space area being
- * 	destroyed.
+ *                destroyed.
  *
- * @return Zero on success or a code from @ref errno.h on failure.
+ * @return zero on success or a code from @ref errno.h on failure.
+ *
  */
 int as_area_destroy(void *address)
 {
-	return __SYSCALL1(SYS_AS_AREA_DESTROY, (sysarg_t ) address);
+	return __SYSCALL1(SYS_AS_AREA_DESTROY, (sysarg_t) address);
 }
 
@@ -89,8 +91,9 @@
  *
  * @param address Virtual address pointing into the address space area being
- * 	modified.
- * @param flags New flags describing type of the area.
+ *                modified.
+ * @param flags   New flags describing type of the area.
  *
- * @return Zero on success or a code from @ref errno.h on failure.
+ * @return zero on success or a code from @ref errno.h on failure.
+ *
  */
 int as_area_change_flags(void *address, int flags)
@@ -100,99 +103,27 @@
 }
 
-static size_t heapsize = 0;
-static size_t maxheapsize = (size_t) (-1);
-
-static void *last_allocated = 0;
-
-/* Start of heap linker symbol */
-extern char _heap;
-
-/** Sbrk emulation 
+/** Return pointer to some unmapped area, where fits new as_area
  *
- * @param incr New area that should be allocated or negative, 
-               if it should be shrinked
- * @return Pointer to newly allocated area
+ * @param size Requested size of the allocation.
+ *
+ * @return pointer to the beginning
+ *
  */
-void *sbrk(ssize_t incr)
+void *as_get_mappable_page(size_t size)
 {
-	int rc;
-	void *res;
-	
-	/* Check for invalid values */
-	if ((incr < 0) && (((size_t) -incr) > heapsize))
+	if (size == 0)
 		return NULL;
 	
-	/* Check for too large value */
-	if ((incr > 0) && (incr + heapsize < heapsize))
-		return NULL;
-	
-	/* Check for too small values */
-	if ((incr < 0) && (incr + heapsize > heapsize))
-		return NULL;
-	
-	/* Check for user limit */
-	if ((maxheapsize != (size_t) (-1)) && (heapsize + incr) > maxheapsize)
-		return NULL;
-	
-	rc = as_area_resize(&_heap, heapsize + incr, 0);
-	if (rc != 0)
-		return NULL;
-	
-	/* Compute start of new area */
-	res = (void *) &_heap + heapsize;
-
-	heapsize += incr;
-
-	return res;
-}
-
-/** Set maximum heap size and return pointer just after the heap */
-void *set_maxheapsize(size_t mhs)
-{
-	maxheapsize = mhs;
-	/* Return pointer to area not managed by sbrk */
-	return ((void *) &_heap + maxheapsize);
-}
-
-/** Return pointer to some unmapped area, where fits new as_area
- *
- * @param sz Requested size of the allocation.
- *
- * @return Pointer to the beginning 
- *
- * TODO: make some first_fit/... algorithm, we are now just incrementing
- *       the pointer to last area
- */
-void *as_get_mappable_page(size_t sz)
-{
-	void *res;
-	uint64_t asz;
-	int i;
-	
-	if (!sz)
-		return NULL;	
-
-	asz = 1 << (fnzb64(sz - 1) + 1);
-
-	/* Set heapsize to some meaningful value */
-	if (maxheapsize == (size_t) -1)
-		set_maxheapsize(MAX_HEAP_SIZE);
+	size_t sz = 1 << (fnzb(size - 1) + 1);
+	if (last_allocated == 0)
+		last_allocated = get_max_heap_addr();
 	
 	/*
 	 * Make sure we allocate from naturally aligned address.
 	 */
-	i = 0;
-	if (!last_allocated) {
-		last_allocated = (void *) ALIGN_UP((void *) &_heap +
-		    maxheapsize, asz);
-	} else {
-		last_allocated = (void *) ALIGN_UP(((uintptr_t)
-		    last_allocated) + (int) (i > 0), asz);
-	}
-
-	res = last_allocated;
-	last_allocated += ALIGN_UP(sz, PAGE_SIZE);
-
-	return res;
+	uintptr_t res = ALIGN_UP(last_allocated, sz);
+	last_allocated = res + ALIGN_UP(size, PAGE_SIZE);
+	
+	return ((void *) res);
 }
 
Index: uspace/lib/libc/generic/async.c
===================================================================
--- uspace/lib/libc/generic/async.c	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/generic/async.c	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -739,5 +739,5 @@
  * @return Zero on success or an error code.
  */
-int _async_init(void)
+int __async_init(void)
 {
 	if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_CHAINS, 1,
Index: uspace/lib/libc/generic/errno.c
===================================================================
--- uspace/lib/libc/generic/errno.c	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
+++ uspace/lib/libc/generic/errno.c	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#include <errno.h>
+#include <fibril.h>
+
+int _errno;
+
+/** @}
+ */
Index: uspace/lib/libc/generic/getopt.c
===================================================================
--- uspace/lib/libc/generic/getopt.c	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/generic/getopt.c	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -48,5 +48,5 @@
 int	optopt = '?';		/* character checked for validity */
 int	optreset;		/* reset getopt */
-char *optarg;		/* argument associated with option */
+const char *optarg;		/* argument associated with option */
 
 
@@ -163,5 +163,5 @@
 	const char *options;
 {
-	char *oli;				/* option letter list index */
+	const char *oli;				/* option letter list index */
 	int optchar;
 
@@ -276,5 +276,5 @@
 		optarg = NULL;
 		if (*place)			/* no white space */
-			optarg = *place;
+			optarg = place;
 		/* XXX: disable test for :: if PC? (GNU doesn't) */
 		else if (oli[1] != ':') {	/* arg not optional */
@@ -354,5 +354,6 @@
 	retval = getopt_internal(nargc, (char **)nargv, options);
 	if (retval == -2) {
-		char *current_argv, *has_equal;
+		char *current_argv;
+		const char *has_equal;
 		size_t current_argv_len;
 		int i, ambiguous, match;
Index: uspace/lib/libc/generic/io/io.c
===================================================================
--- uspace/lib/libc/generic/io/io.c	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/generic/io/io.c	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -90,5 +90,5 @@
 static LIST_INITIALIZE(files);
 
-void stdio_init(int filc, fdi_node_t *filv[])
+void __stdio_init(int filc, fdi_node_t *filv[])
 {
 	if (filc > 0) {
@@ -114,5 +114,5 @@
 }
 
-void stdio_done(void)
+void __stdio_done(void)
 {
 	link_t *link = files.next;
Index: uspace/lib/libc/generic/libc.c
===================================================================
--- uspace/lib/libc/generic/libc.c	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/generic/libc.c	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -53,8 +53,5 @@
 #include <loader/pcb.h>
 
-extern char _heap;
 extern int main(int argc, char *argv[]);
-
-int _errno;
 
 void _exit(int status)
@@ -65,7 +62,6 @@
 void __main(void *pcb_ptr)
 {
-	(void) as_area_create(&_heap, 1, AS_AREA_WRITE | AS_AREA_READ);
-	
-	_async_init();
+	__heap_init();
+	__async_init();
 	fibril_t *fibril = fibril_setup();
 	__tcb_set(fibril->tcb);
@@ -80,13 +76,13 @@
 		argc = 0;
 		argv = NULL;
-		stdio_init(0, NULL);
+		__stdio_init(0, NULL);
 	} else {
 		argc = __pcb->argc;
 		argv = __pcb->argv;
-		stdio_init(__pcb->filc, __pcb->filv);
+		__stdio_init(__pcb->filc, __pcb->filv);
 	}
 	
 	main(argc, argv);
-	stdio_done();
+	__stdio_done();
 }
 
Index: uspace/lib/libc/generic/mman.c
===================================================================
--- uspace/lib/libc/generic/mman.c	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/generic/mman.c	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -38,5 +38,5 @@
 #include <unistd.h>
 
-void *mmap(void  *start, size_t length, int prot, int flags, int fd,
+void *mmap(void *start, size_t length, int prot, int flags, int fd,
     off_t offset)
 {
@@ -44,9 +44,10 @@
 		start = as_get_mappable_page(length);
 	
-//	if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
+//	if (!((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
 //		return MAP_FAILED;
-	if (! (flags & MAP_ANONYMOUS))
+	
+	if (!(flags & MAP_ANONYMOUS))
 		return MAP_FAILED;
-
+	
 	return as_area_create(start, length, prot);
 }
Index: uspace/lib/libc/include/adt/gcdlcm.h
===================================================================
--- uspace/lib/libc/include/adt/gcdlcm.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
+++ uspace/lib/libc/include/adt/gcdlcm.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_GCDLCM_H_
+#define LIBC_GCDLCM_H_
+
+#include <sys/types.h>
+
+#define DECLARE_GCD(type, name) \
+	static inline type name(type a, type b) \
+	{ \
+		if (a == 0) \
+			return b; \
+		 \
+		while (b != 0) { \
+			if (a > b) \
+				a -= b; \
+			else \
+				b -= a; \
+		} \
+		 \
+		return a; \
+	}
+
+#define DECLARE_LCM(type, name, gcd) \
+	static inline type name(type a, type b) \
+	{ \
+		return (a * b) / gcd(a, b); \
+	}
+
+DECLARE_GCD(uint32_t, gcd32);
+DECLARE_GCD(uint64_t, gcd64);
+DECLARE_GCD(size_t, gcd);
+
+DECLARE_LCM(uint32_t, lcm32, gcd32);
+DECLARE_LCM(uint64_t, lcm64, gcd64);
+DECLARE_LCM(size_t, lcm, gcd);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/libc/include/async.h
===================================================================
--- uspace/lib/libc/include/async.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/async.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -47,14 +47,15 @@
 extern atomic_t async_futex;
 
+extern int __async_init(void);
+extern ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs);
+
+static inline ipc_callid_t async_get_call(ipc_call_t *data)
+{
+	return async_get_call_timeout(data, 0);
+}
+
 static inline void async_manager(void)
 {
 	fibril_switch(FIBRIL_TO_MANAGER);
-}
-
-extern ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs);
-
-static inline ipc_callid_t async_get_call(ipc_call_t *data)
-{
-	return async_get_call_timeout(data, 0);
 }
 
@@ -95,5 +96,4 @@
 extern void async_create_manager(void);
 extern void async_destroy_manager(void);
-extern int _async_init(void);
 
 extern void async_set_client_connection(async_client_conn_t conn);
Index: uspace/lib/libc/include/bitops.h
===================================================================
--- uspace/lib/libc/include/bitops.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/bitops.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup generic	
+/** @addtogroup generic
  * @{
  */
@@ -43,8 +43,8 @@
  * If number is zero, it returns 0
  */
-static inline int fnzb32(uint32_t arg)
+static inline unsigned int fnzb32(uint32_t arg)
 {
-	int n = 0;
-
+	unsigned int n = 0;
+	
 	if (arg >> 16) {
 		arg >>= 16;
@@ -75,8 +75,8 @@
 }
 
-static inline int fnzb64(uint64_t arg)
+static inline unsigned int fnzb64(uint64_t arg)
 {
-	int n = 0;
-
+	unsigned int n = 0;
+	
 	if (arg >> 32) {
 		arg >>= 32;
@@ -84,8 +84,11 @@
 	}
 	
-	return n + fnzb32((uint32_t) arg);
+	return (n + fnzb32((uint32_t) arg));
 }
 
-#define fnzb(x) fnzb32(x)
+static inline unsigned int fnzb(size_t arg)
+{
+	return fnzb64(arg);
+}
 
 #endif
Index: uspace/lib/libc/include/errno.h
===================================================================
--- uspace/lib/libc/include/errno.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/errno.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -36,9 +36,10 @@
 #define LIBC_ERRNO_H_
 
-/* TODO: support threads/fibrils */
+#include <kernel/errno.h>
+#include <fibril.h>
+
 extern int _errno;
+
 #define errno _errno
-
-#include <kernel/errno.h>
 
 #define EMFILE        (-17)
Index: uspace/lib/libc/include/getopt.h
===================================================================
--- uspace/lib/libc/include/getopt.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/getopt.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -59,5 +59,5 @@
 
 /* HelenOS Port - These need to be exposed for legacy getopt() */
-extern char *optarg;
+extern const char *optarg;
 extern int optind, opterr, optopt;
 extern int optreset;
Index: uspace/lib/libc/include/macros.h
===================================================================
--- uspace/lib/libc/include/macros.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/macros.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -36,4 +36,7 @@
 #define LIBC_MACROS_H_
 
+#define min(a, b)  ((a) < (b) ? (a) : (b))
+#define max(a, b)  ((a) > (b) ? (a) : (b))
+
 #define SIZE2KB(size)  ((size) >> 10)
 #define SIZE2MB(size)  ((size) >> 20)
Index: uspace/lib/libc/include/mem.h
===================================================================
--- uspace/lib/libc/include/mem.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/mem.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -40,7 +40,7 @@
 #define bzero(ptr, len)  memset((ptr), 0, (len))
 
-extern void * memset(void *, int, size_t);
-extern void * memcpy(void *, const void *, size_t);
-extern void * memmove(void *, const void *, size_t);
+extern void *memset(void *, int, size_t);
+extern void *memcpy(void *, const void *, size_t);
+extern void *memmove(void *, const void *, size_t);
 
 extern int bcmp(const char *, const char *, size_t);
Index: uspace/lib/libc/include/stdio.h
===================================================================
--- uspace/lib/libc/include/stdio.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/stdio.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -38,4 +38,5 @@
 #include <sys/types.h>
 #include <stdarg.h>
+#include <string.h>
 #include <adt/list.h>
 
@@ -43,13 +44,13 @@
 
 /** Default size for stream I/O buffers */
-#define BUFSIZ 4096
+#define BUFSIZ  4096
 
 #define DEBUG(fmt, ...) \
-{ \
-	char buf[256]; \
-	int n = snprintf(buf, sizeof(buf), fmt, ##__VA_ARGS__); \
-	if (n > 0) \
-		(void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, str_size(buf)); \
-}
+	{ \
+		char _buf[256]; \
+		int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \
+		if (_n > 0) \
+			(void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) _buf, str_size(_buf)); \
+	}
 
 #ifndef SEEK_SET
Index: uspace/lib/libc/include/stdlib.h
===================================================================
--- uspace/lib/libc/include/stdlib.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/stdlib.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -39,8 +39,8 @@
 #include <malloc.h>
 
-#define abort() _exit(1)
-#define exit(status)	_exit((status))
+#define abort()       _exit(1)
+#define exit(status)  _exit((status))
 
-#define RAND_MAX 714025
+#define RAND_MAX  714025
 
 extern long int random(void);
@@ -51,4 +51,5 @@
 	return random();
 }
+
 static inline void srand(unsigned int seed)
 {
Index: uspace/lib/libc/include/unistd.h
===================================================================
--- uspace/lib/libc/include/unistd.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/unistd.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -66,5 +66,4 @@
 
 extern void _exit(int status) __attribute__ ((noreturn));
-extern void *sbrk(ssize_t incr);
 extern int usleep(unsigned long usec);
 extern unsigned int sleep(unsigned int seconds);
Index: uspace/lib/libc/include/vfs/vfs.h
===================================================================
--- uspace/lib/libc/include/vfs/vfs.h	(revision 6db6fd18c6afe2f2ade4f934e820a461a6f232bc)
+++ uspace/lib/libc/include/vfs/vfs.h	(revision 2d11a7d86e751706f4d990ffdbd99edec012e4c8)
@@ -56,6 +56,6 @@
     unsigned int);
 
-extern void stdio_init(int filc, fdi_node_t *filv[]);
-extern void stdio_done(void);
+extern void __stdio_init(int filc, fdi_node_t *filv[]);
+extern void __stdio_done(void);
 
 extern int open_node(fdi_node_t *, int);
