summaryrefslogblamecommitdiff
path: root/src/unistd/ualarm.c
blob: 2985855c72afd3e4b88fca07a1179634b1bf1af6 (plain) (tree)
1
2
3
4
5
6
7
8
9
                   
                   
                     
 
                                                  
 


                                                


                                                                        
 
#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
	}, it_old;
	setitimer(ITIMER_REAL, &it, &it_old);
	return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec;
}