The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/include/sys/types.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* The <sys/types.h> header contains important data type definitions.
    2  * It is considered good programming practice to use these definitions, 
    3  * instead of the underlying base type.  By convention, all type names end 
    4  * with _t.
    5  */
    6 
    7 #ifndef _TYPES_H
    8 #define _TYPES_H
    9 
   10 #ifndef _ANSI_H
   11 #include <ansi.h>
   12 #endif
   13 
   14 /* The type size_t holds all results of the sizeof operator.  At first glance,
   15  * it seems obvious that it should be an unsigned int, but this is not always 
   16  * the case. For example, MINIX-ST (68000) has 32-bit pointers and 16-bit
   17  * integers. When one asks for the size of a 70K struct or array, the result 
   18  * requires 17 bits to express, so size_t must be a long type.  The type 
   19  * ssize_t is the signed version of size_t.
   20  */
   21 #ifndef _SIZE_T
   22 #define _SIZE_T
   23 typedef unsigned int size_t;
   24 #endif
   25 
   26 #ifndef _SSIZE_T
   27 #define _SSIZE_T
   28 typedef int ssize_t;
   29 #endif
   30 
   31 #ifndef _TIME_T
   32 #define _TIME_T
   33 typedef long time_t;               /* time in sec since 1 Jan 1970 0000 GMT */
   34 #endif
   35 
   36 #ifndef _CLOCK_T
   37 #define _CLOCK_T
   38 typedef long clock_t;              /* unit for system accounting */
   39 #endif
   40 
   41 #ifndef _SIGSET_T
   42 #define _SIGSET_T
   43 typedef unsigned long sigset_t;
   44 #endif
   45 
   46 /* Open Group Base Specifications Issue 6 (not complete) */
   47 typedef long useconds_t;        /* Time in microseconds */
   48 
   49 /* Types used in disk, inode, etc. data structures. */
   50 typedef short          dev_t;      /* holds (major|minor) device pair */
   51 typedef char           gid_t;      /* group id */
   52 typedef unsigned long  ino_t;      /* i-node number (V3 filesystem) */
   53 typedef unsigned short mode_t;     /* file type and permissions bits */
   54 typedef short        nlink_t;      /* number of links to a file */
   55 typedef unsigned long  off_t;      /* offset within a file */
   56 typedef int            pid_t;      /* process id (must be signed) */
   57 typedef short          uid_t;      /* user id */
   58 typedef unsigned long zone_t;      /* zone number */
   59 typedef unsigned long block_t;     /* block number */
   60 typedef unsigned long  bit_t;      /* bit number in a bit map */
   61 typedef unsigned short zone1_t;    /* zone number for V1 file systems */
   62 typedef unsigned short bitchunk_t; /* collection of bits in a bitmap */
   63 
   64 typedef unsigned char   u8_t;      /* 8 bit type */
   65 typedef unsigned short u16_t;      /* 16 bit type */
   66 typedef unsigned long  u32_t;      /* 32 bit type */
   67 
   68 typedef char            i8_t;      /* 8 bit signed type */
   69 typedef short          i16_t;      /* 16 bit signed type */
   70 typedef long           i32_t;      /* 32 bit signed type */
   71 
   72 typedef struct { u32_t _[2]; } u64_t;
   73 
   74 /* The following types are needed because MINIX uses K&R style function
   75  * definitions (for maximum portability).  When a short, such as dev_t, is
   76  * passed to a function with a K&R definition, the compiler automatically
   77  * promotes it to an int.  The prototype must contain an int as the parameter,
   78  * not a short, because an int is what an old-style function definition
   79  * expects.  Thus using dev_t in a prototype would be incorrect.  It would be
   80  * sufficient to just use int instead of dev_t in the prototypes, but Dev_t
   81  * is clearer.
   82  */
   83 typedef int            Dev_t;
   84 typedef int       _mnx_Gid_t;
   85 typedef int          Nlink_t;
   86 typedef int       _mnx_Uid_t;
   87 typedef int             U8_t;
   88 typedef unsigned long  U32_t;
   89 typedef int             I8_t;
   90 typedef int            I16_t;
   91 typedef long           I32_t;
   92 
   93 /* ANSI C makes writing down the promotion of unsigned types very messy.  When
   94  * sizeof(short) == sizeof(int), there is no promotion, so the type stays
   95  * unsigned.  When the compiler is not ANSI, there is usually no loss of
   96  * unsignedness, and there are usually no prototypes so the promoted type
   97  * doesn't matter.  The use of types like Ino_t is an attempt to use ints
   98  * (which are not promoted) while providing information to the reader.
   99  */
  100 
  101 typedef unsigned long  Ino_t;
  102 
  103 #if _EM_WSIZE == 2
  104 /*typedef unsigned int      Ino_t; Ino_t is now 32 bits */
  105 typedef unsigned int    Zone1_t;
  106 typedef unsigned int Bitchunk_t;
  107 typedef unsigned int      U16_t;
  108 typedef unsigned int  _mnx_Mode_t;
  109 
  110 #else /* _EM_WSIZE == 4, or _EM_WSIZE undefined */
  111 /*typedef int             Ino_t; Ino_t is now 32 bits */
  112 typedef int             Zone1_t;
  113 typedef int          Bitchunk_t;
  114 typedef int               U16_t;
  115 typedef int         _mnx_Mode_t;
  116 
  117 #endif /* _EM_WSIZE == 2, etc */
  118  
  119 /* Signal handler type, e.g. SIG_IGN */
  120 typedef void _PROTOTYPE( (*sighandler_t), (int) );
  121 
  122 /* Compatibility with other systems */
  123 typedef unsigned char   u_char;
  124 typedef unsigned short  u_short;
  125 typedef unsigned int    u_int;
  126 typedef unsigned long   u_long;
  127 typedef char            *caddr_t;
  128 
  129 #endif /* _TYPES_H */

Cache object: c9536788b5a1355bed1b414f09d18b6e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.