ualarm.c 303 B

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