Index: uspace/lib/posix/src/internal/common.h
===================================================================
--- uspace/lib/posix/src/internal/common.h	(revision 9d8307a94aa6d903e4fcaa8ae5c22e2fa48fddfb)
+++ uspace/lib/posix/src/internal/common.h	(revision e43d658b7c92a48bfe62de06cc5d15fdb1395c2f)
@@ -38,4 +38,5 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <errno.h>
 #include <offset.h>
 #include <vfs/vfs.h>
Index: uspace/lib/posix/src/time.c
===================================================================
--- uspace/lib/posix/src/time.c	(revision 9d8307a94aa6d903e4fcaa8ae5c22e2fa48fddfb)
+++ uspace/lib/posix/src/time.c	(revision e43d658b7c92a48bfe62de06cc5d15fdb1395c2f)
@@ -35,4 +35,6 @@
 
 #include "internal/common.h"
+#include "posix/sys/types.h"
+#include "posix/sys/time.h"
 #include "posix/time.h"
 
@@ -47,7 +49,6 @@
 #include "libc/malloc.h"
 #include "libc/task.h"
-#include "libc/stats.h"
 #include "libc/stddef.h"
-#include "libc/sys/time.h"
+#include "libc/time.h"
 
 // TODO: test everything in this file
@@ -219,5 +220,5 @@
 	case CLOCK_REALTIME:
 		res->tv_sec = 0;
-		res->tv_nsec = 1000; /* Microsecond resolution. */
+		res->tv_nsec = USEC2NSEC(1); /* Microsecond resolution. */
 		return 0;
 	default:
@@ -244,5 +245,5 @@
 		gettimeofday(&tv, NULL);
 		tp->tv_sec = tv.tv_sec;
-		tp->tv_nsec = tv.tv_usec * 1000;
+		tp->tv_nsec = USEC2NSEC(tv.tv_usec);
 		return 0;
 	default:
@@ -300,5 +301,5 @@
 		}
 		if (rqtp->tv_nsec != 0) {
-			fibril_usleep(rqtp->tv_nsec / 1000);
+			fibril_usleep(NSEC2USEC(rqtp->tv_nsec));
 		}
 		return 0;
@@ -309,21 +310,13 @@
 }
 
-/**
- * Get CPU time used since the process invocation.
- *
- * @return Consumed CPU cycles by this process or -1 if not available.
- */
-clock_t clock(void)
-{
-	clock_t total_cycles = -1;
-	stats_task_t *task_stats = stats_get_task(task_get_id());
-	if (task_stats) {
-		total_cycles = (clock_t) (task_stats->kcycles +
-		    task_stats->ucycles);
-		free(task_stats);
-		task_stats = 0;
-	}
-
-	return total_cycles;
+int gettimeofday(struct timeval *tv, void *tz)
+{
+	struct timespec ts;
+
+	getrealtime(&ts);
+	tv->tv_sec = ts.tv_sec;
+	tv->tv_usec = NSEC2USEC(ts.tv_nsec);
+
+	return 0;
 }
 
