Index: uspace/app/barber/barber.c
===================================================================
--- uspace/app/barber/barber.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/barber/barber.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -33,5 +33,4 @@
  */
 
-#include <unistd.h>
 #include <stdbool.h>
 #include <errno.h>
Index: uspace/app/bdsh/cmds/builtin_cmds.c
===================================================================
--- uspace/app/bdsh/cmds/builtin_cmds.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/builtin_cmds.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,4 +32,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <str.h>
 #include "errors.h"
Index: uspace/app/bdsh/cmds/builtins/batch/batch.c
===================================================================
--- uspace/app/bdsh/cmds/builtins/batch/batch.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/builtins/batch/batch.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,4 +30,5 @@
 #include <stdlib.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <errno.h>
 #include "config.h"
Index: uspace/app/bdsh/cmds/mod_cmds.c
===================================================================
--- uspace/app/bdsh/cmds/mod_cmds.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/mod_cmds.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -45,4 +45,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <str.h>
 #include "errors.h"
Index: uspace/app/bdsh/cmds/modules/cat/cat.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/modules/cat/cat.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <getopt.h>
 #include <str.h>
Index: uspace/app/bdsh/cmds/modules/cmp/cmp.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cmp/cmp.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/modules/cmp/cmp.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,5 +32,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <vfs/vfs.h>
 
Index: uspace/app/bdsh/cmds/modules/cp/cp.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cp/cp.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/modules/cp/cp.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <io/console.h>
 #include <io/keycode.h>
Index: uspace/app/bdsh/cmds/modules/echo/echo.c
===================================================================
--- uspace/app/bdsh/cmds/modules/echo/echo.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/modules/echo/echo.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include "config.h"
 #include "util.h"
Index: uspace/app/bdsh/cmds/modules/help/help.c
===================================================================
--- uspace/app/bdsh/cmds/modules/help/help.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/modules/help/help.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,4 +30,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <str.h>
 #include <fmtutil.h>
Index: uspace/app/bdsh/cmds/modules/printf/printf.c
===================================================================
--- uspace/app/bdsh/cmds/modules/printf/printf.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/modules/printf/printf.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include "config.h"
 #include "util.h"
Index: uspace/app/bdsh/cmds/modules/sleep/sleep.c
===================================================================
--- uspace/app/bdsh/cmds/modules/sleep/sleep.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/modules/sleep/sleep.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,5 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
+#include <thread.h>
 #include "config.h"
 #include "util.h"
@@ -131,5 +131,5 @@
 	}
 
-	(void) usleep(duration);
+	(void) thread_usleep(duration);
 
 	return CMD_SUCCESS;
Index: uspace/app/bdsh/cmds/modules/touch/touch.c
===================================================================
--- uspace/app/bdsh/cmds/modules/touch/touch.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/cmds/modules/touch/touch.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -34,5 +34,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <dirent.h>
 #include <sys/types.h>
Index: uspace/app/bdsh/errors.c
===================================================================
--- uspace/app/bdsh/errors.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/errors.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,8 +28,8 @@
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stddef.h>
 #include <str.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
 
 #include "config.h"
Index: uspace/app/bdsh/exec.c
===================================================================
--- uspace/app/bdsh/exec.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/exec.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <str.h>
 #include <str_error.h>
Index: uspace/app/bdsh/scli.c
===================================================================
--- uspace/app/bdsh/scli.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/scli.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,6 +29,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <str.h>
-#include <unistd.h>
 #include "config.h"
 #include "scli.h"
Index: uspace/app/bdsh/tok.c
===================================================================
--- uspace/app/bdsh/tok.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bdsh/tok.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -31,4 +31,5 @@
 #include <malloc.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <errno.h>
 
Index: uspace/app/bithenge/test.c
===================================================================
--- uspace/app/bithenge/test.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/bithenge/test.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -38,4 +38,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <sys/types.h>
 #include <bithenge/blob.h>
Index: uspace/app/df/df.c
===================================================================
--- uspace/app/df/df.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/df/df.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,5 +37,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <stdint.h>
 #include <getopt.h>
Index: uspace/app/edit/search.c
===================================================================
--- uspace/app/edit/search.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/edit/search.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,4 +36,5 @@
 
 #include <stdlib.h>
+#include <stddef.h>
 #include <errno.h>
 
Index: uspace/app/getterm/getterm.c
===================================================================
--- uspace/app/getterm/getterm.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/getterm/getterm.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,5 +36,4 @@
 
 #include <sys/types.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <task.h>
Index: uspace/app/getterm/version.c
===================================================================
--- uspace/app/getterm/version.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/getterm/version.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -34,5 +34,4 @@
  */
 
-#include <unistd.h>
 #include <stdio.h>
 #include <macros.h>
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/init/init.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,5 +36,4 @@
 
 #include <stdio.h>
-#include <unistd.h>
 #include <stdarg.h>
 #include <vfs/vfs.h>
Index: uspace/app/killall/killall.c
===================================================================
--- uspace/app/killall/killall.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/killall/killall.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,5 +36,4 @@
 #include <errno.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <task.h>
 #include <stats.h>
Index: uspace/app/mkmfs/mkmfs.c
===================================================================
--- uspace/app/mkmfs/mkmfs.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/mkmfs/mkmfs.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -40,5 +40,4 @@
 #include <stdlib.h>
 #include <block.h>
-#include <unistd.h>
 #include <errno.h>
 #include <sys/typefmt.h>
Index: uspace/app/redir/redir.c
===================================================================
--- uspace/app/redir/redir.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/redir/redir.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,5 +37,4 @@
 #include <sys/types.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <str.h>
 #include <stdio.h>
Index: uspace/app/sbi/src/mytypes.h
===================================================================
--- uspace/app/sbi/src/mytypes.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/sbi/src/mytypes.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -52,5 +52,5 @@
 #include <errno.h>
 /** We need NULL defined. */
-#include <unistd.h>
+#include <stddef.h>
 #define EOK 0
 
Index: uspace/app/sysinfo/sysinfo.c
===================================================================
--- uspace/app/sysinfo/sysinfo.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/sysinfo/sysinfo.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,5 +36,5 @@
 #include <errno.h>
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 #include <sysinfo.h>
 #include <malloc.h>
Index: uspace/app/taskdump/elf_core.c
===================================================================
--- uspace/app/taskdump/elf_core.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/taskdump/elf_core.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -54,5 +54,4 @@
 #include <errno.h>
 #include <sys/types.h>
