home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / sys / types.h < prev    next >
C/C++ Source or Header  |  1993-10-19  |  5KB  |  175 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7. /*
  8.  * HISTORY
  9.  *  7-Jan-93  Mac Gillon (mgillon) at NeXT
  10.  *    Integrated POSIX support
  11.  *
  12.  * 27-Sep-89  Morris Meyer (mmeyer) at NeXT
  13.  *    NFS 4.0 Changes: make uid_t and gid_t signed
  14.  *
  15.  * 02-Mar-87  Mike Accetta (mja) at Carnegie-Mellon University
  16.  *    CS_BUGFIX:  Restored previous unsigned fixes for _quad and
  17.  *    off_t types by Bill Bolosky although this time under a
  18.  *    different conditional and only under -DKERNEL so that, sigh,
  19.  *    user programs which import the file but don't use the type
  20.  *    consistently won't break.  Of course, lseek takes an off_t as
  21.  *    its second paramter which can be legitimately signed.  This
  22.  *    whole thing is a hack and I suspect that eventually someone is
  23.  *    going to have to end up rewriting some kernel code.
  24.  *    [ V5.1(F4) ]
  25.  *
  26.  * 24-Oct-86  Jonathan J. Chew (jjc) at Carnegie-Mellon University
  27.  *    Added 68000 dependent definition of "label_t" and "physadr".
  28.  *    Conditionalized on whether ASSEMBLER is undefined.
  29.  *
  30.  *  7-Oct-86  David L. Black (dlb) at Carnegie-Mellon University
  31.  *    Merged Multimax changes.
  32.  *
  33.  * 24-Sep-86  Michael Young (mwyoung) at Carnegie-Mellon University
  34.  *    Moved boolean declaration to its own file.
  35.  *
  36.  * 23-Aug-86  Michael Young (mwyoung) at Carnegie-Mellon University
  37.  *    Renamed "machtypes.h" to "types.h".
  38.  *
  39.  * 16-Jul-86  Bill Bolosky (bolosky) at Carnegie-Mellon University
  40.  *    CS_GENERIC: changed type quad from longs to u_longs,
  41.  *    and off_t from int to u_long.
  42.  *
  43.  * 19-Feb-86  Bill Bolosky (bolosky) at Carnegie-Mellon University
  44.  *    romp: Added alternate definitions of label_t and physaddr.
  45.  *
  46.  * 25-Jan-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  47.  *    Upgraded to 4.3.
  48.  *
  49.  * 15-Jun-85  Avadis Tevanian (avie) at Carnegie-Mellon University
  50.  *    Allow for nested calls of types.h.
  51.  */
  52.  
  53. #ifndef _TYPES_
  54. #define    _TYPES_
  55.  
  56. /*
  57.  * Copyright (c) 1982, 1986 Regents of the University of California.
  58.  * All rights reserved.  The Berkeley software License Agreement
  59.  * specifies the terms and conditions for redistribution.
  60.  *
  61.  *    @(#)types.h    7.1 (Berkeley) 6/4/86
  62.  */
  63.  
  64. #ifndef    ASSEMBLER
  65.  
  66. #if !defined(KERNEL) && defined(_POSIX_SOURCE)
  67.     #include <standards.h>
  68. #endif
  69.  
  70. #ifdef _NEXT_SOURCE
  71.     /*
  72.      * Basic system types and major/minor device 
  73.      * constructing/busting macros.
  74.      */
  75.  
  76.     /* major part of a device */
  77.     #define    major(x)    ((int)(((unsigned)(x)>>8)&0377))
  78.  
  79.     /* minor part of a device */
  80.     #define    minor(x)    ((int)((x)&0377))
  81.  
  82.     /* make a device number */
  83.     #define    makedev(x,y)    ((dev_t)(((x)<<8) | (y)))
  84.  
  85.     typedef    unsigned char    u_char;
  86.     typedef    unsigned short    u_short;
  87.     typedef    unsigned int    u_int;
  88.     typedef    unsigned long    u_long;
  89.     typedef    unsigned short    ushort;        /* sys III compat */
  90.  
  91.     #import    <bsd/machine/label_t.h>
  92.  
  93.     #ifdef    KERNEL
  94.         typedef    struct    _quad { u_long val[2]; } quad;
  95.     #else    KERNEL
  96.         typedef    struct    _quad { long val[2]; } quad;
  97.     #endif    KERNEL
  98.  
  99.     typedef    long    daddr_t;
  100.     typedef    char *    caddr_t;
  101.  
  102.     #ifndef _TIME_T
  103.         #define _TIME_T
  104.         typedef    long    time_t;
  105.     #endif /* _TIME_T */
  106. #endif /* _NEXT_SOURCE */
  107.  
  108. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  109.     #ifndef _SIZE_T
  110.         #define     _SIZE_T
  111.         #ifdef __STRICT_BSD__
  112.             typedef long size_t;
  113.         #else    
  114.             typedef unsigned long size_t;
  115.         #endif /* __STRICT_BSD__ */
  116.     #endif  /* _SIZE_T */
  117.  
  118.     typedef    short    dev_t;
  119.     typedef    short    gid_t;
  120.     typedef    short    uid_t;
  121.     #ifdef _NEXT_SOURCE
  122.         typedef    u_long    ino_t;
  123.     #else
  124.         typedef unsigned long ino_t;
  125.     #endif
  126. #endif  /* _POSIX_SOURCE || _NEXT_SOURCE */
  127.  
  128. #ifdef KERNEL 
  129.     typedef    u_long    off_t;
  130. #else
  131.     typedef    long    off_t;
  132. #endif /* KERNEL */
  133.  
  134. #if defined(_POSIX_SOURCE)
  135.     typedef int    ssize_t;
  136.     typedef int    pid_t;
  137.     typedef unsigned short     mode_t;
  138.     typedef short    nlink_t;
  139. #endif  /* _POSIX_SOURCE */
  140.  
  141. #ifdef _NEXT_SOURCE
  142.     #define    NBBY    8    /* number of bits in a byte */
  143.     /*
  144.      * Select uses bit masks of file descriptors in longs.
  145.      * These macros manipulate such bit fields (the
  146.      * filesystem macros use chars). FD_SETSIZE may be
  147.      * defined by the user, but the default here should
  148.      * be >= NOFILE (param.h).
  149.      */
  150.     #ifndef    FD_SETSIZE
  151.         #define    FD_SETSIZE    256
  152.     #endif
  153.  
  154.     typedef long    fd_mask;
  155.     #define NFDBITS    (sizeof(fd_mask) * NBBY)
  156.                     /* bits per mask */
  157.     #ifndef howmany
  158.         #define    howmany(x, y)    (((x)+((y)-1))/(y))
  159.     #endif
  160.  
  161.     typedef    struct fd_set {
  162.         fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  163.     } fd_set;
  164.  
  165.     #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= \
  166.                     (1 << ((n) % NFDBITS)))
  167.     #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= \
  168.                     ~(1 << ((n) % NFDBITS)))
  169.     #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & \
  170.                     (1 << ((n) % NFDBITS)))
  171.     #define FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  172. #endif /* _NEXT_SOURCE */
  173. #endif /* ASSEMBLER */
  174. #endif /* _TYPES_ */
  175.