1: /*
   2:  * Copyright (c) 1985 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if defined(LIBC_SCCS) && !defined(lint)
   8: static char sccsid[] = "@(#)ualarm.c	5.2 (Berkeley) 3/9/86";
   9: #endif LIBC_SCCS and not lint
  10: 
  11: #include <sys/time.h>
  12: 
  13: #define USPS    1000000     /* # of microseconds in a second */
  14: 
  15: /*
  16:  * Generate a SIGALRM signal in ``usecs'' microseconds.
  17:  * If ``reload'' is non-zero, keep generating SIGALRM
  18:  * every ``reload'' microseconds after the first signal.
  19:  */
  20: unsigned
  21: ualarm(usecs, reload)
  22:     register unsigned usecs;
  23:     register unsigned reload;
  24: {
  25:     struct itimerval new, old;
  26: 
  27:     new.it_interval.tv_usec = reload % USPS;
  28:     new.it_interval.tv_sec = reload / USPS;
  29: 
  30:     new.it_value.tv_usec = usecs % USPS;
  31:     new.it_value.tv_sec = usecs / USPS;
  32: 
  33:     if (setitimer(ITIMER_REAL, &new, &old) == 0)
  34:         return (old.it_value.tv_sec * USPS + old.it_value.tv_usec);
  35:     /* else */
  36:         return (-1);
  37: }

Defined functions

ualarm defined in line 20; used 1 times

Defined variables

sccsid defined in line 8; never used

Defined macros

USPS defined in line 13; used 5 times
Last modified: 1986-03-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1977
Valid CSS Valid XHTML 1.0 Strict