-#include <unistd.h>
 #include <mem.h>
 #include <stdint.h>
Index: uspace/app/taskdump/taskdump.c
===================================================================
--- uspace/app/taskdump/taskdump.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/taskdump/taskdump.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -38,5 +38,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <errno.h>
 #include <udebug.h>
Index: uspace/app/tester/float/float1.c
===================================================================
--- uspace/app/tester/float/float1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/float/float1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,4 +30,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <atomic.h>
 #include <thread.h>
@@ -88,5 +89,5 @@
 		TPRINTF("Threads left: %" PRIua "\n",
 		    total - atomic_get(&threads_finished));
-		sleep(1);
+		thread_sleep(1);
 	}
 	
Index: uspace/app/tester/float/float2.c
===================================================================
--- uspace/app/tester/float/float2.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/float/float2.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -31,4 +31,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <math.h>
 #include "../tester.h"
Index: uspace/app/tester/float/softfloat1.c
===================================================================
--- uspace/app/tester/float/softfloat1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/float/softfloat1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
+#include <stddef.h>
 #include <mathtypes.h>
 #include <add.h>
@@ -36,5 +38,4 @@
 #include <comparison.h>
 #include <conversion.h>
-#include <stdbool.h>
 #include "../tester.h"
 
Index: uspace/app/tester/hw/misc/virtchar1.c
===================================================================
--- uspace/app/tester/hw/misc/virtchar1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/hw/misc/virtchar1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -40,5 +40,4 @@
 #include <sys/types.h>
 #include <async.h>
-#include <unistd.h>
 #include <char_dev_iface.h>
 #include <str.h>
Index: uspace/app/tester/hw/serial/serial1.c
===================================================================
--- uspace/app/tester/hw/serial/serial1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/hw/serial/serial1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,6 +39,8 @@
 #include <stdlib.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <sys/types.h>
 #include <async.h>
+#include <thread.h>
 #include <ipc/services.h>
 #include <loc.h>
@@ -146,5 +148,5 @@
 		
 		if (read == 0)
-			usleep(DEFAULT_SLEEP);
+			thread_usleep(DEFAULT_SLEEP);
 		else {
 			buf[read] = 0;
Index: uspace/app/tester/mm/malloc1.c
===================================================================
--- uspace/app/tester/mm/malloc1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/mm/malloc1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -31,4 +31,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include "common.h"
 #include "../tester.h"
Index: uspace/app/tester/mm/malloc2.c
===================================================================
--- uspace/app/tester/mm/malloc2.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/mm/malloc2.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,6 +28,6 @@
 
 #include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <malloc.h>
 #include "../tester.h"
Index: uspace/app/tester/mm/malloc3.c
===================================================================
--- uspace/app/tester/mm/malloc3.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/mm/malloc3.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -31,4 +31,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
+#include <libarch/config.h>
 #include "common.h"
 #include "../tester.h"
Index: uspace/app/tester/mm/mapping1.c
===================================================================
--- uspace/app/tester/mm/mapping1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/mm/mapping1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,6 +28,6 @@
 
 #include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <malloc.h>
 #include <as.h>
Index: uspace/app/tester/print/print1.c
===================================================================
--- uspace/app/tester/print/print1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/print/print1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,5 +28,5 @@
 
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 #include "../tester.h"
 
Index: uspace/app/tester/print/print2.c
===================================================================
--- uspace/app/tester/print/print2.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/print/print2.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,5 +28,5 @@
 
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 #include "../tester.h"
 
Index: uspace/app/tester/print/print3.c
===================================================================
--- uspace/app/tester/print/print3.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/print/print3.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,5 +28,5 @@
 
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 #include <macros.h>
 #include "../tester.h"
Index: uspace/app/tester/print/print4.c
===================================================================
--- uspace/app/tester/print/print4.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/print/print4.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,5 +28,5 @@
 
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 #include "../tester.h"
 
Index: uspace/app/tester/print/print5.c
===================================================================
--- uspace/app/tester/print/print5.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/print/print5.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -40,5 +40,5 @@
 
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 #include "../tester.h"
 
Index: uspace/app/tester/print/print6.c
===================================================================
--- uspace/app/tester/print/print6.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/print/print6.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,5 +28,4 @@
 
 #include <stdio.h>
-#include <unistd.h>
 #include "../tester.h"
 
Index: uspace/app/tester/stdio/logger1.c
===================================================================
--- uspace/app/tester/stdio/logger1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/stdio/logger1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <errno.h>
 #include <io/log.h>
Index: uspace/app/tester/stdio/stdio1.c
===================================================================
--- uspace/app/tester/stdio/stdio1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/stdio/stdio1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <errno.h>
 #include "../tester.h"
Index: uspace/app/tester/stdio/stdio2.c
===================================================================
--- uspace/app/tester/stdio/stdio2.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/stdio/stdio2.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <errno.h>
 #include "../tester.h"
Index: uspace/app/tester/tester.c
===================================================================
--- uspace/app/tester/tester.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/tester.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,6 +36,6 @@
  */
 
-#include <unistd.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <str.h>
 #include <io/log.h>
Index: uspace/app/tester/thread/setjmp1.c
===================================================================
--- uspace/app/tester/thread/setjmp1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/thread/setjmp1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,5 @@
 #include <setjmp.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include "../tester.h"
 
Index: uspace/app/tester/thread/thread1.c
===================================================================
--- uspace/app/tester/thread/thread1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/thread/thread1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -34,5 +34,5 @@
 #include <thread.h>
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 #include <inttypes.h>
 #include "../tester.h"
@@ -46,5 +46,5 @@
 	
 	while (atomic_get(&finish))
-		usleep(100000);
+		thread_usleep(100000);
 	
 	atomic_inc(&threads_finished);
@@ -70,5 +70,5 @@
 	
 	TPRINTF("\nRunning threads for %u seconds...", DELAY);
-	sleep(DELAY);
+	thread_sleep(DELAY);
 	TPRINTF("\n");
 	
@@ -77,5 +77,5 @@
 		TPRINTF("Threads left: %" PRIua "\n",
 		    total - atomic_get(&threads_finished));
-		sleep(1);
+		thread_sleep(1);
 	}
 	
Index: uspace/app/tester/vfs/vfs1.c
===================================================================
--- uspace/app/tester/vfs/vfs1.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tester/vfs/vfs1.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,5 +32,4 @@
 #include <str.h>
 #include <vfs/vfs.h>
