home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997: The Complete Utilities Toolkit / macworld-complete-utilities-1997.iso / Programming / kvik / src / systypes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-21  |  4.6 KB  |  141 lines  |  [TEXT/MPCC]

  1. /*-
  2.  * Copyright (c) 1982, 1986, 1991 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)types.h    7.17 (Berkeley) 5/6/91
  34.  */
  35.  
  36. #ifndef _TYPES_H_
  37. #define    _TYPES_H_
  38.  
  39. typedef    unsigned char    u_char;
  40. typedef    unsigned short    u_short;
  41. typedef    unsigned int    u_int;
  42. typedef    unsigned long    u_long;
  43. typedef    unsigned short    ushort;        /* Sys V compatibility */
  44.  
  45. typedef    char *    caddr_t;        /* core address */
  46. typedef    long    daddr_t;        /* disk address */
  47. typedef    short    dev_t;            /* device number */
  48. typedef    u_long    ino_t;            /* inode number */
  49. typedef    long    off_t;            /* file offset (should be a quad) */
  50. typedef    u_short    nlink_t;        /* link count */
  51. typedef    long    swblk_t;        /* swap offset */
  52. typedef    long    segsz_t;        /* segment size */
  53. #ifdef UNIX
  54. typedef    u_short    uid_t;            /* user id */
  55. typedef    u_short    gid_t;            /* group id */
  56. #else
  57. typedef    u_long    uid_t;            /* user id */
  58. typedef    u_long    gid_t;            /* group id */
  59. #endif
  60. typedef    short    pid_t;            /* process id */
  61. typedef    u_short    mode_t;            /* permissions */
  62. typedef u_long    fixpt_t;        /* fixed point number */
  63.  
  64. #ifndef _POSIX_SOURCE
  65. typedef    struct    _uquad    { u_long val[2]; } u_quad;
  66. typedef    struct    _quad    {   long val[2]; } quad;
  67. typedef    long *    qaddr_t;    /* should be typedef quad * qaddr_t; */
  68.  
  69. #define    major(x)    ((int)(((u_int)(x) >> 8)&0xff))    /* major number */
  70. #define    minor(x)    ((int)((x)&0xff))        /* minor number */
  71. #define    makedev(x,y)    ((dev_t)(((x)<<8) | (y)))    /* create dev_t */
  72. #endif
  73.  
  74. #include "machine/ansi.h"
  75. #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  76. #include "machine/types.h"
  77. #endif
  78.  
  79. #ifdef    _CLOCK_T_
  80. typedef    _CLOCK_T_    clock_t;
  81. #undef    _CLOCK_T_
  82. #endif
  83.  
  84. #ifdef    _SIZE_T_
  85. typedef    _SIZE_T_    size_t;
  86. #undef    _SIZE_T_
  87. #endif
  88.  
  89. #ifdef    _TIME_T_
  90. typedef    _TIME_T_    time_t;
  91. #undef    _TIME_T_
  92. #endif
  93.  
  94. #ifndef _POSIX_SOURCE
  95. #define    NBBY    8        /* number of bits in a byte */
  96.  
  97. /*
  98.  * Select uses bit masks of file descriptors in longs.  These macros
  99.  * manipulate such bit fields (the filesystem macros use chars).
  100.  * FD_SETSIZE may be defined by the user, but the default here should
  101.  * be enough for most uses.
  102.  */
  103. #ifndef    FD_SETSIZE
  104. #define    FD_SETSIZE    256
  105. #endif
  106.  
  107. typedef long    fd_mask;
  108. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  109.  
  110. #ifndef howmany
  111. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  112. #endif
  113.  
  114. typedef    struct fd_set {
  115.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  116. } fd_set;
  117.  
  118. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  119. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  120. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  121. #define    FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  122.  
  123. #if defined(__STDC__) && defined(KERNEL)
  124. /*
  125.  * Forward structure declarations for function prototypes.
  126.  * We include the common structures that cross subsystem boundaries here;
  127.  * others are mostly used in the same place that the structure is defined.
  128.  */
  129. struct    proc;
  130. struct    pgrp;
  131. struct    ucred;
  132. struct    rusage;
  133. struct    file;
  134. struct    buf;
  135. struct    tty;
  136. struct    uio;
  137. #endif
  138.  
  139. #endif /* !_POSIX_SOURCE */
  140. #endif /* !_TYPES_H_ */
  141.