source: trunk/minix/include/sys/types.h@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 4.9 KB
Line 
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
23typedef unsigned int size_t;
24#endif
25
26#ifndef _SSIZE_T
27#define _SSIZE_T
28typedef int ssize_t;
29#endif
30
31#ifndef _TIME_T
32#define _TIME_T
33typedef long time_t; /* time in sec since 1 Jan 1970 0000 GMT */
34#endif
35
36#ifndef _CLOCK_T
37#define _CLOCK_T
38typedef long clock_t; /* unit for system accounting */
39#endif
40
41#ifndef _SIGSET_T
42#define _SIGSET_T
43typedef unsigned long sigset_t;
44#endif
45
46/* Open Group Base Specifications Issue 6 (not complete) */
47typedef long useconds_t; /* Time in microseconds */
48
49/* Types used in disk, inode, etc. data structures. */
50typedef short dev_t; /* holds (major|minor) device pair */
51typedef char gid_t; /* group id */
52typedef unsigned long ino_t; /* i-node number (V3 filesystem) */
53typedef unsigned short mode_t; /* file type and permissions bits */
54typedef short nlink_t; /* number of links to a file */
55typedef unsigned long off_t; /* offset within a file */
56typedef int pid_t; /* process id (must be signed) */
57typedef short uid_t; /* user id */
58typedef unsigned long zone_t; /* zone number */
59typedef unsigned long block_t; /* block number */
60typedef unsigned long bit_t; /* bit number in a bit map */
61typedef unsigned short zone1_t; /* zone number for V1 file systems */
62typedef unsigned short bitchunk_t; /* collection of bits in a bitmap */
63
64typedef unsigned char u8_t; /* 8 bit type */
65typedef unsigned short u16_t; /* 16 bit type */
66typedef unsigned long u32_t; /* 32 bit type */
67
68typedef char i8_t; /* 8 bit signed type */
69typedef short i16_t; /* 16 bit signed type */
70typedef long i32_t; /* 32 bit signed type */
71
72typedef 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 */
83typedef int Dev_t;
84typedef int _mnx_Gid_t;
85typedef int Nlink_t;
86typedef int _mnx_Uid_t;
87typedef int U8_t;
88typedef unsigned long U32_t;
89typedef int I8_t;
90typedef int I16_t;
91typedef 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
101typedef unsigned long Ino_t;
102
103#if _EM_WSIZE == 2
104/*typedef unsigned int Ino_t; Ino_t is now 32 bits */
105typedef unsigned int Zone1_t;
106typedef unsigned int Bitchunk_t;
107typedef unsigned int U16_t;
108typedef 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 */
112typedef int Zone1_t;
113typedef int Bitchunk_t;
114typedef int U16_t;
115typedef int _mnx_Mode_t;
116
117#endif /* _EM_WSIZE == 2, etc */
118
119/* Signal handler type, e.g. SIG_IGN */
120typedef void _PROTOTYPE( (*sighandler_t), (int) );
121
122/* Compatibility with other systems */
123typedef unsigned char u_char;
124typedef unsigned short u_short;
125typedef unsigned int u_int;
126typedef unsigned long u_long;
127typedef char *caddr_t;
128
129/* Devices. */
130#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */
131#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */
132
133#ifndef minor
134#define minor(dev) (((dev) >> MINOR) & 0xff)
135#endif
136
137#ifndef major
138#define major(dev) (((dev) >> MAJOR) & 0xff)
139#endif
140
141#ifndef makedev
142#define makedev(major, minor) \
143 ((dev_t) (((major) << MAJOR) | ((minor) << MINOR)))
144#endif
145
146#endif /* _TYPES_H */
Note: See TracBrowser for help on using the repository browser.