-#include <unistd.h>
 #include <dirent.h>
 #include <loc.h>
Index: uspace/app/testwrit/testwrit.c
===================================================================
--- uspace/app/testwrit/testwrit.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/testwrit/testwrit.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,5 +32,5 @@
 
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 
 #define BUF_SIZE  1024
Index: uspace/app/tetris/screen.c
===================================================================
--- uspace/app/tetris/screen.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tetris/screen.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -58,5 +58,4 @@
 #include <stdlib.h>
 #include <str.h>
-#include <unistd.h>
 #include <vfs/vfs.h>
 #include <async.h>
Index: uspace/app/tetris/shapes.c
===================================================================
--- uspace/app/tetris/shapes.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tetris/shapes.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -56,5 +56,4 @@
  */
 
-#include <unistd.h>
 #include "tetris.h"
 
Index: uspace/app/tetris/tetris.c
===================================================================
--- uspace/app/tetris/tetris.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tetris/tetris.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -61,6 +61,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <str.h>
-#include <unistd.h>
 #include <getopt.h>
 #include "scores.h"
Index: uspace/app/tetris/tetris.h
===================================================================
--- uspace/app/tetris/tetris.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/tetris/tetris.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -49,4 +49,6 @@
 /** @file
  */
+
+#include <stdint.h>
 
 /*
Index: uspace/app/top/top.c
===================================================================
--- uspace/app/top/top.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/top/top.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -38,5 +38,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <task.h>
 #include <thread.h>
Index: uspace/app/trace/syscalls.h
===================================================================
--- uspace/app/trace/syscalls.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/trace/syscalls.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,5 +37,5 @@
 
 #include <stdbool.h>
-#include <unistd.h>
+#include <stddef.h>
 
 #include "trace.h"
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/trace/trace.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <fibril.h>
 #include <errno.h>
Index: uspace/app/untar/tar.c
===================================================================
--- uspace/app/untar/tar.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/untar/tar.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,4 +35,5 @@
 #include <str.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <errno.h>
 #include <assert.h>
Index: uspace/app/usbinfo/dump.c
===================================================================
--- uspace/app/usbinfo/dump.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/usbinfo/dump.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,7 +37,8 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
+#include <stddef.h>
 #include <errno.h>
 #include <str_error.h>
-#include <stdbool.h>
 
 #include <usb/usb.h>
Index: uspace/app/vuhid/main.c
===================================================================
--- uspace/app/vuhid/main.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/app/vuhid/main.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,5 +37,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/dist/src/c/demos/edit/search.c
===================================================================
--- uspace/dist/src/c/demos/edit/search.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/dist/src/c/demos/edit/search.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,4 +36,5 @@
 
 #include <stdlib.h>
+#include <stddef.h>
 #include <errno.h>
 
Index: uspace/dist/src/c/demos/tetris/scores.c
===================================================================
--- uspace/dist/src/c/demos/tetris/scores.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/dist/src/c/demos/tetris/scores.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -232,4 +232,9 @@
 
 	f = fopen("/data/tetris.sco", "wb");
+	if (f == NULL) {
+		printf("Error creating table\n");
+		return;
+	}
+	
 	cnt = fwrite(scores, sizeof(struct highscore), NUMSPOTS, f);
 	rc = fclose(f);
Index: uspace/dist/src/c/demos/tetris/screen.c
===================================================================
--- uspace/dist/src/c/demos/tetris/screen.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/dist/src/c/demos/tetris/screen.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -58,5 +58,4 @@
 #include <stdlib.h>
 #include <str.h>
-#include <unistd.h>
 #include <vfs/vfs.h>
 #include <async.h>
Index: uspace/dist/src/c/demos/tetris/shapes.c
===================================================================
--- uspace/dist/src/c/demos/tetris/shapes.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/dist/src/c/demos/tetris/shapes.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -56,5 +56,4 @@
  */
 
-#include <unistd.h>
 #include "tetris.h"
 
Index: uspace/dist/src/c/demos/tetris/tetris.c
===================================================================
--- uspace/dist/src/c/demos/tetris/tetris.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/dist/src/c/demos/tetris/tetris.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -51,5 +51,5 @@
  */
 
-static const char copyright[] =
+static volatile const char copyright[] =
 	"@(#) Copyright (c) 1992, 1993\n"
 	"\tThe Regents of the University of California.  All rights reserved.\n";
@@ -61,6 +61,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <str.h>
-#include <unistd.h>
 #include <getopt.h>
 #include "scores.h"
Index: uspace/dist/src/c/demos/tetris/tetris.h
===================================================================
--- uspace/dist/src/c/demos/tetris/tetris.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/dist/src/c/demos/tetris/tetris.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -49,4 +49,6 @@
 /** @file
  */
+
+#include <stdint.h>
 
 /*
Index: uspace/dist/src/c/demos/top/top.c
===================================================================
--- uspace/dist/src/c/demos/top/top.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/dist/src/c/demos/top/top.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -38,5 +38,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <task.h>
 #include <thread.h>
Index: uspace/drv/audio/sb16/mixer.c
===================================================================
--- uspace/drv/audio/sb16/mixer.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/audio/sb16/mixer.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,5 +32,4 @@
 #include <libarch/ddi.h>
 #include <macros.h>
-#include <unistd.h>
 
 #include "ddf_log.h"
Index: uspace/drv/nic/ar9271/ar9271.c
===================================================================
--- uspace/drv/nic/ar9271/ar9271.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/nic/ar9271/ar9271.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -43,4 +43,5 @@
 #include <nic.h>
 #include <macros.h>
+#include <thread.h>
 #include "ath_usb.h"
 #include "wmi.h"
@@ -817,5 +818,5 @@
 	
 	/* Wait until firmware is ready - wait for 1 second to be sure. */
-	sleep(1);
+	thread_sleep(1);
 	
 	return rc;
Index: uspace/drv/nic/ar9271/hw.c
===================================================================
--- uspace/drv/nic/ar9271/hw.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/nic/ar9271/hw.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,4 @@
 #include <macros.h>
 #include <usb/debug.h>
-#include <unistd.h>
 #include <errno.h>
 #include <nic.h>
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/nic/e1k/e1k.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -38,4 +38,5 @@
 #include <adt/list.h>
 #include <align.h>
+#include <thread.h>
 #include <byteorder.h>
 #include <irc.h>
