Annotation of 43BSDReno/contrib/isode-beta/others/X/server/osdep.h, revision 1.1

1.1     ! root        1: /***********************************************************
        !             2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
        !             3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
        !             4: 
        !             5:                         All Rights Reserved
        !             6: 
        !             7: Permission to use, copy, modify, and distribute this software and its 
        !             8: documentation for any purpose and without fee is hereby granted, 
        !             9: provided that the above copyright notice appear in all copies and that
        !            10: both that copyright notice and this permission notice appear in 
        !            11: supporting documentation, and that the names of Digital or MIT not be
        !            12: used in advertising or publicity pertaining to distribution of the
        !            13: software without specific, written prior permission.  
        !            14: 
        !            15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
        !            16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
        !            17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
        !            18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
        !            19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
        !            20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
        !            21: SOFTWARE.
        !            22: 
        !            23: ******************************************************************/
        !            24: /* $XConsortium: osdep.h,v 1.15 88/09/06 15:50:47 jim Exp $ */
        !            25: 
        !            26: #ifndef NULL
        !            27: #define NULL 0
        !            28: #endif
        !            29: 
        !            30: #define BUFSIZE 4096
        !            31: #define BUFWATERMARK 8192
        !            32: #define MAXBUFSIZE (1 << 18)
        !            33: #if (NOFILE <= 128) /* 128 is value of MAXCLIENTS in dix layer */
        !            34: #define MAXSOCKS (NOFILE - 1)
        !            35: #else
        !            36: #define MAXSOCKS 128
        !            37: #endif
        !            38: #define mskcnt ((MAXSOCKS + 31) / 32)  /* size of bit array */
        !            39: 
        !            40: #if (mskcnt==1)
        !            41: #define BITMASK(i) (1 << (i))
        !            42: #define MASKIDX(i) 0
        !            43: #endif
        !            44: #if (mskcnt>1)
        !            45: #define BITMASK(i) (1 << ((i) & 31))
        !            46: #define MASKIDX(i) ((i) >> 5)
        !            47: #endif
        !            48: 
        !            49: #define MASKWORD(buf, i) buf[MASKIDX(i)]
        !            50: #define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
        !            51: #define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
        !            52: #define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
        !            53: 
        !            54: #if (mskcnt==1)
        !            55: #define COPYBITS(src, dst) dst[0] = src[0]
        !            56: #define CLEARBITS(buf) buf[0] = 0
        !            57: #define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
        !            58: #define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
        !            59: #define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
        !            60: #define ANYSET(src) (src[0])
        !            61: #endif
        !            62: #if (mskcnt==2)
        !            63: #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]
        !            64: #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0
        !            65: #define MASKANDSETBITS(dst, b1, b2)  \
        !            66:                      dst[0] = (b1[0] & b2[0]);\
        !            67:                      dst[1] = (b1[1] & b2[1])
        !            68: #define ORBITS(dst, b1, b2)  \
        !            69:                      dst[0] = (b1[0] | b2[0]);\
        !            70:                      dst[1] = (b1[1] | b2[1])
        !            71: #define UNSETBITS(dst, b1) \
        !            72:                       dst[0] &= ~b1[0]; \
        !            73:                       dst[1] &= ~b1[1]
        !            74: #define ANYSET(src) (src[0] || src[1])
        !            75: #endif
        !            76: #if (mskcnt==3)
        !            77: #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];
        !            78: #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0
        !            79: #define MASKANDSETBITS(dst, b1, b2)  \
        !            80:                      dst[0] = (b1[0] & b2[0]);\
        !            81:                      dst[1] = (b1[1] & b2[1]);\
        !            82:                      dst[2] = (b1[2] & b2[2])
        !            83: #define ORBITS(dst, b1, b2)  \
        !            84:                      dst[0] = (b1[0] | b2[0]);\
        !            85:                      dst[1] = (b1[1] | b2[1]);\
        !            86:                      dst[2] = (b1[2] | b2[2])
        !            87: #define UNSETBITS(dst, b1) \
        !            88:                       dst[0] &= ~b1[0]; \
        !            89:                       dst[1] &= ~b1[1]; \
        !            90:                       dst[2] &= ~b1[2]
        !            91: #define ANYSET(src) (src[0] || src[1] || src[2])
        !            92: #endif
        !            93: #if (mskcnt==4)
        !            94: #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];\
        !            95:                      dst[3] = src[3]
        !            96: #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
        !            97: #define MASKANDSETBITS(dst, b1, b2)  \
        !            98:                       dst[0] = (b1[0] & b2[0]);\
        !            99:                       dst[1] = (b1[1] & b2[1]);\
        !           100:                       dst[2] = (b1[2] & b2[2]);\
        !           101:                       dst[3] = (b1[3] & b2[3])
        !           102: #define ORBITS(dst, b1, b2)  \
        !           103:                       dst[0] = (b1[0] | b2[0]);\
        !           104:                       dst[1] = (b1[1] | b2[1]);\
        !           105:                       dst[2] = (b1[2] | b2[2]);\
        !           106:                       dst[3] = (b1[3] | b2[3])
        !           107: #define UNSETBITS(dst, b1) \
        !           108:                       dst[0] &= ~b1[0]; \
        !           109:                       dst[1] &= ~b1[1]; \
        !           110:                       dst[2] &= ~b1[2]; \
        !           111:                       dst[3] &= ~b1[3]
        !           112: #define ANYSET(src) (src[0] || src[1] || src[2] || src[3])
        !           113: #endif
        !           114: 
        !           115: #if (mskcnt>4)
        !           116: #define COPYBITS(src, dst) bcopy((caddr_t) src, (caddr_t) dst,\
        !           117:                                 mskcnt*sizeof(long))
        !           118: #define CLEARBITS(buf) bzero((caddr_t) buf, mskcnt*sizeof(long))
        !           119: #define MASKANDSETBITS(dst, b1, b2)  \
        !           120:                      { int cri;                        \
        !           121:                        for (cri=0; cri<mskcnt; cri++)  \
        !           122:                          dst[cri] = (b1[cri] & b2[cri]) }
        !           123: #define ORBITS(dst, b1, b2)  \
        !           124:                      { int cri;                        \
        !           125:                      for (cri=0; cri<mskcnt; cri++)    \
        !           126:                          dst[cri] = (b1[cri] | b2[cri]) }
        !           127: #define UNSETBITS(dst, b1) \
        !           128:                      { int cri;                        \
        !           129:                      for (cri=0; cri<mskcnt; cri++)    \
        !           130:                          dst[cri] &= ~b1[cri];  }
        !           131: /*
        !           132:  * If mskcnt>4, then ANYSET is a routine defined in WaitFor.c.
        !           133:  *
        !           134:  * #define ANYSET(src) (src[0] || src[1] || src[2] || src[3] || src[4] ...)
        !           135:  */
        !           136: #endif
        !           137: 
        !           138: typedef struct _connectionInput {
        !           139:     int used;                  /* is this client connected */
        !           140:     char *buffer;               /* contains current client input */
        !           141:     char *bufptr;               /* pointer to current start of data */
        !           142:     int  bufcnt;                /* count of bytes in buffer */
        !           143:     int lenLastReq;
        !           144:     int size;
        !           145: } ConnectionInput;
        !           146: 
        !           147: typedef struct _osComm {
        !           148:     int fd;
        !           149:     unsigned char *buf;
        !           150:     int bufsize;
        !           151:     int count;
        !           152: } OsCommRec, *OsCommPtr;
        !           153: 
        !           154: void Notice();
        !           155: 
        !           156: #ifdef ISOCONN
        !           157: #ifdef ISODEBUG
        !           158: extern int isodexbug;
        !           159: #endif /* ISODEBUG */
        !           160: /*
        !           161:  * For want of a better place to put these for the moment...
        !           162:  * 
        !           163:  * Should really appear in system headers eventuallement
        !           164:  */
        !           165: 
        !           166: #define FamilyIso 3
        !           167: 
        !           168: 
        !           169: #define UNIX_IO 0
        !           170: #define ISODE_IO 1
        !           171: 
        !           172: /*
        !           173:  * The following could all be optimised by putting it in the 
        !           174:  * OsCommRec
        !           175:  * so we would not have to double array index for every IO...
        !           176:  * 
        !           177:  * but i'm not sure that that rec is available in all IO call places
        !           178:  */
        !           179: extern int fd2family[];
        !           180: 
        !           181: extern int (*acceptfn[])(); 
        !           182: extern int (*getpeerfn[])(); 
        !           183: extern int (*readfn[])(); 
        !           184: extern int (*writefn[])(); 
        !           185: extern int (*readvfn[])(); 
        !           186: extern int (*writevfn[])(); 
        !           187: extern int (*closefn[])(); 
        !           188: 
        !           189: 
        !           190: #define SAccept(fd, a, b) \
        !           191: acceptfn[fd2family[fd]]((fd), (a), (b))
        !           192: 
        !           193: #define SGetPeerName(fd, ptr, len) \
        !           194: getpeerfn[fd2family[(fd)]]((fd), (ptr), (len))
        !           195: 
        !           196: #define SRead(fd, data, size, dum) \
        !           197: readfn[fd2family[(fd)]]((fd), (data), (size), (dum))
        !           198: 
        !           199: #define SWrite(fd, data, size) \
        !           200: writefn[fd2family[(fd)]]((fd), (data), (size))
        !           201: 
        !           202: #define SWritev(fd, iov, iovcnt) \
        !           203: writevfn[fd2family[(fd)]]((fd), (iov), (iovcnt))
        !           204: 
        !           205: #define SClose(fd) \
        !           206: closefn[fd2family[(fd)]]((fd))
        !           207: 
        !           208: #endif /* ISOCONN */

unix.superglobalmegacorp.com

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