Annotation of coherent/f/usr/include.78/sys/fun.h, revision 1.1

1.1     ! root        1: /* (-lgl
        !             2:  *     COHERENT 386 Device Driver Kit release 2.0
        !             3:  *     Copyright (c) 1982, 1992 by Mark Williams Company.
        !             4:  *     All rights reserved. May not be copied without permission.
        !             5:  -lgl) */
        !             6: /*
        !             7:  * Coherent.  Some useful functions.
        !             8:  */
        !             9: 
        !            10: #ifndef        __SYS_FUN_H__
        !            11: #define        __SYS_FUN_H__
        !            12: 
        !            13: /*
        !            14:  * Number of elements in a structure.
        !            15:  */
        !            16: #define nel(a)         (sizeof(a)/sizeof((a)[0]))
        !            17: 
        !            18: /*
        !            19:  * Character pointer to integer.
        !            20:  */
        !            21: #define cpi(p)         ((char *)(p) - (char *)0)
        !            22: 
        !            23: /*
        !            24:  * Round a number upwards to be a multiple of another.
        !            25:  */
        !            26: #define        roundu(n1, n2)  (((n1)+(n2)-1)/n2*n2)
        !            27: 
        !            28: /*
        !            29:  * Offset in bytes of `m' in the structure `s'.
        !            30:  */
        !            31: #define offset(s, m)   ((int) &(((struct s *) 0)->m))
        !            32: 
        !            33: /*
        !            34:  * Add an unsigned number without overflow.
        !            35:  */
        !            36: #define        addu(v, n) {                                                    \
        !            37:        unsigned x;                                                     \
        !            38:                                                                        \
        !            39:        x = v + (n);                                                    \
        !            40:        v = x>=v ? x : MAXU;                                            \
        !            41: }
        !            42: 
        !            43: /*
        !            44:  * Subtract an unsigned number without overflow.
        !            45:  */
        !            46: #define        subu(v, n) {                                                    \
        !            47:        unsigned x;                                                     \
        !            48:                                                                        \
        !            49:        x = v - (n);                                                    \
        !            50:        v = x<=v ? x : 0;                                               \
        !            51: };
        !            52: 
        !            53: #endif

unix.superglobalmegacorp.com

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