@@ -365,5 +366,5 @@
 		ctrl &= ~(CTRL_SLU);
 		fibril_mutex_unlock(&e1000->ctrl_lock);
-		usleep(10);
+		thread_usleep(10);
 		fibril_mutex_lock(&e1000->ctrl_lock);
 		ctrl |= CTRL_SLU;
@@ -1717,5 +1718,5 @@
 	
 	/* Wait for the reset */
-	usleep(20);
+	thread_usleep(20);
 	
 	/* check if RST_BIT cleared */
@@ -1805,5 +1806,5 @@
 	 * transfers to descriptors.
 	 */
-	usleep(100);
+	thread_usleep(100);
 	
 	return EOK;
@@ -2223,5 +2224,5 @@
 	uint32_t eerd = E1000_REG_READ(e1000, E1000_EERD);
 	while ((eerd & e1000->info.eerd_done) == 0) {
-		usleep(1);
+		thread_usleep(1);
 		eerd = E1000_REG_READ(e1000, E1000_EERD);
 	}
Index: uspace/drv/nic/ne2k/dp8390.c
===================================================================
--- uspace/drv/nic/ne2k/dp8390.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/nic/ne2k/dp8390.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -59,4 +59,5 @@
 #include <stdio.h>
 #include <ddi.h>
+#include <thread.h>
 #include "dp8390.h"
 
@@ -171,7 +172,7 @@
 	/* Reset the ethernet card */
 	uint8_t val = pio_read_8(ne2k->port + NE2K_RESET);
-	usleep(2000);
+	thread_usleep(2000);
 	pio_write_8(ne2k->port + NE2K_RESET, val);
-	usleep(2000);
+	thread_usleep(2000);
 	
 	/* Reset the DP8390 */
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/nic/rtl8139/driver.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,4 +30,5 @@
 #include <errno.h>
 #include <align.h>
+#include <thread.h>
 #include <byteorder.h>
 #include <libarch/barrier.h>
@@ -471,5 +472,5 @@
 	memory_barrier();
 	while(pio_read_8(io_base + CR) & CR_RST) {
-		usleep(1);
+		thread_usleep(1);
 		read_barrier();
 	}
Index: uspace/drv/nic/rtl8139/general.c
===================================================================
--- uspace/drv/nic/rtl8139/general.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/nic/rtl8139/general.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,4 @@
 
 #include <mem.h>
-#include <unistd.h>
 #include <errno.h>
 #include <stdint.h>
Index: uspace/drv/nic/rtl8139/general.h
===================================================================
--- uspace/drv/nic/rtl8139/general.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/nic/rtl8139/general.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,6 @@
 #define RTL8139_GENERAL_H_
 
-#include <unistd.h>
+#include <stddef.h>
+#include <time.h>
 
 /** Number of microseconds in second */
Index: uspace/drv/nic/rtl8169/driver.c
===================================================================
--- uspace/drv/nic/rtl8169/driver.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/drv/nic/rtl8169/driver.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,4 +35,5 @@
 
 #include <as.h>
+#include <thread.h>
 #include <ddf/log.h>
 #include <ddf/interrupt.h>
@@ -760,5 +761,5 @@
 	memory_barrier();
 	while (pio_read_8(rtl8169->regs + CR) & CR_RST) {
-		usleep(1);
+		thread_usleep(1);
 		read_barrier();
 	}
@@ -1174,5 +1175,5 @@
 	do {
 		phyar = pio_read_32(rtl8169->regs + PHYAR);
-		usleep(20);
+		thread_usleep(20);
 	} while ((phyar & PHYAR_RW_WRITE) == 0);
 
@@ -1192,8 +1193,8 @@
 	do {
 		phyar = pio_read_32(rtl8169->regs + PHYAR);
-		usleep(20);
+		thread_usleep(20);
 	} while ((phyar & PHYAR_RW_WRITE) != 0);
 
-	usleep(20);
+	thread_usleep(20);
 }
 
Index: uspace/lib/bithenge/src/failure.c
===================================================================
--- uspace/lib/bithenge/src/failure.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/bithenge/src/failure.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -43,5 +43,4 @@
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <unistd.h>
 #define BITHENGE_FAILURE_DECLS_ONLY 1
 #include "failure.h"
Index: uspace/lib/bithenge/src/failure.h
===================================================================
--- uspace/lib/bithenge/src/failure.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/bithenge/src/failure.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -43,5 +43,4 @@
 #include <stdlib.h>
 #include <sys/types.h>
-#include <unistd.h>
 
 int bithenge_should_fail(void);
Index: uspace/lib/bithenge/src/file.c
===================================================================
--- uspace/lib/bithenge/src/file.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/bithenge/src/file.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -42,5 +42,4 @@
 #include <vfs/vfs.h>
 #include <sys/types.h>
-#include <unistd.h>
 #include "common.h"
 #include <bithenge/blob.h>
Index: uspace/lib/bithenge/src/helenos/common.h
===================================================================
--- uspace/lib/bithenge/src/helenos/common.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/bithenge/src/helenos/common.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,4 +32,6 @@
 #include <bithenge/os.h>
 #include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
 #include <byteorder.h>
 #include <errno.h>
@@ -37,5 +39,4 @@
 #include <macros.h>
 #include <mem.h>
-#include <stdlib.h>
 #include <str.h>
 #include <str_error.h>
Index: uspace/lib/c/arch/abs32le/include/libarch/tls.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/libarch/tls.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/abs32le/include/libarch/tls.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,5 +39,4 @@
 
 #include <libc.h>
