Index: uspace/app/barber/barber.c
===================================================================
--- uspace/app/barber/barber.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/barber/barber.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -130,5 +130,5 @@
 }
 
-static void plan_frame_timer(suseconds_t render_time)
+static void plan_frame_timer(usec_t render_time)
 {
 	/*
@@ -139,5 +139,5 @@
 	 */
 
-	suseconds_t delta = 1000000 / fps;
+	usec_t delta = 1000000 / fps;
 	load_t load = get_load();
 
@@ -190,5 +190,5 @@
 static void frame_timer_callback(void *data)
 {
-	struct timeval prev;
+	struct timespec prev;
 	getuptime(&prev);
 
@@ -199,8 +199,8 @@
 	update_canvas(frame_canvas, frames[frame]);
 
-	struct timeval cur;
+	struct timespec cur;
 	getuptime(&cur);
 
-	plan_frame_timer(tv_sub_diff(&cur, &prev));
+	plan_frame_timer(NSEC2USEC(ts_sub_diff(&cur, &prev)));
 }
 
Index: uspace/app/bdsh/cmds/modules/sleep/sleep.c
===================================================================
--- uspace/app/bdsh/cmds/modules/sleep/sleep.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/bdsh/cmds/modules/sleep/sleep.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -57,5 +57,5 @@
 }
 
-/** Convert string containing decimal seconds to useconds_t.
+/** Convert string containing decimal seconds to usec_t.
  *
  * @param nptr   Pointer to string.
@@ -63,9 +63,9 @@
  * @return EOK if conversion was successful.
  */
-static errno_t decimal_to_useconds(const char *nptr, useconds_t *result)
+static errno_t decimal_to_useconds(const char *nptr, usec_t *result)
 {
 	errno_t ret;
-	uint64_t whole_seconds;
-	uint64_t frac_seconds;
+	sec_t whole_seconds;
+	usec_t frac_seconds;
 	const char *endptr;
 
@@ -75,5 +75,5 @@
 		endptr = (char *)nptr;
 	} else {
-		ret = str_uint64_t(nptr, &endptr, 10, false, &whole_seconds);
+		ret = str_int64_t(nptr, &endptr, 10, false, &whole_seconds);
 		if (ret != EOK)
 			return ret;
@@ -87,5 +87,5 @@
 	} else if (*endptr == '.') {
 		nptr = endptr + 1;
-		ret = str_uint64_t(nptr, &endptr, 10, true, &frac_seconds);
+		ret = str_int64_t(nptr, &endptr, 10, true, &frac_seconds);
 		if (ret != EOK)
 			return ret;
@@ -101,6 +101,6 @@
 
 	/* Check for overflow */
-	useconds_t total = whole_seconds * 1000000 + frac_seconds;
-	if (total / 1000000 != whole_seconds)
+	usec_t total = SEC2USEC(whole_seconds) + frac_seconds;
+	if (USEC2SEC(total) != whole_seconds)
 		return EOVERFLOW;
 
@@ -115,5 +115,5 @@
 	errno_t ret;
 	unsigned int argc;
-	useconds_t duration = 0;
+	usec_t duration = 0;
 
 	/* Count the arguments */
Index: uspace/app/bnchmark/bnchmark.c
===================================================================
--- uspace/app/bnchmark/bnchmark.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/bnchmark/bnchmark.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -56,12 +56,11 @@
 
 typedef errno_t (*measure_func_t)(void *);
-typedef unsigned long umseconds_t; /* milliseconds */
 
 static void syntax_print(void);
 
-static errno_t measure(measure_func_t fn, void *data, umseconds_t *result)
-{
-	struct timeval start_time;
-	gettimeofday(&start_time, NULL);
+static errno_t measure(measure_func_t fn, void *data, msec_t *result)
+{
+	struct timespec start_time;
+	getuptime(&start_time);
 
 	errno_t rc = fn(data);
@@ -71,10 +70,9 @@
 	}
 
-	struct timeval final_time;
-	gettimeofday(&final_time, NULL);
+	struct timespec final_time;
+	getuptime(&final_time);
 
 	/* Calculate time difference in milliseconds */
-	*result = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
-	    ((final_time.tv_sec - start_time.tv_sec) * 1000);
+	*result = NSEC2USEC(ts_sub_diff(&final_time, &start_time));
 	return EOK;
 }
@@ -133,5 +131,5 @@
 {
 	errno_t rc;
-	umseconds_t milliseconds_taken = 0;
+	msec_t milliseconds_taken = 0;
 	char *path = NULL;
 	measure_func_t fn = NULL;
@@ -194,5 +192,5 @@
 		}
 
-		printf("%s;%s;%s;%lu;ms\n", test_type, path, log_str, milliseconds_taken);
+		printf("%s;%s;%s;%lld;ms\n", test_type, path, log_str, milliseconds_taken);
 	}
 
Index: uspace/app/modplay/modplay.c
===================================================================
--- uspace/app/modplay/modplay.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/modplay/modplay.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -75,5 +75,5 @@
 	console_ctrl_t *con;
 	cons_event_t event;
-	suseconds_t timeout;
+	usec_t timeout;
 	pcm_format_t format;
 	void *buffer;
