8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / libc / gen / common / ualarm.c
blob9972b0b2796c0e28e808db3848c54da50acda16d
1 #pragma ident "%Z%%M% %I% %E% SMI"
2 /* from UCB 5.1 85/06/05 */
4 /*
5 * Copyright (c) 1985 Regents of the University of California.
6 * All rights reserved. The Berkeley software License Agreement
7 * specifies the terms and conditions for redistribution.
8 */
10 #include <sys/time.h>
12 #define USPS 1000000 /* # of microseconds in a second */
15 * Generate a SIGALRM signal in ``usecs'' microseconds.
16 * If ``reload'' is non-zero, keep generating SIGALRM
17 * every ``reload'' microseconds after the first signal.
19 unsigned
20 ualarm(usecs, reload)
21 register unsigned usecs;
22 register unsigned reload;
24 struct itimerval new, old;
26 new.it_interval.tv_usec = reload % USPS;
27 new.it_interval.tv_sec = reload / USPS;
29 new.it_value.tv_usec = usecs % USPS;
30 new.it_value.tv_sec = usecs / USPS;
32 if (setitimer(ITIMER_REAL, &new, &old) == 0)
33 return (old.it_value.tv_sec * USPS + old.it_value.tv_usec);
34 /* else */
35 return (-1);