-#include <unistd.h>
 
 typedef struct {
Index: uspace/lib/c/arch/abs32le/src/entry.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/entry.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/abs32le/src/entry.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,4 @@
  */
 
-#include <unistd.h>
 #include <libarch/entry.h>
 #include "../../../generic/private/libc.h"
Index: uspace/lib/c/arch/abs32le/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/stacktrace.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/abs32le/src/stacktrace.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -31,5 +31,4 @@
 
 #include <sys/types.h>
-#include <unistd.h>
 #include <stdbool.h>
 #include <stacktrace.h>
Index: uspace/lib/c/arch/abs32le/src/thread_entry.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/thread_entry.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/abs32le/src/thread_entry.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,4 @@
  */
 
-#include <unistd.h>
 #include "../../../generic/private/thread.h"
 
Index: uspace/lib/c/arch/abs32le/src/tls.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/tls.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/abs32le/src/tls.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,5 +32,4 @@
 #include <tls.h>
 #include <sys/types.h>
-#include <unistd.h>
 
 tcb_t * tls_alloc_arch(void **data, size_t size)
Index: uspace/lib/c/arch/riscv64/include/libarch/tls.h
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/tls.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/riscv64/include/libarch/tls.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,5 +39,4 @@
 
 #include <libc.h>
-#include <unistd.h>
 
 typedef struct {
Index: uspace/lib/c/arch/riscv64/src/entry.c
===================================================================
--- uspace/lib/c/arch/riscv64/src/entry.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/riscv64/src/entry.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,4 @@
  */
 
-#include <unistd.h>
 #include <libarch/entry.h>
 #include "../../../generic/private/libc.h"
Index: uspace/lib/c/arch/riscv64/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/riscv64/src/stacktrace.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/riscv64/src/stacktrace.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -31,5 +31,4 @@
 
 #include <sys/types.h>
-#include <unistd.h>
 #include <stdbool.h>
 #include <stacktrace.h>
Index: uspace/lib/c/arch/riscv64/src/thread_entry.c
===================================================================
--- uspace/lib/c/arch/riscv64/src/thread_entry.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/riscv64/src/thread_entry.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,4 @@
  */
 
-#include <unistd.h>
 #include "../../../generic/private/thread.h"
 
Index: uspace/lib/c/arch/riscv64/src/tls.c
===================================================================
--- uspace/lib/c/arch/riscv64/src/tls.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/arch/riscv64/src/tls.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,5 +32,4 @@
 #include <tls.h>
 #include <sys/types.h>
-#include <unistd.h>
 
 tcb_t *tls_alloc_arch(void **data, size_t size)
Index: uspace/lib/c/generic/adt/hash_table.c
===================================================================
--- uspace/lib/c/generic/adt/hash_table.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/adt/hash_table.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -51,5 +51,4 @@
 #include <adt/hash_table.h>
 #include <adt/list.h>
-#include <unistd.h>
 #include <malloc.h>
 #include <assert.h>
Index: uspace/lib/c/generic/as.c
===================================================================
--- uspace/lib/c/generic/as.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/as.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,5 +36,4 @@
 #include <libc.h>
 #include <errno.h>
-#include <unistd.h>
 #include <align.h>
 #include <sys/types.h>
Index: uspace/lib/c/generic/config.c
===================================================================
--- uspace/lib/c/generic/config.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/config.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,5 @@
 #include <stdlib.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <config.h>
 #include <sysinfo.h>
Index: uspace/lib/c/generic/ddi.c
===================================================================
--- uspace/lib/c/generic/ddi.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/ddi.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,4 @@
 #include <assert.h>
 #include <atomic.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
Index: uspace/lib/c/generic/dlfcn.c
===================================================================
--- uspace/lib/c/generic/dlfcn.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/dlfcn.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,4 +37,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <dlfcn.h>
 
Index: uspace/lib/c/generic/double_to_str.c
===================================================================
--- uspace/lib/c/generic/double_to_str.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/double_to_str.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -33,6 +33,7 @@
 
 #include <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
 #include <assert.h>
-#include <stdbool.h>
 
 /*
Index: uspace/lib/c/generic/fibril.c
===================================================================
--- uspace/lib/c/generic/fibril.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/fibril.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -42,5 +42,4 @@
 #include <abi/mm/as.h>
 #include <as.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <libarch/barrier.h>
Index: uspace/lib/c/generic/getopt.c
===================================================================
--- uspace/lib/c/generic/getopt.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/getopt.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -34,8 +34,9 @@
 #include <assert.h>
 #include <stdarg.h>
+#include <stdlib.h>
+#include <stddef.h>
 #include <err.h>
 #include <errno.h>
 #include <getopt.h>
-#include <stdlib.h>
 #include <str.h>
 
Index: uspace/lib/c/generic/inet/addr.c
===================================================================
--- uspace/lib/c/generic/inet/addr.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/inet/addr.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,7 +36,7 @@
 #include <assert.h>
 #include <errno.h>
-#include <unistd.h>
 #include <inet/addr.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <malloc.h>
 #include <bitops.h>
Index: uspace/lib/c/generic/inet/hostname.c
===================================================================
--- uspace/lib/c/generic/inet/hostname.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/inet/hostname.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,4 +37,5 @@
 #include <inet/hostname.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <str.h>
 
Index: uspace/lib/c/generic/io/asprintf.c
===================================================================
--- uspace/lib/c/generic/io/asprintf.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/io/asprintf.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,4 +37,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <str.h>
 #include <io/printf_core.h>
Index: uspace/lib/c/generic/io/chargrid.c
===================================================================
--- uspace/lib/c/generic/io/chargrid.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/io/chargrid.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,7 +35,7 @@
 #include <io/style.h>
 #include <malloc.h>
-#include <unistd.h>
 #include <assert.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <as.h>
 #include <io/chargrid.h>
Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/io/io.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -34,5 +34,4 @@
 
 #include <stdio.h>
-#include <unistd.h>
 #include <assert.h>
 #include <str.h>
Index: uspace/lib/c/generic/io/kio.c
===================================================================
--- uspace/lib/c/generic/io/kio.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/io/kio.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -34,8 +34,8 @@
  */
 
+#include <stddef.h>
 #include <libc.h>
 #include <str.h>
 #include <sys/types.h>
-#include <unistd.h>
 #include <errno.h>
 #include <abi/kio.h>
Index: uspace/lib/c/generic/io/klog.c
===================================================================
--- uspace/lib/c/generic/io/klog.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/io/klog.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,5 +36,4 @@
 #include <str.h>
 #include <sys/types.h>
-#include <unistd.h>
 #include <errno.h>
 #include <abi/klog.h>
Index: uspace/lib/c/generic/io/logctl.c
===================================================================
--- uspace/lib/c/generic/io/logctl.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/io/logctl.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,5 +32,4 @@
 
 #include <assert.h>
-#include <unistd.h>
 #include <errno.h>
 #include <io/logctl.h>
Index: uspace/lib/c/generic/io/printf_core.c
===================================================================
--- uspace/lib/c/generic/io/printf_core.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/io/printf_core.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,6 +37,6 @@
  */
 
-#include <unistd.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <io/printf_core.h>
 #include <ctype.h>
Index: uspace/lib/c/generic/io/vprintf.c
===================================================================
--- uspace/lib/c/generic/io/vprintf.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/io/vprintf.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,4 @@
 #include <stdarg.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <io/printf_core.h>
 #include <fibril_synch.h>
Index: uspace/lib/c/generic/irq.c
===================================================================
--- uspace/lib/c/generic/irq.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/irq.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,4 +36,5 @@
 #include <libc.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <macros.h>
 
Index: uspace/lib/c/generic/malloc.c
===================================================================
--- uspace/lib/c/generic/malloc.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/malloc.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,4 +36,5 @@
 #include <malloc.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <as.h>
 #include <align.h>
Index: uspace/lib/c/generic/rcu.c
===================================================================
--- uspace/lib/c/generic/rcu.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/rcu.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -70,4 +70,5 @@
 #include <fibril.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <compiler/barrier.h>
 #include <libarch/barrier.h>
@@ -79,4 +80,5 @@
 #include <assert.h>
 #include <time.h>
+#include <thread.h>
 
 
@@ -428,5 +430,5 @@
 		async_usleep(RCU_SLEEP_MS * 1000);
 	} else {
-		usleep(RCU_SLEEP_MS * 1000);
+		thread_usleep(RCU_SLEEP_MS * 1000);
 	}
 		
Index: uspace/lib/c/generic/rtld/module.c
===================================================================
--- uspace/lib/c/generic/rtld/module.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/rtld/module.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -41,5 +41,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 
 #include <rtld/rtld.h>
Index: uspace/lib/c/generic/stacktrace.c
===================================================================
--- uspace/lib/c/generic/stacktrace.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/stacktrace.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,7 +36,7 @@
 #include <stacktrace.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <sys/types.h>
 #include <errno.h>
-#include <unistd.h>
 
 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
Index: uspace/lib/c/generic/stats.c
===================================================================
--- uspace/lib/c/generic/stats.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/stats.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -40,5 +40,4 @@
 #include <inttypes.h>
 #include <malloc.h>
-#include <unistd.h>
 
 #define SYSINFO_STATS_MAX_PATH  64
Index: uspace/lib/c/generic/str.c
===================================================================
--- uspace/lib/c/generic/str.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/str.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -38,4 +38,5 @@
 #include <str.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <assert.h>
 #include <stdint.h>
Index: uspace/lib/c/generic/sysinfo.c
===================================================================
--- uspace/lib/c/generic/sysinfo.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/sysinfo.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,5 +39,5 @@
 #include <malloc.h>
 #include <stdbool.h>
-#include <unistd.h>
+#include <stddef.h>
 
 /** Get sysinfo keys size
Index: uspace/lib/c/generic/task.c
===================================================================
--- uspace/lib/c/generic/task.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/task.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -48,5 +48,4 @@
 #include "private/ns.h"
 #include <vfs/vfs.h>
-#include <unistd.h>
 
 task_id_t task_get_id(void)
Index: uspace/lib/c/generic/thread.c
===================================================================
--- uspace/lib/c/generic/thread.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/thread.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -196,4 +196,33 @@
 }
 
+/** Wait unconditionally for specified number of microseconds
+ *
+ */
+int thread_usleep(useconds_t usec)
+{
+	(void) __SYSCALL1(SYS_THREAD_USLEEP, usec);
+	return 0;
+}
+
+/** Wait unconditionally for specified number of seconds
+ *
+ */
+unsigned int thread_sleep(unsigned int sec)
+{
+	/*
+	 * Sleep in 1000 second steps to support
+	 * full argument range
+	 */
+	
+	while (sec > 0) {
+		unsigned int period = (sec > 1000) ? 1000 : sec;
+		
+		thread_usleep(period * 1000000);
+		sec -= period;
+	}
+	
+	return 0;
+}
+
 /** @}
  */
Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/time.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -49,8 +49,8 @@
 #include <ctype.h>
 #include <assert.h>
-#include <unistd.h>
 #include <loc.h>
 #include <device/clock_dev.h>
 #include <malloc.h>
+#include <thread.h>
 
 #define ASCTIME_BUF_LEN  26
@@ -685,37 +685,7 @@
 }
 
