/*1* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 20082* The President and Fellows of Harvard College.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the University nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _TYPES_H_30#define _TYPES_H_3132/*33* Master kernel header file.34*35* The model for the include files in the kernel is as follows:36*37* - Every source file includes this file, <types.h>, first.38*39* - Every other header file may assume this file has been40* included, but should explicitly include any other headers it41* uses to compile.42*43* - Some exceptions to the previous rules exist among the headers44* exported to userland; those files should be included in the45* kernel only indirectly via other, non-exported, headers, as46* described in comments therein.47*48* - Every source or header file should include each file it49* directly uses, even if that header is included via some other50* header. This helps to prevent build failures when unrelated51* dependencies are changed around.52*53* - As a matter of convention, the ordering of include files in54* the base system is in order of subsystem dependence. That is,55* lower-level code like <spinlock.h> should come before56* higher-level code like <addrspace.h> or <vfs.h>. This57* convention helps one to keep keep track of (and learn) the58* organization of the system.59*60* The general ordering is as follows:61* 1. <types.h>62* 2. Kernel ABI definitions, e.g. <kern/errno.h>.63* 3. Support code: <lib.h>, arrays, queues, etc.64* 4. Low-level code: locks, trapframes, etc.65* 5. Kernel subsystems: threads, VM, VFS, etc.66* 6. System call layer, e.g. <elf.h>, <syscall.h>.67*68* Subsystem-private headers (the only extant example is69* switchframe.h) and then kernel option headers generated by70* config come last.71*72* There is no one perfect ordering, because the kernel is not73* composed of perfectly nested layers. But for the most part74* this principle produces a workable result.75*/767778/* Get types visible to userland, both MI and MD. */79#include <kern/types.h>8081/* Get machine-dependent types not visible to userland. */82#include <machine/types.h>8384/*85* Define userptr_t as a pointer to a one-byte struct, so it won't mix86* with other pointers.87*/8889struct __userptr { char _dummy; };90typedef struct __userptr *userptr_t;91typedef const struct __userptr *const_userptr_t;9293/*94* Proper (non-underscore) names for the types that are exposed to95* userland.96*/9798/* machine-dependent from <kern/machine/types.h>... */99typedef __i8 int8_t;100typedef __i16 int16_t;101typedef __i32 int32_t;102typedef __i64 int64_t;103typedef __u8 uint8_t;104typedef __u16 uint16_t;105typedef __u32 uint32_t;106typedef __u64 uint64_t;107typedef __size_t size_t;108typedef __ssize_t ssize_t;109typedef __intptr_t intptr_t;110typedef __uintptr_t uintptr_t;111typedef __ptrdiff_t ptrdiff_t;112113/* ...and machine-independent from <kern/types.h>. */114typedef __blkcnt_t blkcnt_t;115typedef __blksize_t blksize_t;116typedef __daddr_t daddr_t;117typedef __dev_t dev_t;118typedef __fsid_t fsid_t;119typedef __gid_t gid_t;120typedef __in_addr_t in_addr_t;121typedef __in_port_t in_port_t;122typedef __ino_t ino_t;123typedef __mode_t mode_t;124typedef __nlink_t nlink_t;125typedef __off_t off_t;126typedef __pid_t pid_t;127typedef __rlim_t rlim_t;128typedef __sa_family_t sa_family_t;129typedef __time_t time_t;130typedef __uid_t uid_t;131132typedef __nfds_t nfds_t;133typedef __socklen_t socklen_t;134135/*136* Number of bits per byte.137*/138139#define CHAR_BIT __CHAR_BIT140141/*142* Null pointer.143*/144145#define NULL ((void *)0)146147/*148* Boolean.149*/150typedef _Bool bool;151#define true 1152#define false 0153154#endif /* _TYPES_H_ */155156157