xref: /xnu-8792.81.2/bsd/sys/kernel_types.h (revision 19c3b8c28c31cb8130e034cfb5df6bf9ba342d90)
1 /*
2  * Copyright (c) 2004-2010 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 
29 #ifndef _KERN_SYS_KERNELTYPES_H_
30 #define _KERN_SYS_KERNELTYPES_H_
31 
32 #include <sys/cdefs.h>
33 #include <sys/constrained_ctypes.h>
34 #include <sys/types.h>
35 #include <stdint.h>
36 
37 #ifdef BSD_BUILD
38 /* Macros(?) to clear/set/test flags. */
39 #define SET(t, f)       (t) |= (f)
40 #define CLR(t, f)       (t) &= ~(f)
41 #define ISSET(t, f)     ((t) & (f))
42 #endif
43 
44 
45 typedef int64_t daddr64_t;
46 
47 #ifndef BSD_BUILD
48 struct buf;
49 typedef struct buf * buf_t;
50 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct buf, buf);
51 
52 struct file;
53 typedef struct file * file_t;
54 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct file, file);
55 
56 #ifndef __LP64__
57 struct ucred;
58 typedef struct ucred * ucred_t;
59 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct ucred, ucred);
60 #endif
61 
62 #if defined(KERNEL) || !defined(_SYS_MOUNT_H_) /* also defined in mount.h */
63 struct mount;
64 typedef struct mount * mount_t;
65 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct mount, mount);
66 
67 struct vnode;
68 typedef struct vnode * vnode_t;
69 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct vnode, vnode);
70 #endif
71 
72 struct proc;
73 typedef struct proc * proc_t;
74 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct proc, proc);
75 
76 struct proc_ident;
77 typedef struct proc_ident * proc_ident_t;
78 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct proc_ident, proc_ident);
79 
80 struct uio;
81 typedef struct uio * uio_t;
82 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct uio, uio);
83 
84 struct vfs_context;
85 typedef struct vfs_context * vfs_context_t;
86 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct vfs_context, vfs_context);
87 
88 struct vfstable;
89 typedef struct vfstable * vfstable_t;
90 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct vfstable, vfstable);
91 
92 struct __ifnet;
93 struct __mbuf;
94 struct __pkthdr;
95 struct __socket;
96 struct __sockopt;
97 struct __ifaddr;
98 struct __ifmultiaddr;
99 struct __ifnet_filter;
100 struct __rtentry;
101 struct __if_clone;
102 struct __bufattr;
103 
104 typedef struct __ifnet*                 ifnet_t;
105 typedef struct __mbuf*                  mbuf_t;
106 typedef struct __pkthdr*                pkthdr_t;
107 typedef struct __socket*                socket_t;
108 typedef struct __sockopt*               sockopt_t;
109 typedef struct __ifaddr*                ifaddr_t;
110 typedef struct __ifmultiaddr*   ifmultiaddr_t;
111 typedef struct __ifnet_filter*  interface_filter_t;
112 typedef struct __rtentry*               route_t;
113 typedef struct __if_clone*              if_clone_t;
114 typedef struct __bufattr*               bufattr_t;
115 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __ifnet, ifnet);
116 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __mbuf, mbuf);
117 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __pkthdr, pkthdr);
118 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __socket, socket);
119 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __sockopt, sockopt);
120 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __ifaddr, ifaddr);
121 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __ifmultiaddr, ifmultiaddr);
122 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __ifnet_filter, ifnet_filter);
123 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __rtentry, rtentry);
124 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __if_clone, if_clone);
125 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct __bufattr, bufattr);
126 
127 #else /* BSD_BUILD */
128 
129 typedef struct buf * buf_t;
130 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct buf, buf);
131 
132 typedef struct file * file_t;
133 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct file, file);
134 
135 #ifndef __LP64__
136 typedef struct ucred * ucred_t;
137 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct ucred, ucred);
138 #endif
139 
140 #if defined(KERNEL) || !defined(_SYS_MOUNT_H_) /* also defined in mount.h */
141 
142 typedef struct mount * mount_t;
143 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct mount, mount);
144 
145 typedef struct vnode * vnode_t;
146 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct vnode, vnode);
147 #endif
148 typedef struct proc * proc_t;
149 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct proc, proc);
150 
151 typedef struct proc_ident * proc_ident_t;
152 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct proc_ident, proc_ident);
153 
154 typedef struct uio * uio_t;
155 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct uio, uio);
156 
157 typedef struct user_iovec * user_iovec_t;
158 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct user_iovec, user_iovec);
159 
160 typedef struct vfs_context * vfs_context_t;
161 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct vfs_context, vfs_context);
162 
163 typedef struct vfstable * vfstable_t;
164 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct vfstable, vfstable);
165 
166 #ifdef KERNEL_PRIVATE
167 typedef struct kern_iovec * kern_iovec_t;
168 typedef struct ifnet*           ifnet_t;
169 typedef struct mbuf*            mbuf_t;
170 typedef struct pkthdr*          pkthdr_t;
171 typedef struct socket*          socket_t;
172 typedef struct sockopt*         sockopt_t;
173 typedef struct ifaddr*          ifaddr_t;
174 typedef struct ifmultiaddr*     ifmultiaddr_t;
175 typedef struct ifnet_filter*    interface_filter_t;
176 typedef struct rtentry*         route_t;
177 typedef struct if_clone*        if_clone_t;
178 typedef struct bufattr*         bufattr_t;
179 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct kern_iovec, kern_iovec);
180 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct ifnet, ifnet);
181 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct mbuf, mbuf);
182 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct pkthdr, pkthdr);
183 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct socket, socket);
184 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct sockopt, sockopt);
185 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct ifaddr, ifaddr);
186 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct ifmultiaddr, ifmultiaddr);
187 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct ifnet_filter, ifnet_filter);
188 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct rtentry, rtentry);
189 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct if_clone, if_clone);
190 __CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct bufattr, bufattr);
191 
192 #endif /* KERNEL_PRIVATE */
193 
194 #endif /* !BSD_BUILD */
195 
196 #include <sys/_types/_guid_t.h>
197 
198 #ifndef _KAUTH_ACE
199 #define _KAUTH_ACE
200 struct kauth_ace;
201 typedef struct kauth_ace * kauth_ace_t;
202 #endif
203 #ifndef _KAUTH_ACL
204 #define _KAUTH_ACL
205 struct kauth_acl;
206 typedef struct kauth_acl * kauth_acl_t;
207 #endif
208 #ifndef _KAUTH_FILESEC
209 #define _KAUTH_FILESEC
210 struct kauth_filesec;
211 typedef struct kauth_filesec * kauth_filesec_t;
212 #endif
213 
214 #ifndef _KAUTH_ACTION_T
215 #define _KAUTH_ACTION_T
216 typedef int kauth_action_t;
217 #endif
218 
219 #endif /* !_KERN_SYS_KERNELTYPES_H_ */
220