-/** Wait unconditionally for specified number of microseconds
- *
- */
-int usleep(useconds_t usec)
-{
-	(void) __SYSCALL1(SYS_THREAD_USLEEP, usec);
-	return 0;
-}
-
 void udelay(useconds_t time)
 {
 	(void) __SYSCALL1(SYS_THREAD_UDELAY, (sysarg_t) time);
-}
-
-
-/** Wait unconditionally for specified number of seconds
- *
- */
-unsigned int sleep(unsigned int sec)
-{
-	/*
-	 * Sleep in 1000 second steps to support
-	 * full argument range
-	 */
-	
-	while (sec > 0) {
-		unsigned int period = (sec > 1000) ? 1000 : sec;
-		
-		usleep(period * 1000000);
-		sec -= period;
-	}
-	
-	return 0;
 }
 
Index: uspace/lib/c/generic/tls.c
===================================================================
--- uspace/lib/c/generic/tls.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/tls.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,9 +36,9 @@
  */
 
+#include <stddef.h>
 #include <align.h>
 #include <tls.h>
 #include <malloc.h>
 #include <str.h>
-#include <unistd.h>
 
 #ifdef CONFIG_RTLD
Index: uspace/lib/c/generic/uuid.c
===================================================================
--- uspace/lib/c/generic/uuid.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/uuid.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,4 +36,6 @@
 #include <uuid.h>
 #include <stdlib.h>
+#include <stddef.h>
+#include <time.h>
 #include <str.h>
 
Index: uspace/lib/c/generic/vfs/canonify.c
===================================================================
--- uspace/lib/c/generic/vfs/canonify.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/generic/vfs/canonify.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,4 +37,5 @@
 
 #include <stdlib.h>
+#include <stddef.h>
 #include <vfs/canonify.h>
 
Index: uspace/lib/c/include/adt/hash_table.h
===================================================================
--- uspace/lib/c/include/adt/hash_table.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/include/adt/hash_table.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,5 +39,4 @@
 
 #include <adt/list.h>
-#include <unistd.h>
 #include <stdbool.h>
 #include <macros.h>
Index: uspace/lib/c/include/double_to_str.h
===================================================================
--- uspace/lib/c/include/double_to_str.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/include/double_to_str.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,5 @@
 #define DOUBLE_TO_STR_H_
 
