2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1985 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
18 #include <sys/types.h>
22 #define USPS 1000000 /* # of microseconds in a second */
25 * Generate a SIGALRM signal in ``usecs'' microseconds.
26 * If ``reload'' is non-zero, keep generating SIGALRM
27 * every ``reload'' microseconds after the first signal.
30 ualarm(useconds_t usecs
, useconds_t reload
)
32 struct itimerval
new, old
;
34 new.it_interval
.tv_usec
= reload
% USPS
;
35 new.it_interval
.tv_sec
= reload
/ USPS
;
37 new.it_value
.tv_usec
= usecs
% USPS
;
38 new.it_value
.tv_sec
= usecs
/ USPS
;
40 if (setitimer(ITIMER_REAL
, &new, &old
) != 0)
41 return (0); /* no errors are defined */
42 return (old
.it_value
.tv_sec
* USPS
+ old
.it_value
.tv_usec
);