1#define _GNU_SOURCE
2#include <unistd.h>
3#include <sys/time.h>
4
5unsigned ualarm(unsigned value, unsigned interval)
6{
7	struct itimerval it = {
8		.it_interval.tv_usec = interval,
9		.it_value.tv_usec = value
10	}, it_old;
11	setitimer(ITIMER_REAL, &it, &it_old);
12	return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec;
13}
14