Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/kern/include/types.h
2093 views
1
/*
2
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
3
* The President and Fellows of Harvard College.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the University nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
30
#ifndef _TYPES_H_
31
#define _TYPES_H_
32
33
/*
34
* Master kernel header file.
35
*
36
* The model for the include files in the kernel is as follows:
37
*
38
* - Every source file includes this file, <types.h>, first.
39
*
40
* - Every other header file may assume this file has been
41
* included, but should explicitly include any other headers it
42
* uses to compile.
43
*
44
* - Some exceptions to the previous rules exist among the headers
45
* exported to userland; those files should be included in the
46
* kernel only indirectly via other, non-exported, headers, as
47
* described in comments therein.
48
*
49
* - Every source or header file should include each file it
50
* directly uses, even if that header is included via some other
51
* header. This helps to prevent build failures when unrelated
52
* dependencies are changed around.
53
*
54
* - As a matter of convention, the ordering of include files in
55
* the base system is in order of subsystem dependence. That is,
56
* lower-level code like <spinlock.h> should come before
57
* higher-level code like <addrspace.h> or <vfs.h>. This
58
* convention helps one to keep keep track of (and learn) the
59
* organization of the system.
60
*
61
* The general ordering is as follows:
62
* 1. <types.h>
63
* 2. Kernel ABI definitions, e.g. <kern/errno.h>.
64
* 3. Support code: <lib.h>, arrays, queues, etc.
65
* 4. Low-level code: locks, trapframes, etc.
66
* 5. Kernel subsystems: threads, VM, VFS, etc.
67
* 6. System call layer, e.g. <elf.h>, <syscall.h>.
68
*
69
* Subsystem-private headers (the only extant example is
70
* switchframe.h) and then kernel option headers generated by
71
* config come last.
72
*
73
* There is no one perfect ordering, because the kernel is not
74
* composed of perfectly nested layers. But for the most part
75
* this principle produces a workable result.
76
*/
77
78
79
/* Get types visible to userland, both MI and MD. */
80
#include <kern/types.h>
81
82
/* Get machine-dependent types not visible to userland. */
83
#include <machine/types.h>
84
85
/*
86
* Define userptr_t as a pointer to a one-byte struct, so it won't mix
87
* with other pointers.
88
*/
89
90
struct __userptr { char _dummy; };
91
typedef struct __userptr *userptr_t;
92
typedef const struct __userptr *const_userptr_t;
93
94
/*
95
* Proper (non-underscore) names for the types that are exposed to
96
* userland.
97
*/
98
99
/* machine-dependent from <kern/machine/types.h>... */
100
typedef __i8 int8_t;
101
typedef __i16 int16_t;
102
typedef __i32 int32_t;
103
typedef __i64 int64_t;
104
typedef __u8 uint8_t;
105
typedef __u16 uint16_t;
106
typedef __u32 uint32_t;
107
typedef __u64 uint64_t;
108
typedef __size_t size_t;
109
typedef __ssize_t ssize_t;
110
typedef __intptr_t intptr_t;
111
typedef __uintptr_t uintptr_t;
112
typedef __ptrdiff_t ptrdiff_t;
113
114
/* ...and machine-independent from <kern/types.h>. */
115
typedef __blkcnt_t blkcnt_t;
116
typedef __blksize_t blksize_t;
117
typedef __daddr_t daddr_t;
118
typedef __dev_t dev_t;
119
typedef __fsid_t fsid_t;
120
typedef __gid_t gid_t;
121
typedef __in_addr_t in_addr_t;
122
typedef __in_port_t in_port_t;
123
typedef __ino_t ino_t;
124
typedef __mode_t mode_t;
125
typedef __nlink_t nlink_t;
126
typedef __off_t off_t;
127
typedef __pid_t pid_t;
128
typedef __rlim_t rlim_t;
129
typedef __sa_family_t sa_family_t;
130
typedef __time_t time_t;
131
typedef __uid_t uid_t;
132
133
typedef __nfds_t nfds_t;
134
typedef __socklen_t socklen_t;
135
136
/*
137
* Number of bits per byte.
138
*/
139
140
#define CHAR_BIT __CHAR_BIT
141
142
/*
143
* Null pointer.
144
*/
145
146
#define NULL ((void *)0)
147
148
/*
149
* Boolean.
150
*/
151
typedef _Bool bool;
152
#define true 1
153
#define false 0
154
155
#endif /* _TYPES_H_ */
156
157