os161-1.99
 All Data Structures
types.h
00001 /*
00002  * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
00003  *      The President and Fellows of Harvard College.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  */
00029 
00030 #ifndef _TYPES_H_
00031 #define _TYPES_H_
00032 
00033 /*
00034  * Master kernel header file.
00035  *
00036  * The model for the include files in the kernel is as follows:
00037  *
00038  *     - Every source file includes this file, <types.h>, first.
00039  *
00040  *     - Every other header file may assume this file has been
00041  *       included, but should explicitly include any other headers it
00042  *       uses to compile.
00043  *
00044  *     - Some exceptions to the previous rules exist among the headers
00045  *       exported to userland; those files should be included in the
00046  *       kernel only indirectly via other, non-exported, headers, as
00047  *       described in comments therein.
00048  *
00049  *     - Every source or header file should include each file it
00050  *       directly uses, even if that header is included via some other
00051  *       header. This helps to prevent build failures when unrelated
00052  *       dependencies are changed around.
00053  *
00054  *     - As a matter of convention, the ordering of include files in
00055  *       the base system is in order of subsystem dependence. That is,
00056  *       lower-level code like <spinlock.h> should come before
00057  *       higher-level code like <addrspace.h> or <vfs.h>. This
00058  *       convention helps one to keep keep track of (and learn) the
00059  *       organization of the system.
00060  *
00061  *       The general ordering is as follows:
00062  *           1. <types.h>
00063  *           2. Kernel ABI definitions, e.g. <kern/errno.h>.
00064  *           3. Support code: <lib.h>, arrays, queues, etc.
00065  *           4. Low-level code: locks, trapframes, etc.
00066  *           5. Kernel subsystems: threads, VM, VFS, etc.
00067  *           6. System call layer, e.g. <elf.h>, <syscall.h>.
00068  *
00069  *       Subsystem-private headers (the only extant example is
00070  *       switchframe.h) and then kernel option headers generated by
00071  *       config come last.
00072  *  
00073  *       There is no one perfect ordering, because the kernel is not
00074  *       composed of perfectly nested layers. But for the most part
00075  *       this principle produces a workable result.
00076  */
00077 
00078 
00079 /* Get types visible to userland, both MI and MD. */
00080 #include <kern/types.h>
00081 
00082 /* Get machine-dependent types not visible to userland. */
00083 #include <machine/types.h>
00084 
00085 /*
00086  * Define userptr_t as a pointer to a one-byte struct, so it won't mix
00087  * with other pointers.
00088  */
00089 
00090 struct __userptr { char _dummy; };
00091 typedef struct __userptr *userptr_t;
00092 typedef const struct __userptr *const_userptr_t;
00093 
00094 /*
00095  * Proper (non-underscore) names for the types that are exposed to
00096  * userland.
00097  */
00098 
00099 /* machine-dependent from <kern/machine/types.h>... */
00100 typedef __i8 int8_t;
00101 typedef __i16 int16_t;
00102 typedef __i32 int32_t;
00103 typedef __i64 int64_t;
00104 typedef __u8 uint8_t;
00105 typedef __u16 uint16_t;
00106 typedef __u32 uint32_t;
00107 typedef __u64 uint64_t;
00108 typedef __size_t size_t;
00109 typedef __ssize_t ssize_t;
00110 typedef __intptr_t intptr_t;
00111 typedef __uintptr_t uintptr_t;
00112 typedef __ptrdiff_t ptrdiff_t;
00113 
00114 /* ...and machine-independent from <kern/types.h>. */
00115 typedef __blkcnt_t blkcnt_t;
00116 typedef __blksize_t blksize_t;
00117 typedef __daddr_t daddr_t;
00118 typedef __dev_t dev_t;
00119 typedef __fsid_t fsid_t;
00120 typedef __gid_t gid_t;
00121 typedef __in_addr_t in_addr_t;
00122 typedef __in_port_t in_port_t;
00123 typedef __ino_t ino_t;
00124 typedef __mode_t mode_t;
00125 typedef __nlink_t nlink_t;
00126 typedef __off_t off_t;
00127 typedef __pid_t pid_t;
00128 typedef __rlim_t rlim_t;
00129 typedef __sa_family_t sa_family_t;
00130 typedef __time_t time_t;
00131 typedef __uid_t uid_t;
00132 
00133 typedef __nfds_t nfds_t;
00134 typedef __socklen_t socklen_t;
00135 
00136 /*
00137  * Number of bits per byte.
00138  */
00139 
00140 #define CHAR_BIT __CHAR_BIT
00141 
00142 /*
00143  * Null pointer.
00144  */
00145 
00146 #define NULL ((void *)0)
00147 
00148 /*
00149  * Boolean.
00150  */
00151 typedef _Bool bool;
00152 #define true  1
00153 #define false 0
00154 
00155 #endif /* _TYPES_H_ */
 All Data Structures