summaryrefslogtreecommitdiff
path: root/src/unistd/ualarm.c
blob: 855504bca42c743580fbbb3425a3176736411c7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/time.h>

unsigned ualarm(unsigned value, unsigned interval)
{
	struct itimerval it = {
		.it_interval.tv_usec = interval,
		.it_value.tv_usec = value
	};
	setitimer(ITIMER_REAL, &it, &it);
	return it.it_value.tv_sec*1000000 + it.it_value.tv_usec;
}