• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2     System type declarations.
3 
4     Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
5     This program and the accompanying materials are licensed and made available
6     under the terms and conditions of the BSD License that accompanies this
7     distribution.  The full text of the license may be found at
8     http://opensource.org/licenses/bsd-license.
9 
10     THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11     WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13     Copyright (c) 1990, 1993
14     The Regents of the University of California.  All rights reserved.
15 
16     Redistribution and use in source and binary forms, with or without
17     modification, are permitted provided that the following conditions
18     are met:
19       - Redistributions of source code must retain the above copyright
20         notice, this list of conditions and the following disclaimer.
21       - Redistributions in binary form must reproduce the above copyright
22         notice, this list of conditions and the following disclaimer in the
23         documentation and/or other materials provided with the distribution.
24       - Neither the name of the University nor the names of its contributors
25         may be used to endorse or promote products derived from this software
26         without specific prior written permission.
27 
28     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31     ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38     POSSIBILITY OF SUCH DAMAGE.
39 
40     NetBSD: types.h,v 1.71.12.1 2007/09/27 13:40:47 xtraeme Exp
41     types.h 8.4 (Berkeley) 1/21/94
42 **/
43 #ifndef _SYS_TYPES_H_
44 #define _SYS_TYPES_H_
45 
46 #include  <sys/EfiCdefs.h>
47 
48 /* Machine type dependent parameters. */
49 #include  <machine/types.h>
50 
51 #include  <machine/ansi.h>
52 #include  <machine/int_types.h>
53 
54 
55 #include  <sys/ansi.h>
56 
57 #ifndef int8_t
58   typedef __int8_t  int8_t;
59   #define int8_t    __int8_t
60 #endif
61 
62 #ifndef uint8_t
63   typedef __uint8_t uint8_t;
64   #define uint8_t   __uint8_t
65 #endif
66 
67 #ifndef int16_t
68   typedef __int16_t int16_t;
69   #define int16_t   __int16_t
70 #endif
71 
72 #ifndef uint16_t
73   typedef __uint16_t  uint16_t;
74   #define uint16_t  __uint16_t
75 #endif
76 
77 #ifndef int32_t
78   typedef __int32_t int32_t;
79   #define int32_t   __int32_t
80 #endif
81 
82 #ifndef uint32_t
83   typedef __uint32_t  uint32_t;
84   #define uint32_t  __uint32_t
85 #endif
86 
87 #ifndef int64_t
88   typedef __int64_t int64_t;
89   #define int64_t   __int64_t
90 #endif
91 
92 #ifndef uint64_t
93   typedef __uint64_t  uint64_t;
94   #define uint64_t  __uint64_t
95 #endif
96 
97 typedef uint8_t   u_int8_t;
98 typedef uint16_t  u_int16_t;
99 typedef uint32_t  u_int32_t;
100 typedef uint64_t  u_int64_t;
101 
102 #include <machine/endian.h>
103 
104 #if defined(_NETBSD_SOURCE)
105   typedef UINT8   u_char;
106   typedef UINT16  u_short;
107   typedef UINTN   u_int;
108   typedef ULONGN  u_long;
109 
110   typedef UINT8   unchar;   /* Sys V compatibility */
111   typedef UINT16  ushort;   /* Sys V compatibility */
112   typedef UINTN   uint;     /* Sys V compatibility */
113   typedef ULONGN  ulong;    /* Sys V compatibility */
114 
115   typedef u_long    cpuid_t;
116 #endif
117 
118 typedef uint64_t  u_quad_t; /* quads */
119 typedef int64_t   quad_t;
120 typedef quad_t *  qaddr_t;
121 
122 /*
123  * The types longlong_t and u_longlong_t exist for use with the
124  * Sun-derived XDR routines involving these types, and their usage
125  * in other contexts is discouraged.  Further note that these types
126  * may not be equivalent to "long long" and "unsigned long long",
127  * they are only guaranteed to be signed and unsigned 64-bit types
128  * respectively.  Portable programs that need 64-bit types should use
129  * the C99 types int64_t and uint64_t instead.
130  */
131 
132 typedef int64_t   longlong_t; /* for XDR */
133 typedef uint64_t  u_longlong_t; /* for XDR */
134 
135 typedef int64_t   blkcnt_t; /* fs block count */
136 typedef uint32_t  blksize_t;  /* fs optimal block size */
137 
138 #ifndef fsblkcnt_t
139   typedef __fsblkcnt_t  fsblkcnt_t; /* fs block count (statvfs) */
140   #define fsblkcnt_t  __fsblkcnt_t
141 #endif
142 
143 #ifndef fsfilcnt_t
144   typedef __fsfilcnt_t  fsfilcnt_t; /* fs file count */
145   #define fsfilcnt_t  __fsfilcnt_t
146 #endif
147 
148 #ifndef caddr_t
149   typedef __caddr_t caddr_t;  /* core address */
150   #define caddr_t   __caddr_t
151 #endif
152 
153 #ifdef __daddr_t
154   typedef __daddr_t daddr_t;  /* disk address */
155   #undef __daddr_t
156 #else
157   typedef int64_t   daddr_t;  /* disk address */
158 #endif
159 
160 typedef uint32_t  dev_t;    /* device number */
161 typedef uint32_t  fixpt_t;  /* fixed point number */
162 
163 #ifndef gid_t
164   typedef __gid_t   gid_t;    /* group id */
165   #define gid_t   __gid_t
166 #endif
167 
168 typedef uint32_t  id_t;   /* group id, process id or user id */
169 typedef uint64_t  ino_t;    /* inode number */
170 typedef EFI_LONG_T    key_t;    /* IPC key (for Sys V IPC) */
171 
172 #ifndef mode_t
173   typedef __mode_t  mode_t;   /* permissions */
174   #define mode_t    __mode_t
175 #endif
176 
177 typedef uint32_t  nlink_t;  /* link count */
178 
179 #ifndef off_t
180   typedef __off_t   off_t;    /* file offset */
181   #define off_t   __off_t
182 #endif
183 
184 #ifndef pid_t
185   typedef __pid_t   pid_t;    /* process id */
186   #define pid_t   __pid_t
187 #endif
188 typedef int32_t   lwpid_t;  /* LWP id */
189 typedef quad_t    rlim_t;   /* resource limit */
190 typedef int32_t   segsz_t;  /* segment size */
191 typedef int32_t   swblk_t;  /* swap offset */
192 
193 #ifndef uid_t
194   typedef __uid_t   uid_t;    /* user id */
195   #define uid_t   __uid_t
196 #endif
197 
198 typedef int64_t   dtime_t;  /* on-disk time_t */
199 
200 #if defined(_LIBC)
201   /*
202    * semctl(2)'s argument structure.  This is here for the benefit of
203    * <sys/syscallargs.h>.  It is not in the user's namespace in SUSv2.
204    * The SUSv2 semctl(2) takes variable arguments.
205    */
206   union __semun {
207     int   val;    /* value for SETVAL */
208     struct semid_ds *buf;   /* buffer for IPC_STAT & IPC_SET */
209     unsigned short  *array;   /* array for GETALL & SETALL */
210   };
211   /* For the same reason as above */
212   #include <sys/stdint.h>
213   typedef intptr_t semid_t;
214 #endif /* _LIBC */
215 
216 /*
217  * These belong in EfiSysCall.h, but are also placed here to ensure that
218  * long arguments will be promoted to off_t if the program fails to
219  * include that header or explicitly cast them to off_t.
220  */
221 #ifndef __OFF_T_SYSCALLS_DECLARED
222   #define __OFF_T_SYSCALLS_DECLARED
223   __BEGIN_DECLS
224   extern off_t    lseek     (int, off_t, int);
225   extern int      truncate  (const char *, off_t);
226   extern int      ftruncate (int, off_t);
227   __END_DECLS
228 #endif /* __OFF_T_SYSCALLS_DECLARED */
229 
230 #if defined(_NETBSD_SOURCE)
231   /* Major, minor numbers, dev_t's. */
232   #define major(x)  ((int32_t)((((x) & 0x000fff00) >>  8)))
233   #define minor(x)  ((int32_t)((((x) & 0xfff00000) >> 12) | \
234              (((x) & 0x000000ff) >>  0)))
235   #define makedev(x,y)  ((dev_t)((((x) <<  8) & 0x000fff00) | \
236            (((y) << 12) & 0xfff00000) | \
237            (((y) <<  0) & 0x000000ff)))
238 #endif
239 
240 #if   defined(_BSD_CLOCK_T_) && defined(_EFI_CLOCK_T)
241   typedef _EFI_CLOCK_T      clock_t;
242   #undef  _BSD_CLOCK_T_
243   #undef  _EFI_CLOCK_T
244 #endif
245 
246 #ifdef  _EFI_SIZE_T_
247   typedef _EFI_SIZE_T_      size_t;
248   #define _SIZE_T
249   #undef  _BSD_SIZE_T_
250   #undef  _EFI_SIZE_T_
251 #endif
252 
253 #ifdef  _BSD_SSIZE_T_
254   typedef _BSD_SSIZE_T_   ssize_t;
255   #undef  _BSD_SSIZE_T_
256 #endif
257 
258 #if   defined(_BSD_TIME_T_) && defined(_EFI_TIME_T)
259   typedef _EFI_TIME_T     time_t;
260   #undef  _BSD_TIME_T_
261   #undef  _EFI_TIME_T
262 #endif
263 
264 #ifdef  _BSD_CLOCKID_T_
265   typedef _BSD_CLOCKID_T_   clockid_t;
266   #undef  _BSD_CLOCKID_T_
267 #endif
268 
269 #ifdef  _BSD_TIMER_T_
270   typedef _BSD_TIMER_T_   timer_t;
271   #undef  _BSD_TIMER_T_
272 #endif
273 
274 #ifdef  _BSD_SUSECONDS_T_
275   typedef _BSD_SUSECONDS_T_ suseconds_t;
276   #undef  _BSD_SUSECONDS_T_
277 #endif
278 
279 #ifdef  _BSD_USECONDS_T_
280   typedef _BSD_USECONDS_T_  useconds_t;
281   #undef  _BSD_USECONDS_T_
282 #endif
283 
284 #ifdef _NETBSD_SOURCE
285   #include <sys/fd_set.h>
286   #define NBBY  __NBBY
287 
288   typedef struct kauth_cred *kauth_cred_t;
289 
290 #endif
291 
292 #if 0
293   #if !defined(_KERNEL) && !defined(_STANDALONE)
294     #if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
295          defined(_NETBSD_SOURCE)
296       #include <pthread_types.h>
297     #endif
298   #endif
299 #endif  /* if 0 */
300 
301 #endif /* !_SYS_TYPES_H_ */
302