Annotation of 43BSD/lib/libc/gen/ualarm.c, revision 1.1

1.1     ! root        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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.