more stack for boot
[minix.git] / include / minix / types.h
blobe78c51cb622d3680f5f6ebf7d970e23b323bd716
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 */
7 #ifndef _TYPES_H
8 #define _TYPES_H
10 #ifndef _ANSI_H
11 #include <ansi.h>
12 #endif
14 typedef unsigned char u8_t; /* 8 bit type */
15 typedef unsigned short u16_t; /* 16 bit type */
16 typedef signed char i8_t; /* 8 bit signed type */
17 typedef short i16_t; /* 16 bit signed type */
19 #if __SIZEOF_LONG__ > 4
20 /* compiling with gcc on some (e.g. x86-64) platforms */
21 typedef unsigned int u32_t; /* 32 bit type */
22 typedef int i32_t; /* 32 bit signed type */
23 #else
24 /* default for ACK or gcc on 32 bit platforms */
25 typedef unsigned long u32_t; /* 32 bit type */
26 typedef long i32_t; /* 32 bit signed type */
27 #endif
29 typedef struct {
30 u32_t lo;
31 u32_t hi;
32 } u64_t;
34 /* some Minix specific types that do not conflict with posix */
35 typedef u32_t zone_t; /* zone number */
36 typedef u32_t block_t; /* block number */
37 typedef u32_t bit_t; /* bit number in a bit map */
38 typedef u16_t zone1_t; /* zone number for V1 file systems */
39 typedef u16_t bitchunk_t; /* collection of bits in a bitmap */
41 /* ANSI C makes writing down the promotion of unsigned types very messy. When
42 * sizeof(short) == sizeof(int), there is no promotion, so the type stays
43 * unsigned. When the compiler is not ANSI, there is usually no loss of
44 * unsignedness, and there are usually no prototypes so the promoted type
45 * doesn't matter. The use of types like Ino_t is an attempt to use ints
46 * (which are not promoted) while providing information to the reader.
49 typedef unsigned long Ino_t;
51 #if defined(_MINIX) || defined(__minix)
53 /* The type size_t holds all results of the sizeof operator. At first glance,
54 * it seems obvious that it should be an unsigned int, but this is not always
55 * the case. For example, MINIX-ST (68000) has 32-bit pointers and 16-bit
56 * integers. When one asks for the size of a 70K struct or array, the result
57 * requires 17 bits to express, so size_t must be a long type. The type
58 * ssize_t is the signed version of size_t.
60 #ifndef _SIZE_T
61 #define _SIZE_T
62 typedef unsigned int size_t;
63 #endif
65 #ifndef _SSIZE_T
66 #define _SSIZE_T
67 typedef int ssize_t;
68 #endif
70 #ifndef _TIME_T
71 #define _TIME_T
72 typedef long time_t; /* time in sec since 1 Jan 1970 0000 GMT */
73 #endif
75 #ifndef _CLOCK_T
76 #define _CLOCK_T
77 typedef long clock_t; /* unit for system accounting */
78 #endif
80 #ifndef _SIGSET_T
81 #define _SIGSET_T
82 typedef unsigned long sigset_t;
83 #endif
85 #ifndef _KEY_T
86 #define _KEY_T
87 typedef long key_t;
88 #endif
90 /* Open Group Base Specifications Issue 6 (not complete) */
91 typedef long useconds_t; /* Time in microseconds */
93 typedef short dev_t; /* holds (major|minor) device pair */
95 /* Types used in disk, inode, etc. data structures. */
96 typedef char gid_t; /* group id */
97 typedef unsigned long ino_t; /* i-node number (V3 filesystem) */
98 typedef unsigned short mode_t; /* file type and permissions bits */
99 typedef short nlink_t; /* number of links to a file */
100 typedef long off_t; /* offset within a file */
101 typedef int pid_t; /* process id (must be signed) */
102 typedef short uid_t; /* user id */
104 /* The following types are needed because MINIX uses K&R style function
105 * definitions (for maximum portability). When a short, such as dev_t, is
106 * passed to a function with a K&R definition, the compiler automatically
107 * promotes it to an int. The prototype must contain an int as the parameter,
108 * not a short, because an int is what an old-style function definition
109 * expects. Thus using dev_t in a prototype would be incorrect. It would be
110 * sufficient to just use int instead of dev_t in the prototypes, but Dev_t
111 * is clearer.
113 typedef int Dev_t;
114 typedef int _mnx_Gid_t;
115 typedef int Nlink_t;
116 typedef int _mnx_Uid_t;
117 typedef unsigned long U32_t;
118 typedef int I16_t;
119 typedef long I32_t;
121 #if _EM_WSIZE == 2
122 /*typedef unsigned int Ino_t; Ino_t is now 32 bits */
123 typedef unsigned int Zone1_t;
124 typedef unsigned int Bitchunk_t;
125 typedef unsigned int U16_t;
126 typedef unsigned int _mnx_Mode_t;
128 #else /* _EM_WSIZE == 4, or _EM_WSIZE undefined */
129 /*typedef int Ino_t; Ino_t is now 32 bits */
130 typedef int Zone1_t;
131 typedef int Bitchunk_t;
132 typedef int U16_t;
133 typedef int _mnx_Mode_t;
135 #endif /* _EM_WSIZE == 2, etc */
137 /* Signal handler type, e.g. SIG_IGN */
138 typedef void _PROTOTYPE( (*sighandler_t), (int) );
140 /* Compatibility with other systems */
141 typedef unsigned char u_char;
142 typedef unsigned short u_short;
143 typedef unsigned int u_int;
144 typedef unsigned long u_long;
145 typedef char *caddr_t;
147 /* Devices. */
148 #define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */
149 #define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */
151 #ifndef minor
152 #define minor(dev) (((dev) >> MINOR) & 0xff)
153 #endif
155 #ifndef major
156 #define major(dev) (((dev) >> MAJOR) & 0xff)
157 #endif
159 #ifndef makedev
160 #define makedev(major, minor) \
161 ((dev_t) (((major) << MAJOR) | ((minor) << MINOR)))
162 #endif
164 #endif /* _MINIX || __minix */
166 #endif /* _TYPES_H */