00001 /* The <sys/types.h> header contains important data type definitions. 00002 * It is considered good programming practice to use these definitions, 00003 * instead of the underlying base type. By convention, all type names end 00004 * with _t. 00005 */ 00006 00007 #ifndef _TYPES_H 00008 #define _TYPES_H 00009 00010 #ifndef _ANSI_H 00011 #include <ansi.h> 00012 #endif 00013 00014 /* The type size_t holds all results of the sizeof operator. At first glance, 00015 * it seems obvious that it should be an unsigned int, but this is not always 00016 * the case. For example, MINIX-ST (68000) has 32-bit pointers and 16-bit 00017 * integers. When one asks for the size of a 70K struct or array, the result 00018 * requires 17 bits to express, so size_t must be a long type. The type 00019 * ssize_t is the signed version of size_t. 00020 */ 00021 #ifndef _SIZE_T 00022 #define _SIZE_T 00023 typedef unsigned int size_t; 00024 #endif 00025 00026 #ifndef _SSIZE_T 00027 #define _SSIZE_T 00028 typedef int ssize_t; 00029 #endif 00030 00031 #ifndef _TIME_T 00032 #define _TIME_T 00033 typedef long time_t; /* time in sec since 1 Jan 1970 0000 GMT */ 00034 #endif 00035 00036 #ifndef _CLOCK_T 00037 #define _CLOCK_T 00038 typedef long clock_t; /* unit for system accounting */ 00039 #endif 00040 00041 #ifndef _SIGSET_T 00042 #define _SIGSET_T 00043 typedef unsigned long sigset_t; 00044 #endif 00045 00046 /* Open Group Base Specifications Issue 6 (not complete) */ 00047 typedef long useconds_t; /* Time in microseconds */ 00048 00049 /* Types used in disk, inode, etc. data structures. */ 00050 typedef short dev_t; /* holds (major|minor) device pair */ 00051 typedef char gid_t; /* group id */ 00052 typedef unsigned long ino_t; /* i-node number (V3 filesystem) */ 00053 typedef unsigned short mode_t; /* file type and permissions bits */ 00054 typedef short nlink_t; /* number of links to a file */ 00055 typedef unsigned long off_t; /* offset within a file */ 00056 typedef int pid_t; /* process id (must be signed) */ 00057 typedef short uid_t; /* user id */ 00058 typedef unsigned long zone_t; /* zone number */ 00059 typedef unsigned long block_t; /* block number */ 00060 typedef unsigned long bit_t; /* bit number in a bit map */ 00061 typedef unsigned short zone1_t; /* zone number for V1 file systems */ 00062 typedef unsigned short bitchunk_t; /* collection of bits in a bitmap */ 00063 00064 typedef unsigned char u8_t; /* 8 bit type */ 00065 typedef unsigned short u16_t; /* 16 bit type */ 00066 typedef unsigned long u32_t; /* 32 bit type */ 00067 00068 typedef char i8_t; /* 8 bit signed type */ 00069 typedef short i16_t; /* 16 bit signed type */ 00070 typedef long i32_t; /* 32 bit signed type */ 00071 00072 typedef struct { u32_t _[2]; } u64_t; 00073 00074 /* The following types are needed because MINIX uses K&R style function 00075 * definitions (for maximum portability). When a short, such as dev_t, is 00076 * passed to a function with a K&R definition, the compiler automatically 00077 * promotes it to an int. The prototype must contain an int as the parameter, 00078 * not a short, because an int is what an old-style function definition 00079 * expects. Thus using dev_t in a prototype would be incorrect. It would be 00080 * sufficient to just use int instead of dev_t in the prototypes, but Dev_t 00081 * is clearer. 00082 */ 00083 typedef int Dev_t; 00084 typedef int _mnx_Gid_t; 00085 typedef int Nlink_t; 00086 typedef int _mnx_Uid_t; 00087 typedef int U8_t; 00088 typedef unsigned long U32_t; 00089 typedef int I8_t; 00090 typedef int I16_t; 00091 typedef long I32_t; 00092 00093 /* ANSI C makes writing down the promotion of unsigned types very messy. When 00094 * sizeof(short) == sizeof(int), there is no promotion, so the type stays 00095 * unsigned. When the compiler is not ANSI, there is usually no loss of 00096 * unsignedness, and there are usually no prototypes so the promoted type 00097 * doesn't matter. The use of types like Ino_t is an attempt to use ints 00098 * (which are not promoted) while providing information to the reader. 00099 */ 00100 00101 typedef unsigned long Ino_t; 00102 00103 #if _EM_WSIZE == 2 00104 /*typedef unsigned int Ino_t; Ino_t is now 32 bits */ 00105 typedef unsigned int Zone1_t; 00106 typedef unsigned int Bitchunk_t; 00107 typedef unsigned int U16_t; 00108 typedef unsigned int _mnx_Mode_t; 00109 00110 #else /* _EM_WSIZE == 4, or _EM_WSIZE undefined */ 00111 /*typedef int Ino_t; Ino_t is now 32 bits */ 00112 typedef int Zone1_t; 00113 typedef int Bitchunk_t; 00114 typedef int U16_t; 00115 typedef int _mnx_Mode_t; 00116 00117 #endif /* _EM_WSIZE == 2, etc */ 00118 00119 /* Signal handler type, e.g. SIG_IGN */ 00120 typedef void _PROTOTYPE( (*sighandler_t), (int) ); 00121 00122 /* Compatibility with other systems */ 00123 typedef unsigned char u_char; 00124 typedef unsigned short u_short; 00125 typedef unsigned int u_int; 00126 typedef unsigned long u_long; 00127 typedef char *caddr_t; 00128 00129 /* Devices. */ 00130 #define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */ 00131 #define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */ 00132 00133 #ifndef minor 00134 #define minor(dev) (((dev) >> MINOR) & 0xff) 00135 #endif 00136 00137 #ifndef major 00138 #define major(dev) (((dev) >> MAJOR) & 0xff) 00139 #endif 00140 00141 #ifndef makedev 00142 #define makedev(major, minor) \ 00143 ((dev_t) (((major) << MAJOR) | ((minor) << MINOR))) 00144 #endif 00145 00146 #endif /* _TYPES_H */
1.4.6