-#include <unistd.h>
+#include <stddef.h>
 
 /** Maximum number of digits double_to_*_str conversion functions produce. 
Index: uspace/lib/c/include/getopt.h
===================================================================
--- uspace/lib/c/include/getopt.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/include/getopt.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,6 +35,4 @@
 #define _GETOPT_H_
 
-#include <unistd.h>
-
 /*
  * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
Index: uspace/lib/c/include/io/pixelmap.h
===================================================================
--- uspace/lib/c/include/io/pixelmap.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/include/io/pixelmap.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,5 +39,5 @@
 
 #include <sys/types.h>
-#include <unistd.h>
+#include <stddef.h>
 #include <io/pixel.h>
 
Index: uspace/lib/c/include/ipc/dev_iface.h
===================================================================
--- uspace/lib/c/include/ipc/dev_iface.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/include/ipc/dev_iface.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -31,5 +31,4 @@
 
 #include <malloc.h>
-#include <unistd.h>
 #include <libarch/types.h>
 
Index: uspace/lib/c/include/stdlib.h
===================================================================
--- uspace/lib/c/include/stdlib.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/include/stdlib.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,5 +36,4 @@
 #define LIBC_STDLIB_H_
 
-#include <unistd.h>
 #include <malloc.h>
 #include <stacktrace.h>
Index: uspace/lib/c/include/thread.h
===================================================================
--- uspace/lib/c/include/thread.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/c/include/thread.h	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,4 +39,5 @@
 #include <sys/types.h>
 #include <abi/proc/thread.h>
+#include <time.h>
 
 extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *);
@@ -45,4 +46,6 @@
 extern int thread_join(thread_id_t);
 extern thread_id_t thread_get_id(void);
+extern int thread_usleep(useconds_t);
+extern unsigned int thread_sleep(unsigned int);
 
 #endif
Index: pace/lib/c/include/unistd.h
===================================================================
--- uspace/lib/c/include/unistd.h	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ 	(revision )
@@ -1,54 +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.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_UNISTD_H_
-#define LIBC_UNISTD_H_
-
-#include <sys/types.h>
-#include <time.h>
-#include <libarch/config.h>
-
-#ifndef NULL
-	#define NULL  ((void *) 0)
-#endif
-
-#define getpagesize()  (PAGE_SIZE)
-
-extern int usleep(useconds_t);
-extern unsigned int sleep(unsigned int);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/compress/gzip.c
===================================================================
--- uspace/lib/compress/gzip.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/compress/gzip.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -28,8 +28,8 @@
 
 #include <sys/types.h>
+#include <stddef.h>
 #include <errno.h>
 #include <mem.h>
 #include <malloc.h>
-#include <unistd.h>
 #include <byteorder.h>
 #include "gzip.h"
Index: uspace/lib/crypto/crypto.c
===================================================================
--- uspace/lib/crypto/crypto.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/crypto/crypto.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -32,5 +32,4 @@
  */
 
-#include <unistd.h>
 #include <str.h>
 #include <macros.h>
Index: uspace/lib/drv/generic/dev_iface.c
===================================================================
--- uspace/lib/drv/generic/dev_iface.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/drv/generic/dev_iface.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,4 +37,5 @@
 
 #include <assert.h>
+#include <stddef.h>
 
 #include "dev_iface.h"
Index: uspace/lib/drv/generic/logbuf.c
===================================================================
--- uspace/lib/drv/generic/logbuf.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/drv/generic/logbuf.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -33,7 +33,7 @@
 #include <libarch/common.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <ddf/log.h>
 #include <assert.h>
-#include <unistd.h>
 
 /** Formatting string for printing number of not-printed items. */
Index: uspace/lib/pcut/src/os/helenos.c
===================================================================
--- uspace/lib/pcut/src/os/helenos.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/pcut/src/os/helenos.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,4 @@
 #include <str.h>
 #include <str_error.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <errno.h>
Index: uspace/lib/pcut/tests/timeout.c
===================================================================
--- uspace/lib/pcut/tests/timeout.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/pcut/tests/timeout.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -30,5 +30,6 @@
 
 #ifdef __unix
-#include <unistd.h>
+// FIXME
+#include <thread.h>
 #endif
 #if defined(__WIN64) || defined(__WIN32) || defined(_WIN32)