Index: uspace/app/stats/stats.c
===================================================================
--- uspace/app/stats/stats.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/stats/stats.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -190,8 +190,8 @@
 static void print_uptime(void)
 {
-	struct timeval uptime;
+	struct timespec uptime;
 	getuptime(&uptime);
 
-	printf("%s: Up %ld days, %ld hours, %ld minutes, %ld seconds\n",
+	printf("%s: Up %lld days, %lld hours, %lld minutes, %lld seconds\n",
 	    NAME, uptime.tv_sec / DAY, (uptime.tv_sec % DAY) / HOUR,
 	    (uptime.tv_sec % HOUR) / MINUTE, uptime.tv_sec % MINUTE);
Index: uspace/app/tester/ipc/ping_pong.c
===================================================================
--- uspace/app/tester/ipc/ping_pong.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/tester/ipc/ping_pong.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -29,5 +29,5 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/time.h>
+#include <time.h>
 #include <ns.h>
 #include <async.h>
@@ -42,13 +42,13 @@
 	TPRINTF("Pinging ns server for %d seconds...", DURATION_SECS);
 
-	struct timeval start;
-	gettimeofday(&start, NULL);
+	struct timespec start;
+	getuptime(&start);
 
 	uint64_t count = 0;
 	while (true) {
-		struct timeval now;
-		gettimeofday(&now, NULL);
+		struct timespec now;
+		getuptime(&now);
 
-		if (tv_sub_diff(&now, &start) >= DURATION_SECS * 1000000L)
+		if (NSEC2SEC(ts_sub_diff(&now, &start)) >= DURATION_SECS)
 			break;
 
Index: uspace/app/tester/ipc/starve.c
===================================================================
--- uspace/app/tester/ipc/starve.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/tester/ipc/starve.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -29,5 +29,5 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/time.h>
+#include <time.h>
 #include <io/console.h>
 #include <async.h>
@@ -43,18 +43,18 @@
 		return "Failed to init connection with console.";
 
-	struct timeval start;
-	gettimeofday(&start, NULL);
+	struct timespec start;
+	getuptime(&start);
 
 	TPRINTF("Intensive computation shall be imagined (for %ds)...\n", DURATION_SECS);
 	TPRINTF("Press a key to terminate prematurely...\n");
 	while (true) {
-		struct timeval now;
-		gettimeofday(&now, NULL);
+		struct timespec now;
+		getuptime(&now);
 
-		if (tv_sub_diff(&now, &start) >= DURATION_SECS * 1000000L)
+		if (NSEC2SEC(ts_sub_diff(&now, &start)) >= DURATION_SECS)
 			break;
 
 		cons_event_t ev;
-		suseconds_t timeout = 0;
+		usec_t timeout = 0;
 		bool has_event = console_get_event_timeout(console, &ev, &timeout);
 		if (has_event && ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
Index: uspace/app/testread/testread.c
===================================================================
--- uspace/app/testread/testread.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/testread/testread.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -126,7 +126,7 @@
 	next_mark = 0;
 	last_mark = 0;
-	struct timeval prev_time;
-	struct timeval start_time;
-	gettimeofday(&start_time, NULL);
+	struct timespec prev_time;
+	struct timespec start_time;
+	getuptime(&start_time);
 	prev_time = start_time;
 
@@ -152,6 +152,6 @@
 
 		if (progress && offset >= next_mark) {
-			struct timeval cur_time;
-			gettimeofday(&cur_time, NULL);
+			struct timespec cur_time;
+			getuptime(&cur_time);
 
 			uint32_t last_run = cur_time.tv_sec - prev_time.tv_sec;
@@ -170,6 +170,6 @@
 	}
 
-	struct timeval final_time;
-	gettimeofday(&final_time, NULL);
+	struct timespec final_time;
+	getuptime(&final_time);
 
 	uint32_t total_run_time = final_time.tv_sec - start_time.tv_sec;
Index: uspace/app/tetris/scores.h
===================================================================
--- uspace/app/tetris/scores.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/tetris/scores.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -54,5 +54,5 @@
  */
 
-#include <sys/time.h>
+#include <time.h>
 #include <str.h>
 
Index: uspace/app/tetris/screen.c
===================================================================
--- uspace/app/tetris/screen.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/tetris/screen.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -75,5 +75,5 @@
 static const struct shape *lastshape;
 
-static suseconds_t timeleft = 0;
+static usec_t timeleft = 0;
 
 console_ctrl_t *console;
@@ -340,5 +340,5 @@
 void tsleep(void)
 {
-	suseconds_t timeout = fallrate;
+	usec_t timeout = fallrate;
 
 	while (timeout > 0) {
Index: uspace/app/tetris/tetris.c
===================================================================
--- uspace/app/tetris/tetris.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/tetris/tetris.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -55,5 +55,5 @@
     "\tThe Regents of the University of California.  All rights reserved.\n";
 
-#include <sys/time.h>
+#include <time.h>
 #include <errno.h>
 #include <stdbool.h>
@@ -170,8 +170,8 @@
 static void srandomdev(void)
 {
-	struct timeval tv;
-
-	gettimeofday(&tv, NULL);
-	srand(tv.tv_sec + tv.tv_usec / 100000);
+	struct timespec ts;
+
+	getrealtime(&ts);
+	srand(ts.tv_sec + ts.tv_nsec / 100000000);
 }
 
Index: uspace/app/top/screen.c
===================================================================
--- uspace/app/top/screen.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/top/screen.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -49,7 +49,5 @@
 #include "top.h"
 
-#define USEC_COUNT  1000000
-
-static suseconds_t timeleft = 0;
+static usec_t timeleft = 0;
 
 console_ctrl_t *console;
@@ -57,5 +55,5 @@
 static sysarg_t warning_col = 0;
 static sysarg_t warning_row = 0;
-static suseconds_t warning_timeleft = 0;
+static usec_t warning_timeleft = 0;
 static char *warning_text = NULL;
 
@@ -179,5 +177,5 @@
 static inline void print_global_head(data_t *data)
 {
-	printf("top - %02lu:%02lu:%02lu up "
+	printf("top - %02lld:%02lld:%02lld up "
 	    "%" PRIun " days, %02" PRIun ":%02" PRIun ":%02" PRIun ", "
 	    "load average:",
@@ -527,5 +525,5 @@
 	va_end(args);
 
-	warning_timeleft = 2 * USEC_COUNT;
+	warning_timeleft = SEC2USEC(2);
 
 	screen_moveto(warning_col, warning_row);
@@ -537,5 +535,5 @@
  *
  */
-int tgetchar(unsigned int sec)
+int tgetchar(sec_t sec)
 {
 	/*
@@ -544,5 +542,5 @@
 
 	if (timeleft <= 0)
-		timeleft = sec * USEC_COUNT;
+		timeleft = SEC2USEC(sec);
 
 	/*
Index: uspace/app/top/screen.h
===================================================================
--- uspace/app/top/screen.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/top/screen.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -47,5 +47,5 @@
     _HELENOS_PRINTF_ATTRIBUTE(1, 2);
 
-extern int tgetchar(unsigned int);
+extern int tgetchar(sec_t);
 
 #endif
Index: uspace/app/top/top.c
===================================================================
--- uspace/app/top/top.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/top/top.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -39,5 +39,5 @@
 #include <stdlib.h>
 #include <task.h>
-#include <sys/time.h>
+#include <time.h>
 #include <errno.h>
 #include <gsort.h>
@@ -154,6 +154,6 @@
 
 	/* Get current time */
-	struct timeval time;
-	gettimeofday(&time, NULL);
+	struct timespec time;
+	getrealtime(&time);
 
 	target->hours = (time.tv_sec % DAY) / HOUR;
@@ -162,5 +162,5 @@
 
 	/* Get uptime */
-	struct timeval uptime;
+	struct timespec uptime;
 	getuptime(&uptime);
 
Index: uspace/app/wavplay/dplay.c
===================================================================
--- uspace/app/wavplay/dplay.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/app/wavplay/dplay.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -42,5 +42,5 @@
 #include <pcm/format.h>
 #include <as.h>
-#include <sys/time.h>
+#include <time.h>
 #include <inttypes.h>
 #include <stdbool.h>
@@ -242,5 +242,6 @@
 
 #define DPRINTF(f, ...) \
-	printf("%.2lu:%.6lu   "f, time.tv_sec % 100, time.tv_usec, __VA_ARGS__)
+	printf("%.2lld:%.6lld   "f, time.tv_sec % 100, \
+	    NSEC2USEC(time.tv_nsec), __VA_ARGS__)
 
 /**
@@ -255,8 +256,8 @@
 	printf("Playing: %dHz, %s, %d channel(s).\n", pb->f.sampling_rate,
 	    pcm_sample_format_str(pb->f.sample_format), pb->f.channels);
-	useconds_t work_time = 50000; /* 50 ms */
+	usec_t work_time = 50000; /* 50 ms */
 	bool started = false;
 	size_t pos = 0;
-	struct timeval time = { 0 };
+	struct timespec time = { 0 };
 	getuptime(&time);
 	while (true) {
@@ -303,11 +304,10 @@
 		}
 		const size_t to_play = buffer_occupied(pb, pos);
-		const useconds_t usecs =
-		    pcm_format_size_to_usec(to_play, &pb->f);
+		const usec_t usecs = pcm_format_size_to_usec(to_play, &pb->f);
 
 		/* Compute delay time */
-		const useconds_t real_delay = (usecs > work_time) ?
+		const usec_t real_delay = (usecs > work_time) ?
 		    usecs - work_time : 0;
-		DPRINTF("POS %zu: %u usecs (%u) to play %zu bytes.\n",
+		DPRINTF("POS %zu: %lld usecs (%lld) to play %zu bytes.\n",
 		    pos, usecs, real_delay, to_play);
 		if (real_delay)
Index: uspace/dist/src/c/demos/tetris/scores.h
===================================================================
--- uspace/dist/src/c/demos/tetris/scores.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/dist/src/c/demos/tetris/scores.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -54,5 +54,5 @@
  */
 
-#include <sys/time.h>
+#include <time.h>
 #include <str.h>
 
Index: uspace/dist/src/c/demos/tetris/tetris.c
===================================================================
--- uspace/dist/src/c/demos/tetris/tetris.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/dist/src/c/demos/tetris/tetris.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -55,5 +55,5 @@
     "\tThe Regents of the University of California.  All rights reserved.\n";
 
-#include <sys/time.h>
+#include <time.h>
 #include <err.h>
 #include <errno.h>
@@ -171,8 +171,8 @@
 static void srandomdev(void)
 {
-	struct timeval tv;
-
-	gettimeofday(&tv, NULL);
-	srand(tv.tv_sec + tv.tv_usec / 100000);
+	struct timespec ts;
+
+	getuptime(&ts);
+	srand(tv.tv_sec + tv.tv_nsec / 100000000);
 }
 
Index: uspace/dist/src/c/demos/top/top.c
===================================================================
--- uspace/dist/src/c/demos/top/top.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/dist/src/c/demos/top/top.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -40,5 +40,5 @@
 #include <task.h>
 #include <thread.h>
-#include <sys/time.h>
+#include <time.h>
 #include <errno.h>
 #include <gsort.h>
@@ -155,6 +155,6 @@
 
 	/* Get current time */
-	struct timeval time;
-	gettimeofday(&time, NULL);
+	struct timespec time;
+	getrealtime(&time);
 
 	target->hours = (time.tv_sec % DAY) / HOUR;
@@ -163,5 +163,5 @@
 
 	/* Get uptime */
-	struct timeval uptime;
+	struct timespec uptime;
 	getuptime(&uptime);
 
Index: uspace/drv/bus/usb/uhci/uhci_rh.c
===================================================================
--- uspace/drv/bus/usb/uhci/uhci_rh.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/bus/usb/uhci/uhci_rh.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -34,5 +34,5 @@
 #include <macros.h>
 #include <mem.h>
-#include <sys/time.h>
+#include <time.h>
 
 #include <usb/debug.h>
Index: uspace/drv/bus/usb/usbdiag/tests.c
===================================================================
--- uspace/drv/bus/usb/usbdiag/tests.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/bus/usb/usbdiag/tests.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -72,12 +72,12 @@
 	uint32_t transfer_count = 0;
 
-	struct timeval start_time, final_time, stop_time;
-	gettimeofday(&start_time, NULL);
-	gettimeofday(&stop_time, NULL);
-
-	tv_add_diff(&stop_time, params->min_duration * 1000);
-	gettimeofday(&final_time, NULL);
-
-	while (!tv_gt(&final_time, &stop_time)) {
+	struct timespec start_time, final_time, stop_time;
+	getuptime(&start_time);
+	getuptime(&stop_time);
+
+	ts_add_diff(&stop_time, MSEC2NSEC(params->min_duration));
+	getuptime(&final_time);
+
+	while (!ts_gt(&final_time, &stop_time)) {
 		++transfer_count;
 
@@ -121,9 +121,9 @@
 		}
 
-		gettimeofday(&final_time, NULL);
-	}
-
-	usbdiag_dur_t in_duration = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
-	    ((final_time.tv_sec - start_time.tv_sec) * 1000);
+		getuptime(&final_time);
+	}
+
+	usbdiag_dur_t in_duration = NSEC2MSEC(final_time.tv_nsec - start_time.tv_nsec) +
+	    SEC2MSEC(final_time.tv_sec - start_time.tv_sec);
 
 	usb_log_info("Test on %s IN endpoint completed in %lu ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
@@ -170,12 +170,12 @@
 	uint32_t transfer_count = 0;
 
-	struct timeval start_time, final_time, stop_time;
-	gettimeofday(&start_time, NULL);
-	gettimeofday(&stop_time, NULL);
-
-	tv_add_diff(&stop_time, params->min_duration * 1000);
-	gettimeofday(&final_time, NULL);
-
-	while (!tv_gt(&final_time, &stop_time)) {
+	struct timespec start_time, final_time, stop_time;
+	getuptime(&start_time);
+	getuptime(&stop_time);
+
+	ts_add_diff(&stop_time, MSEC2NSEC(params->min_duration));
+	getuptime(&final_time);
+
+	while (!ts_gt(&final_time, &stop_time)) {
 		++transfer_count;
 
@@ -186,9 +186,9 @@
 		}
 
-		gettimeofday(&final_time, NULL);
-	}
-
-	usbdiag_dur_t in_duration = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
-	    ((final_time.tv_sec - start_time.tv_sec) * 1000);
+		getuptime(&final_time);
+	}
+
+	usbdiag_dur_t in_duration = NSEC2MSEC(final_time.tv_nsec - start_time.tv_nsec) +
+	    SEC2MSEC(final_time.tv_sec - start_time.tv_sec);
 
 	usb_log_info("Test on %s OUT endpoint completed in %ld ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
Index: uspace/drv/bus/usb/vhc/hub/hub.c
===================================================================
--- uspace/drv/bus/usb/vhc/hub/hub.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/bus/usb/vhc/hub/hub.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -64,6 +64,6 @@
 static void clear_port_status_change(hub_port_t *, uint16_t);
 static errno_t set_port_state_delayed_fibril(void *);
-static void set_port_state_delayed(hub_t *, size_t, suseconds_t,
-    hub_port_state_t, hub_port_state_t);
+static void set_port_state_delayed(hub_t *, size_t, usec_t, hub_port_state_t,
+    hub_port_state_t);
 
 /** Convert hub port state to a char. */
@@ -444,5 +444,5 @@
 struct delay_port_state_change {
 	/** Delay in microseconds. */
-	suseconds_t delay;
+	usec_t delay;
 	/** Old state of the port. */
 	hub_port_state_t old_state;
@@ -496,6 +496,6 @@
  */
 static void set_port_state_delayed(hub_t *hub, size_t port_index,
-    suseconds_t delay_time_ms,
-    hub_port_state_t old_state, hub_port_state_t new_state)
+    usec_t delay_time_ms, hub_port_state_t old_state,
+    hub_port_state_t new_state)
 {
 	struct delay_port_state_change *change =
@@ -504,5 +504,5 @@
 	change->hub = hub;
 	change->port = port_index;
-	change->delay = delay_time_ms * 1000;
+	change->delay = MSEC2USEC(delay_time_ms);
 	change->old_state = old_state;
 	change->new_state = new_state;
Index: uspace/drv/bus/usb/xhci/hc.c
===================================================================
--- uspace/drv/bus/usb/xhci/hc.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/bus/usb/xhci/hc.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -229,7 +229,7 @@
 	hc->max_slots = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_MAX_SLOTS);
 
-	struct timeval tv;
-	getuptime(&tv);
-	hc->wrap_time = tv.tv_sec * 1000000 + tv.tv_usec;
+	struct timespec ts;
+	getuptime(&ts);
+	hc->wrap_time = SEC2USEC(ts.tv_sec) + NSEC2USEC(ts.tv_nsec);
 	hc->wrap_count = 0;
 
@@ -591,9 +591,9 @@
 static errno_t xhci_handle_mfindex_wrap_event(xhci_hc_t *hc, xhci_trb_t *trb)
 {
-	struct timeval tv;
-	getuptime(&tv);
-	usb_log_debug("Microframe index wrapped (@%lu.%li, %" PRIu64 " total).",
-	    tv.tv_sec, tv.tv_usec, hc->wrap_count);
-	hc->wrap_time = ((uint64_t) tv.tv_sec) * 1000000 + ((uint64_t) tv.tv_usec);
+	struct timespec ts;
+	getuptime(&ts);
+	usb_log_debug("Microframe index wrapped (@%lld.%lld, %" PRIu64 " total).",
+	    ts.tv_sec, NSEC2USEC(ts.tv_nsec), hc->wrap_count);
+	hc->wrap_time = SEC2USEC(ts.tv_sec) + NSEC2USEC(ts.tv_nsec);
 	++hc->wrap_count;
 	return EOK;
Index: uspace/drv/bus/usb/xhci/isoch.c
===================================================================
--- uspace/drv/bus/usb/xhci/isoch.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/bus/usb/xhci/isoch.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -113,5 +113,5 @@
 {
 	xhci_isoch_t *const isoch = ep->isoch;
-	const suseconds_t delay = isoch->buffer_count * ep->interval * 125 +
+	const usec_t delay = isoch->buffer_count * ep->interval * 125 +
 	    RESET_TIMER_DELAY;
 
@@ -210,7 +210,7 @@
 static inline uint64_t get_system_time()
 {
-	struct timeval tv;
-	getuptime(&tv);
-	return ((uint64_t) tv.tv_sec) * 1000000 + ((uint64_t) tv.tv_usec);
+	struct timespec ts;
+	getuptime(&ts);
+	return SEC2USEC(ts.tv_sec) + NSEC2USEC(ts.tv_nsec);
 }
 
@@ -314,5 +314,5 @@
 	while (isoch->transfers[isoch->hw_enqueue].state == ISOCH_FILLED) {
 		xhci_isoch_transfer_t *const it = &isoch->transfers[isoch->hw_enqueue];
-		suseconds_t delay;
+		usec_t delay;
 
 		assert(it->state == ISOCH_FILLED);
@@ -324,5 +324,5 @@
 		case WINDOW_TOO_SOON:
 			delay = wd.offset * 125;
-			usb_log_debug("[isoch] delaying feeding buffer %zu for %ldus",
+			usb_log_debug("[isoch] delaying feeding buffer %zu for %lldus",
 			    it - isoch->transfers, delay);
 			fibril_timer_set_locked(isoch->feeding_timer, delay,
@@ -400,5 +400,5 @@
 	while (isoch->transfers[isoch->enqueue].state <= ISOCH_FILLED) {
 		xhci_isoch_transfer_t *const it = &isoch->transfers[isoch->enqueue];
-		suseconds_t delay;
+		usec_t delay;
 
 		/* IN buffers are "filled" with free space */
@@ -416,5 +416,5 @@
 			/* Not allowed to feed yet. Defer to later. */
 			delay = wd.offset * 125;
-			usb_log_debug("[isoch] delaying feeding buffer %zu for %ldus",
+			usb_log_debug("[isoch] delaying feeding buffer %zu for %lldus",
 			    it - isoch->transfers, delay);
 			fibril_timer_set_locked(isoch->feeding_timer, delay,
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/nic/e1k/e1k.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -327,5 +327,5 @@
 }
 
-static uint16_t e1000_calculate_itr_interval_from_usecs(suseconds_t useconds)
+static uint16_t e1000_calculate_itr_interval_from_usecs(usec_t useconds)
 {
 	return useconds * 4;
@@ -1299,13 +1299,13 @@
 }
 
-/** Calculates ITR register interrupt from timeval structure
+/** Calculates ITR register interrupt from timespec structure
  *
  * @param period Period
  *
  */
-static uint16_t e1000_calculate_itr_interval(const struct timeval *period)
+static uint16_t e1000_calculate_itr_interval(const struct timespec *period)
 {
 	// TODO: use also tv_sec
-	return e1000_calculate_itr_interval_from_usecs(period->tv_usec);
+	return e1000_calculate_itr_interval_from_usecs(NSEC2USEC(period->tv_nsec));
 }
 
@@ -1321,5 +1321,5 @@
  */
 static errno_t e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode,
-    const struct timeval *period)
+    const struct timespec *period)
 {
 	assert(nic);
@@ -2182,7 +2182,7 @@
 		goto err_rx_structure;
 
-	struct timeval period;
+	struct timespec period;
 	period.tv_sec = 0;
-	period.tv_usec = E1000_DEFAULT_INTERRUPT_INTERVAL_USEC;
+	period.tv_nsec = USEC2NSEC(E1000_DEFAULT_INTERRUPT_INTERVAL_USEC);
 	rc = nic_report_poll_mode(nic, NIC_POLL_PERIODIC, &period);
 	if (rc != EOK)
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/nic/rtl8139/driver.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -313,5 +313,5 @@
 
 static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
-    const struct timeval *period);
+    const struct timespec *period);
 static void rtl8139_poll(nic_t *nic_data);
 
@@ -2068,5 +2068,5 @@
  */
 static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
-    const struct timeval *period)
+    const struct timespec *period)
 {
 	assert(nic_data);
Index: uspace/drv/nic/rtl8139/general.c
===================================================================
--- uspace/drv/nic/rtl8139/general.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/nic/rtl8139/general.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -85,5 +85,5 @@
  */
 errno_t rtl8139_timer_act_init(rtl8139_timer_act_t *ta, uint32_t timer_freq,
-    const struct timeval *time)
+    const struct timespec *time)
 {
 	if (!ta || timer_freq == 0 || !time)
@@ -95,11 +95,11 @@
 	ta->full_val = seconds_in_reg * tics_per_ms * 1000;
 
-	struct timeval remains = *time;
+	struct timespec remains = *time;
 	ta->full_skips = remains.tv_sec / seconds_in_reg;
 	remains.tv_sec = remains.tv_sec % seconds_in_reg;
 
-	if (remains.tv_usec > RTL8139_USEC_IN_SEC) {
-		remains.tv_sec += remains.tv_usec / RTL8139_USEC_IN_SEC;
-		remains.tv_usec = remains.tv_usec % RTL8139_USEC_IN_SEC;
+	if (NSEC2USEC(remains.tv_nsec) > RTL8139_USEC_IN_SEC) {
+		remains.tv_sec += NSEC2USEC(remains.tv_nsec) / RTL8139_USEC_IN_SEC;
+		remains.tv_nsec = NSEC2USEC(remains.tv_nsec) % RTL8139_USEC_IN_SEC;
 
 		/* it can be increased above seconds_in_reg again */
@@ -108,5 +108,5 @@
 	}
 
-	ta->last_val = remains.tv_sec * 1000 + remains.tv_usec / 1000;
+	ta->last_val = SEC2MSEC(remains.tv_sec) + NSEC2MSEC(remains.tv_nsec);
 	ta->last_val *= tics_per_ms;
 
Index: uspace/drv/nic/rtl8139/general.h
===================================================================
--- uspace/drv/nic/rtl8139/general.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/nic/rtl8139/general.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -36,4 +36,5 @@
 
 #include <stddef.h>
+#include <stdint.h>
 #include <time.h>
 
@@ -62,5 +63,5 @@
     size_t);
 extern errno_t rtl8139_timer_act_init(rtl8139_timer_act_t *, uint32_t,
-    const struct timeval *);
+    const struct timespec *);
 extern int rtl8139_timer_act_step(rtl8139_timer_act_t *, uint32_t *);
 
Index: uspace/drv/time/cmos-rtc/cmos-rtc.c
===================================================================
--- uspace/drv/time/cmos-rtc/cmos-rtc.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/drv/time/cmos-rtc/cmos-rtc.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -75,5 +75,5 @@
 	int clients_connected;
 	/** time at which the system booted */
-	struct timeval boot_time;
+	struct timespec boot_time;
 } rtc_t;
 
@@ -204,5 +204,5 @@
 
 	rtc->boot_time.tv_sec = 0;
-	rtc->boot_time.tv_usec = 0;
+	rtc->boot_time.tv_nsec = 0;
 	rtc->clients_connected = 0;
 
@@ -331,11 +331,11 @@
 		 */
 
-		struct timeval curtime;
+		struct timespec curtime;
 
 		getuptime(&curtime);
-		tv_add(&curtime, &rtc->boot_time);
+		ts_add(&curtime, &rtc->boot_time);
 		fibril_mutex_unlock(&rtc->mutex);
 
-		return time_tv2tm(&curtime, t);
+		return time_ts2tm(&curtime, t);
 	}
 
@@ -346,6 +346,6 @@
 	}
 
-	/* Microseconds are below RTC's resolution, assume 0. */
-	t->tm_usec = 0;
+	/* Nanoseconds are below RTC's resolution, assume 0. */
+	t->tm_nsec = 0;
 
 	/* now read the registers */
@@ -419,10 +419,10 @@
 		result = EINVAL;
 	else {
-		struct timeval uptime;
+		struct timespec uptime;
 
 		getuptime(&uptime);
 		rtc->boot_time.tv_sec = r;
-		rtc->boot_time.tv_usec = t->tm_usec;	/* normalized */
-		tv_sub(&rtc->boot_time, &uptime);
+		rtc->boot_time.tv_nsec = t->tm_nsec;	/* normalized */
+		ts_sub(&rtc->boot_time, &uptime);
 		result = EOK;
 	}
@@ -445,6 +445,6 @@
 	bool bcd_mode;
 	time_t norm_time;
-	struct timeval uptime;
-	struct timeval ntv;
+	struct timespec uptime;
+	struct timespec ntv;
 	int  reg_b;
 	int  reg_a;
@@ -457,8 +457,8 @@
 
 	ntv.tv_sec = norm_time;
-	ntv.tv_usec = t->tm_usec;
+	ntv.tv_nsec = t->tm_nsec;
 	getuptime(&uptime);
 
-	if (tv_gteq(&uptime, &ntv)) {
+	if (ts_gteq(&uptime, &ntv)) {
 		/* This is not acceptable */
 		return EINVAL;
@@ -474,5 +474,5 @@
 	/* boot_time must be recomputed */
 	rtc->boot_time.tv_sec = 0;
-	rtc->boot_time.tv_usec = 0;
+	rtc->boot_time.tv_nsec = 0;
 
 	/* Detect the RTC epoch */
Index: uspace/lib/c/generic/async/client.c
===================================================================
--- uspace/lib/c/generic/async/client.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/async/client.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -110,5 +110,5 @@
 #include <assert.h>
 #include <errno.h>
-#include <sys/time.h>
+#include <time.h>
 #include <barrier.h>
 #include <stdbool.h>
@@ -342,5 +342,5 @@
  *
  */
-errno_t async_wait_timeout(aid_t amsgid, errno_t *retval, suseconds_t timeout)
+errno_t async_wait_timeout(aid_t amsgid, errno_t *retval, usec_t timeout)
 {
 	if (amsgid == 0) {
@@ -359,7 +359,7 @@
 		timeout = 0;
 
-	struct timeval expires;
+	struct timespec expires;
 	getuptime(&expires);
-	tv_add_diff(&expires, timeout);
+	ts_add_diff(&expires, USEC2NSEC(timeout));
 
 	errno_t rc = fibril_wait_timeout(&msg->received, &expires);
Index: uspace/lib/c/generic/async/ports.c
===================================================================
--- uspace/lib/c/generic/async/ports.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/async/ports.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -41,5 +41,5 @@
 #include <assert.h>
 #include <errno.h>
-#include <sys/time.h>
+#include <time.h>
 #include <barrier.h>
 #include <stdbool.h>
Index: uspace/lib/c/generic/async/server.c
===================================================================
--- uspace/lib/c/generic/async/server.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/async/server.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -110,5 +110,5 @@
 #include <assert.h>
 #include <errno.h>
-#include <sys/time.h>
+#include <time.h>
 #include <stdbool.h>
 #include <stdlib.h>
@@ -916,15 +916,15 @@
  *
  */
-bool async_get_call_timeout(ipc_call_t *call, suseconds_t usecs)
+bool async_get_call_timeout(ipc_call_t *call, usec_t usecs)
 {
 	assert(call);
 	assert(fibril_connection);
 
-	struct timeval tv;
-	struct timeval *expires = NULL;
+	struct timespec ts;
+	struct timespec *expires = NULL;
 	if (usecs) {
-		getuptime(&tv);
-		tv_add_diff(&tv, usecs);
-		expires = &tv;
+		getuptime(&ts);
+		ts_add_diff(&ts, USEC2NSEC(usecs));
+		expires = &ts;
 	}
 
Index: uspace/lib/c/generic/io/console.c
===================================================================
--- uspace/lib/c/generic/io/console.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/io/console.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -223,8 +223,8 @@
 
 bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event,
-    suseconds_t *timeout)
-{
-	struct timeval t0;
-	gettimeofday(&t0, NULL);
+    usec_t *timeout)
+{
+	struct timespec t0;
+	getuptime(&t0);
 
 	if (ctrl->input_aid == 0) {
@@ -257,7 +257,7 @@
 
 	/* Update timeout */
-	struct timeval t1;
-	gettimeofday(&t1, NULL);
-	*timeout -= tv_sub_diff(&t1, &t0);
+	struct timespec t1;
+	getuptime(&t1);
+	*timeout -= NSEC2USEC(ts_sub_diff(&t1, &t0));
 
 	return true;
Index: uspace/lib/c/generic/private/async.h
===================================================================
--- uspace/lib/c/generic/private/async.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/private/async.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -40,5 +40,5 @@
 #include <fibril.h>
 #include <fibril_synch.h>
-#include <sys/time.h>
+#include <time.h>
 #include <stdbool.h>
 
Index: uspace/lib/c/generic/private/fibril.h
===================================================================
--- uspace/lib/c/generic/private/fibril.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/private/fibril.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -81,8 +81,8 @@
 
 extern void fibril_wait_for(fibril_event_t *);
-extern errno_t fibril_wait_timeout(fibril_event_t *, const struct timeval *);
+extern errno_t fibril_wait_timeout(fibril_event_t *, const struct timespec *);
 extern void fibril_notify(fibril_event_t *);
 
-extern errno_t fibril_ipc_wait(ipc_call_t *, const struct timeval *);
+extern errno_t fibril_ipc_wait(ipc_call_t *, const struct timespec *);
 extern void fibril_ipc_poke(void);
 
Index: uspace/lib/c/generic/private/futex.h
===================================================================
--- uspace/lib/c/generic/private/futex.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/private/futex.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -102,5 +102,6 @@
  *
  */
-static inline errno_t futex_down_composable(futex_t *futex, const struct timeval *expires)
+static inline errno_t futex_down_composable(futex_t *futex,
+    const struct timespec *expires)
 {
 	// TODO: Add tests for this.
@@ -109,5 +110,5 @@
 		return EOK;
 
-	suseconds_t timeout;
+	usec_t timeout;
 
 	if (!expires) {
@@ -119,8 +120,8 @@
 			timeout = 1;
 		} else {
-			struct timeval tv;
+			struct timespec tv;
 			getuptime(&tv);
-			timeout = tv_gteq(&tv, expires) ? 1 :
-			    tv_sub_diff(expires, &tv);
+			timeout = ts_gteq(&tv, expires) ? 1 :
+			    NSEC2USEC(ts_sub_diff(expires, &tv));
 		}
 
@@ -148,7 +149,8 @@
 }
 
-static inline errno_t futex_down_timeout(futex_t *futex, const struct timeval *expires)
-{
-	if (expires && expires->tv_sec == 0 && expires->tv_usec == 0) {
+static inline errno_t futex_down_timeout(futex_t *futex,
+    const struct timespec *expires)
+{
+	if (expires && expires->tv_sec == 0 && expires->tv_nsec == 0) {
 		/* Nonblocking down. */
 
@@ -209,5 +211,5 @@
 	 * trydown.
 	 */
-	struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
+	struct timespec tv = { .tv_sec = 0, .tv_nsec = 0 };
 	return futex_down_timeout(futex, &tv) == EOK;
 }
Index: uspace/lib/c/generic/private/thread.h
===================================================================
--- uspace/lib/c/generic/private/thread.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/private/thread.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -49,6 +49,6 @@
 extern void thread_detach(thread_id_t);
 extern thread_id_t thread_get_id(void);
-extern int thread_usleep(useconds_t);
-extern unsigned int thread_sleep(unsigned int);
+extern void thread_usleep(usec_t);
+extern void thread_sleep(sec_t);
 
 #endif
Index: uspace/lib/c/generic/rndgen.c
===================================================================
--- uspace/lib/c/generic/rndgen.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/rndgen.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -52,5 +52,5 @@
 {
 	rndgen_t *rndgen;
-	struct timeval tv;
+	struct timespec ts;
 
 	rndgen = calloc(1, sizeof(rndgen_t));
@@ -59,6 +59,6 @@
 
 	/* XXX This is a rather poor way of generating random numbers */
-	gettimeofday(&tv, NULL);
-	rndgen->seed = tv.tv_sec ^ tv.tv_usec;
+	getuptime(&ts);
+	rndgen->seed = ts.tv_sec ^ ts.tv_nsec;
 
 	*rrndgen = rndgen;
Index: uspace/lib/c/generic/stdlib.c
===================================================================
--- uspace/lib/c/generic/stdlib.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/stdlib.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -37,4 +37,5 @@
 #include <fibril_synch.h>
 #include <stdlib.h>
+#include <errno.h>
 #include "private/libc.h"
 #include "private/scanf.h"
Index: uspace/lib/c/generic/thread/fibril.c
===================================================================
--- uspace/lib/c/generic/thread/fibril.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/thread/fibril.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -60,5 +60,5 @@
 typedef struct {
 	link_t link;
-	struct timeval expires;
+	struct timespec expires;
 	fibril_event_t *event;
 } _timeout_t;
@@ -142,5 +142,5 @@
 }
 
-static inline errno_t _ready_down(const struct timeval *expires)
+static inline errno_t _ready_down(const struct timespec *expires)
 {
 	if (multithreaded)
@@ -253,5 +253,5 @@
 }
 
-static errno_t _ipc_wait(ipc_call_t *call, const struct timeval *expires)
+static errno_t _ipc_wait(ipc_call_t *call, const struct timespec *expires)
 {
 	if (!expires)
@@ -261,11 +261,12 @@
 		return ipc_wait(call, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING);
 
-	struct timeval now;
+	struct timespec now;
 	getuptime(&now);
 
-	if (tv_gteq(&now, expires))
+	if (ts_gteq(&now, expires))
 		return ipc_wait(call, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING);
 
-	return ipc_wait(call, tv_sub_diff(expires, &now), SYNCH_FLAGS_NONE);
+	return ipc_wait(call, NSEC2USEC(ts_sub_diff(expires, &now)),
+	    SYNCH_FLAGS_NONE);
 }
 
@@ -275,5 +276,5 @@
  * wait after new ready fibrils are added.
  */
-static fibril_t *_ready_list_pop(const struct timeval *expires, bool locked)
+static fibril_t *_ready_list_pop(const struct timespec *expires, bool locked)
 {
 	if (locked) {
@@ -370,5 +371,5 @@
 static fibril_t *_ready_list_pop_nonblocking(bool locked)
 {
-	struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
+	struct timespec tv = { .tv_sec = 0, .tv_nsec = 0 };
 	return _ready_list_pop(&tv, locked);
 }
@@ -393,5 +394,5 @@
 
 /* Blocks the current fibril until an IPC call arrives. */
-static errno_t _wait_ipc(ipc_call_t *call, const struct timeval *expires)
+static errno_t _wait_ipc(ipc_call_t *call, const struct timespec *expires)
 {
 	futex_assert_is_not_locked(&fibril_futex);
@@ -430,8 +431,8 @@
 
 /** Fire all timeouts that expired. */
-static struct timeval *_handle_expired_timeouts(struct timeval *next_timeout)
-{
-	struct timeval tv;
-	getuptime(&tv);
+static struct timespec *_handle_expired_timeouts(struct timespec *next_timeout)
+{
+	struct timespec ts;
+	getuptime(&ts);
 
 	futex_lock(&fibril_futex);
@@ -441,5 +442,5 @@
 		_timeout_t *to = list_get_instance(cur, _timeout_t, link);
 
-		if (tv_gt(&to->expires, &tv)) {
+		if (ts_gt(&to->expires, &ts)) {
 			*next_timeout = to->expires;
 			futex_unlock(&fibril_futex);
@@ -535,7 +536,7 @@
 	(void) arg;
 
-	struct timeval next_timeout;
+	struct timespec next_timeout;
 	while (true) {
-		struct timeval *to = _handle_expired_timeouts(&next_timeout);
+		struct timespec *to = _handle_expired_timeouts(&next_timeout);
 		fibril_t *f = _ready_list_pop(to, false);
 		if (f) {
@@ -615,5 +616,5 @@
 		_timeout_t *cur = list_get_instance(tmp, _timeout_t, link);
 
-		if (tv_gteq(&cur->expires, &timeout->expires))
+		if (ts_gteq(&cur->expires, &timeout->expires))
 			break;
 
@@ -634,5 +635,6 @@
  * @return ETIMEOUT if timed out. EOK otherwise.
  */
-errno_t fibril_wait_timeout(fibril_event_t *event, const struct timeval *expires)
+errno_t fibril_wait_timeout(fibril_event_t *event,
+    const struct timespec *expires)
 {
 	assert(fibril_self()->rmutex_locks == 0);
@@ -889,9 +891,9 @@
 }
 
-void fibril_usleep(suseconds_t timeout)
-{
-	struct timeval expires;
+void fibril_usleep(usec_t timeout)
+{
+	struct timespec expires;
 	getuptime(&expires);
-	tv_add_diff(&expires, timeout);
+	ts_add_diff(&expires, USEC2NSEC(timeout));
 
 	fibril_event_t event = FIBRIL_EVENT_INIT;
@@ -899,7 +901,7 @@
 }
 
-void fibril_sleep(unsigned int sec)
-{
-	struct timeval expires;
+void fibril_sleep(sec_t sec)
+{
+	struct timespec expires;
 	getuptime(&expires);
 	expires.tv_sec += sec;
@@ -916,5 +918,5 @@
 }
 
-errno_t fibril_ipc_wait(ipc_call_t *call, const struct timeval *expires)
+errno_t fibril_ipc_wait(ipc_call_t *call, const struct timespec *expires)
 {
 	return _wait_ipc(call, expires);
Index: uspace/lib/c/generic/thread/fibril_synch.c
===================================================================
--- uspace/lib/c/generic/thread/fibril_synch.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/thread/fibril_synch.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -37,5 +37,5 @@
 #include <async.h>
 #include <adt/list.h>
-#include <sys/time.h>
+#include <time.h>
 #include <errno.h>
 #include <assert.h>
@@ -390,5 +390,5 @@
 errno_t
 fibril_condvar_wait_timeout(fibril_condvar_t *fcv, fibril_mutex_t *fm,
-    suseconds_t timeout)
+    usec_t timeout)
 {
 	assert(fibril_mutex_is_locked(fm));
@@ -400,10 +400,10 @@
 	wdata.mutex = fm;
 
-	struct timeval tv;
-	struct timeval *expires = NULL;
+	struct timespec ts;
+	struct timespec *expires = NULL;
 	if (timeout) {
-		getuptime(&tv);
-		tv_add_diff(&tv, timeout);
-		expires = &tv;
+		getuptime(&ts);
+		ts_add_diff(&ts, USEC2NSEC(timeout));
+		expires = &ts;
 	}
 
@@ -557,5 +557,5 @@
  * @param arg		Argument for @a fun
  */
-void fibril_timer_set(fibril_timer_t *timer, suseconds_t delay,
+void fibril_timer_set(fibril_timer_t *timer, usec_t delay,
     fibril_timer_fun_t fun, void *arg)
 {
@@ -575,5 +575,5 @@
  * @param arg		Argument for @a fun
  */
-void fibril_timer_set_locked(fibril_timer_t *timer, suseconds_t delay,
+void fibril_timer_set_locked(fibril_timer_t *timer, usec_t delay,
     fibril_timer_fun_t fun, void *arg)
 {
@@ -728,5 +728,5 @@
 }
 
-errno_t fibril_semaphore_down_timeout(fibril_semaphore_t *sem, suseconds_t timeout)
+errno_t fibril_semaphore_down_timeout(fibril_semaphore_t *sem, usec_t timeout)
 {
 	if (timeout < 0)
@@ -751,10 +751,10 @@
 	futex_unlock(&fibril_synch_futex);
 
-	struct timeval tv;
-	struct timeval *expires = NULL;
+	struct timespec ts;
+	struct timespec *expires = NULL;
 	if (timeout) {
-		getuptime(&tv);
-		tv_add_diff(&tv, timeout);
-		expires = &tv;
+		getuptime(&ts);
+		ts_add_diff(&ts, USEC2NSEC(timeout));
+		expires = &ts;
 	}
 
Index: uspace/lib/c/generic/thread/mpsc.c
===================================================================
--- uspace/lib/c/generic/thread/mpsc.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/thread/mpsc.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -146,5 +146,5 @@
  * there is no message left in the queue.
  */
-errno_t mpsc_receive(mpsc_t *q, void *b, const struct timeval *expires)
+errno_t mpsc_receive(mpsc_t *q, void *b, const struct timespec *expires)
 {
 	mpsc_node_t *n;
Index: uspace/lib/c/generic/thread/thread.c
===================================================================
--- uspace/lib/c/generic/thread/thread.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/thread/thread.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -176,8 +176,7 @@
  *
  */
-int thread_usleep(useconds_t usec)
+void thread_usleep(usec_t usec)
 {
 	(void) __SYSCALL1(SYS_THREAD_USLEEP, usec);
-	return 0;
 }
 
@@ -185,19 +184,15 @@
  *
  */
-unsigned int thread_sleep(unsigned int sec)
+void thread_sleep(sec_t sec)
 {
 	/*
-	 * Sleep in 1000 second steps to support
-	 * full argument range
+	 * Sleep in 1000 second steps to support full argument range
 	 */
-
 	while (sec > 0) {
 		unsigned int period = (sec > 1000) ? 1000 : sec;
 
-		thread_usleep(period * 1000000);
+		thread_usleep(SEC2USEC(period));
 		sec -= period;
 	}
-
-	return 0;
 }
 
Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/generic/time.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -35,5 +35,4 @@
  */
 
-#include <sys/time.h>
 #include <time.h>
 #include <stdbool.h>
@@ -51,4 +50,5 @@
 #include <loc.h>
 #include <device/clock_dev.h>
+#include <stats.h>
 
 #define ASCTIME_BUF_LEN  26
@@ -57,5 +57,5 @@
 #define MINS_PER_HOUR  60
 #define SECS_PER_MIN   60
-#define USECS_PER_SEC  1000000
+#define NSECS_PER_SEC  1000000000ll
 #define MINS_PER_DAY   (MINS_PER_HOUR * HOURS_PER_DAY)
 #define SECS_PER_HOUR  (SECS_PER_MIN * MINS_PER_HOUR)
@@ -71,4 +71,36 @@
 static async_sess_t *clock_conn = NULL;
 
+/**
+ * Get CPU time used since the process invocation.
+ *
+ * @return Consumed microseconds by this process or -1 if not available.
+ */
+clock_t clock(void)
+{
+	static_assert(CLOCKS_PER_SEC == 1000000);
+
+	size_t count;
+	stats_cpu_t *cpu_stats = stats_get_cpus(&count);
+	if (!cpu_stats)
+		return (clock_t) -1;
+	if (!cpu_stats->frequency_mhz) {
+		free(cpu_stats);
+		return (clock_t) -1;
+	}
+
+	clock_t total_usecs = -1;
+	if (cpu_stats) {
+		stats_task_t *task_stats = stats_get_task(task_get_id());
+		if (task_stats) {
+			total_usecs = (clock_t) (task_stats->kcycles +
+			    task_stats->ucycles) / cpu_stats->frequency_mhz;
+			free(task_stats);
+		}
+		free(cpu_stats);
+	}
+
+	return total_usecs;
+}
+
 /** Check whether the year is a leap year.
  *
@@ -252,16 +284,16 @@
  *
  * @param tm Broken-down time to normalize.
- * @param tv Timeval to add.
+ * @param ts Timespec to add.
  *
  * @return 0 on success, -1 on overflow
  *
  */
-static int normalize_tm_tv(struct tm *tm, const struct timeval *tv)
+static int normalize_tm_ts(struct tm *tm, const struct timespec *ts)
 {
 	// TODO: DST correction
 
 	/* Set initial values. */
-	time_t usec = tm->tm_usec + tv->tv_usec;
-	time_t sec = tm->tm_sec + tv->tv_sec;
+	time_t nsec = tm->tm_nsec + ts->tv_nsec;
+	time_t sec = tm->tm_sec + ts->tv_sec;
 	time_t min = tm->tm_min;
 	time_t hour = tm->tm_hour;
@@ -271,6 +303,6 @@
 
 	/* Adjust time. */
-	sec += floor_div(usec, USECS_PER_SEC);
-	usec = floor_mod(usec, USECS_PER_SEC);
+	sec += floor_div(nsec, NSECS_PER_SEC);
+	nsec = floor_mod(nsec, NSECS_PER_SEC);
 	min += floor_div(sec, SECS_PER_MIN);
 	sec = floor_mod(sec, SECS_PER_MIN);
@@ -321,5 +353,5 @@
 
 	/* And put the values back to the struct. */
-	tm->tm_usec = (int) usec;
+	tm->tm_nsec = (int) nsec;
 	tm->tm_sec = (int) sec;
 	tm->tm_min = (int) min;
@@ -340,10 +372,10 @@
 static int normalize_tm_time(struct tm *tm, time_t time)
 {
-	struct timeval tv = {
+	struct timespec ts = {
 		.tv_sec = time,
-		.tv_usec = 0
+		.tv_nsec = 0
 	};
 
-	return normalize_tm_tv(tm, &tv);
+	return normalize_tm_ts(tm, &ts);
 }
 
@@ -456,84 +488,83 @@
 }
 
-static void tv_normalize(struct timeval *tv)
-{
-	while (tv->tv_usec > USECS_PER_SEC) {
-		tv->tv_sec++;
-		tv->tv_usec -= USECS_PER_SEC;
-	}
-	while (tv->tv_usec < 0) {
-		tv->tv_sec--;
-		tv->tv_usec += USECS_PER_SEC;
-	}
-}
-
-/** Add microseconds to given timeval.
- *
- * @param tv    Destination timeval.
- * @param usecs Number of microseconds to add.
- *
- */
-void tv_add_diff(struct timeval *tv, suseconds_t usecs)
-{
-	tv->tv_sec += usecs / USECS_PER_SEC;
-	tv->tv_usec += usecs % USECS_PER_SEC;
-	tv_normalize(tv);
-}
-
-/** Add two timevals.
- *
- * @param tv1 First timeval.
- * @param tv2 Second timeval.
- */
-void tv_add(struct timeval *tv1, const struct timeval *tv2)
-{
-	tv1->tv_sec += tv2->tv_sec;
-	tv1->tv_usec += tv2->tv_usec;
-	tv_normalize(tv1);
-}
-
-/** Subtract two timevals.
- *
- * @param tv1 First timeval.
- * @param tv2 Second timeval.
- *
- * @return Difference between tv1 and tv2 (tv1 - tv2) in
- *         microseconds.
- *
- */
-suseconds_t tv_sub_diff(const struct timeval *tv1, const struct timeval *tv2)
-{
-	return (tv1->tv_usec - tv2->tv_usec) +
-	    ((tv1->tv_sec - tv2->tv_sec) * USECS_PER_SEC);
-}
-
-/** Subtract two timevals.
- *
- * @param tv1 First timeval.
- * @param tv2 Second timeval.
- *
- */
-void tv_sub(struct timeval *tv1, const struct timeval *tv2)
-{
-	tv1->tv_sec -= tv2->tv_sec;
-	tv1->tv_usec -= tv2->tv_usec;
-	tv_normalize(tv1);
-}
-
-/** Decide if one timeval is greater than the other.
- *
- * @param t1 First timeval.
- * @param t2 Second timeval.
- *
- * @return True if tv1 is greater than tv2.
- * @return False otherwise.
- *
- */
-int tv_gt(const struct timeval *tv1, const struct timeval *tv2)
-{
-	if (tv1->tv_sec > tv2->tv_sec)
+static void ts_normalize(struct timespec *ts)
+{
+	while (ts->tv_nsec >= NSECS_PER_SEC) {
+		ts->tv_sec++;
+		ts->tv_nsec -= NSECS_PER_SEC;
+	}
+	while (ts->tv_nsec < 0) {
+		ts->tv_sec--;
+		ts->tv_nsec += NSECS_PER_SEC;
+	}
+}
+
+/** Add nanoseconds to given timespec.
+ *
+ * @param ts     Destination timespec.
+ * @param nsecs  Number of nanoseconds to add.
+ *
+ */
+void ts_add_diff(struct timespec *ts, nsec_t nsecs)
+{
+	ts->tv_sec += nsecs / NSECS_PER_SEC;
+	ts->tv_nsec += nsecs % NSECS_PER_SEC;
+	ts_normalize(ts);
+}
+
+/** Add two timespecs.
+ *
+ * @param ts1  First timespec.
+ * @param ts2  Second timespec.
+ */
+void ts_add(struct timespec *ts1, const struct timespec *ts2)
+{
+	ts1->tv_sec += ts2->tv_sec;
+	ts1->tv_nsec += ts2->tv_nsec;
+	ts_normalize(ts1);
+}
+
+/** Subtract two timespecs.
+ *
+ * @param ts1  First timespec.
+ * @param ts2  Second timespec.
+ *
+ * @return  Difference between ts1 and ts2 (ts1 - ts2) in nanoseconds.
+ *
+ */
+nsec_t ts_sub_diff(const struct timespec *ts1, const struct timespec *ts2)
+{
+	return (nsec_t) (ts1->tv_nsec - ts2->tv_nsec) +
+	    SEC2NSEC((ts1->tv_sec - ts2->tv_sec));
+}
+
+/** Subtract two timespecs.
+ *
+ * @param ts1  First timespec.
+ * @param ts2  Second timespec.
+ *
+ */
+void ts_sub(struct timespec *ts1, const struct timespec *ts2)
+{
+	ts1->tv_sec -= ts2->tv_sec;
+	ts1->tv_nsec -= ts2->tv_nsec;
+	ts_normalize(ts1);
+}
+
+/** Decide if one timespec is greater than the other.
+ *
+ * @param ts1  First timespec.
+ * @param ts2  Second timespec.
+ *
+ * @return  True if ts1 is greater than ts2.
+ * @return  False otherwise.
+ *
+ */
+bool ts_gt(const struct timespec *ts1, const struct timespec *ts2)
+{
+	if (ts1->tv_sec > ts2->tv_sec)
 		return true;
 
-	if ((tv1->tv_sec == tv2->tv_sec) && (tv1->tv_usec > tv2->tv_usec))
+	if ((ts1->tv_sec == ts2->tv_sec) && (ts1->tv_nsec > ts2->tv_nsec))
 		return true;
 
@@ -541,19 +572,19 @@
 }
 
-/** Decide if one timeval is greater than or equal to the other.
- *
- * @param tv1 First timeval.
- * @param tv2 Second timeval.
- *
- * @return True if tv1 is greater than or equal to tv2.
- * @return False otherwise.
- *
- */
-int tv_gteq(const struct timeval *tv1, const struct timeval *tv2)
-{
-	if (tv1->tv_sec > tv2->tv_sec)
+/** Decide if one timespec is greater than or equal to the other.
+ *
+ * @param ts1  First timespec.
+ * @param ts2  Second timespec.
+ *
+ * @return  True if ts1 is greater than or equal to ts2.
+ * @return  False otherwise.
+ *
+ */
+bool ts_gteq(const struct timespec *ts1, const struct timespec *ts2)
+{
+	if (ts1->tv_sec > ts2->tv_sec)
 		return true;
 
-	if ((tv1->tv_sec == tv2->tv_sec) && (tv1->tv_usec >= tv2->tv_usec))
+	if ((ts1->tv_sec == ts2->tv_sec) && (ts1->tv_nsec >= ts2->tv_nsec))
 		return true;
 
@@ -561,25 +592,12 @@
 }
 
-/** Get time of day.
- *
- * The time variables are memory mapped (read-only) from kernel which
- * updates them periodically.
- *
- * As it is impossible to read 2 values atomically, we use a trick:
- * First we read the seconds, then we read the microseconds, then we
- * read the seconds again. If a second elapsed in the meantime, set
- * the microseconds to zero.
- *
- * This assures that the values returned by two subsequent calls
- * to gettimeofday() are monotonous.
- *
- */
-void gettimeofday(struct timeval *tv, struct timezone *tz)
-{
-	if (tz) {
-		tz->tz_minuteswest = 0;
-		tz->tz_dsttime = DST_NONE;
-	}
-
+/** Get real time from a RTC service.
+ *
+ * @param[out] ts  Timespec to hold time read from the RTC service (if
+ *                 available). If no such service exists, the returned time
+ *                 corresponds to system uptime.
+ */
+void getrealtime(struct timespec *ts)
+{
 	if (clock_conn == NULL) {
 		category_id_t cat_id;
@@ -620,14 +638,30 @@
 		goto fallback;
 
-	tv->tv_usec = time.tm_usec;
-	tv->tv_sec = mktime(&time);
+	ts->tv_nsec = time.tm_nsec;
+	ts->tv_sec = mktime(&time);
 
 	return;
 
 fallback:
-	getuptime(tv);
-}
-
-void getuptime(struct timeval *tv)
+	getuptime(ts);
+}
+
+/** Get system uptime.
+ *
+ * @param[out] ts  Timespec to hold time current uptime.
+ *
+ * The time variables are memory mapped (read-only) from kernel which
+ * updates them periodically.
+ *
+ * As it is impossible to read 2 values atomically, we use a trick:
+ * First we read the seconds, then we read the microseconds, then we
+ * read the seconds again. If a second elapsed in the meantime, set
+ * the microseconds to zero.
+ *
+ * This assures that the values returned by two subsequent calls
+ * to getuptime() are monotonous.
+ *
+ */
+void getuptime(struct timespec *ts)
 {
 	if (ktime == NULL) {
@@ -654,5 +688,5 @@
 
 	read_barrier();
-	tv->tv_usec = ktime->useconds;
+	ts->tv_nsec = USEC2NSEC(ktime->useconds);
 
 	read_barrier();
@@ -660,28 +694,28 @@
 
 	if (s1 != s2) {
-		tv->tv_sec = max(s1, s2);
-		tv->tv_usec = 0;
+		ts->tv_sec = max(s1, s2);
+		ts->tv_nsec = 0;
 	} else
-		tv->tv_sec = s1;
+		ts->tv_sec = s1;
 
 	return;
 
 fallback:
-	tv->tv_sec = 0;
-	tv->tv_usec = 0;
+	ts->tv_sec = 0;
+	ts->tv_nsec = 0;
 }
 
 time_t time(time_t *tloc)
 {
-	struct timeval tv;
-	gettimeofday(&tv, NULL);
+	struct timespec ts;
+	getrealtime(&ts);
 
 	if (tloc)
-		*tloc = tv.tv_sec;
-
-	return tv.tv_sec;
-}
-
-void udelay(useconds_t time)
+		*tloc = ts.tv_sec;
+
+	return ts.tv_sec;
+}
+
+void udelay(sysarg_t time)
 {
 	(void) __SYSCALL1(SYS_THREAD_UDELAY, (sysarg_t) time);
@@ -884,5 +918,5 @@
 			break;
 		case 's':
-			APPEND("%ld", secs_since_epoch(tm));
+			APPEND("%lld", secs_since_epoch(tm));
 			break;
 		case 'S':
@@ -961,5 +995,5 @@
 
 	/* Set result to epoch. */
-	result->tm_usec = 0;
+	result->tm_nsec = 0;
 	result->tm_sec = 0;
 	result->tm_min = 0;
@@ -1038,5 +1072,5 @@
  *
  */
-errno_t time_tv2tm(const struct timeval *tv, struct tm *restrict result)
+errno_t time_ts2tm(const struct timespec *ts, struct tm *restrict result)
 {
 	// TODO: Deal with timezones.
@@ -1044,5 +1078,5 @@
 
 	/* Set result to epoch. */
-	result->tm_usec = 0;
+	result->tm_nsec = 0;
 	result->tm_sec = 0;
 	result->tm_min = 0;
@@ -1052,5 +1086,5 @@
 	result->tm_year = 70; /* 1970 */
 
-	if (normalize_tm_tv(result, tv) == -1)
+	if (normalize_tm_ts(result, ts) == -1)
 		return EOVERFLOW;
 
@@ -1070,10 +1104,10 @@
 errno_t time_local2tm(const time_t time, struct tm *restrict result)
 {
-	struct timeval tv = {
+	struct timespec ts = {
 		.tv_sec = time,
-		.tv_usec = 0
+		.tv_nsec = 0
 	};
 
-	return time_tv2tm(&tv, result);
+	return time_ts2tm(&ts, result);
 }
 
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/include/async.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -42,5 +42,5 @@
 #include <ipc/common.h>
 #include <fibril.h>
-#include <sys/time.h>
+#include <time.h>
 #include <stdbool.h>
 #include <abi/proc/task.h>
@@ -112,5 +112,5 @@
 	async_get_call_timeout(data, 0)
 
-extern bool async_get_call_timeout(ipc_call_t *, suseconds_t);
+extern bool async_get_call_timeout(ipc_call_t *, usec_t);
 
 /*
@@ -140,5 +140,5 @@
 
 extern void async_wait_for(aid_t, errno_t *);
-extern errno_t async_wait_timeout(aid_t, errno_t *, suseconds_t);
+extern errno_t async_wait_timeout(aid_t, errno_t *, usec_t);
 extern void async_forget(aid_t);
 
Index: uspace/lib/c/include/ddi.h
===================================================================
--- uspace/lib/c/include/ddi.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/include/ddi.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -39,5 +39,5 @@
 #include <stddef.h>
 #include <stdint.h>
-#include <sys/time.h>
+#include <time.h>
 #include <byteorder.h>
 #include <abi/ddi/irq.h>
@@ -138,5 +138,5 @@
 
 static inline uint8_t pio_change_8(ioport8_t *reg, uint8_t val, uint8_t mask,
-    useconds_t delay)
+    usec_t delay)
 {
 	uint8_t v = pio_read_8(reg);
@@ -147,5 +147,5 @@
 
 static inline uint16_t pio_change_16(ioport16_t *reg, uint16_t val,
-    uint16_t mask, useconds_t delay)
+    uint16_t mask, usec_t delay)
 {
 	uint16_t v = pio_read_16(reg);
@@ -156,5 +156,5 @@
 
 static inline uint32_t pio_change_32(ioport32_t *reg, uint32_t val,
-    uint32_t mask, useconds_t delay)
+    uint32_t mask, usec_t delay)
 {
 	uint32_t v = pio_read_32(reg);
@@ -165,5 +165,5 @@
 
 static inline uint64_t pio_change_64(ioport64_t *reg, uint64_t val,
-    uint64_t mask, useconds_t delay)
+    uint64_t mask, usec_t delay)
 {
 	uint64_t v = pio_read_64(reg);
@@ -173,34 +173,34 @@
 }
 
-static inline uint8_t pio_set_8(ioport8_t *r, uint8_t v, useconds_t d)
+static inline uint8_t pio_set_8(ioport8_t *r, uint8_t v, usec_t d)
 {
 	return pio_change_8(r, v, 0, d);
 }
-static inline uint16_t pio_set_16(ioport16_t *r, uint16_t v, useconds_t d)
+static inline uint16_t pio_set_16(ioport16_t *r, uint16_t v, usec_t d)
 {
 	return pio_change_16(r, v, 0, d);
 }
-static inline uint32_t pio_set_32(ioport32_t *r, uint32_t v, useconds_t d)
+static inline uint32_t pio_set_32(ioport32_t *r, uint32_t v, usec_t d)
 {
 	return pio_change_32(r, v, 0, d);
 }
-static inline uint64_t pio_set_64(ioport64_t *r, uint64_t v, useconds_t d)
+static inline uint64_t pio_set_64(ioport64_t *r, uint64_t v, usec_t d)
 {
 	return pio_change_64(r, v, 0, d);
 }
 
-static inline uint8_t pio_clear_8(ioport8_t *r, uint8_t v, useconds_t d)
+static inline uint8_t pio_clear_8(ioport8_t *r, uint8_t v, usec_t d)
 {
 	return pio_change_8(r, 0, v, d);
 }
-static inline uint16_t pio_clear_16(ioport16_t *r, uint16_t v, useconds_t d)
+static inline uint16_t pio_clear_16(ioport16_t *r, uint16_t v, usec_t d)
 {
 	return pio_change_16(r, 0, v, d);
 }
-static inline uint32_t pio_clear_32(ioport32_t *r, uint32_t v, useconds_t d)
+static inline uint32_t pio_clear_32(ioport32_t *r, uint32_t v, usec_t d)
 {
 	return pio_change_32(r, 0, v, d);
 }
-static inline uint64_t pio_clear_64(ioport64_t *r, uint64_t v, useconds_t d)
+static inline uint64_t pio_clear_64(ioport64_t *r, uint64_t v, usec_t d)
 {
 	return pio_change_64(r, 0, v, d);
Index: uspace/lib/c/include/fibril.h
===================================================================
--- uspace/lib/c/include/fibril.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/include/fibril.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -60,6 +60,6 @@
 extern void fibril_yield(void);
 
-extern void fibril_usleep(suseconds_t);
-extern void fibril_sleep(unsigned int);
+extern void fibril_usleep(usec_t);
+extern void fibril_sleep(sec_t);
 
 extern void fibril_enable_multithreaded(void);
Index: uspace/lib/c/include/fibril_synch.h
===================================================================
--- uspace/lib/c/include/fibril_synch.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/include/fibril_synch.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -39,5 +39,5 @@
 #include <adt/list.h>
 #include <tls.h>
-#include <sys/time.h>
+#include <time.h>
 #include <stdbool.h>
 
@@ -138,5 +138,5 @@
 	fid_t handler_fid;
 
-	suseconds_t delay;
+	usec_t delay;
 	fibril_timer_fun_t fun;
 	void *arg;
@@ -181,5 +181,5 @@
 extern void fibril_condvar_initialize(fibril_condvar_t *);
 extern errno_t fibril_condvar_wait_timeout(fibril_condvar_t *, fibril_mutex_t *,
-    suseconds_t);
+    usec_t);
 extern void fibril_condvar_wait(fibril_condvar_t *, fibril_mutex_t *);
 extern void fibril_condvar_signal(fibril_condvar_t *);
@@ -188,7 +188,7 @@
 extern fibril_timer_t *fibril_timer_create(fibril_mutex_t *);
 extern void fibril_timer_destroy(fibril_timer_t *);
-extern void fibril_timer_set(fibril_timer_t *, suseconds_t, fibril_timer_fun_t,
+extern void fibril_timer_set(fibril_timer_t *, usec_t, fibril_timer_fun_t,
     void *);
-extern void fibril_timer_set_locked(fibril_timer_t *, suseconds_t,
+extern void fibril_timer_set_locked(fibril_timer_t *, usec_t,
     fibril_timer_fun_t, void *);
 extern fibril_timer_state_t fibril_timer_clear(fibril_timer_t *);
@@ -198,5 +198,5 @@
 extern void fibril_semaphore_up(fibril_semaphore_t *);
 extern void fibril_semaphore_down(fibril_semaphore_t *);
-extern errno_t fibril_semaphore_down_timeout(fibril_semaphore_t *, suseconds_t);
+extern errno_t fibril_semaphore_down_timeout(fibril_semaphore_t *, usec_t);
 extern void fibril_semaphore_close(fibril_semaphore_t *);
 
@@ -205,5 +205,5 @@
 extern void mpsc_destroy(mpsc_t *);
 extern errno_t mpsc_send(mpsc_t *, const void *);
-extern errno_t mpsc_receive(mpsc_t *, void *, const struct timeval *);
+extern errno_t mpsc_receive(mpsc_t *, void *, const struct timespec *);
 extern void mpsc_close(mpsc_t *);
 
Index: uspace/lib/c/include/io/con_srv.h
===================================================================
--- uspace/lib/c/include/io/con_srv.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/include/io/con_srv.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -45,5 +45,5 @@
 #include <io/style.h>
 #include <stdbool.h>
-#include <sys/time.h>
+#include <time.h>
 #include <stddef.h>
 
@@ -55,5 +55,5 @@
 	void *sarg;
 	/** Period to check for abort */
-	suseconds_t abort_timeout;
+	usec_t abort_timeout;
 	bool aborted;
 } con_srvs_t;
Index: uspace/lib/c/include/io/console.h
===================================================================
--- uspace/lib/c/include/io/console.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/include/io/console.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -36,5 +36,5 @@
 #define LIBC_IO_CONSOLE_H_
 
-#include <sys/time.h>
+#include <time.h>
 #include <io/concaps.h>
 #include <io/kbd_event.h>
@@ -85,5 +85,5 @@
 extern bool console_get_event(console_ctrl_t *, cons_event_t *);
 extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *,
-    suseconds_t *);
+    usec_t *);
 
 #endif
Index: pace/lib/c/include/sys/time.h
===================================================================
--- uspace/lib/c/include/sys/time.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ 	(revision )
@@ -1,102 +1,0 @@
-/*
- * Copyright (c) 2006 Ondrej Palkovsky
- * Copyright (c) 2011 Petr Koupy
- * Copyright (c) 2011 Jiri Zarevucky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_SYS_TIME_H_
-#define LIBC_SYS_TIME_H_
-
-#include <errno.h>
-#include <stddef.h>
-#include <stdint.h>
-
-#define DST_NONE  0
-#define ASCTIME_BUF_LEN  26
-
-typedef long time_t;
-typedef long suseconds_t;
-
-typedef uint32_t useconds_t;
-typedef uint32_t mseconds_t;
-
-struct tm {
-	int tm_usec;   /* Microseconds [0,999999]. */
-	int tm_sec;    /* Seconds [0,60]. */
-	int tm_min;    /* Minutes [0,59]. */
-	int tm_hour;   /* Hour [0,23]. */
-	int tm_mday;   /* Day of month [1,31]. */
-	int tm_mon;    /* Month of year [0,11]. */
-	int tm_year;   /* Years since 1900. */
-	int tm_wday;   /* Day of week [0,6] (Sunday = 0). */
-	int tm_yday;   /* Day of year [0,365]. */
-	int tm_isdst;  /* Daylight Savings flag. */
-};
-
-struct timeval {
-	time_t tv_sec;        /* seconds */
-	suseconds_t tv_usec;  /* microseconds */
-};
-
-struct timezone {
-	int tz_minuteswest;  /* minutes W of Greenwich */
-	int tz_dsttime;      /* type of dst correction */
-};
-
-extern void tv_add_diff(struct timeval *, suseconds_t);
-extern void tv_add(struct timeval *, const struct timeval *);
-extern suseconds_t tv_sub_diff(const struct timeval *, const struct timeval *);
-extern void tv_sub(struct timeval *, const struct timeval *);
-extern int tv_gt(const struct timeval *, const struct timeval *);
-extern int tv_gteq(const struct timeval *, const struct timeval *);
-extern void gettimeofday(struct timeval *, struct timezone *);
-extern void getuptime(struct timeval *);
-
-extern void udelay(useconds_t);
-extern errno_t usleep(useconds_t);
-
-extern time_t mktime(struct tm *);
-extern errno_t time_utc2tm(const time_t, struct tm *);
-extern errno_t time_utc2str(const time_t, char *);
-extern void time_tm2str(const struct tm *, char *);
-extern errno_t time_tv2tm(const struct timeval *, struct tm *);
-extern errno_t time_local2tm(const time_t, struct tm *);
-extern errno_t time_local2str(const time_t, char *);
-extern double difftime(time_t, time_t);
-extern size_t strftime(char *__restrict__, size_t, const char *__restrict__,
-    const struct tm *__restrict__);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/time.h
===================================================================
--- uspace/lib/c/include/time.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/c/include/time.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2007 Jakub Jermar
+ * Copyright (c) 2018 Jakub Jermar
  * All rights reserved.
  *
@@ -40,7 +40,117 @@
 #endif
 
-#include <sys/time.h>
 
+/* ISO/IEC 9899:2011 7.27.1 (2) */
+
+#include <_bits/NULL.h>
+
+#define CLOCKS_PER_SEC	((clock_t) 1000000)
+
+#define TIME_UTC	1
+
+
+/* ISO/IEC 9899:2011 7.27.1 (3) */
+
+#include <_bits/size_t.h>
+
+/* ISO/IEC 9899:2011 7.27.1 (3), (4) */
+
+typedef long long time_t;
+typedef long long clock_t;
+
+struct timespec {
+	time_t tv_sec;
+	long tv_nsec;
+};
+
+struct tm {
+	int tm_sec;
+	int tm_nsec;
+	int tm_min;
+	int tm_hour;
+	int tm_mday;
+	int tm_mon;
+	int tm_year;
+	int tm_wday;
+	int tm_yday;
+	int tm_isdst;
+};
+
+/* ISO/IEC 9899:2011 7.27.2.1 (1) */
+extern clock_t clock(void);
+
+/* ISO/IEC 9899:2011 7.27.2.2 (1) */
+extern double difftime(time_t, time_t);
+
+/* ISO/IEC 9899:2011 7.27.2.3 (1) */
+extern time_t mktime(struct tm *);
+
+/* ISO/IEC 9899:2011 7.27.2.4 (1) */
 extern time_t time(time_t *);
+
+/* ISO/IEC 9899:2011 7.27.2.5 (1) */
+extern int timespec_get(struct timespec *, int);
+
+/* ISO/IEC 9899:2011 7.27.3.1 (1) */
+extern char *asctime(const struct tm *);
+
+/* ISO/IEC 9899:2011 7.27.3.2 (1) */
+extern char *ctime(const time_t *);
+
+/* ISO/IEC 9899:2011 7.27.3.3 (1) */
+extern struct tm *gmtime(const time_t *);
+
+/* ISO/IEC 9899:2011 7.27.3.4 (1) */
+extern struct tm *localtime(const time_t *);
+
+/* ISO/IEC 9899:2011 7.27.3.5 (1) */
+extern size_t strftime(char *, size_t, const char *, const struct tm *);
+
+/*
+ * HelenOS specific extensions
+ */
+
+#include <stdbool.h>
+#include <_bits/errno.h>
+
+typedef long long sec_t;
+typedef long long msec_t;
+typedef long long usec_t;
+typedef long long nsec_t;	/* good for +/- 292 years */
+
+#define SEC2MSEC(s)	((s) * 1000ll)
+#define SEC2USEC(s)	((s) * 1000000ll)
+#define SEC2NSEC(s)	((s) * 1000000000ll)
+
+#define MSEC2SEC(ms)	((ms) / 1000ll)
+#define MSEC2USEC(ms)	((ms) * 1000ll)
+#define MSEC2NSEC(ms)	((ms) * 1000000ll)
+
+#define USEC2SEC(us)	((us) / 1000000ll)
+#define USEC2MSEC(us)	((us) / 1000ll)
+#define USEC2NSEC(us)	((us) * 1000ll)
+
+#define NSEC2SEC(ns)	((ns) / 1000000000ll)
+#define NSEC2MSEC(ns)	((ns) / 1000000ll)
+#define NSEC2USEC(ns)	((ns) / 1000ll)
+
+extern void getuptime(struct timespec *);
+extern void getrealtime(struct timespec *);
+
+extern void ts_add_diff(struct timespec *, nsec_t);
+extern void ts_add(struct timespec *, const struct timespec *);
+extern void ts_sub(struct timespec *, const struct timespec *);
+extern nsec_t ts_sub_diff(const struct timespec *, const struct timespec *);
+extern bool ts_gt(const struct timespec *, const struct timespec *);
+extern bool ts_gteq(const struct timespec *, const struct timespec *);
+
+extern errno_t time_utc2tm(const time_t, struct tm *);
+extern errno_t time_utc2str(const time_t, char *);
+extern void time_tm2str(const struct tm *, char *);
+extern errno_t time_ts2tm(const struct timespec *, struct tm *);
+extern errno_t time_local2tm(const time_t, struct tm *);
+extern errno_t time_local2str(const time_t, char *);
+
+extern void udelay(sysarg_t);
 
 #ifdef __cplusplus
Index: uspace/lib/cpp/include/__bits/chrono.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/chrono.hpp	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/cpp/include/__bits/chrono.hpp	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -611,9 +611,9 @@
             static time_point now()
             {
-                hel::timeval tv{};
-                hel::gettimeofday(&tv, nullptr);
-
-                rep time = tv.tv_usec;
-                time += (tv.tv_sec * 1'000'000ul);
+                hel::timespec ts{};
+                hel::getrealtime(&ts);
+
+                rep time = NSEC2USEC(ts.tv_nsec);
+                time += (ts.tv_sec * 1'000'000ul);
 
                 return time_point{duration{time - epoch_usecs}};
@@ -654,9 +654,9 @@
             static time_point now()
             {
-                hel::timeval tv{};
-                hel::getuptime(&tv);
-
-                rep time = tv.tv_usec;
-                time += (tv.tv_sec * 1'000'000ul);
+                hel::timespec ts{};
+                hel::getuptime(&ts);
+
+                rep time = NSEC2USEC(ts.tv_nsec);
+                time += (ts.tv_sec * 1'000'000ul);
 
                 return time_point{duration{time}};
Index: uspace/lib/cpp/include/__bits/thread/threading.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/thread/threading.hpp	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/cpp/include/__bits/thread/threading.hpp	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -58,5 +58,5 @@
         using thread_type       = hel::fid_t;
         using condvar_type      = hel::fibril_condvar_t;
-        using time_unit         = hel::suseconds_t;
+        using time_unit         = hel::usec_t;
         using shared_mutex_type = hel::fibril_rwlock_t;
 
Index: uspace/lib/drv/generic/remote_nic.c
===================================================================
--- uspace/lib/drv/generic/remote_nic.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/drv/generic/remote_nic.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -39,5 +39,5 @@
 #include <errno.h>
 #include <ipc/services.h>
-#include <sys/time.h>
+#include <time.h>
 #include <macros.h>
 
@@ -1262,5 +1262,5 @@
  */
 errno_t nic_poll_get_mode(async_sess_t *dev_sess, nic_poll_mode_t *mode,
-    struct timeval *period)
+    struct timespec *period)
 {
 	assert(mode);
@@ -1280,5 +1280,5 @@
 
 	if (period != NULL)
-		rc = async_data_read_start(exch, period, sizeof(struct timeval));
+		rc = async_data_read_start(exch, period, sizeof(struct timespec));
 
 	async_exchange_end(exch);
@@ -1296,5 +1296,5 @@
  */
 errno_t nic_poll_set_mode(async_sess_t *dev_sess, nic_poll_mode_t mode,
-    const struct timeval *period)
+    const struct timespec *period)
 {
 	async_exch_t *exch = async_exchange_begin(dev_sess);
@@ -1305,5 +1305,5 @@
 	errno_t rc;
 	if (period)
-		rc = async_data_write_start(exch, period, sizeof(struct timeval));
+		rc = async_data_write_start(exch, period, sizeof(struct timespec));
 	else
 		rc = EOK;
@@ -2405,7 +2405,7 @@
 	nic_poll_mode_t mode = NIC_POLL_IMMEDIATE;
 	int request_data = IPC_GET_ARG2(*call);
-	struct timeval period = {
+	struct timespec period = {
 		.tv_sec = 0,
-		.tv_usec = 0
+		.tv_nsec = 0
 	};
 
@@ -2421,5 +2421,5 @@
 		}
 
-		if (max_len != sizeof(struct timeval)) {
+		if (max_len != sizeof(struct timespec)) {
 			async_answer_0(&data, ELIMIT);
 			async_answer_0(call, ELIMIT);
@@ -2428,5 +2428,5 @@
 
 		async_data_read_finalize(&data, &period,
-		    sizeof(struct timeval));
+		    sizeof(struct timespec));
 	}
 
@@ -2441,6 +2441,6 @@
 	nic_poll_mode_t mode = IPC_GET_ARG2(*call);
 	int has_period = IPC_GET_ARG3(*call);
-	struct timeval period_buf;
-	struct timeval *period = NULL;
+	struct timespec period_buf;
+	struct timespec *period = NULL;
 	size_t length;
 
@@ -2453,5 +2453,5 @@
 		}
 
-		if (length != sizeof(struct timeval)) {
+		if (length != sizeof(struct timespec)) {
 			async_answer_0(&data, ELIMIT);
 			async_answer_0(call, ELIMIT);
Index: uspace/lib/drv/include/nic_iface.h
===================================================================
--- uspace/lib/drv/include/nic_iface.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/drv/include/nic_iface.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -106,7 +106,7 @@
 
 extern errno_t nic_poll_get_mode(async_sess_t *, nic_poll_mode_t *,
-    struct timeval *);
+    struct timespec *);
 extern errno_t nic_poll_set_mode(async_sess_t *, nic_poll_mode_t,
-    const struct timeval *);
+    const struct timespec *);
 extern errno_t nic_poll_now(async_sess_t *);
 
Index: uspace/lib/drv/include/ops/nic.h
===================================================================
--- uspace/lib/drv/include/ops/nic.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/drv/include/ops/nic.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -39,5 +39,5 @@
 #include <ipc/services.h>
 #include <nic/nic.h>
-#include <sys/time.h>
+#include <time.h>
 #include "../ddf/driver.h"
 
@@ -104,7 +104,7 @@
 
 	errno_t (*poll_get_mode)(ddf_fun_t *, nic_poll_mode_t *,
-	    struct timeval *);
+	    struct timespec *);
 	errno_t (*poll_set_mode)(ddf_fun_t *, nic_poll_mode_t,
-	    const struct timeval *);
+	    const struct timespec *);
 	errno_t (*poll_now)(ddf_fun_t *);
 } nic_iface_t;
Index: uspace/lib/drv/include/pci_dev_iface.h
===================================================================
--- uspace/lib/drv/include/pci_dev_iface.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/drv/include/pci_dev_iface.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -37,4 +37,6 @@
 #ifndef LIBDRV_PCI_DEV_IFACE_H_
 #define LIBDRV_PCI_DEV_IFACE_H_
+
+#include <errno.h>
 
 #include "ddf/driver.h"
Index: uspace/lib/nic/include/nic.h
===================================================================
--- uspace/lib/nic/include/nic.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/nic/include/nic.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -196,5 +196,5 @@
  */
 typedef errno_t (*poll_mode_change_handler)(nic_t *,
-    nic_poll_mode_t, const struct timeval *);
+    nic_poll_mode_t, const struct timespec *);
 
 /**
@@ -240,9 +240,9 @@
 extern void nic_set_tx_busy(nic_t *, int);
 extern errno_t nic_report_address(nic_t *, const nic_address_t *);
-extern errno_t nic_report_poll_mode(nic_t *, nic_poll_mode_t, struct timeval *);
+extern errno_t nic_report_poll_mode(nic_t *, nic_poll_mode_t, struct timespec *);
 extern void nic_query_address(nic_t *, nic_address_t *);
 extern void nic_received_frame(nic_t *, nic_frame_t *);
 extern void nic_received_frame_list(nic_t *, nic_frame_list_t *);
-extern nic_poll_mode_t nic_query_poll_mode(nic_t *, struct timeval *);
+extern nic_poll_mode_t nic_query_poll_mode(nic_t *, struct timespec *);
 
 /* Statistics updates */
Index: uspace/lib/nic/include/nic_driver.h
===================================================================
--- uspace/lib/nic/include/nic_driver.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/nic/include/nic_driver.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -83,9 +83,9 @@
 	nic_poll_mode_t poll_mode;
 	/** Polling period (applicable when poll_mode == NIC_POLL_PERIODIC) */
-	struct timeval poll_period;
+	struct timespec poll_period;
 	/** Current polling mode of the NIC */
 	nic_poll_mode_t default_poll_mode;
 	/** Polling period (applicable when default_poll_mode == NIC_POLL_PERIODIC) */
-	struct timeval default_poll_period;
+	struct timespec default_poll_period;
 	/** Software period fibrill information */
 	struct sw_poll_info sw_poll_info;
Index: uspace/lib/nic/include/nic_impl.h
===================================================================
--- uspace/lib/nic/include/nic_impl.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/nic/include/nic_impl.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -78,7 +78,7 @@
 extern errno_t nic_wol_virtue_get_caps_impl(ddf_fun_t *, nic_wv_type_t, int *);
 extern errno_t nic_poll_get_mode_impl(ddf_fun_t *,
-    nic_poll_mode_t *, struct timeval *);
+    nic_poll_mode_t *, struct timespec *);
 extern errno_t nic_poll_set_mode_impl(ddf_fun_t *,
-    nic_poll_mode_t, const struct timeval *);
+    nic_poll_mode_t, const struct timespec *);
 extern errno_t nic_poll_now_impl(ddf_fun_t *);
 
Index: uspace/lib/nic/src/nic_driver.c
===================================================================
--- uspace/lib/nic/src/nic_driver.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/nic/src/nic_driver.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -384,5 +384,5 @@
  *  @return Current polling mode of the controller
  */
-nic_poll_mode_t nic_query_poll_mode(nic_t *nic_data, struct timeval *period)
+nic_poll_mode_t nic_query_poll_mode(nic_t *nic_data, struct timespec *period)
 {
 	if (period)
@@ -400,5 +400,5 @@
  */
 errno_t nic_report_poll_mode(nic_t *nic_data, nic_poll_mode_t mode,
-    struct timeval *period)
+    struct timespec *period)
 {
 	errno_t rc = EOK;
@@ -408,6 +408,6 @@
 	if (mode == NIC_POLL_PERIODIC) {
 		if (period) {
-			memcpy(&nic_data->default_poll_period, period, sizeof(struct timeval));
-			memcpy(&nic_data->poll_period, period, sizeof(struct timeval));
+			memcpy(&nic_data->default_poll_period, period, sizeof(struct timespec));
+			memcpy(&nic_data->poll_period, period, sizeof(struct timespec));
 		} else {
 			rc = EINVAL;
@@ -1030,7 +1030,7 @@
  *  @returns Nonzero if t is zero interval
  */
-static int timeval_nonpositive(struct timeval t)
-{
-	return (t.tv_sec <= 0) && (t.tv_usec <= 0);
+static int timespec_nonpositive(struct timespec t)
+{
+	return (t.tv_sec <= 0) && (t.tv_nsec <= 0);
 }
 
@@ -1051,15 +1051,15 @@
 		int run = info->run;
 		int running = info->running;
-		struct timeval remaining = nic->poll_period;
+		struct timespec remaining = nic->poll_period;
 		fibril_rwlock_read_unlock(&nic->main_lock);
 
 		if (!running) {
 			remaining.tv_sec = 5;
-			remaining.tv_usec = 0;
+			remaining.tv_nsec = 0;
 		}
 
 		/* Wait the period (keep attention to overflows) */
-		while (!timeval_nonpositive(remaining)) {
-			suseconds_t wait = 0;
+		while (!timespec_nonpositive(remaining)) {
+			usec_t wait = 0;
 			if (remaining.tv_sec > 0) {
 				time_t wait_sec = remaining.tv_sec;
@@ -1071,9 +1071,9 @@
 					wait_sec = 5;
 
-				wait = (suseconds_t) wait_sec * 1000000;
+				wait = SEC2USEC(wait_sec);
 
 				remaining.tv_sec -= wait_sec;
 			} else {
-				wait = remaining.tv_usec;
+				wait = NSEC2USEC(remaining.tv_nsec);
 
 				if (wait > 5 * 1000000) {
@@ -1081,5 +1081,5 @@
 				}
 
-				remaining.tv_usec -= wait;
+				remaining.tv_nsec -= USEC2NSEC(wait);
 			}
 			fibril_usleep(wait);
Index: uspace/lib/nic/src/nic_impl.c
===================================================================
--- uspace/lib/nic/src/nic_impl.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/nic/src/nic_impl.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -121,5 +121,5 @@
 		nic_data->poll_mode = nic_data->default_poll_mode;
 		memcpy(&nic_data->poll_period, &nic_data->default_poll_period,
-		    sizeof(struct timeval));
+		    sizeof(struct timespec));
 		if (rc != EOK) {
 			/*
@@ -714,10 +714,10 @@
  */
 errno_t nic_poll_get_mode_impl(ddf_fun_t *fun,
-    nic_poll_mode_t *mode, struct timeval *period)
+    nic_poll_mode_t *mode, struct timespec *period)
 {
 	nic_t *nic_data = nic_get_from_ddf_fun(fun);
 	fibril_rwlock_read_lock(&nic_data->main_lock);
 	*mode = nic_data->poll_mode;
-	memcpy(period, &nic_data->poll_period, sizeof(struct timeval));
+	memcpy(period, &nic_data->poll_period, sizeof(struct timespec));
 	fibril_rwlock_read_unlock(&nic_data->main_lock);
 	return EOK;
@@ -737,5 +737,5 @@
  */
 errno_t nic_poll_set_mode_impl(ddf_fun_t *fun,
-    nic_poll_mode_t mode, const struct timeval *period)
+    nic_poll_mode_t mode, const struct timespec *period)
 {
 	nic_t *nic_data = nic_get_from_ddf_fun(fun);
@@ -753,7 +753,7 @@
 		if (period == NULL)
 			return EINVAL;
-		if (period->tv_sec == 0 && period->tv_usec == 0)
+		if (period->tv_sec == 0 && period->tv_nsec == 0)
 			return EINVAL;
-		if (period->tv_sec < 0 || period->tv_usec < 0)
+		if (period->tv_sec < 0 || period->tv_nsec < 0)
 			return EINVAL;
 	}
Index: uspace/lib/pcm/include/pcm/format.h
===================================================================
--- uspace/lib/pcm/include/pcm/format.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/pcm/include/pcm/format.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -80,6 +80,5 @@
  * @return Number of microseconds.
  */
-static inline useconds_t pcm_format_size_to_usec(size_t size,
-    const pcm_format_t *a)
+static inline usec_t pcm_format_size_to_usec(size_t size, const pcm_format_t *a)
 {
 	return pcm_sample_format_size_to_usec(size, a->sampling_rate,
Index: uspace/lib/pcm/include/pcm/sample_format.h
===================================================================
--- uspace/lib/pcm/include/pcm/sample_format.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/pcm/include/pcm/sample_format.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -167,5 +167,5 @@
  * @return Number of useconds of audio data.
  */
-static inline useconds_t pcm_sample_format_size_to_usec(size_t size,
+static inline usec_t pcm_sample_format_size_to_usec(size_t size,
     unsigned sample_rate, unsigned channels, pcm_sample_format_t format)
 {
Index: uspace/lib/pcut/src/os/helenos.c
===================================================================
--- uspace/lib/pcut/src/os/helenos.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/pcut/src/os/helenos.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -141,5 +141,5 @@
 	pcut_item_t *test = arg;
 	int timeout_sec = pcut_get_test_timeout(test);
-	suseconds_t timeout_us = (suseconds_t) timeout_sec * 1000 * 1000;
+	usec_t timeout_us = SEC2USEC(timeout_sec);
 
 	fibril_mutex_lock(&forced_termination_mutex);
Index: uspace/lib/posix/include/posix/sys/time.h
===================================================================
--- uspace/lib/posix/include/posix/sys/time.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/posix/include/posix/sys/time.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -34,5 +34,12 @@
 #define POSIX_SYS_TIME_H_
 
-#include "libc/sys/time.h"
+#include "libc/time.h"
+
+struct timeval {
+	time_t tv_sec;        /* seconds */
+	suseconds_t tv_usec;  /* microseconds */
+};
+
+extern int gettimeofday(struct timeval *, void *);
 
 #endif
Index: uspace/lib/posix/include/posix/sys/types.h
===================================================================
--- uspace/lib/posix/include/posix/sys/types.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/posix/include/posix/sys/types.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -38,5 +38,4 @@
 
 #include "libc/offset.h"
-#include "libc/sys/time.h"
 #include "libc/types/common.h"
 
@@ -56,7 +55,7 @@
 
 /* Clock Types */
-typedef long clock_t;
 typedef int clockid_t;
 
+typedef long suseconds_t;
 
 #endif /* POSIX_SYS_TYPES_H_ */
Index: uspace/lib/posix/include/posix/time.h
===================================================================
--- uspace/lib/posix/include/posix/time.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/posix/include/posix/time.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -41,7 +41,5 @@
 #include <_bits/NULL.h>
 
-#ifndef CLOCKS_PER_SEC
-#define CLOCKS_PER_SEC (1000000L)
-#endif
+#include "libc/time.h"
 
 #ifndef __locale_t_defined
@@ -57,8 +55,5 @@
 #define CLOCK_REALTIME ((clockid_t) 0)
 
-struct timespec {
-	time_t tv_sec; /* Seconds. */
-	long tv_nsec; /* Nanoseconds. */
-};
+#define ASCTIME_BUF_LEN  26
 
 struct itimerspec {
@@ -104,8 +99,4 @@
     const struct timespec *rqtp, struct timespec *rmtp);
 
-/* CPU Time */
-extern clock_t clock(void);
-
-
 #endif  // POSIX_TIME_H_
 
Index: uspace/lib/posix/src/internal/common.h
===================================================================
--- uspace/lib/posix/src/internal/common.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/posix/src/internal/common.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -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 e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/posix/src/time.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -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;
 }
 
Index: uspace/lib/usb/include/usb/port.h
===================================================================
--- uspace/lib/usb/include/usb/port.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/usb/include/usb/port.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -90,6 +90,5 @@
 
 /* And these are to be called from the connected handler. */
-int usb_port_condvar_wait_timeout(usb_port_t *port,
-    fibril_condvar_t *, suseconds_t);
+int usb_port_condvar_wait_timeout(usb_port_t *port, fibril_condvar_t *, usec_t);
 
 /**
Index: uspace/lib/usb/src/port.c
===================================================================
--- uspace/lib/usb/src/port.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/usb/src/port.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -237,5 +237,6 @@
 }
 
-int usb_port_condvar_wait_timeout(usb_port_t *port, fibril_condvar_t *cv, suseconds_t timeout)
+int usb_port_condvar_wait_timeout(usb_port_t *port, fibril_condvar_t *cv,
+    usec_t timeout)
 {
 	assert(port);
Index: uspace/lib/usbhost/include/usb/host/endpoint.h
===================================================================
--- uspace/lib/usbhost/include/usb/host/endpoint.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/usbhost/include/usb/host/endpoint.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -45,5 +45,5 @@
 #include <refcount.h>
 #include <stdbool.h>
-#include <sys/time.h>
+#include <time.h>
 #include <usb/usb.h>
 #include <usb/host/bus.h>
@@ -125,5 +125,5 @@
 extern void endpoint_set_offline_locked(endpoint_t *);
 
-extern void endpoint_wait_timeout_locked(endpoint_t *ep, suseconds_t);
+extern void endpoint_wait_timeout_locked(endpoint_t *ep, usec_t);
 extern int endpoint_activate_locked(endpoint_t *, usb_transfer_batch_t *);
 extern void endpoint_deactivate_locked(endpoint_t *);
Index: uspace/lib/usbhost/src/endpoint.c
===================================================================
--- uspace/lib/usbhost/src/endpoint.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/lib/usbhost/src/endpoint.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -145,5 +145,5 @@
  * offline (and is interrupted by the endpoint going offline).
  */
-void endpoint_wait_timeout_locked(endpoint_t *ep, suseconds_t timeout)
+void endpoint_wait_timeout_locked(endpoint_t *ep, usec_t timeout)
 {
 	assert(ep);
Index: uspace/srv/audio/hound/audio_device.c
===================================================================
--- uspace/srv/audio/hound/audio_device.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/srv/audio/hound/audio_device.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -266,5 +266,5 @@
 static void device_event_callback(ipc_call_t *icall, void *arg)
 {
-	struct timeval time1;
+	struct timespec time1;
 	errno_t ret;
 
@@ -286,8 +286,8 @@
 			    dev->buffer.fragment_size);
 			advance_buffer(dev, dev->buffer.fragment_size);
-			struct timeval time2;
+			struct timespec time2;
 			getuptime(&time2);
-			log_verbose("Time to mix sources: %li\n",
-			    tv_sub_diff(&time2, &time1));
+			log_verbose("Time to mix sources: %lld\n",
+			    NSEC2USEC(ts_sub_diff(&time2, &time1)));
 			break;
 		case PCM_EVENT_CAPTURE_TERMINATED:
Index: uspace/srv/net/ethip/atrans.c
===================================================================
--- uspace/srv/net/ethip/atrans.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/srv/net/ethip/atrans.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -134,5 +134,5 @@
 }
 
-errno_t atrans_lookup_timeout(addr32_t ip_addr, suseconds_t timeout,
+errno_t atrans_lookup_timeout(addr32_t ip_addr, usec_t timeout,
     addr48_t mac_addr)
 {
Index: uspace/srv/net/ethip/atrans.h
===================================================================
--- uspace/srv/net/ethip/atrans.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/srv/net/ethip/atrans.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -45,5 +45,5 @@
 extern errno_t atrans_remove(addr32_t);
 extern errno_t atrans_lookup(addr32_t, addr48_t);
-extern errno_t atrans_lookup_timeout(addr32_t, suseconds_t, addr48_t);
+extern errno_t atrans_lookup_timeout(addr32_t, usec_t, addr48_t);
 
 #endif
Index: uspace/srv/net/inetsrv/ntrans.c
===================================================================
--- uspace/srv/net/inetsrv/ntrans.c	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/srv/net/inetsrv/ntrans.c	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -156,5 +156,5 @@
  *
  */
-errno_t ntrans_wait_timeout(suseconds_t timeout)
+errno_t ntrans_wait_timeout(usec_t timeout)
 {
 	fibril_mutex_lock(&ntrans_list_lock);
Index: uspace/srv/net/inetsrv/ntrans.h
===================================================================
--- uspace/srv/net/inetsrv/ntrans.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/srv/net/inetsrv/ntrans.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -51,5 +51,5 @@
 extern errno_t ntrans_remove(addr128_t);
 extern errno_t ntrans_lookup(addr128_t, addr48_t);
-extern errno_t ntrans_wait_timeout(suseconds_t);
+extern errno_t ntrans_wait_timeout(usec_t);
 
 #endif
Index: uspace/srv/net/tcp/tcp_type.h
===================================================================
--- uspace/srv/net/tcp/tcp_type.h	(revision e2625b1a1e5a2895b86f0e39c2d70a39e49e042a)
+++ uspace/srv/net/tcp/tcp_type.h	(revision bd41ac52cf7d20e9e568c519bf2cb5ac7104b86a)
@@ -192,5 +192,5 @@
 typedef struct {
 	link_t link;
-	suseconds_t delay;
+	usec_t delay;
 	inet_ep2_t epp;
 	tcp_segment_t *seg;