@@ -41,5 +42,6 @@
 static void my_sleep(int sec) {
 #ifdef __unix
-	sleep(sec);
+// FIXME
+	thread_sleep(sec);
 #endif
 #if defined(__WIN64) || defined(__WIN32) || defined(_WIN32)
Index: uspace/lib/posix/source/fcntl.c
===================================================================
--- uspace/lib/posix/source/fcntl.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/posix/source/fcntl.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,5 +39,4 @@
 #include "posix/fcntl.h"
 
-#include "libc/unistd.h"
 #include "libc/vfs/vfs.h"
 #include "posix/errno.h"
Index: uspace/lib/posix/source/time.c
===================================================================
--- uspace/lib/posix/source/time.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/posix/source/time.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -49,4 +49,6 @@
 #include "libc/stats.h"
 #include "libc/stdbool.h"
+#include "libc/stddef.h"
+#include "libc/thread.h"
 #include "libc/sys/time.h"
 
@@ -313,8 +315,8 @@
 			// TODO: interruptible sleep
 			if (rqtp->tv_sec != 0) {
-				sleep(rqtp->tv_sec);
+				thread_sleep(rqtp->tv_sec);
 			}
 			if (rqtp->tv_nsec != 0) {
-				usleep(rqtp->tv_nsec / 1000);
+				thread_usleep(rqtp->tv_nsec / 1000);
 			}
 			return 0;
Index: uspace/lib/posix/source/unistd.c
===================================================================
--- uspace/lib/posix/source/unistd.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/posix/source/unistd.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -49,4 +49,6 @@
 #include "libc/vfs/vfs.h"
 
+#include <libarch/config.h>
+
 aoff64_t posix_pos[MAX_OPEN_FILES];
 
@@ -134,5 +136,5 @@
 int posix_getpagesize(void)
 {
-	return getpagesize();
+	return PAGE_SIZE;
 }
 
@@ -384,6 +386,6 @@
 	stats_physmem_t *mem_stats = stats_get_physmem();
 	if (mem_stats) {
-		phys_pages = (long) (mem_stats->total / getpagesize());
-		avphys_pages = (long) (mem_stats->free / getpagesize());
+		phys_pages = (long) (mem_stats->total / posix_getpagesize());
+		avphys_pages = (long) (mem_stats->free / posix_getpagesize());
 		free(mem_stats);
 		mem_stats = 0;
@@ -396,5 +398,5 @@
 		return avphys_pages;
 	case _SC_PAGESIZE:
-		return getpagesize();
+		return posix_getpagesize();
 	case _SC_CLK_TCK:
 		return clk_tck;
Index: uspace/lib/scsi/src/spc.c
===================================================================
--- uspace/lib/scsi/src/spc.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/scsi/src/spc.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -29,4 +29,5 @@
 #include <stdint.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include "scsi/spc.h"
 
Index: uspace/lib/uri/uri.c
===================================================================
--- uspace/lib/uri/uri.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/uri/uri.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -36,4 +36,5 @@
 #include <assert.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <str.h>
 #include <ctype.h>
Index: uspace/lib/usb/src/dump.c
===================================================================
--- uspace/lib/usb/src/dump.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/usb/src/dump.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,4 +35,5 @@
 #include <stdlib.h>
 #include <stdio.h>
+#include <stddef.h>
 #include <usb/debug.h>
 #include <usb/descriptor.h>
Index: uspace/lib/usbdev/src/altiface.c
===================================================================
--- uspace/lib/usbdev/src/altiface.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/usbdev/src/altiface.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -39,4 +39,5 @@
 #include <errno.h>
 #include <stdlib.h>
+#include <stddef.h>
 
 /** Count number of alternate settings of a interface.
Index: uspace/lib/usbdev/src/dp.c
===================================================================
--- uspace/lib/usbdev/src/dp.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/lib/usbdev/src/dp.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -48,4 +48,5 @@
 #include <stdlib.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <sys/types.h>
 
Index: uspace/srv/bd/file_bd/file_bd.c
===================================================================
--- uspace/srv/bd/file_bd/file_bd.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/bd/file_bd/file_bd.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -40,5 +40,4 @@
 
 #include <stdio.h>
-#include <unistd.h>
 #include <async.h>
 #include <as.h>
Index: uspace/srv/fs/exfat/exfat.c
===================================================================
--- uspace/srv/fs/exfat/exfat.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/fs/exfat/exfat.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -43,5 +43,4 @@
 #include <async.h>
 #include <errno.h>
-#include <unistd.h>
 #include <task.h>
 #include <stdio.h>
Index: uspace/srv/fs/fat/fat.c
===================================================================
--- uspace/srv/fs/fat/fat.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/fs/fat/fat.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -43,5 +43,4 @@
 #include <async.h>
 #include <errno.h>
-#include <unistd.h>
 #include <task.h>
 #include <stdio.h>
Index: uspace/srv/fs/fat/fat_dentry.c
===================================================================
--- uspace/srv/fs/fat/fat_dentry.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/fs/fat/fat_dentry.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -43,5 +43,5 @@
 #include <byteorder.h>
 #include <assert.h>
-#include <unistd.h>
+#include <stddef.h>
 #include <sys/types.h>
 
Index: uspace/srv/fs/mfs/mfs.c
===================================================================
--- uspace/srv/fs/mfs/mfs.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/fs/mfs/mfs.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -44,5 +44,4 @@
 #include <async.h>
 #include <errno.h>
-#include <unistd.h>
 #include <task.h>
 #include <stdio.h>
Index: uspace/srv/fs/tmpfs/tmpfs.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/fs/tmpfs/tmpfs.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -46,5 +46,4 @@
 #include <async.h>
 #include <errno.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <task.h>
Index: uspace/srv/fs/udf/udf.c
===================================================================
--- uspace/srv/fs/udf/udf.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/fs/udf/udf.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -41,5 +41,4 @@
 #include <async.h>
 #include <errno.h>
-#include <unistd.h>
 #include <task.h>
 #include <libfs.h>
Index: uspace/srv/hid/input/input.c
===================================================================
--- uspace/srv/hid/input/input.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/hid/input/input.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -44,5 +44,4 @@
 #include <config.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <ns.h>
Index: uspace/srv/hid/input/port/niagara.c
===================================================================
--- uspace/srv/hid/input/port/niagara.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/hid/input/port/niagara.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -135,5 +135,5 @@
 	while (1) {
 		niagara_key_pressed();
-		usleep(POLL_INTERVAL);
+		thread_usleep(POLL_INTERVAL);
 	}
 }
Index: uspace/srv/hid/input/port/ski.c
===================================================================
--- uspace/srv/hid/input/port/ski.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/hid/input/port/ski.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -37,5 +37,4 @@
 
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <thread.h>
@@ -97,5 +96,5 @@
 		}
 
-		usleep(POLL_INTERVAL);
+		thread_usleep(POLL_INTERVAL);
 	}
 }
Index: uspace/srv/hid/isdv4_tablet/isdv4.c
===================================================================
--- uspace/srv/hid/isdv4_tablet/isdv4.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/hid/isdv4_tablet/isdv4.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -31,4 +31,5 @@
 #include <stdlib.h>
 #include <mem.h>
+#include <thread.h>
 
 #include "isdv4.h"
@@ -377,5 +378,5 @@
 		return EIO;
 
-	usleep(250000); /* 250 ms */
+	thread_usleep(250000); /* 250 ms */
 
 	// FIXME: Read all possible garbage before sending commands
Index: uspace/srv/hid/output/proto/vt100.c
===================================================================
--- uspace/srv/hid/output/proto/vt100.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/hid/output/proto/vt100.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -34,5 +34,5 @@
 #include <errno.h>
 #include <stdio.h>
-#include <unistd.h>
+#include <stddef.h>
 #include <malloc.h>
 #include <io/color.h>
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -43,5 +43,4 @@
 #include <ipc/mouseev.h>
 #include <async.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -41,5 +41,4 @@
 #include <ipc/char.h>
 #include <async.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/loader/main.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -46,5 +46,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <stdbool.h>
 #include <sys/types.h>
Index: uspace/srv/logger/ctl.c
===================================================================
--- uspace/srv/logger/ctl.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/logger/ctl.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -35,5 +35,4 @@
  */
 
-#include <unistd.h>
 #include <malloc.h>
 #include <stdio.h>
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 73db198fc789c011416723b1513d3e3943f91afa)
+++ uspace/srv/vfs/vfs_ops.c	(revision 582a0b84b0a73672531e7b404a89997af41ba0b9)
@@ -47,5 +47,4 @@
 #include <fibril_synch.h>
 #include <adt/list.h>
-#include <unistd.h>
 #include <ctype.h>
 #include <assert.h>
