summaryrefslogtreecommitdiff
path: root/StdLib/Include/sys
diff options
context:
space:
mode:
Diffstat (limited to 'StdLib/Include/sys')
-rw-r--r--StdLib/Include/sys/EfiCdefs.h367
-rw-r--r--StdLib/Include/sys/EfiSysCall.h84
-rw-r--r--StdLib/Include/sys/_ctype.h66
-rw-r--r--StdLib/Include/sys/ansi.h63
-rw-r--r--StdLib/Include/sys/bswap.h77
-rw-r--r--StdLib/Include/sys/callout.h131
-rw-r--r--StdLib/Include/sys/cdefs_aout.h136
-rw-r--r--StdLib/Include/sys/dirent.h90
-rw-r--r--StdLib/Include/sys/endian.h309
-rw-r--r--StdLib/Include/sys/errno.h151
-rw-r--r--StdLib/Include/sys/fcntl.h150
-rw-r--r--StdLib/Include/sys/fd_set.h107
-rw-r--r--StdLib/Include/sys/featuretest.h73
-rw-r--r--StdLib/Include/sys/filio.h62
-rw-r--r--StdLib/Include/sys/float_ieee754.h99
-rw-r--r--StdLib/Include/sys/ieee754.h152
-rw-r--r--StdLib/Include/sys/inttypes.h52
-rw-r--r--StdLib/Include/sys/ioccom.h67
-rw-r--r--StdLib/Include/sys/localedef.h100
-rw-r--r--StdLib/Include/sys/param.h321
-rw-r--r--StdLib/Include/sys/pool.h311
-rw-r--r--StdLib/Include/sys/resource.h143
-rw-r--r--StdLib/Include/sys/select.h51
-rw-r--r--StdLib/Include/sys/signal.h37
-rw-r--r--StdLib/Include/sys/sigtypes.h123
-rw-r--r--StdLib/Include/sys/socket.h570
-rw-r--r--StdLib/Include/sys/stat.h213
-rw-r--r--StdLib/Include/sys/stdint.h107
-rw-r--r--StdLib/Include/sys/syslimits.h53
-rw-r--r--StdLib/Include/sys/termios.h304
-rw-r--r--StdLib/Include/sys/time.h183
-rw-r--r--StdLib/Include/sys/types.h301
-rw-r--r--StdLib/Include/sys/uio.h123
33 files changed, 5176 insertions, 0 deletions
diff --git a/StdLib/Include/sys/EfiCdefs.h b/StdLib/Include/sys/EfiCdefs.h
new file mode 100644
index 0000000000..46aaf6e744
--- /dev/null
+++ b/StdLib/Include/sys/EfiCdefs.h
@@ -0,0 +1,367 @@
+/** @file
+ Common declarations and definitions for Standard C Library headers.
+
+ This header consolidates definitions and declarations for compiler specific
+ features in one place in order to assist in making the remainder of the
+ library as compiler independent as possible.
+
+ Certain macro and type definitions are required to be provided by several
+ different headers. In order to avoid having multiple definitions, and the
+ attendant risk of having the definitions get out of sync, they are defined in
+ this header.
+
+ Note that MdePkg/Include/Base.h is automatically included and will bring
+ processor architecture specific definitions along with it.
+
+ Throughout the library, the following macros are used instead of keywords so
+ that the library can be easily tuned for different compilers.
+ __inline Defined to the appropriate keyword or not defined.
+ __func__ Defined to __FUNC__, __FUNCTION__, or NULL as appropriate.
+ __restrict Defined to nothing for VC++ or to restrict for C99 compliant compilers.
+
+ This file and its contents are inspired by the <sys/cdefs.h> files in Berkeley
+ Unix. They have been re-implemented to be specific to the EFI environment.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Portions Copyright (c) 1991, 1993
+ The Regents of the University of California. All rights reserved.
+
+ Portions of this code are derived from software contributed to Berkeley by
+ Berkeley Software Design, Inc.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+**/
+#ifndef _EFI_CDEFS_H
+#define _EFI_CDEFS_H
+
+/*
+* Macro to test if we're using a GNU C compiler of a specific vintage
+* or later, for e.g. features that appeared in a particular version
+* of GNU C. Usage:
+*
+* #if __GNUC_PREREQ__(major, minor)
+* ...cool feature...
+* #else
+* ...delete feature...
+* #endif
+*/
+#ifdef __GNUC__
+#define __GNUC_PREREQ__(x, y) \
+((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
+ (__GNUC__ > (x)))
+
+#define DONT_USE_STRONG_WEAK_ALIAS 1
+
+#else
+#define __GNUC_PREREQ__(x, y) 0
+#endif
+
+#include <sys/featuretest.h>
+//#include <machine/_EfiCdefs.h>
+#ifdef __PE32__
+#include <sys/_EfiCdefs_PE32.h>
+#else
+#include <sys/cdefs_aout.h>
+#endif
+
+/* NULL is defined by the automatic inclusion of Base.h by the build tools. */
+
+#ifdef __GNUC__
+ #define _EFI_SIZE_T_ __SIZE_TYPE__ /* sizeof() */
+ #define _EFI_WCHAR_T __WCHAR_TYPE__
+ #define _EFI_WINT_T __WINT_TYPE__
+ //#define _EFI_WINT_MIN (0)
+ //#define _EFI_WINT_MAX (0xFFFF)
+ #define _EFI_PTRDIFF_T_ __PTRDIFF_TYPE__ /* ptr1 - ptr2 --- Must be same size as size_t */
+#else
+#define _EFI_SIZE_T_ UINTN /* sizeof() */
+#define _EFI_WCHAR_T UINT16
+#define _EFI_WINT_T INT32
+ //#define _EFI_WINT_MIN (-2147483647) /* wint_t */
+ //#define _EFI_WINT_MAX ( 2147483647) /* wint_t */
+ #define _EFI_PTRDIFF_T_ INTN /* ptr1 - ptr2 --- Must be same size as size_t */
+#endif /* __GNUC__ */
+
+#define _EFI_CLOCK_T UINT64
+#define _EFI_TIME_T INT32
+
+#if defined(__cplusplus)
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS }
+#define __static_cast(x,y) static_cast<x>(y)
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#define __static_cast(x,y) (x)y
+#endif
+
+ /*
+ * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
+ * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
+ * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
+ * in between its arguments. __CONCAT can also concatenate double-quoted
+ * strings produced by the __STRING macro, but this only works with ANSI C.
+ */
+
+#define ___STRING(x) __STRING(x)
+#define ___CONCAT(x,y) __CONCAT(x,y)
+#define __CONCAT(x,y) x ## y
+#define __STRING(x) #x
+
+#define __const CONST
+#define __signed signed
+#define __volatile volatile
+
+#if __STDC__ || defined(__cplusplus)
+ #if defined(__cplusplus)
+ #define __inline inline /* convert to C++ keyword */
+ #else
+ #if defined(_MSC_VER) || (!defined(__GNUC__) && !defined(__lint__))
+ #define __inline /* delete C99 keyword */
+ #endif /* !__GNUC__ && !__lint__ */
+ #endif /* !__cplusplus */
+#endif /* !(__STDC__ || __cplusplus) */
+
+/* Used in NetBSD for internal auditing of the source tree. */
+#define __aconst
+
+ /*
+ * The following macro is used to remove const cast-away warnings
+ * from gcc -Wcast-qual; it should be used with caution because it
+ * can hide valid errors; in particular most valid uses are in
+ * situations where the API requires it, not to cast away string
+ * constants. We don't use *intptr_t on purpose here and we are
+ * explicit about unsigned long so that we don't have additional
+ * dependencies.
+ */
+#define __UNCONST(a) ((void *)(a))
+//#define __UNCONST(a) ((void *)(PHYSICAL_ADDRESS)(const void *)(a))
+
+ /*
+ * The following macro is used to remove the volatile cast-away warnings
+ * from gcc -Wcast-qual; as above it should be used with caution
+ * because it can hide valid errors or warnings. Valid uses include
+ * making it possible to pass a volatile pointer to memset().
+ * For the same reasons as above, we use unsigned long and not intptr_t.
+ */
+#define __UNVOLATILE(a) ((void *)(PHYSICAL_ADDRESS)(volatile void *)(a))
+
+ /*
+ * GCC2 provides __extension__ to suppress warnings for various GNU C
+ * language extensions under "-ansi -pedantic".
+ */
+#if !__GNUC_PREREQ__(2, 0)
+#define __extension__ /* delete __extension__ if non-gcc or gcc1 */
+#endif
+
+ /*
+ * GCC1 and some versions of GCC2 declare dead (non-returning) and
+ * pure (no side effects) functions using "volatile" and "const";
+ * unfortunately, these then cause warnings under "-ansi -pedantic".
+ * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
+ * these work for GNU C++ (modulo a slight glitch in the C++ grammar
+ * in the distribution version of 2.5.5).
+ */
+#if !__GNUC_PREREQ__(2, 5)
+#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#define __dead __volatile
+#define __pure __const
+#endif
+#endif
+
+ /* Delete pseudo-keywords wherever they are not available or needed. */
+#ifndef __dead
+#define __dead
+#define __pure
+#endif
+
+#if __GNUC_PREREQ__(2, 7)
+#define __unused __attribute__((__unused__))
+#define __noreturn __attribute__((__noreturn__))
+#else
+#define __unused /* delete */
+#define __noreturn /* delete */
+#endif
+
+#if __GNUC_PREREQ__(3, 1)
+#define __used __attribute__((__used__))
+#else
+#define __used __unused
+#endif
+
+#if __GNUC_PREREQ__(2, 7)
+#define __packed __attribute__((__packed__))
+#define __aligned(x) __attribute__((__aligned__(x)))
+#define __section(x) __attribute__((__section__(x)))
+#elif defined(__lint__)
+#define __packed /* delete */
+#define __aligned(x) /* delete */
+#define __section(x) /* delete */
+#else
+#define __packed error: no __packed for this compiler
+#define __aligned(x) error: no __aligned for this compiler
+#define __section(x) error: no __section for this compiler
+#endif
+
+/*
+* C99 defines the restrict type qualifier keyword, which was made available
+* in GCC 2.92.
+*/
+#if __STDC_VERSION__ >= 199901L
+ #define __restrict restrict
+#else
+ #if defined(_MSC_VER) || !__GNUC_PREREQ__(2, 92)
+ #define __restrict /* delete __restrict when not supported */
+ #endif
+#endif
+
+/*
+* C99 defines __func__ predefined identifier, which was made available
+* in GCC 2.95.
+*/
+#if !(__STDC_VERSION__ >= 199901L)
+ #if defined(_MSC_VER)
+ #define __func__ __FUNCTION__ /* Use the MS-specific predefined macro */
+ #elif __GNUC_PREREQ__(2, 6)
+ #define __func__ __PRETTY_FUNCTION__
+ #elif __GNUC_PREREQ__(2, 4)
+ #define __func__ __FUNCTION__
+ #else
+ #define __func__ ""
+ #endif
+#endif /* !(__STDC_VERSION__ >= 199901L) */
+
+// <DVM 12/21/2010> Experiment to disable RENAME for GCC
+#if 0
+#ifdef __GNUC__
+ #define __RENAME(x) ___RENAME(x)
+#else
+ #ifdef __lint__
+ #define __RENAME(x) __symbolrename(x)
+ #else
+ /*DVM To see where this might be used... */
+ //#error "No function renaming possible"
+ #define __RENAME(x)
+ #endif /* __lint__ */
+#endif /* __GNUC__ */
+#else /* if 0 */
+ #define __RENAME(x)
+#endif /* if 0 */
+
+ /*
+ * A barrier to stop the optimizer from moving code or assume live
+ * register values. This is gcc specific, the version is more or less
+ * arbitrary, might work with older compilers.
+ */
+#if __GNUC_PREREQ__(2, 95)
+#define __insn_barrier() __asm __volatile("":::"memory")
+#else
+#define __insn_barrier() /* */
+#endif
+
+ /*
+ * GNU C version 2.96 adds explicit branch prediction so that
+ * the CPU back-end can hint the processor and also so that
+ * code blocks can be reordered such that the predicted path
+ * sees a more linear flow, thus improving cache behavior, etc.
+ *
+ * The following two macros provide us with a way to use this
+ * compiler feature. Use __predict_true() if you expect the expression
+ * to evaluate to true, and __predict_false() if you expect the
+ * expression to evaluate to false.
+ *
+ * A few notes about usage:
+ *
+ * * Generally, __predict_false() error condition checks (unless
+ * you have some _strong_ reason to do otherwise, in which case
+ * document it), and/or __predict_true() `no-error' condition
+ * checks, assuming you want to optimize for the no-error case.
+ *
+ * * Other than that, if you don't know the likelihood of a test
+ * succeeding from empirical or other `hard' evidence, don't
+ * make predictions.
+ *
+ * * These are meant to be used in places that are run `a lot'.
+ * It is wasteful to make predictions in code that is run
+ * seldomly (e.g. at subsystem initialization time) as the
+ * basic block reordering that this affects can often generate
+ * larger code.
+ */
+#if __GNUC_PREREQ__(2, 96)
+#define __predict_true(exp) __builtin_expect((exp) != 0, 1)
+#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
+#else
+#define __predict_true(exp) (exp)
+#define __predict_false(exp) (exp)
+#endif
+
+/* find least significant bit that is set */
+#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask))
+
+#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask))
+#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask))
+#define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask))
+
+#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
+
+ /* VC++, by default, defines wchar_t as an intrinsic type, equivalent to
+ unsigned short. This conflicts which Standard C Library
+ implementations which try to define wchar_t.
+ Make sure that this behavior has been turned off by using
+ /Zc:wchar_t- on the command line.
+ */
+ #ifdef _NATIVE_WCHAR_T_DEFINED
+ #error You must specify /Zc:wchar_t- to the compiler to turn off intrinsic wchar_t.
+ #endif
+
+ // Keep compiler quiet about casting from smaller to larger types
+ #pragma warning ( disable : 4306 )
+#endif /* defined(_MSC_VER) */
+extern int _fltused; // VC++ requires this if you use floating point. KEEP for all compilers.
+
+#define _Bool BOOLEAN
+#define _DIAGASSERT(e)
+
+// Types used to replace long so that it will have constant length regardless of compiler.
+typedef INT32 EFI_LONG_T; // Equivalent to long in VS200?
+typedef UINT32 EFI_ULONG_T; // Equivalent to unsigned long in VS200?
+typedef INTN LONGN;
+typedef UINTN ULONGN;
+typedef INT32 LONG32;
+typedef UINT32 ULONG32;
+typedef INT64 LONG64;
+typedef UINT64 ULONG64;
+
+//extern int EFIAPI main();
+
+#endif /* _EFI_CDEFS_H */
diff --git a/StdLib/Include/sys/EfiSysCall.h b/StdLib/Include/sys/EfiSysCall.h
new file mode 100644
index 0000000000..14ecb49890
--- /dev/null
+++ b/StdLib/Include/sys/EfiSysCall.h
@@ -0,0 +1,84 @@
+/** @file
+ Function declarations for UEFI "system calls".
+
+ Concept derived from NetBSD's unistd.h file.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifndef _EFI_SYS_CALL_H
+#define _EFI_SYS_CALL_H
+
+#include <sys/EfiCdefs.h>
+#include <sys/types.h>
+
+struct stat; // Structure declared in <sys/stat.h>
+
+#define STDIN_FILENO 0 /* standard input file descriptor */
+#define STDOUT_FILENO 1 /* standard output file descriptor */
+#define STDERR_FILENO 2 /* standard error file descriptor */
+
+/* access function */
+#define F_OK 0 /* test for existence of file */
+#define X_OK 0x01 /* test for execute or search permission */
+#define W_OK 0x02 /* test for write permission */
+#define R_OK 0x04 /* test for read permission */
+
+/* whence values for lseek(2) */
+#define SEEK_SET 0 /* set file offset to offset */
+#define SEEK_CUR 1 /* set file offset to current plus offset */
+#define SEEK_END 2 /* set file offset to EOF plus offset */
+
+__BEGIN_DECLS
+
+/* EFI versions of BSD system calls used in stdio */
+extern int close (int fd);
+extern ssize_t read (int fd, void *buf, size_t n);
+extern ssize_t write (int fd, const void *buf, size_t n);
+extern int unlink (const char *name);
+extern int dup2 (int, int);
+extern int rmdir (const char *);
+extern int isatty (int);
+
+/* These system calls are also declared in sys/fcntl.h */
+#ifndef __FCNTL_SYSCALLS_DECLARED
+ #define __FCNTL_SYSCALLS_DECLARED
+ extern int open (const char *name, int oflags, int mode);
+ extern int creat (const char *, mode_t);
+ extern int fcntl (int, int, ...);
+#endif // __FCNTL_SYSCALLS_DECLARED
+
+/* These system calls are also declared in stat.h */
+#ifndef __STAT_SYSCALLS_DECLARED
+ #define __STAT_SYSCALLS_DECLARED
+ extern int mkdir (const char *, mode_t);
+ extern int fstat (int, struct stat *);
+ extern int lstat (const char *, struct stat *);
+ extern int stat (const char *, void *);
+// extern int chmod (const char *, mode_t);
+#endif // __STAT_SYSCALLS_DECLARED
+
+// These are also declared in sys/types.h
+#ifndef __OFF_T_SYSCALLS_DECLARED
+ #define __OFF_T_SYSCALLS_DECLARED
+ extern off_t lseek (int, off_t, int);
+ extern int truncate (const char *, off_t);
+ extern int ftruncate (int, off_t); // IEEE Std 1003.1b-93
+#endif /* __OFF_T_SYSCALLS_DECLARED */
+
+/* These system calls don't YET have EFI implementations. */
+extern int access (const char *path, int amode);
+extern int chdir (const char *);
+extern char *getcwd (char *, size_t);
+extern int reboot (int, char *);
+
+__END_DECLS
+
+#endif /* _EFI_SYS_CALL_H */
diff --git a/StdLib/Include/sys/_ctype.h b/StdLib/Include/sys/_ctype.h
new file mode 100644
index 0000000000..e5872f48f8
--- /dev/null
+++ b/StdLib/Include/sys/_ctype.h
@@ -0,0 +1,66 @@
+/** @file
+ Implementation specific support for Single-byte character classification and
+ case conversion macros and function declarations.
+
+ This file is intended to only be included by <ctype.h>.
+
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifndef _CTYPE_H
+#error This file, <sys/_ctype.h>, may only be included by <ctype.h>.
+#endif
+
+__BEGIN_DECLS
+extern const UINT16 *_cClass; // Locale independent pointer to Character Classification Table
+extern const UINT8 *_uConvT; // Locale independent pointer to Lowercase to Uppercase Conversion Table
+extern const UINT8 *_lConvT; // Locale independent pointer to Uppercase to Lowercase Conversion Table
+
+extern int __isCClass( int _c, unsigned int mask); // Internal character classification function
+__END_DECLS
+
+
+// Character Class bit masks
+#define _CC 0x0001U // Control Characters
+#define _CW 0x0002U // White Space
+#define _CP 0x0004U // Punctuation
+#define _CD 0x0008U // Digits [0-9]
+#define _CU 0x0010U // Uppercase Letter [A-Z]
+#define _CL 0x0020U // Lowercase Letter [a-z]
+#define _CX 0x0040U // Hexadecimal Digits [A-Fa-f]
+#define _C0 0x0080U
+#define _CS 0x0100U // Space Characters, ' ' in C locale
+#define _CG 0x0200U // Graphic Characters
+#define _CB 0x0400U // Blank Characters, ' ' and '\t' in C locale
+#define _C4 0x0800U
+#define _XA 0x1000U // eXtra Alpha characters not in _CU or _CL
+#define _C6 0x2000U
+#define _C7 0x4000U
+#define _C8 0x8000U
+
+#ifndef NO_CTYPE_MACROS
+ #define __isCClass( _c, mask) (((_c) < 0 || (_c) > 127) ? 0 : (_cClass[(_c)] & (mask)))
+ #define __toLower( _c) ((__isCClass( ((int)_c), (_CU))) ? _lConvT[(_c)] : (_c))
+ #define __toUpper( _c) ((__isCClass( ((int)_c), (_CL))) ? _uConvT[(_c)] : (_c))
+#endif /* NO_CTYPE_MACROS */
+
+/* Macros used by implementation functions */
+#define __isHexLetter(_c) (__isCClass( (int)c, (_CX)))
+
+#ifdef _CTYPE_PRIVATE
+ #define _CTYPE_NUM_CHARS (256)
+
+ #define _CTYPE_ID "BSDCTYPE"
+ #define _CTYPE_REV 2
+
+ extern const UINT16 _C_CharClassTable[];
+ extern const UINT8 _C_ToUpperTable[];
+ extern const UINT8 _C_ToLowerTable[];
+#endif
diff --git a/StdLib/Include/sys/ansi.h b/StdLib/Include/sys/ansi.h
new file mode 100644
index 0000000000..a52a9994c9
--- /dev/null
+++ b/StdLib/Include/sys/ansi.h
@@ -0,0 +1,63 @@
+/** @file
+ ANSI type definitions.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License that accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Copyright (c) 1990, 1993
+ The Regents of the University of California. All rights reserved.
+
+ This code is derived from software contributed to The NetBSD Foundation
+ by Jun-ichiro itojun Hagino and by Klaus Klein.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ - Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ NetBSD: ansi.h,v 1.11 2005/12/11 12:25:20 christos Exp
+**/
+#ifndef _SYS_ANSI_H_
+#define _SYS_ANSI_H_
+
+#include <machine/int_types.h>
+
+typedef INT8 * __caddr_t; /* core address */
+typedef __uint32_t __gid_t; /* group id */
+typedef __uint32_t __in_addr_t; /* IP(v4) address */
+typedef __uint16_t __in_port_t; /* "Internet" port number */
+typedef __uint32_t __mode_t; /* file permissions */
+typedef __int64_t __off_t; /* file offset */
+typedef __int32_t __pid_t; /* process id */
+typedef __uint8_t __sa_family_t; /* socket address family */
+typedef UINTN __socklen_t; /* socket-related datum length */
+typedef __uint32_t __uid_t; /* user id */
+typedef __uint64_t __fsblkcnt_t; /* fs block count (statvfs) */
+typedef __uint64_t __fsfilcnt_t; /* fs file count */
+
+#endif /* !_SYS_ANSI_H_ */
diff --git a/StdLib/Include/sys/bswap.h b/StdLib/Include/sys/bswap.h
new file mode 100644
index 0000000000..a9284eb81d
--- /dev/null
+++ b/StdLib/Include/sys/bswap.h
@@ -0,0 +1,77 @@
+/* $NetBSD: bswap.h,v 1.12 2006/05/22 16:28:27 drochner Exp $ */
+
+/* Written by Manuel Bouyer. Public domain */
+
+#ifndef _SYS_BSWAP_H_
+#define _SYS_BSWAP_H_
+
+#ifndef _LOCORE
+#include <sys/EfiCdefs.h>
+#include <sys/types.h>
+
+#include <machine/bswap.h>
+
+__BEGIN_DECLS
+/* Always declare the functions in case their address is taken (etc) */
+#if !defined(__BSWAP_RENAME)
+uint16_t bswap16(uint16_t) __attribute__((__const__));
+uint32_t bswap32(uint32_t) __attribute__((__const__));
+#else
+uint16_t bswap16(uint16_t) __RENAME(__bswap16) __attribute__((__const__));
+uint32_t bswap32(uint32_t) __RENAME(__bswap32) __attribute__((__const__));
+#endif
+uint64_t bswap64(uint64_t) __attribute__((__const__));
+__END_DECLS
+
+#if defined(__GNUC__) && defined(__OPTIMIZE__)
+
+/* machine/byte_swap.h might have defined inline versions */
+#ifndef __BYTE_SWAP_U64_VARIABLE
+#define __BYTE_SWAP_U64_VARIABLE bswap64
+#endif
+
+#ifndef __BYTE_SWAP_U32_VARIABLE
+#define __BYTE_SWAP_U32_VARIABLE bswap32
+#endif
+
+#ifndef __BYTE_SWAP_U16_VARIABLE
+#define __BYTE_SWAP_U16_VARIABLE bswap16
+#endif
+
+#define __byte_swap_u64_constant(x) \
+ ((uint64_t) \
+ ((((x) & 0xff00000000000000ull) >> 56) | \
+ (((x) & 0x00ff000000000000ull) >> 40) | \
+ (((x) & 0x0000ff0000000000ull) >> 24) | \
+ (((x) & 0x000000ff00000000ull) >> 8) | \
+ (((x) & 0x00000000ff000000ull) << 8) | \
+ (((x) & 0x0000000000ff0000ull) << 24) | \
+ (((x) & 0x000000000000ff00ull) << 40) | \
+ (((x) & 0x00000000000000ffull) << 56)))
+
+#define __byte_swap_u32_constant(x) \
+ ((((x) & 0xff000000) >> 24) | \
+ (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | \
+ (((x) & 0x000000ff) << 24))
+
+#define __byte_swap_u16_constant(x) \
+ ((((x) & 0xff00) >> 8) | \
+ (((x) & 0x00ff) << 8))
+
+#define bswap64(x) \
+ (__builtin_constant_p((x)) ? \
+ __byte_swap_u64_constant(x) : __BYTE_SWAP_U64_VARIABLE(x))
+
+#define bswap32(x) \
+ (__builtin_constant_p((x)) ? \
+ __byte_swap_u32_constant(x) : __BYTE_SWAP_U32_VARIABLE(x))
+
+#define bswap16(x) \
+ (__builtin_constant_p((x)) ? \
+ __byte_swap_u16_constant(x) : __BYTE_SWAP_U16_VARIABLE(x))
+
+#endif /* __GNUC__ && __OPTIMIZE__ */
+#endif /* !_LOCORE */
+
+#endif /* !_SYS_BSWAP_H_ */
diff --git a/StdLib/Include/sys/callout.h b/StdLib/Include/sys/callout.h
new file mode 100644
index 0000000000..b3768199fa
--- /dev/null
+++ b/StdLib/Include/sys/callout.h
@@ -0,0 +1,131 @@
+/* $NetBSD: callout.h,v 1.22 2005/12/11 12:25:20 christos Exp $ */
+
+/*-
+ * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CALLOUT_H_
+#define _SYS_CALLOUT_H_
+
+/*
+ * The following funkyness is to appease gcc3's strict aliasing.
+ */
+struct callout;
+struct callout_circq {
+ /* next element */
+ union {
+ struct callout *elem;
+ struct callout_circq *list;
+ } cq_next;
+ /* previous element */
+ union {
+ struct callout *elem;
+ struct callout_circq *list;
+ } cq_prev;
+};
+#define cq_next_e cq_next.elem
+#define cq_prev_e cq_prev.elem
+#define cq_next_l cq_next.list
+#define cq_prev_l cq_prev.list
+
+struct callout {
+ struct callout_circq c_list; /* linkage on queue */
+ void (*c_func)(void *); /* function to call */
+ void *c_arg; /* function argument */
+ int c_time; /* when callout fires */
+ int c_flags; /* state of this entry */
+};
+
+#define CALLOUT_PENDING 0x0002 /* callout is on the queue */
+#define CALLOUT_FIRED 0x0004 /* callout has fired */
+#define CALLOUT_INVOKING 0x0008 /* callout function is being invoked */
+
+#define CALLOUT_INITIALIZER_SETFUNC(func, arg) \
+ { {{NULL}, {NULL}}, func, arg, 0, 0 }
+
+#define CALLOUT_INITIALIZER CALLOUT_INITIALIZER_SETFUNC(NULL, NULL)
+
+#ifdef _KERNEL
+void callout_startup(void);
+void callout_init(struct callout *);
+void callout_setfunc(struct callout *, void (*)(void *), void *);
+void callout_reset(struct callout *, int, void (*)(void *), void *);
+void callout_schedule(struct callout *, int);
+void callout_stop(struct callout *);
+int callout_hardclock(void);
+
+#define callout_setfunc(c, f, a) \
+do { \
+ (c)->c_func = (f); \
+ (c)->c_arg = (a); \
+} while (/*CONSTCOND*/0)
+
+#define callout_pending(c) ((c)->c_flags & CALLOUT_PENDING)
+#define callout_expired(c) ((c)->c_flags & CALLOUT_FIRED)
+#define callout_active(c) ((c)->c_flags & (CALLOUT_PENDING|CALLOUT_FIRED))
+#define callout_invoking(c) ((c)->c_flags & CALLOUT_INVOKING)
+#define callout_ack(c) ((c)->c_flags &= ~CALLOUT_INVOKING)
+#endif /* _KERNEL */
+
+#endif /* !_SYS_CALLOUT_H_ */
diff --git a/StdLib/Include/sys/cdefs_aout.h b/StdLib/Include/sys/cdefs_aout.h
new file mode 100644
index 0000000000..ce4ca06193
--- /dev/null
+++ b/StdLib/Include/sys/cdefs_aout.h
@@ -0,0 +1,136 @@
+/* $NetBSD: cdefs_aout.h,v 1.20 2006/05/18 17:55:38 christos Exp $ */
+
+/*
+ * Written by J.T. Conklin <jtc@wimsey.com> 01/17/95.
+ * Public domain.
+ */
+
+#ifndef _SYS_CDEFS_AOUT_H_
+#define _SYS_CDEFS_AOUT_H_
+
+#define _C_LABEL(x) __CONCAT(_,x)
+#define _C_LABEL_STRING(x) "_"x
+
+#if __STDC__
+#define ___RENAME(x) __asm(___STRING(_C_LABEL(x)))
+#else
+#define ___RENAME(x) ____RENAME(_/**/x)
+#define ____RENAME(x) __asm(___STRING(x))
+#endif
+
+#define __indr_reference(sym,alias) /* nada, since we do weak refs */
+
+#ifdef __GNUC__
+#if __STDC__
+ #ifndef DONT_USE_STRONG_WEAK_ALIAS
+#define __strong_alias(alias,sym) \
+ __asm(".global " _C_LABEL_STRING(#alias) "\n" \
+ _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
+#define __weak_alias(alias,sym) \
+ __asm(".weak " _C_LABEL_STRING(#alias) "\n" \
+ _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
+
+/* Do not use __weak_extern, use __weak_reference instead */
+#define __weak_extern(sym) \
+ __asm(".weak " _C_LABEL_STRING(#sym));
+
+#if __GNUC_PREREQ__(4, 0)
+#define __weak_reference(sym) __attribute__((__weakref__))
+#else
+#define __weak_reference(sym) ; __asm(".weak " _C_LABEL_STRING(#sym))
+#endif
+
+#define __warn_references(sym,msg) \
+ __asm(".stabs \"" msg "\",30,0,0,0"); \
+ __asm(".stabs \"_" #sym "\",1,0,0,0");
+ #else
+ #define __strong_alias(alias,sym) /* NOTHING */
+ #define __weak_alias(alias,sym) /* NOTHING */
+ #define __weak_extern(sym) /* NOTHING */
+ #define __weak_reference(sym) /* NOTHING */
+
+ #define __warn_references(sym,msg) \
+ __asm(".stabs \"" msg "\",30,0,0,0"); \
+ __asm(".stabs \"_" #sym "\",1,0,0,0");
+ #endif
+#else /* __STDC__ */
+#define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym)
+#define ___weak_alias(alias,sym) \
+ __asm(".weak alias\nalias = sym");
+/* Do not use __weak_extern, use __weak_reference instead */
+#define __weak_extern(sym) ___weak_extern(_/**/sym)
+#define ___weak_extern(sym) \
+ __asm(".weak sym");
+
+#if __GNUC_PREREQ__(4, 0)
+#define __weak_reference(sym) __attribute__((__weakref__))
+#else
+#define ___weak_reference(sym) ; __asm(".weak sym");
+#define __weak_reference(sym) ___weak_reference(_/**/sym)
+#endif
+
+#define __warn_references(sym,msg) \
+ __asm(".stabs msg,30,0,0,0"); \
+ __asm(".stabs \"_/**/sym\",1,0,0,0");
+#endif /* __STDC__ */
+#else /* __GNUC__ */
+#define __warn_references(sym,msg)
+#endif /* __GNUC__ */
+
+#if defined(__sh__) /* XXX SH COFF */
+#undef __indr_reference(sym,alias)
+#undef __warn_references(sym,msg)
+#define __warn_references(sym,msg)
+#endif
+
+#define __IDSTRING(_n,_s) \
+ __asm(".data ; .asciz \"" _s "\" ; .text")
+
+#undef __KERNEL_RCSID
+
+#define __RCSID(_s) __IDSTRING(rcsid,_s)
+#define __SCCSID(_s)
+#define __SCCSID2(_s)
+#if 0 /* XXX userland __COPYRIGHTs have \ns in them */
+#define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
+#else
+#define __COPYRIGHT(_s) \
+ static const char copyright[] __attribute__((__unused__)) = _s
+#endif
+
+#if defined(USE_KERNEL_RCSIDS) || !defined(_KERNEL)
+#define __KERNEL_RCSID(_n,_s) __IDSTRING(__CONCAT(rcsid,_n),_s)
+#else
+#define __KERNEL_RCSID(_n,_s)
+#endif
+#define __KERNEL_SCCSID(_n,_s)
+#define __KERNEL_COPYRIGHT(_n, _s) __IDSTRING(__CONCAT(copyright,_n),_s)
+
+#ifndef __lint__
+#define __link_set_make_entry(set, sym, type) \
+ static void const * const \
+ __link_set_##set##_sym_##sym __used = &sym; \
+ __asm(".stabs \"___link_set_" #set "\", " #type ", 0, 0, _" #sym)
+#else
+#define __link_set_make_entry(set, sym, type) \
+ extern void const * const __link_set_##set##_sym_##sym
+#endif /* __lint__ */
+
+#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym, 23)
+#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym, 23)
+#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym, 25)
+#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym, 27)
+
+#define __link_set_decl(set, ptype) \
+extern struct { \
+ int __ls_length; \
+ ptype *__ls_items[1]; \
+} __link_set_##set
+
+#define __link_set_start(set) (&(__link_set_##set).__ls_items[0])
+#define __link_set_end(set) \
+ (&(__link_set_##set).__ls_items[(__link_set_##set).__ls_length])
+
+#define __link_set_count(set) ((__link_set_##set).__ls_length)
+
+#endif /* !_SYS_CDEFS_AOUT_H_ */
diff --git a/StdLib/Include/sys/dirent.h b/StdLib/Include/sys/dirent.h
new file mode 100644
index 0000000000..1d5f91185f
--- /dev/null
+++ b/StdLib/Include/sys/dirent.h
@@ -0,0 +1,90 @@
+/** @file
+ Declarations pertaining to directory entries under the UEFI environment.
+
+ The information is based upon the EFI_FILE_INFO structure
+ in MdePkg/Include/Guid/FileInfo.h.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Copyright (c) 1989, 1993
+ The Regents of the University of California. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ @(#)dirent.h 8.3 (Berkeley) 8/10/94
+ NetBSD: dirent.h,v 1.23 2005/12/26 18:41:36 perry Exp
+**/
+
+#ifndef _SYS_DIRENT_H_
+#define _SYS_DIRENT_H_
+
+#include <sys/featuretest.h>
+#include <time.h>
+
+#define MAXNAMLEN 511
+
+/*
+ * The dirent structure defines the format of directory entries returned by
+ * read(fd, ...) when fd refers to a directory.
+ *
+ * All names are wide characters and are guaranteed to be null terminated.
+ * The maximum length of a name in a directory is MAXNAMLEN.
+ */
+struct dirent {
+ UINT64 Size; // Size of this dirent structure instance,
+ // including the Null-terminated FileName string.
+ UINT64 FileSize; // The size of the file in bytes.
+ UINT64 PhysicalSize; // The amount of physical space the file consumes
+ // on the file system volume.
+ UINT64 Attribute; // The time the file was created.
+ timespec CreateTime; // The time when the file was last accessed.
+ timespec LastAccessTime; // The time when the file’s contents were last modified.
+ timespec ModificationTime; // The attribute bits for the file. See below.
+ CHAR16 FileName[]; // The Null-terminated name of the file.
+};
+
+/*
+ * File Attributes
+ */
+#define DT_UNKNOWN 0
+#define DT_READ_ONLY 0x0000000000000001
+#define DT_HIDDEN 0x0000000000000002
+#define DT_SYSTEM 0x0000000000000004
+#define DT_RESERVED 0x0000000000000008
+#define DT_DIRECTORY 0x0000000000000010
+#define DT_ARCHIVE 0x0000000000000020
+#define DT_CHR 0x0000000000010000 // File attaches to a character device
+#define DT_BLK 0x0000000000020000 // File attaches to a block device
+#define DT_SOCKET 0x0000000000030000 // File attaches to a socket
+#define DT_VALID_ATTR 0x0000000000030037 // Mask for valid attribute bits
+
+#endif /* !_SYS_DIRENT_H_ */
diff --git a/StdLib/Include/sys/endian.h b/StdLib/Include/sys/endian.h
new file mode 100644
index 0000000000..dfe013fa40
--- /dev/null
+++ b/StdLib/Include/sys/endian.h
@@ -0,0 +1,309 @@
+/** @file
+ Byte order related definitions and declarations.
+
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License that accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Copyright (c) 1990, 1993
+ The Regents of the University of California. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ - Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ NetBSD: endian.h,v 1.24 2006/05/05 15:08:11 christos Exp
+ endian.h 8.1 (Berkeley) 6/11/93
+**/
+#ifndef _SYS_ENDIAN_H_
+#define _SYS_ENDIAN_H_
+
+#include <sys/EfiCdefs.h>
+
+/*
+ * Definitions for byte order, according to byte significance from low
+ * address to high.
+ */
+#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
+#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
+#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
+
+
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+#ifndef _LOCORE
+
+/* C-family endian-ness definitions */
+
+#include <sys/ansi.h>
+#include <sys/types.h>
+
+#ifndef in_addr_t
+typedef __in_addr_t in_addr_t;
+#define in_addr_t __in_addr_t
+#endif
+
+#ifndef in_port_t
+typedef __in_port_t in_port_t;
+#define in_port_t __in_port_t
+#endif
+
+__BEGIN_DECLS
+uint32_t htonl(uint32_t) __attribute__((__const__));
+uint16_t htons(uint16_t) __attribute__((__const__));
+uint32_t ntohl(uint32_t) __attribute__((__const__));
+uint16_t ntohs(uint16_t) __attribute__((__const__));
+__END_DECLS
+
+#endif /* !_LOCORE */
+#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
+
+
+#include <machine/endian_machdep.h>
+
+/*
+ * Define the order of 32-bit words in 64-bit words.
+ */
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#define _QUAD_HIGHWORD 1
+#define _QUAD_LOWWORD 0
+#endif
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define _QUAD_HIGHWORD 0
+#define _QUAD_LOWWORD 1
+#endif
+
+
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+/*
+ * Traditional names for byteorder. These are defined as the numeric
+ * sequences so that third party code can "#define XXX_ENDIAN" and not
+ * cause errors.
+ */
+#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
+#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
+#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
+#define BYTE_ORDER _BYTE_ORDER
+
+#ifndef _LOCORE
+
+#include <machine/bswap.h>
+
+/*
+ * Macros for network/external number representation conversion.
+ */
+#if BYTE_ORDER == BIG_ENDIAN && !defined(__lint__)
+#define ntohl(x) (x)
+#define ntohs(x) (x)
+#define htonl(x) (x)
+#define htons(x) (x)
+
+#define NTOHL(x) (void) (x)
+#define NTOHS(x) (void) (x)
+#define HTONL(x) (void) (x)
+#define HTONS(x) (void) (x)
+
+#else /* LITTLE_ENDIAN || !defined(__lint__) */
+
+#define ntohl(x) bswap32((uint32_t)(x))
+#define ntohs(x) bswap16((uint16_t)(x))
+#define htonl(x) bswap32((uint32_t)(x))
+#define htons(x) bswap16((uint16_t)(x))
+
+#define NTOHL(x) (x) = ntohl((uint32_t)(x))
+#define NTOHS(x) (x) = ntohs((uint16_t)(x))
+#define HTONL(x) (x) = htonl((uint32_t)(x))
+#define HTONS(x) (x) = htons((uint16_t)(x))
+#endif /* LITTLE_ENDIAN || !defined(__lint__) */
+
+/*
+ * Macros to convert to a specific endianness.
+ */
+
+#if BYTE_ORDER == BIG_ENDIAN
+
+#define htobe16(x) (x)
+#define htobe32(x) (x)
+#define htobe64(x) (x)
+#define htole16(x) bswap16((uint16_t)(x))
+#define htole32(x) bswap32((uint32_t)(x))
+#define htole64(x) bswap64((uint64_t)(x))
+
+#define HTOBE16(x) (void) (x)
+#define HTOBE32(x) (void) (x)
+#define HTOBE64(x) (void) (x)
+#define HTOLE16(x) (x) = bswap16((uint16_t)(x))
+#define HTOLE32(x) (x) = bswap32((uint32_t)(x))
+#define HTOLE64(x) (x) = bswap64((uint64_t)(x))
+
+#else /* LITTLE_ENDIAN */
+
+#define htobe16(x) bswap16((uint16_t)(x))
+#define htobe32(x) bswap32((uint32_t)(x))
+#define htobe64(x) bswap64((uint64_t)(x))
+#define htole16(x) (x)
+#define htole32(x) (x)
+#define htole64(x) (x)
+
+#define HTOBE16(x) (x) = bswap16((uint16_t)(x))
+#define HTOBE32(x) (x) = bswap32((uint32_t)(x))
+#define HTOBE64(x) (x) = bswap64((uint64_t)(x))
+#define HTOLE16(x) (void) (x)
+#define HTOLE32(x) (void) (x)
+#define HTOLE64(x) (void) (x)
+
+#endif /* LITTLE_ENDIAN */
+
+#define be16toh(x) htobe16(x)
+#define be32toh(x) htobe32(x)
+#define be64toh(x) htobe64(x)
+#define le16toh(x) htole16(x)
+#define le32toh(x) htole32(x)
+#define le64toh(x) htole64(x)
+
+#define BE16TOH(x) HTOBE16(x)
+#define BE32TOH(x) HTOBE32(x)
+#define BE64TOH(x) HTOBE64(x)
+#define LE16TOH(x) HTOLE16(x)
+#define LE32TOH(x) HTOLE32(x)
+#define LE64TOH(x) HTOLE64(x)
+
+/*
+ * Routines to encode/decode big- and little-endian multi-octet values
+ * to/from an octet stream.
+ */
+
+static __inline void __unused
+be16enc(void *buf, uint16_t u)
+{
+ uint8_t *p = (uint8_t *)buf;
+
+ p[0] = (uint8_t)(((unsigned)u >> 8) & 0xff);
+ p[1] = (uint8_t)(u & 0xff);
+}
+
+static __inline void __unused
+le16enc(void *buf, uint16_t u)
+{
+ uint8_t *p = (uint8_t *)buf;
+
+ p[0] = (uint8_t)(u & 0xff);
+ p[1] = (uint8_t)(((unsigned)u >> 8) & 0xff);
+}
+
+static __inline uint16_t __unused
+be16dec(const void *buf)
+{
+ const uint8_t *p = (const uint8_t *)buf;
+
+ return ((p[0] << 8) | p[1]);
+}
+
+static __inline uint16_t __unused
+le16dec(const void *buf)
+{
+ const uint8_t *p = (const uint8_t *)buf;
+
+ return ((p[1] << 8) | p[0]);
+}
+
+static __inline void __unused
+be32enc(void *buf, uint32_t u)
+{
+ uint8_t *p = (uint8_t *)buf;
+
+ p[0] = (uint8_t)((u >> 24) & 0xff);
+ p[1] = (uint8_t)((u >> 16) & 0xff);
+ p[2] = (uint8_t)((u >> 8) & 0xff);
+ p[3] = (uint8_t)(u & 0xff);
+}
+
+static __inline void __unused
+le32enc(void *buf, uint32_t u)
+{
+ uint8_t *p = (uint8_t *)buf;
+
+ p[0] = (uint8_t)(u & 0xff);
+ p[1] = (uint8_t)((u >> 8) & 0xff);
+ p[2] = (uint8_t)((u >> 16) & 0xff);
+ p[3] = (uint8_t)((u >> 24) & 0xff);
+}
+
+static __inline uint32_t __unused
+be32dec(const void *buf)
+{
+ const uint8_t *p = (const uint8_t *)buf;
+
+ return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
+}
+
+static __inline uint32_t __unused
+le32dec(const void *buf)
+{
+ const uint8_t *p = (const uint8_t *)buf;
+
+ return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
+}
+
+static __inline void __unused
+be64enc(void *buf, uint64_t u)
+{
+ uint8_t *p = (uint8_t *)buf;
+
+ be32enc(p, (uint32_t)(u >> 32));
+ be32enc(p + 4, (uint32_t)(u & 0xffffffffULL));
+}
+
+static __inline void __unused
+le64enc(void *buf, uint64_t u)
+{
+ uint8_t *p = (uint8_t *)buf;
+
+ le32enc(p, (uint32_t)(u & 0xffffffffULL));
+ le32enc(p + 4, (uint32_t)(u >> 32));
+}
+
+static __inline uint64_t __unused
+be64dec(const void *buf)
+{
+ const uint8_t *p = (const uint8_t *)buf;
+
+ return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
+}
+
+static __inline uint64_t __unused
+le64dec(const void *buf)
+{
+ const uint8_t *p = (const uint8_t *)buf;
+
+ return (le32dec(p) | ((uint64_t)le32dec(p + 4) << 32));
+}
+
+#endif /* !_LOCORE */
+#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
+#endif /* !_SYS_ENDIAN_H_ */
diff --git a/StdLib/Include/sys/errno.h b/StdLib/Include/sys/errno.h
new file mode 100644
index 0000000000..3662c8d441
--- /dev/null
+++ b/StdLib/Include/sys/errno.h
@@ -0,0 +1,151 @@
+/** @file
+ The header <sys/errno.h> defines several values, all relating to the reporting of
+ error conditions.
+
+ The enum members expand to integral constant expressions
+ with distinct nonzero values, suitable for use in #if preprocessing
+ directives.
+
+ Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifdef _ERRNO_H // May only be included from <errno.h>
+#ifndef _SYS_ERRNO_H
+#define _SYS_ERRNO_H
+
+/* Define the error numbers, sequentially, beginning at 1. */
+enum {
+ __EMINERRORVAL = 1, /* The lowest valid error value */
+ __EPERM = __EMINERRORVAL, /* 1 Operation not permitted */
+ __ENOENT, /* 2 No such file or directory */
+ __ESRCH, /* 3 No such process */
+ __EINTR, /* 4 Interrupted system call */
+ __EIO, /* 5 Input/output error */
+ __ENXIO, /* 6 Device not configured */
+ __E2BIG, /* 7 Argument list too long */
+ __ENOEXEC, /* 8 Exec format error */
+ __EBADF, /* 9 Bad file descriptor */
+ __ECHILD, /* 10 No child processes */
+ __EDEADLK, /* 11 Resource deadlock avoided */
+ __ENOMEM, /* 12 Cannot allocate memory */
+ __EACCES, /* 13 Permission denied */
+ __EFAULT, /* 14 Bad address */
+ __ENOTBLK, /* 15 Block device required */
+ __EBUSY, /* 16 Device busy */
+ __EEXIST, /* 17 File exists */
+ __EXDEV, /* 18 Cross-device link */
+ __ENODEV, /* 19 Operation not supported by device */
+ __ENOTDIR, /* 20 Not a directory */
+ __EISDIR, /* 21 Is a directory */
+ __EINVAL, /* 22 Invalid argument */
+ __ENFILE, /* 23 Too many open files in system */
+ __EMFILE, /* 24 Too many open file descriptors */
+ __ENOTTY, /* 25 Inappropriate ioctl for device */
+ __ETXTBSY, /* 26 Text file busy */
+ __EFBIG, /* 27 File too large */
+ __ENOSPC, /* 28 No space left on device */
+ __ESPIPE, /* 29 Illegal seek */
+ __EROFS, /* 30 Read-only filesystem */
+ __EMLINK, /* 31 Too many links */
+ __EPIPE, /* 32 Broken pipe */
+
+ /* math software -- these are the only two values required by the C Standard */
+ __EDOM, /* 33 Numerical argument out of domain */
+ __ERANGE, /* 34 Result too large */
+
+ /* non-blocking and interrupt i/o */
+ __EAGAIN, /* 35 Resource temporarily unavailable */
+ __EWOULDBLOCK = __EAGAIN, /* 35 Operation would block */
+ __EINPROGRESS, /* 36 Operation now in progress */
+ __EALREADY, /* 37 Operation already in progress */
+
+ /* ipc/network software -- argument errors */
+ __ENOTSOCK, /* 38 Socket operation on non-socket */
+ __EDESTADDRREQ, /* 39 Destination address required */
+ __EMSGSIZE, /* 40 Message too long */
+ __EPROTOTYPE, /* 41 Protocol wrong type for socket */
+ __ENOPROTOOPT, /* 42 Protocol not available */
+ __EPROTONOSUPPORT, /* 43 Protocol not supported */
+ __ESOCKTNOSUPPORT, /* 44 Socket type not supported */
+ __EOPNOTSUPP, /* 45 Operation not supported */
+ __ENOTSUP = __EOPNOTSUPP, /* 45 Operation not supported */
+ __EPFNOSUPPORT, /* 46 Protocol family not supported */
+ __EAFNOSUPPORT, /* 47 Address family not supported by protocol family */
+ __EADDRINUSE, /* 48 Address already in use */
+ __EADDRNOTAVAIL, /* 49 Can't assign requested address */
+
+ /* ipc/network software -- operational errors */
+ __ENETDOWN, /* 50 Network is down */
+ __ENETUNREACH, /* 51 Network is unreachable */
+ __ENETRESET, /* 52 Network dropped connection on reset */
+ __ECONNABORTED, /* 53 Software caused connection abort */
+ __ECONNRESET, /* 54 Connection reset by peer */
+ __ENOBUFS, /* 55 No buffer space available */
+ __EISCONN, /* 56 Socket is already connected */
+ __ENOTCONN, /* 57 Socket is not connected */
+ __ESHUTDOWN, /* 58 Can't send after socket shutdown */
+ __ETOOMANYREFS, /* 59 Too many references: can't splice */
+ __ETIMEDOUT, /* 60 Operation timed out */
+ __ECONNREFUSED, /* 61 Connection refused */
+ __ELOOP, /* 62 Too many levels of symbolic links */
+ __ENAMETOOLONG, /* 63 File name too long */
+ __EHOSTDOWN, /* 64 Host is down */
+ __EHOSTUNREACH, /* 65 No route to host */
+
+ __ENOTEMPTY, /* 66 Directory not empty */
+
+ /* quotas, etc. */
+ __EPROCLIM, /* 67 Too many processes */
+ __EUSERS, /* 68 Too many users */
+ __EDQUOT, /* 69 Disc quota exceeded */
+
+ /* Network File System */
+ __ESTALE, /* 70 Stale NFS file handle */
+ __EREMOTE, /* 71 Too many levels of remote in path */
+ __EBADRPC, /* 72 RPC struct is bad */
+ __ERPCMISMATCH, /* 73 RPC version wrong */
+ __EPROGUNAVAIL, /* 74 RPC prog. not avail */
+ __EPROGMISMATCH, /* 75 Program version wrong */
+ __EPROCUNAVAIL, /* 76 Bad procedure for program */
+ __ENOLCK, /* 77 No locks available */
+ __ENOSYS, /* 78 Function not implemented */
+ __EFTYPE, /* 79 Inappropriate file type or format */
+ __EAUTH, /* 80 Authentication error */
+ __ENEEDAUTH, /* 81 Need authenticator */
+ __EIDRM, /* 82 Identifier removed */
+ __ENOMSG, /* 83 No message of desired type */
+ __EOVERFLOW, /* 84 Value too large to be stored in data type */
+ __EILSEQ, /* 85 Illegal byte sequence */
+ __ENOTHING_1, /* 86 Place Holder */
+ __ECANCELED, /* 87 Operation canceled */
+
+ __EBADMSG, /* 88 Bad message */
+ __ENODATA, /* 89 No message available */
+ __ENOSR, /* 90 No STREAM resources */
+ __ENOSTR, /* 91 Not a STREAM */
+ __ETIME, /* 92 STREAM ioctl timeout */
+
+ __ENOATTR, /* 93 Attribute not found */
+
+ __EDOOFUS, /* 94 Programming error */
+
+ __EMULTIHOP, /* 95 Multihop attempted */
+ __ENOLINK, /* 96 Link has been severed */
+ __EPROTO, /* 97 Protocol error */
+
+ __EBUFSIZE, /* 98 Buffer too small to hold result */
+
+ __EMAXERRORVAL /* One more than the highest defined error value. */
+};
+
+#endif /* _SYS_ERRNO_H */
+#else /* not defined _ERRNO_H */
+#error <sys/errno.h> must only be included by <errno.h>.
+#endif /* _ERRNO_H */
diff --git a/StdLib/Include/sys/fcntl.h b/StdLib/Include/sys/fcntl.h
new file mode 100644
index 0000000000..cd720c03d9
--- /dev/null
+++ b/StdLib/Include/sys/fcntl.h
@@ -0,0 +1,150 @@
+/** @file
+ This file includes the definitions for open and fcntl described by POSIX
+ for <fcntl.h>; it also includes related kernel definitions.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made
+ available under the terms and conditions of the BSD License which
+ accompanies this distribution. The full text of the license may be found
+ at http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Copyright (c) 1983, 1990, 1993
+ The Regents of the University of California. All rights reserved.
+ (c) UNIX System Laboratories, Inc.
+ All or some portions of this file are derived from material licensed
+ to the University of California by American Telephone and Telegraph
+ Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ the permission of UNIX System Laboratories, Inc.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ fcntl.h 8.3 (Berkeley) 1/21/94
+ NetBSD: fcntl.h,v 1.34 2006/10/05 14:48:33 chs Exp
+ */
+#ifndef _SYS_FCNTL_H_
+#define _SYS_FCNTL_H_
+
+#include <sys/featuretest.h>
+#include <sys/types.h>
+
+#include <sys/stat.h>
+
+/*
+ * File status flags: these are used by open(2), fcntl(2).
+ * They are also used (indirectly) in the kernel file structure f_flags,
+ * which is a superset of the open/fcntl flags. Open flags and f_flags
+ * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
+ * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
+ */
+/* open-only flags */
+#define O_RDONLY 0x00000000 /* open for reading only */
+#define O_WRONLY 0x00000001 /* open for writing only */
+#define O_RDWR 0x00000002 /* open for reading and writing */
+#define O_ACCMODE 0x00000003 /* mask for above modes */
+
+/*
+ * Kernel encoding of open mode; separate read and write bits that are
+ * independently testable: 1 greater than the above.
+ *
+ * XXX
+ * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH,
+ * which was documented to use FREAD/FWRITE, continues to work.
+ */
+#define FREAD 0x00000001
+#define FWRITE 0x00000002
+#define O_NONBLOCK 0x00000004 /* no delay */
+#define O_APPEND 0x00000008 /* set append mode */
+#define O_CREAT 0x00000200 /* create if nonexistent */
+#define O_TRUNC 0x00000400 /* truncate to zero length */
+#define O_EXCL 0x00000800 /* error if already exists */
+
+//#define O_DIRECT 0x00080000 /* direct I/O hint */
+
+#define O_SETMASK 0x0000000F /* Flags modifiable by F_SETFD (fcntl) */
+
+/*
+ * Constants used for fcntl(2)
+ */
+
+/* command values */
+#define F_DUPFD 0 /* duplicate file descriptor */
+#define F_GETFD 1 /* get file descriptor flags */
+#define F_SETFD 2 /* set file descriptor flags */
+#define F_GETFL 3 /* get file status flags */
+#define F_SETFL 4 /* set file status flags */
+#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
+#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
+#define F_GETLK 7 /* get record locking information */
+#define F_SETLK 8 /* set record locking information */
+#define F_SETLKW 9 /* F_SETLK; wait if blocked */
+#define F_CLOSEM 10 /* close all fds >= to the one given */
+#define F_MAXFD 11 /* return the max open fd */
+
+/* file descriptor flags (F_GETFD, F_SETFD) */
+#define FD_CLOEXEC 1 /* close-on-exec flag */
+
+/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
+#define F_RDLCK 1 /* shared or read lock */
+#define F_UNLCK 2 /* unlock */
+#define F_WRLCK 3 /* exclusive or write lock */
+
+/* Constants for fcntl's passed to the underlying fs - like ioctl's. */
+#define F_PARAM_MASK 0xfff
+#define F_PARAM_LEN(x) (((x) >> 16) & F_PARAM_MASK)
+#define F_PARAM_MAX 4095
+#define F_FSCTL (int)0x80000000 /* This fcntl goes to the fs */
+#define F_FSVOID (int)0x40000000 /* no parameters */
+#define F_FSOUT (int)0x20000000 /* copy out parameter */
+#define F_FSIN (int)0x10000000 /* copy in parameter */
+#define F_FSINOUT (F_FSIN | F_FSOUT)
+#define F_FSDIRMASK (int)0x70000000 /* mask for IN/OUT/VOID */
+#define F_FSPRIV (int)0x00008000 /* command is fs-specific */
+
+/* Always ensure that these are consistent with <stdio.h> and <unistd.h>! */
+#ifndef SEEK_SET
+ #define SEEK_SET 0 /* set file offset to offset */
+#endif
+#ifndef SEEK_CUR
+ #define SEEK_CUR 1 /* set file offset to current plus offset */
+#endif
+#ifndef SEEK_END
+ #define SEEK_END 2 /* set file offset to EOF plus offset */
+#endif
+
+#include <sys/EfiCdefs.h>
+
+__BEGIN_DECLS
+#ifndef __FCNTL_SYSCALLS_DECLARED
+ #define __FCNTL_SYSCALLS_DECLARED
+ int open(const char *, int, int );
+ int creat(const char *, mode_t);
+ int fcntl(int, int, ...);
+#endif // __FCNTL_SYSCALLS_DECLARED
+__END_DECLS
+
+#endif /* !_SYS_FCNTL_H_ */
diff --git a/StdLib/Include/sys/fd_set.h b/StdLib/Include/sys/fd_set.h
new file mode 100644
index 0000000000..acbfbf0c9a
--- /dev/null
+++ b/StdLib/Include/sys/fd_set.h
@@ -0,0 +1,107 @@
+/* $NetBSD: fd_set.h,v 1.2 2005/12/11 12:25:20 christos Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)types.h 8.4 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_FD_SET_H_
+#define _SYS_FD_SET_H_
+
+#include <sys/EfiCdefs.h>
+#include <machine/int_types.h>
+
+/*
+ * Implementation dependent defines, hidden from user space. X/Open does not
+ * specify them.
+ */
+#define __NBBY 8 /* number of bits in a byte */
+typedef __int32_t __fd_mask;
+
+/* bits per mask */
+#define __NFDBITS ((unsigned int)sizeof(__fd_mask) * __NBBY)
+
+#define __howmany(x, y) (((x) + ((y) - 1)) / (y))
+
+/*
+ * Select uses bit masks of file descriptors in longs. These macros
+ * manipulate such bit fields (the filesystem macros use chars).
+ * FD_SETSIZE may be defined by the user, but the default here should
+ * be enough for most uses.
+ */
+#ifndef FD_SETSIZE
+#define FD_SETSIZE 256
+#endif
+
+typedef struct fd_set {
+ __fd_mask fds_bits[__howmany(FD_SETSIZE, __NFDBITS)];
+} fd_set;
+
+#define FD_SET(n, p) \
+ ((p)->fds_bits[(n)/__NFDBITS] |= (1 << ((n) % __NFDBITS)))
+#define FD_CLR(n, p) \
+ ((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS)))
+#define FD_ISSET(n, p) \
+ ((p)->fds_bits[(n)/__NFDBITS] & (1 << ((n) % __NFDBITS)))
+#if __GNUC_PREREQ__(2, 95)
+#define FD_ZERO(p) (void)__builtin_memset((p), 0, sizeof(*(p)))
+#else
+#define FD_ZERO(p) do { \
+ fd_set *__fds = (p); \
+ unsigned int __i; \
+ for (__i = 0; __i < __howmany(FD_SETSIZE, __NFDBITS); __i++) \
+ __fds->fds_bits[__i] = 0; \
+ } while (/* CONSTCOND */ 0)
+#endif /* GCC 2.95 */
+
+/*
+ * Expose our internals if we are not required to hide them.
+ */
+#if defined(_NETBSD_SOURCE)
+
+#define fd_mask __fd_mask
+#define NFDBITS __NFDBITS
+#ifndef howmany
+#define howmany(a, b) __howmany(a, b)
+#endif
+
+#if __GNUC_PREREQ__(2, 95)
+#define FD_COPY(f, t) (void)__builtin_memcpy((t), (f), sizeof(*(f)))
+#else
+#define FD_COPY(f, t) do { \
+ fd_set *__f = (f), *__t = (t); \
+ unsigned int __i; \
+ for (__i = 0; __i < __howmany(FD_SETSIZE, __NFDBITS); __i++) \
+ __t->fds_bits[__i] = __f->fds_bits[__i]; \
+ } while (/* CONSTCOND */ 0)
+#endif /* GCC 2.95 */
+
+#endif /* _NETBSD_SOURCE */
+
+#endif /* _SYS_FD_SET_H_ */
diff --git a/StdLib/Include/sys/featuretest.h b/StdLib/Include/sys/featuretest.h
new file mode 100644
index 0000000000..f36396af17
--- /dev/null
+++ b/StdLib/Include/sys/featuretest.h
@@ -0,0 +1,73 @@
+/* $NetBSD: featuretest.h,v 1.8 2005/12/11 12:25:20 christos Exp $ */
+
+/*
+ * Written by Klaus Klein <kleink@NetBSD.org>, February 2, 1998.
+ * Public domain.
+ *
+ * NOTE: Do not protect this header against multiple inclusion. Doing
+ * so can have subtle side-effects due to header file inclusion order
+ * and testing of e.g. _POSIX_SOURCE vs. _POSIX_C_SOURCE. Instead,
+ * protect each CPP macro that we want to supply.
+ */
+
+/*
+ * Feature-test macros are defined by several standards, and allow an
+ * application to specify what symbols they want the system headers to
+ * expose, and hence what standard they want them to conform to.
+ * There are two classes of feature-test macros. The first class
+ * specify complete standards, and if one of these is defined, header
+ * files will try to conform to the relevant standard. They are:
+ *
+ * ANSI macros:
+ * _ANSI_SOURCE ANSI C89
+ *
+ * POSIX macros:
+ * _POSIX_SOURCE == 1 IEEE Std 1003.1 (version?)
+ * _POSIX_C_SOURCE == 1 IEEE Std 1003.1-1990
+ * _POSIX_C_SOURCE == 2 IEEE Std 1003.2-1992
+ * _POSIX_C_SOURCE == 199309L IEEE Std 1003.1b-1993
+ * _POSIX_C_SOURCE == 199506L ISO/IEC 9945-1:1996
+ * _POSIX_C_SOURCE == 200112L IEEE Std 1003.1-2001
+ *
+ * X/Open macros:
+ * _XOPEN_SOURCE System Interfaces and Headers, Issue 4, Ver 2
+ * _XOPEN_SOURCE_EXTENDED == 1 XSH4.2 UNIX extensions
+ * _XOPEN_SOURCE == 500 System Interfaces and Headers, Issue 5
+ * _XOPEN_SOURCE == 520 Networking Services (XNS), Issue 5.2
+ * _XOPEN_SOURCE == 600 IEEE Std 1003.1-2001, XSI option
+ *
+ * NetBSD macros:
+ * _NETBSD_SOURCE == 1 Make all NetBSD features available.
+ *
+ * If more than one of these "major" feature-test macros is defined,
+ * then the set of facilities provided (and namespace used) is the
+ * union of that specified by the relevant standards, and in case of
+ * conflict, the earlier standard in the above list has precedence (so
+ * if both _POSIX_C_SOURCE and _NETBSD_SOURCE are defined, the version
+ * of rename() that's used is the POSIX one). If none of the "major"
+ * feature-test macros is defined, _NETBSD_SOURCE is assumed.
+ *
+ * There are also "minor" feature-test macros, which enable extra
+ * functionality in addition to some base standard. They should be
+ * defined along with one of the "major" macros. The "minor" macros
+ * are:
+ *
+ * _REENTRANT
+ * _ISOC99_SOURCE
+ * _LARGEFILE_SOURCE Large File Support
+ * <http://ftp.sas.com/standards/large.file/x_open.20Mar96.html>
+ */
+
+#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
+#define _POSIX_C_SOURCE 1L
+#endif
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
+ !defined(_XOPEN_SOURCE) && !defined(_NETBSD_SOURCE)
+#define _NETBSD_SOURCE 1
+#endif
+
+#if ((_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500) && \
+ !defined(_REENTRANT)
+#define _REENTRANT
+#endif
diff --git a/StdLib/Include/sys/filio.h b/StdLib/Include/sys/filio.h
new file mode 100644
index 0000000000..65f34bcb5c
--- /dev/null
+++ b/StdLib/Include/sys/filio.h
@@ -0,0 +1,62 @@
+/* $NetBSD: filio.h,v 1.10 2005/12/11 12:25:20 christos Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)filio.h 8.1 (Berkeley) 3/28/94
+ */
+
+#ifndef _SYS_FILIO_H_
+#define _SYS_FILIO_H_
+
+#include <sys/ioccom.h>
+
+/* Generic file-descriptor ioctl's. */
+#define FIOCLEX _IO('f', 1) /* set close on exec on fd */
+#define FIONCLEX _IO('f', 2) /* remove close on exec */
+#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
+#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
+#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */
+#define FIOSETOWN _IOW('f', 124, int) /* set owner */
+#define FIOGETOWN _IOR('f', 123, int) /* get owner */
+#define OFIOGETBMAP _IOWR('f', 122, uint32_t) /* get underlying block no. */
+#define FIOGETBMAP _IOWR('f', 122, daddr_t) /* get underlying block no. */
+#define FIONWRITE _IOR('f', 121, int) /* get # bytes outstanding
+ * in send queue. */
+#define FIONSPACE _IOR('f', 120, int) /* get space in send queue. */
+
+
+/* Ugly symbol for compatibility with other operating systems */
+#define FIBMAP FIOGETBMAP
+
+#endif /* !_SYS_FILIO_H_ */
diff --git a/StdLib/Include/sys/float_ieee754.h b/StdLib/Include/sys/float_ieee754.h
new file mode 100644
index 0000000000..1c8cfdeddb
--- /dev/null
+++ b/StdLib/Include/sys/float_ieee754.h
@@ -0,0 +1,99 @@
+/* $NetBSD: float_ieee754.h,v 1.8 2005/12/11 12:25:20 christos Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)float.h 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * NOTICE: This is not a standalone file. To use it, #include it in
+ * your port's float.h header.
+ */
+
+#ifndef _SYS_FLOAT_IEEE754_H_
+#define _SYS_FLOAT_IEEE754_H_
+
+#include <sys/EfiCdefs.h>
+#include <sys/featuretest.h>
+
+#ifndef FLT_ROUNDS
+__BEGIN_DECLS
+extern int __flt_rounds(void);
+__END_DECLS
+#define FLT_ROUNDS __flt_rounds()
+#endif
+
+#ifndef FLT_EVAL_METHOD
+#if __GNUC_PREREQ__(3, 3)
+#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
+#endif /* GCC >= 3.3 */
+#endif /* defined(FLT_EVAL_METHOD) */
+
+#define FLT_RADIX 2 /* b */
+
+#define FLT_MANT_DIG 24 /* p */
+#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */
+#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
+#define FLT_MIN_EXP (-125) /* emin */
+#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
+#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
+#define FLT_MAX_EXP 128 /* emax */
+//#define FLT_MAX 3.40282347e+38F /* (1-b**(-p))*b**emax */
+#define FLT_MAX 3.402823e+38F /* (1-b**(-p))*b**emax */
+#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
+
+#define DBL_MANT_DIG 53
+#define DBL_EPSILON 2.2204460492503131E-16
+#define DBL_DIG 15
+#define DBL_MIN_EXP (-1021)
+#define DBL_MIN 2.2250738585072014E-308
+#define DBL_MIN_10_EXP (-307)
+#define DBL_MAX_EXP 1024
+#define DBL_MAX 1.7976931348623157E+308
+#define DBL_MAX_10_EXP 308
+
+/*
+ * If no extended-precision type is defined by the machine-dependent
+ * header including this, default to `long double' being double-precision.
+ */
+#ifndef LDBL_MANT_DIG
+ #define LDBL_MANT_DIG DBL_MANT_DIG
+ #define LDBL_EPSILON DBL_EPSILON
+ #define LDBL_DIG DBL_DIG
+ #define LDBL_MIN_EXP DBL_MIN_EXP
+ #define LDBL_MIN DBL_MIN
+ #define LDBL_MIN_10_EXP DBL_MIN_10_EXP
+ #define LDBL_MAX_EXP DBL_MAX_EXP
+ #define LDBL_MAX DBL_MAX
+ #define LDBL_MAX_10_EXP DBL_MAX_10_EXP
+
+ #define DECIMAL_DIG 17 /* ceil((1+p*log10(b))-(b==10) */
+#endif /* LDBL_MANT_DIG */
+
+#endif /* _SYS_FLOAT_IEEE754_H_ */
diff --git a/StdLib/Include/sys/ieee754.h b/StdLib/Include/sys/ieee754.h
new file mode 100644
index 0000000000..740b58eb55
--- /dev/null
+++ b/StdLib/Include/sys/ieee754.h
@@ -0,0 +1,152 @@
+/* $NetBSD: ieee754.h,v 1.6.24.1 2007/05/07 19:49:10 pavel Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ieee.h 8.1 (Berkeley) 6/11/93
+ */
+#ifndef _SYS_IEEE754_H_
+#define _SYS_IEEE754_H_
+
+/*
+ * NOTICE: This is not a standalone file. To use it, #include it in
+ * your port's ieee.h header.
+ */
+
+#include <machine/endian.h>
+
+/*
+ * <sys/ieee754.h> defines the layout of IEEE 754 floating point types.
+ * Only single-precision and double-precision types are defined here;
+ * extended types, if available, are defined in the machine-dependent
+ * header.
+ */
+
+/*
+ * Define the number of bits in each fraction and exponent.
+ *
+ * k k+1
+ * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented
+ *
+ * (-exp_bias+1)
+ * as fractions that look like 0.fffff x 2 . This means that
+ *
+ * -126
+ * the number 0.10000 x 2 , for instance, is the same as the normalized
+ *
+ * -127 -128
+ * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero
+ *
+ * -129
+ * in the fraction; to represent 2 , we need two, and so on. This
+ *
+ * (-exp_bias-fracbits+1)
+ * implies that the smallest denormalized number is 2
+ *
+ * for whichever format we are talking about: for single precision, for
+ *
+ * -126 -149
+ * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and
+ *
+ * -149 == -127 - 23 + 1.
+ */
+#define SNG_EXPBITS 8
+#define SNG_FRACBITS 23
+
+struct ieee_single {
+#if _BYTE_ORDER == _BIG_ENDIAN
+ u_int sng_sign:1;
+ u_int sng_exp:SNG_EXPBITS;
+ u_int sng_frac:SNG_FRACBITS;
+#else
+ u_int sng_frac:SNG_FRACBITS;
+ u_int sng_exp:SNG_EXPBITS;
+ u_int sng_sign:1;
+#endif
+};
+
+#define DBL_EXPBITS 11
+#define DBL_FRACHBITS 20
+#define DBL_FRACLBITS 32
+#define DBL_FRACBITS (DBL_FRACHBITS + DBL_FRACLBITS)
+
+struct ieee_double {
+#if _BYTE_ORDER == _BIG_ENDIAN
+ u_int dbl_sign:1;
+ u_int dbl_exp:DBL_EXPBITS;
+ u_int dbl_frach:DBL_FRACHBITS;
+ u_int dbl_fracl:DBL_FRACLBITS;
+#else
+ u_int dbl_fracl:DBL_FRACLBITS;
+ u_int dbl_frach:DBL_FRACHBITS;
+ u_int dbl_exp:DBL_EXPBITS;
+ u_int dbl_sign:1;
+#endif
+};
+
+/*
+ * Floats whose exponent is in [1..INFNAN) (of whatever type) are
+ * `normal'. Floats whose exponent is INFNAN are either Inf or NaN.
+ * Floats whose exponent is zero are either zero (iff all fraction
+ * bits are zero) or subnormal values.
+ *
+ * At least one `signalling NaN' and one `quiet NaN' value must be
+ * implemented. It is left to the architecture to specify how to
+ * distinguish between these.
+ */
+#define SNG_EXP_INFNAN 255
+#define DBL_EXP_INFNAN 2047
+
+/*
+ * Exponent biases.
+ */
+#define SNG_EXP_BIAS 127
+#define DBL_EXP_BIAS 1023
+
+/*
+ * Convenience data structures.
+ */
+union ieee_single_u {
+ float sngu_f;
+ struct ieee_single sngu_sng;
+};
+
+union ieee_double_u {
+ double dblu_d;
+ struct ieee_double dblu_dbl;
+};
+#endif /* _SYS_IEEE754_H_ */
diff --git a/StdLib/Include/sys/inttypes.h b/StdLib/Include/sys/inttypes.h
new file mode 100644
index 0000000000..5dc3565f3d
--- /dev/null
+++ b/StdLib/Include/sys/inttypes.h
@@ -0,0 +1,52 @@
+/* $NetBSD: inttypes.h,v 1.4 2001/04/28 15:41:30 kleink Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus J. Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_INTTYPES_H_
+#define _SYS_INTTYPES_H_
+
+/*
+ * 7.8 Format conversion of integer types
+ */
+
+#include <sys/stdint.h>
+
+#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
+#include <machine/int_fmtio.h>
+#endif
+
+#endif /* !_SYS_INTTYPES_H_ */
diff --git a/StdLib/Include/sys/ioccom.h b/StdLib/Include/sys/ioccom.h
new file mode 100644
index 0000000000..210c9180d7
--- /dev/null
+++ b/StdLib/Include/sys/ioccom.h
@@ -0,0 +1,67 @@
+/* $NetBSD: ioccom.h,v 1.8 2005/12/11 12:25:20 christos Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ioccom.h 8.3 (Berkeley) 1/9/95
+ */
+
+#ifndef _SYS_IOCCOM_H_
+#define _SYS_IOCCOM_H_
+
+/*
+ * Ioctl's have the command encoded in the lower word, and the size of
+ * any in or out parameters in the upper word. The high 3 bits of the
+ * upper word are used to encode the in/out status of the parameter.
+ */
+#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
+#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
+#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16))
+#define IOCGROUP(x) (((x) >> 8) & 0xff)
+
+#define IOCPARM_MAX NBPG /* max size of ioctl args, mult. of NBPG */
+ /* no parameters */
+#define IOC_VOID (unsigned long)0x20000000
+ /* copy parameters out */
+#define IOC_OUT (unsigned long)0x40000000
+ /* copy parameters in */
+#define IOC_IN (unsigned long)0x80000000
+ /* copy parameters in and out */
+#define IOC_INOUT (IOC_IN|IOC_OUT)
+ /* mask for IN/OUT/VOID */
+#define IOC_DIRMASK (unsigned long)0xe0000000
+
+#define _IOC(inout,group,num,len) \
+ (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
+#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
+#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
+#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
+/* this should be _IORW, but stdio got there first */
+#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
+
+#endif /* !_SYS_IOCCOM_H_ */
diff --git a/StdLib/Include/sys/localedef.h b/StdLib/Include/sys/localedef.h
new file mode 100644
index 0000000000..63ea8a2307
--- /dev/null
+++ b/StdLib/Include/sys/localedef.h
@@ -0,0 +1,100 @@
+/* $NetBSD: localedef.h,v 1.7 2005/11/29 03:12:16 christos Exp $ */
+
+/*
+ * Copyright (c) 1994 Winning Strategies, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_LOCALEDEF_H_
+#define _SYS_LOCALEDEF_H_
+
+typedef struct {
+ const char *yesexpr;
+ const char *noexpr;
+ const char *yesstr;
+ const char *nostr;
+} _MessagesLocale;
+
+extern const _MessagesLocale *_CurrentMessagesLocale;
+extern const _MessagesLocale _DefaultMessagesLocale;
+
+
+typedef struct {
+ const char *int_curr_symbol;
+ const char *currency_symbol;
+ const char *mon_decimal_point;
+ const char *mon_thousands_sep;
+ const char *mon_grouping;
+ const char *positive_sign;
+ const char *negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+ char int_p_cs_precedes;
+ char int_n_cs_precedes;
+ char int_p_sep_by_space;
+ char int_n_sep_by_space;
+ char int_p_sign_posn;
+ char int_n_sign_posn;
+} _MonetaryLocale;
+
+extern const _MonetaryLocale *_CurrentMonetaryLocale;
+extern const _MonetaryLocale _DefaultMonetaryLocale;
+
+
+typedef struct {
+ const char *decimal_point;
+ const char *thousands_sep;
+ const char *grouping;
+} _NumericLocale;
+
+extern const _NumericLocale *_CurrentNumericLocale;
+extern const _NumericLocale _DefaultNumericLocale;
+
+
+typedef struct {
+ const char *abday[7];
+ const char *day[7];
+ const char *abmon[12];
+ const char *mon[12];
+ const char *am_pm[2];
+ const char *d_t_fmt;
+ const char *d_fmt;
+ const char *t_fmt;
+ const char *t_fmt_ampm;
+} _TimeLocale;
+
+extern const _TimeLocale *_CurrentTimeLocale;
+extern const _TimeLocale _DefaultTimeLocale;
+
+#endif /* !_SYS_LOCALEDEF_H_ */
diff --git a/StdLib/Include/sys/param.h b/StdLib/Include/sys/param.h
new file mode 100644
index 0000000000..19de391a9f
--- /dev/null
+++ b/StdLib/Include/sys/param.h
@@ -0,0 +1,321 @@
+/* $NetBSD: param.h,v 1.244.2.9.2.2 2008/10/05 08:44:03 bouyer Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)param.h 8.3 (Berkeley) 4/4/95
+ */
+
+#ifndef _SYS_PARAM_H_
+#define _SYS_PARAM_H_
+
+/*
+ * Historic BSD #defines -- probably will remain untouched for all time.
+ */
+#define BSD 199506 /* System version (year & month). */
+#define BSD4_3 1
+#define BSD4_4 1
+
+/*
+ * #define __NetBSD_Version__ MMmmrrpp00
+ *
+ * M = major version
+ * m = minor version; a minor number of 99 indicates current.
+ * r = 0 (*)
+ * p = patchlevel
+ *
+ * When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local
+ * needs to be updated and the changes sent back to the groff maintainers.
+ *
+ * (*) Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric
+ * e.g. NetBSD-1.2D = 102040000 ('D' == 4)
+ * NetBSD-2.0H (200080000) was changed on 20041001 to:
+ * 2.99.9 (299000900)
+ */
+
+#define __NetBSD_Version__ 400000003 /* NetBSD 4.0.1 */
+
+#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
+ (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
+
+/*
+ * Historical NetBSD #define
+ *
+ * NetBSD 1.4 was the last release for which this value was incremented.
+ * The value is now permanently fixed at 199905. It will never be
+ * changed again.
+ *
+ * New code must use __NetBSD_Version__ instead, and should not even
+ * count on NetBSD being defined.
+ *
+ */
+
+#define NetBSD 199905 /* NetBSD version (year & month). */
+
+#ifndef _LOCORE
+//#include <sys/inttypes.h>
+#include <sys/types.h>
+#endif
+
+/*
+ * Machine-independent constants (some used in following include files).
+ * Redefined constants are from POSIX 1003.1 limits file.
+ *
+ * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
+ * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
+ */
+#include <sys/syslimits.h>
+
+#define MAXCOMLEN 16 /* max command name remembered */
+#define MAXINTERP PATH_MAX /* max interpreter file name length */
+/* DEPRECATED: use LOGIN_NAME_MAX instead. */
+#define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */
+#define NCARGS ARG_MAX /* max bytes for an exec function */
+#define NGROUPS NGROUPS_MAX /* max number groups */
+#define NOGROUP 65535 /* marker for empty group set member */
+#define MAXHOSTNAMELEN 256 /* max hostname size */
+
+#ifndef NOFILE
+#define NOFILE OPEN_MAX /* max open files per process */
+#endif
+#ifndef MAXUPRC /* max simultaneous processes */
+#define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */
+#else
+#if (MAXUPRC - 0) < CHILD_MAX
+#error MAXUPRC less than CHILD_MAX. See options(4) for details.
+#endif /* (MAXUPRC - 0) < CHILD_MAX */
+#endif /* !defined(MAXUPRC) */
+
+/* Signals. */
+#include <sys/signal.h>
+
+/* Machine type dependent parameters. */
+#include <machine/param.h>
+#include <machine/limits.h>
+
+/* pages ("clicks") to disk blocks */
+#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
+#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
+
+/* bytes to pages */
+#define ctob(x) ((x) << PGSHIFT)
+#define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
+
+/* bytes to disk blocks */
+#define dbtob(x) ((x) << DEV_BSHIFT)
+#define btodb(x) ((x) >> DEV_BSHIFT)
+
+/*
+ * Stack macros. On most architectures, the stack grows down,
+ * towards lower addresses; it is the rare architecture where
+ * it grows up, towards higher addresses.
+ *
+ * STACK_GROW and STACK_SHRINK adjust a stack pointer by some
+ * size, no questions asked. STACK_ALIGN aligns a stack pointer.
+ *
+ * STACK_ALLOC returns a pointer to allocated stack space of
+ * some size; given such a pointer and a size, STACK_MAX gives
+ * the maximum (in the "maxsaddr" sense) stack address of the
+ * allocated memory.
+ */
+#if defined(_KERNEL) || defined(__EXPOSE_STACK)
+#ifdef __MACHINE_STACK_GROWS_UP
+#define STACK_GROW(sp, _size) (((caddr_t)(sp)) + (_size))
+#define STACK_SHRINK(sp, _size) (((caddr_t)(sp)) - (_size))
+#define STACK_ALIGN(sp, bytes) \
+ ((caddr_t)((((unsigned long)(sp)) + (bytes)) & ~(bytes)))
+#define STACK_ALLOC(sp, _size) ((caddr_t)(sp))
+#define STACK_MAX(p, _size) (((caddr_t)(p)) + (_size))
+#else
+#define STACK_GROW(sp, _size) (((caddr_t)(sp)) - (_size))
+#define STACK_SHRINK(sp, _size) (((caddr_t)(sp)) + (_size))
+#define STACK_ALIGN(sp, bytes) \
+ ((caddr_t)(((unsigned long)(sp)) & ~(bytes)))
+#define STACK_ALLOC(sp, _size) (((caddr_t)(sp)) - (_size))
+#define STACK_MAX(p, _size) ((caddr_t)(p))
+#endif
+#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */
+
+/*
+ * Priorities. Note that with 32 run queues, differences less than 4 are
+ * insignificant.
+ */
+#define PSWP 0
+#define PVM 4
+#define PINOD 8
+#define PRIBIO 16
+#define PVFS 20
+#define PZERO 22 /* No longer magic, shouldn't be here. XXX */
+#define PSOCK 24
+#define PWAIT 32
+#define PLOCK 36
+#define PPAUSE 40
+#define PUSER 50
+#define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */
+
+#define PRIMASK 0x0ff
+#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
+#define PNORELOCK 0x200 /* OR'd with pri for cond_wait() to not relock
+ the interlock */
+#define PNOEXITERR 0x400 /* OR'd with pri for tsleep to not exit
+ with an error code when LWPs are exiting */
+#define NBPW sizeof(int) /* number of bytes per word (integer) */
+
+#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
+#define NODEV (dev_t)(-1) /* non-existent device */
+
+#define CBLOCK 64 /* Clist block size, must be a power of 2. */
+#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
+ /* Data chars/clist. */
+#define CBSIZE (CBLOCK - (int)sizeof(struct cblock *) - CBQSIZE)
+#define CROUND (CBLOCK - 1) /* Clist rounding. */
+
+/*
+ * File system parameters and macros.
+ *
+ * The file system is made out of blocks of at most MAXBSIZE units, with
+ * smaller units (fragments) only in the last direct block. MAXBSIZE
+ * primarily determines the size of buffers in the buffer pool. It may be
+ * made larger without any effect on existing file systems; however making
+ * it smaller may make some file systems unmountable.
+ */
+#ifndef MAXBSIZE /* XXX */
+#define MAXBSIZE MAXPHYS
+#endif
+#define MAXFRAG 8
+
+/*
+ * MAXPATHLEN defines the longest permissible path length after expanding
+ * symbolic links. It is used to allocate a temporary buffer from the buffer
+ * pool in which to do the name expansion, hence should be a power of two,
+ * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
+ * maximum number of symbolic links that may be expanded in a path name.
+ * It should be set high enough to allow all legitimate uses, but halt
+ * infinite loops reasonably quickly.
+ */
+#define MAXPATHLEN PATH_MAX
+#define MAXSYMLINKS 32
+
+/* Bit map related macros. */
+#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+/* Macros for counting and rounding. */
+#ifndef howmany
+#define howmany(x, y) (((x)+((y)-1))/(y))
+#endif
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
+#define rounddown(x,y) (((x)/(y))*(y))
+#define powerof2(x) ((((x)-1)&(x))==0)
+
+///* Macros for min/max. */
+//#define MIN(a,b) (((a)<(b))?(a):(b))
+//#define MAX(a,b) (((a)>(b))?(a):(b))
+
+/*
+ * Constants for setting the parameters of the kernel memory allocator.
+ *
+ * 2 ** MINBUCKET is the smallest unit of memory that will be
+ * allocated. It must be at least large enough to hold a pointer.
+ *
+ * Units of memory less or equal to MAXALLOCSAVE will permanently
+ * allocate physical memory; requests for these size pieces of
+ * memory are quite fast. Allocations greater than MAXALLOCSAVE must
+ * always allocate and free physical memory; requests for these
+ * size allocations should be done infrequently as they will be slow.
+ *
+ * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
+ * MAXALLOCSAVE must be a power of two.
+ */
+#ifdef _LP64
+#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */
+#else
+#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
+#endif
+#define MAXALLOCSAVE (2 * NBPG)
+
+/*
+ * Scale factor for scaled integers used to count %cpu time and load avgs.
+ *
+ * The number of CPU `tick's that map to a unique `%age' can be expressed
+ * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
+ * can be calculated (assuming 32 bits) can be closely approximated using
+ * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
+ *
+ * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
+ * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
+ */
+#define FSHIFT 11 /* bits to right of fixed binary point */
+#define FSCALE (1<<FSHIFT)
+
+/*
+ * The time for a process to be blocked before being very swappable.
+ * This is a number of seconds which the system takes as being a non-trivial
+ * amount of real time. You probably shouldn't change this;
+ * it is used in subtle ways (fractions and multiples of it are, that is, like
+ * half of a ``long time'', almost a long time, etc.)
+ * It is related to human patience and other factors which don't really
+ * change over time.
+ */
+#define MAXSLP 20
+
+/*
+ * Defaults for Unified Buffer Cache parameters.
+ * These may be overridden in <machine/param.h>.
+ */
+
+#ifndef UBC_WINSHIFT
+#define UBC_WINSHIFT 13
+#endif
+#ifndef UBC_NWINS
+#define UBC_NWINS 1024
+#endif
+
+#ifdef _KERNEL
+/*
+ * macro to convert from milliseconds to hz without integer overflow
+ * Default version using only 32bits arithmetics.
+ * 64bit port can define 64bit version in their <machine/param.h>
+ * 0x20000 is safe for hz < 20000
+ */
+#ifndef mstohz
+#define mstohz(ms) \
+ (__predict_false((ms) >= 0x20000) ? \
+ ((ms +0u) / 1000u) * hz : \
+ ((ms +0u) * hz) / 1000u)
+#endif
+#endif /* _KERNEL */
+
+#endif /* !_SYS_PARAM_H_ */
diff --git a/StdLib/Include/sys/pool.h b/StdLib/Include/sys/pool.h
new file mode 100644
index 0000000000..43c080a227
--- /dev/null
+++ b/StdLib/Include/sys/pool.h
@@ -0,0 +1,311 @@
+/* $NetBSD: pool.h,v 1.54 2006/08/20 09:35:25 yamt Exp $ */
+
+/*-
+ * Copyright (c) 1997, 1998, 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Kranenburg; by Jason R. Thorpe of the Numerical Aerospace
+ * Simulation Facility, NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_POOL_H_
+#define _SYS_POOL_H_
+
+#ifdef _KERNEL
+#define __POOL_EXPOSE
+#endif
+
+#if defined(_KERNEL_OPT)
+#include "opt_pool.h"
+#endif
+
+#ifdef __POOL_EXPOSE
+#include <sys/lock.h>
+#include <sys/queue.h>
+#include <sys/time.h>
+#include <sys/tree.h>
+#if defined(_KERNEL)
+#include <sys/callback.h>
+#endif /* defined(_KERNEL) */
+#endif
+
+#define PCG_NOBJECTS 16
+
+#define POOL_PADDR_INVALID ((paddr_t) -1)
+
+#ifdef __POOL_EXPOSE
+/* The pool cache group. */
+struct pool_cache_group {
+ LIST_ENTRY(pool_cache_group)
+ pcg_list; /* link in the pool cache's group list */
+ u_int pcg_avail; /* # available objects */
+ /* pointers to the objects */
+ struct {
+ void *pcgo_va; /* cache object virtual address */
+ paddr_t pcgo_pa;/* cache object physical address */
+ } pcg_objects[PCG_NOBJECTS];
+};
+
+LIST_HEAD(pool_cache_grouplist,pool_cache_group);
+struct pool_cache {
+ LIST_ENTRY(pool_cache)
+ pc_poollist; /* entry on pool's group list */
+ struct pool_cache_grouplist
+ pc_emptygroups; /* list of empty cache groups */
+ struct pool_cache_grouplist
+ pc_fullgroups; /* list of full cache groups */
+ struct pool_cache_grouplist
+ pc_partgroups; /* list of partial cache groups */
+ struct pool *pc_pool; /* parent pool */
+ struct simplelock pc_slock; /* mutex */
+
+ int (*pc_ctor)(void *, void *, int);
+ void (*pc_dtor)(void *, void *);
+ void *pc_arg;
+
+ /* Statistics. */
+ unsigned long pc_hits; /* cache hits */
+ unsigned long pc_misses; /* cache misses */
+
+ unsigned long pc_ngroups; /* # cache groups */
+
+ unsigned long pc_nitems; /* # objects currently in cache */
+};
+
+struct pool_allocator {
+ void *(*pa_alloc)(struct pool *, int);
+ void (*pa_free)(struct pool *, void *);
+ unsigned int pa_pagesz;
+
+ /* The following fields are for internal use only. */
+ struct simplelock pa_slock;
+ TAILQ_HEAD(, pool) pa_list; /* list of pools using this allocator */
+ int pa_flags;
+#define PA_INITIALIZED 0x01
+ int pa_pagemask;
+ int pa_pageshift;
+ struct vm_map *pa_backingmap;
+#if defined(_KERNEL)
+ struct vm_map **pa_backingmapptr;
+ SLIST_ENTRY(pool_allocator) pa_q;
+#endif /* defined(_KERNEL) */
+};
+
+LIST_HEAD(pool_pagelist,pool_item_header);
+
+struct pool {
+ LIST_ENTRY(pool)
+ pr_poollist;
+ struct pool_pagelist
+ pr_emptypages; /* Empty pages */
+ struct pool_pagelist
+ pr_fullpages; /* Full pages */
+ struct pool_pagelist
+ pr_partpages; /* Partially-allocated pages */
+ struct pool_item_header *pr_curpage;
+ struct pool *pr_phpool; /* Pool item header pool */
+ LIST_HEAD(,pool_cache)
+ pr_cachelist; /* Caches for this pool */
+ unsigned int pr_size; /* Size of item */
+ unsigned int pr_align; /* Requested alignment, must be 2^n */
+ unsigned int pr_itemoffset; /* Align this offset in item */
+ unsigned int pr_minitems; /* minimum # of items to keep */
+ unsigned int pr_minpages; /* same in page units */
+ unsigned int pr_maxpages; /* maximum # of pages to keep */
+ unsigned int pr_npages; /* # of pages allocated */
+ unsigned int pr_itemsperpage;/* # items that fit in a page */
+ unsigned int pr_slack; /* unused space in a page */
+ unsigned int pr_nitems; /* number of available items in pool */
+ unsigned int pr_nout; /* # items currently allocated */
+ unsigned int pr_hardlimit; /* hard limit to number of allocated
+ items */
+ struct pool_allocator *pr_alloc;/* back-end allocator */
+ TAILQ_ENTRY(pool) pr_alloc_list;/* link on allocator's pool list */
+
+ /* Drain hook. */
+ void (*pr_drain_hook)(void *, int);
+ void *pr_drain_hook_arg;
+
+ const char *pr_wchan; /* tsleep(9) identifier */
+ unsigned int pr_flags; /* r/w flags */
+ unsigned int pr_roflags; /* r/o flags */
+#define PR_NOWAIT 0x00 /* for symmetry */
+#define PR_WAITOK 0x02
+#define PR_WANTED 0x04
+#define PR_PHINPAGE 0x40
+#define PR_LOGGING 0x80
+#define PR_LIMITFAIL 0x100 /* even if waiting, fail if we hit limit */
+#define PR_RECURSIVE 0x200 /* pool contains pools, for vmstat(8) */
+#define PR_NOTOUCH 0x400 /* don't use free items to keep internal state*/
+#define PR_NOALIGN 0x800 /* don't assume backend alignment */
+
+ /*
+ * `pr_slock' protects the pool's data structures when removing
+ * items from or returning items to the pool, or when reading
+ * or updating read/write fields in the pool descriptor.
+ *
+ * We assume back-end page allocators provide their own locking
+ * scheme. They will be called with the pool descriptor _unlocked_,
+ * since the page allocators may block.
+ */
+ struct simplelock pr_slock;
+
+ SPLAY_HEAD(phtree, pool_item_header) pr_phtree;
+
+ int pr_maxcolor; /* Cache colouring */
+ int pr_curcolor;
+ int pr_phoffset; /* Offset in page of page header */
+
+ /*
+ * Warning message to be issued, and a per-time-delta rate cap,
+ * if the hard limit is reached.
+ */
+ const char *pr_hardlimit_warning;
+ struct timeval pr_hardlimit_ratecap;
+ struct timeval pr_hardlimit_warning_last;
+
+ /*
+ * Instrumentation
+ */
+ unsigned long pr_nget; /* # of successful requests */
+ unsigned long pr_nfail; /* # of unsuccessful requests */
+ unsigned long pr_nput; /* # of releases */
+ unsigned long pr_npagealloc; /* # of pages allocated */
+ unsigned long pr_npagefree; /* # of pages released */
+ unsigned int pr_hiwat; /* max # of pages in pool */
+ unsigned long pr_nidle; /* # of idle pages */
+
+ /*
+ * Diagnostic aides.
+ */
+ struct pool_log *pr_log;
+ int pr_curlogentry;
+ int pr_logsize;
+
+ const char *pr_entered_file; /* reentrancy check */
+ long pr_entered_line;
+
+#if defined(_KERNEL)
+ struct callback_entry pr_reclaimerentry;
+#endif
+};
+#endif /* __POOL_EXPOSE */
+
+#ifdef _KERNEL
+/*
+ * pool_allocator_kmem is the default that all pools get unless
+ * otherwise specified. pool_allocator_nointr is provided for
+ * pools that know they will never be accessed in interrupt
+ * context.
+ */
+extern struct pool_allocator pool_allocator_kmem;
+extern struct pool_allocator pool_allocator_nointr;
+#ifdef POOL_SUBPAGE
+/* The above are subpage allocators in this case. */
+extern struct pool_allocator pool_allocator_kmem_fullpage;
+extern struct pool_allocator pool_allocator_nointr_fullpage;
+#endif
+
+struct link_pool_init { /* same as args to pool_init() */
+ struct pool *pp;
+ size_t size;
+ u_int align;
+ u_int align_offset;
+ int flags;
+ const char *wchan;
+ struct pool_allocator *palloc;
+};
+#define POOL_INIT(pp, size, align, align_offset, flags, wchan, palloc) \
+struct pool pp; \
+static const struct link_pool_init _link_ ## pp[1] = { \
+ { &pp, size, align, align_offset, flags, wchan, palloc } \
+}; \
+__link_set_add_rodata(pools, _link_ ## pp)
+
+void pool_subsystem_init(void);
+
+void pool_init(struct pool *, size_t, u_int, u_int,
+ int, const char *, struct pool_allocator *);
+void pool_destroy(struct pool *);
+
+void pool_set_drain_hook(struct pool *,
+ void (*)(void *, int), void *);
+
+void *pool_get(struct pool *, int);
+void pool_put(struct pool *, void *);
+int pool_reclaim(struct pool *);
+
+#ifdef POOL_DIAGNOSTIC
+/*
+ * These versions do reentrancy checking.
+ */
+void *_pool_get(struct pool *, int, const char *, long);
+void _pool_put(struct pool *, void *, const char *, long);
+int _pool_reclaim(struct pool *, const char *, long);
+#define pool_get(h, f) _pool_get((h), (f), __FILE__, __LINE__)
+#define pool_put(h, v) _pool_put((h), (v), __FILE__, __LINE__)
+#define pool_reclaim(h) _pool_reclaim((h), __FILE__, __LINE__)
+#endif /* POOL_DIAGNOSTIC */
+
+int pool_prime(struct pool *, int);
+void pool_setlowat(struct pool *, int);
+void pool_sethiwat(struct pool *, int);
+void pool_sethardlimit(struct pool *, int, const char *, int);
+void pool_drain(void *);
+
+/*
+ * Debugging and diagnostic aides.
+ */
+void pool_print(struct pool *, const char *);
+void pool_printit(struct pool *, const char *,
+ void (*)(const char *, ...));
+void pool_printall(const char *, void (*)(const char *, ...));
+int pool_chk(struct pool *, const char *);
+
+/*
+ * Pool cache routines.
+ */
+void pool_cache_init(struct pool_cache *, struct pool *,
+ int (*)(void *, void *, int),
+ void (*)(void *, void *),
+ void *);
+void pool_cache_destroy(struct pool_cache *);
+void *pool_cache_get_paddr(struct pool_cache *, int, paddr_t *);
+#define pool_cache_get(pc, f) pool_cache_get_paddr((pc), (f), NULL)
+void pool_cache_put_paddr(struct pool_cache *, void *, paddr_t);
+#define pool_cache_put(pc, o) pool_cache_put_paddr((pc), (o), \
+ POOL_PADDR_INVALID)
+void pool_cache_destruct_object(struct pool_cache *, void *);
+void pool_cache_invalidate(struct pool_cache *);
+#endif /* _KERNEL */
+
+#endif /* _SYS_POOL_H_ */
diff --git a/StdLib/Include/sys/resource.h b/StdLib/Include/sys/resource.h
new file mode 100644
index 0000000000..c54c816cd6
--- /dev/null
+++ b/StdLib/Include/sys/resource.h
@@ -0,0 +1,143 @@
+/* $NetBSD: resource.h,v 1.29 2006/07/23 22:06:14 ad Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)resource.h 8.4 (Berkeley) 1/9/95
+ */
+
+#ifndef _SYS_RESOURCE_H_
+#define _SYS_RESOURCE_H_
+
+#include <sys/featuretest.h>
+#include <sys/time.h>
+
+/*
+ * Process priority specifications to get/setpriority.
+ */
+#define PRIO_MIN -20
+#define PRIO_MAX 20
+
+#define PRIO_PROCESS 0
+#define PRIO_PGRP 1
+#define PRIO_USER 2
+
+/*
+ * Resource utilization information.
+ */
+
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
+
+struct rusage {
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+ long ru_maxrss; /* max resident set size */
+#ifdef _KERNEL
+#define ru_first ru_ixrss
+#endif
+ long ru_ixrss; /* integral shared memory size */
+ long ru_idrss; /* integral unshared data " */
+ long ru_isrss; /* integral unshared stack " */
+ long ru_minflt; /* page reclaims */
+ long ru_majflt; /* page faults */
+ long ru_nswap; /* swaps */
+ long ru_inblock; /* block input operations */
+ long ru_oublock; /* block output operations */
+ long ru_msgsnd; /* messages sent */
+ long ru_msgrcv; /* messages received */
+ long ru_nsignals; /* signals received */
+ long ru_nvcsw; /* voluntary context switches */
+ long ru_nivcsw; /* involuntary " */
+#ifdef _KERNEL
+#define ru_last ru_nivcsw
+#endif
+};
+
+/*
+ * Resource limits
+ */
+#define RLIMIT_CPU 0 /* cpu time in milliseconds */
+#define RLIMIT_FSIZE 1 /* maximum file size */
+#define RLIMIT_DATA 2 /* data size */
+#define RLIMIT_STACK 3 /* stack size */
+#define RLIMIT_CORE 4 /* core file size */
+#define RLIMIT_RSS 5 /* resident set size */
+#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */
+#define RLIMIT_NPROC 7 /* number of processes */
+#define RLIMIT_NOFILE 8 /* number of open files */
+#define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */
+
+#if defined(_NETBSD_SOURCE)
+#define RLIM_NLIMITS 10 /* number of resource limits */
+#endif
+
+#define RLIM_INFINITY (~((u_quad_t)1 << 63)) /* no limit */
+#define RLIM_SAVED_MAX RLIM_INFINITY /* unrepresentable hard limit */
+#define RLIM_SAVED_CUR RLIM_INFINITY /* unrepresentable soft limit */
+
+#if defined(_KERNEL)
+/* 4.3BSD compatibility rlimit argument structure. */
+struct orlimit {
+ int32_t rlim_cur; /* current (soft) limit */
+ int32_t rlim_max; /* maximum value for rlim_cur */
+};
+#endif
+
+struct rlimit {
+ rlim_t rlim_cur; /* current (soft) limit */
+ rlim_t rlim_max; /* maximum value for rlim_cur */
+};
+
+#if defined(_NETBSD_SOURCE)
+/* Load average structure. */
+struct loadavg {
+ fixpt_t ldavg[3];
+ long fscale;
+};
+#endif
+
+#ifdef _KERNEL
+extern struct loadavg averunnable;
+struct pcred;
+int dosetrlimit(struct lwp *, struct proc *, int, struct rlimit *);
+int donice(struct lwp *, struct proc *, int);
+
+#else
+#include <sys/EfiCdefs.h>
+
+__BEGIN_DECLS
+int getpriority(int, id_t);
+int getrlimit(int, struct rlimit *);
+int getrusage(int, struct rusage *);
+int setpriority(int, id_t, int);
+int setrlimit(int, const struct rlimit *);
+__END_DECLS
+
+#endif /* _KERNEL */
+#endif /* !_SYS_RESOURCE_H_ */
diff --git a/StdLib/Include/sys/select.h b/StdLib/Include/sys/select.h
new file mode 100644
index 0000000000..e1e5de1d5f
--- /dev/null
+++ b/StdLib/Include/sys/select.h
@@ -0,0 +1,51 @@
+/* $NetBSD: select.h,v 1.27 2006/02/16 20:17:20 perry Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)select.h 8.2 (Berkeley) 1/4/94
+ */
+
+#ifndef _SYS_SELECT_H_
+#define _SYS_SELECT_H_
+
+#include <sys/EfiCdefs.h>
+#include <sys/fd_set.h>
+
+#include <sys/sigtypes.h>
+#include <time.h>
+
+__BEGIN_DECLS
+int pselect(int, fd_set * __restrict, fd_set * __restrict,
+ fd_set * __restrict, const struct timespec * __restrict,
+ const sigset_t * __restrict);
+int select(int, fd_set * __restrict, fd_set * __restrict,
+ fd_set * __restrict, struct timeval * __restrict);
+__END_DECLS
+
+#endif /* !_SYS_SELECT_H_ */
diff --git a/StdLib/Include/sys/signal.h b/StdLib/Include/sys/signal.h
new file mode 100644
index 0000000000..8cc32f08c9
--- /dev/null
+++ b/StdLib/Include/sys/signal.h
@@ -0,0 +1,37 @@
+/**
+Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifndef _SYS_SIGNAL_H
+#define _SYS_SIGNAL_H
+#include <sys/EfiCdefs.h>
+#include <machine/signal.h>
+
+/** The type of a signal handler function. **/
+typedef void __sighandler_t(int);
+
+/** The signal function associates a "signal handler" with a signal number.
+
+ For historical reasons; programs expect signal to be declared
+ in <sys/signal.h>.
+
+ @param[in] sig Signal number that function is to be associated with.
+ @param[in] function The "handler" function to be associated with signal sig.
+
+ @return If the request can be honored, the signal function returns the
+ value of func for the most recent successful call to signal for
+ the specified signal sig. Otherwise, a value of SIG_ERR is
+ returned and a positive value is stored in errno.
+ */
+__BEGIN_DECLS
+__sighandler_t *signal(int sig, __sighandler_t *func);
+__END_DECLS
+
+#endif /* _SYS_SIGNAL_H */
diff --git a/StdLib/Include/sys/sigtypes.h b/StdLib/Include/sys/sigtypes.h
new file mode 100644
index 0000000000..c640296f49
--- /dev/null
+++ b/StdLib/Include/sys/sigtypes.h
@@ -0,0 +1,123 @@
+/* $NetBSD: sigtypes.h,v 1.8 2005/12/11 12:25:21 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)signal.h 8.4 (Berkeley) 5/4/95
+ */
+
+#ifndef _SYS_SIGTYPES_H_
+#define _SYS_SIGTYPES_H_
+
+/*
+ * This header file defines various signal-related types. We also keep
+ * the macros to manipulate sigset_t here, to encapsulate knowledge of
+ * its internals.
+ */
+
+#include <sys/featuretest.h>
+#include <machine/int_types.h>
+#include <machine/ansi.h>
+
+#ifdef _EFI_SIZE_T_
+ typedef _EFI_SIZE_T_ size_t;
+ #undef _EFI_SIZE_T_
+ #undef _BSD_SIZE_T_
+#endif
+
+#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
+ defined(_NETBSD_SOURCE)
+
+typedef struct {
+ __uint32_t __bits[4];
+} sigset_t;
+
+/*
+ * Macro for manipulating signal masks.
+ */
+#define __sigmask(n) (1 << (((unsigned int)(n) - 1) & 31))
+#define __sigword(n) (((unsigned int)(n) - 1) >> 5)
+#define __sigaddset(s, n) ((s)->__bits[__sigword(n)] |= __sigmask(n))
+#define __sigdelset(s, n) ((s)->__bits[__sigword(n)] &= ~__sigmask(n))
+#define __sigismember(s, n) (((s)->__bits[__sigword(n)] & __sigmask(n)) != 0)
+#define __sigemptyset(s) ((s)->__bits[0] = 0x00000000, \
+ (s)->__bits[1] = 0x00000000, \
+ (s)->__bits[2] = 0x00000000, \
+ (s)->__bits[3] = 0x00000000)
+#define __sigsetequal(s1,s2) ((s1)->__bits[0] == (s2)->__bits[0] && \
+ (s1)->__bits[1] == (s2)->__bits[1] && \
+ (s1)->__bits[2] == (s2)->__bits[2] && \
+ (s1)->__bits[3] == (s2)->__bits[3])
+#define __sigfillset(s) ((s)->__bits[0] = 0xffffffff, \
+ (s)->__bits[1] = 0xffffffff, \
+ (s)->__bits[2] = 0xffffffff, \
+ (s)->__bits[3] = 0xffffffff)
+#define __sigplusset(s, t) \
+ do { \
+ (t)->__bits[0] |= (s)->__bits[0]; \
+ (t)->__bits[1] |= (s)->__bits[1]; \
+ (t)->__bits[2] |= (s)->__bits[2]; \
+ (t)->__bits[3] |= (s)->__bits[3]; \
+ } while (/* CONSTCOND */ 0)
+#define __sigminusset(s, t) \
+ do { \
+ (t)->__bits[0] &= ~(s)->__bits[0]; \
+ (t)->__bits[1] &= ~(s)->__bits[1]; \
+ (t)->__bits[2] &= ~(s)->__bits[2]; \
+ (t)->__bits[3] &= ~(s)->__bits[3]; \
+ } while (/* CONSTCOND */ 0)
+#define __sigandset(s, t) \
+ do { \
+ (t)->__bits[0] &= (s)->__bits[0]; \
+ (t)->__bits[1] &= (s)->__bits[1]; \
+ (t)->__bits[2] &= (s)->__bits[2]; \
+ (t)->__bits[3] &= (s)->__bits[3]; \
+ } while (/* CONSTCOND */ 0)
+
+#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
+ (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
+typedef struct
+#if defined(_NETBSD_SOURCE)
+ sigaltstack
+#endif /* _NETBSD_SOURCE */
+ {
+ void *ss_sp; /* signal stack base */
+ size_t ss_size; /* signal stack length */
+ int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
+} stack_t;
+
+#endif /* _XOPEN_SOURCE_EXTENDED || XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
+
+#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || ... */
+
+#endif /* !_SYS_SIGTYPES_H_ */
diff --git a/StdLib/Include/sys/socket.h b/StdLib/Include/sys/socket.h
new file mode 100644
index 0000000000..8cc297d58b
--- /dev/null
+++ b/StdLib/Include/sys/socket.h
@@ -0,0 +1,570 @@
+/* $NetBSD: socket.h,v 1.82 2006/06/27 03:49:08 mrg Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)socket.h 8.6 (Berkeley) 5/3/95
+ */
+
+#ifndef _SYS_SOCKET_H_
+#define _SYS_SOCKET_H_
+
+#include <sys/featuretest.h>
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Data types.
+ */
+#include <sys/ansi.h>
+
+#ifndef sa_family_t
+typedef __sa_family_t sa_family_t;
+#define sa_family_t __sa_family_t
+#endif
+
+#ifndef socklen_t
+typedef __socklen_t socklen_t;
+#define socklen_t __socklen_t
+#endif
+
+#include <machine/ansi.h>
+
+#ifdef _BSD_SIZE_T_
+typedef _BSD_SIZE_T_ size_t;
+#undef _BSD_SIZE_T_
+#endif
+
+#ifdef _BSD_SSIZE_T_
+typedef _BSD_SSIZE_T_ ssize_t;
+#undef _BSD_SSIZE_T_
+#endif
+
+#include <sys/uio.h>
+
+/*
+ * Socket types.
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
+#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */
+
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+#define SO_OVERFLOWED 0x1009 /* datagrams: return packets dropped */
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+ int l_onoff; /* option on/off */
+ int l_linger; /* linger time in seconds */
+};
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_LOCAL 1 /* local to host (pipes, portals) */
+#define AF_UNIX AF_LOCAL /* backward compatibility */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_ISO 7 /* ISO protocols */
+#define AF_OSI AF_ISO
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* DEC Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+#define AF_ROUTE 17 /* Internal Routing Protocol */
+#define AF_LINK 18 /* Link layer interface */
+#if defined(_NETBSD_SOURCE)
+#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
+#endif
+#define AF_COIP 20 /* connection-oriented IP, aka ST II */
+#define AF_CNT 21 /* Computer Network Technology */
+#if defined(_NETBSD_SOURCE)
+#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
+#endif
+#define AF_IPX 23 /* Novell Internet Protocol */
+#define AF_INET6 24 /* IP version 6 */
+#if defined(_NETBSD_SOURCE)
+#define pseudo_AF_PIP 25 /* Help Identify PIP packets */
+#endif
+#define AF_ISDN 26 /* Integrated Services Digital Network*/
+#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
+#define AF_NATM 27 /* native ATM access */
+#define AF_ARP 28 /* (rev.) addr. res. prot. (RFC 826) */
+#if defined(_NETBSD_SOURCE)
+#define pseudo_AF_KEY 29 /* Internal key management protocol */
+#define pseudo_AF_HDRCMPLT 30 /* Used by BPF to not rewrite hdrs
+ in interface output routine */
+#endif
+#define AF_BLUETOOTH 31
+
+#define AF_MAX 32
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ __uint8_t sa_len; /* total length */
+ sa_family_t sa_family; /* address family */
+ char sa_data[14]; /* actually longer; address value */
+};
+
+#if defined(_KERNEL)
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ u_short sp_family; /* address family */
+ u_short sp_protocol; /* protocol */
+};
+#endif /* _KERNEL */
+
+#if 1
+/*
+ * RFC 2553: protocol-independent placeholder for socket addresses
+ */
+#define _SS_MAXSIZE 128
+#define _SS_ALIGNSIZE (sizeof(__int64_t))
+#define _SS_PAD1SIZE (_SS_ALIGNSIZE - 2)
+#define _SS_PAD2SIZE (_SS_MAXSIZE - 2 - \
+ _SS_PAD1SIZE - _SS_ALIGNSIZE)
+
+#if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
+struct sockaddr_storage {
+ __uint8_t ss_len; /* address length */
+ sa_family_t ss_family; /* address family */
+ char __ss_pad1[_SS_PAD1SIZE];
+ __int64_t __ss_align;/* force desired structure storage alignment */
+ char __ss_pad2[_SS_PAD2SIZE];
+};
+#endif /* _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
+#endif /* 1 */
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_LOCAL AF_LOCAL
+#define PF_UNIX PF_LOCAL /* backward compatibility */
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_ISO AF_ISO
+#define PF_OSI AF_ISO
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+#define PF_ROUTE AF_ROUTE
+#define PF_LINK AF_LINK
+#if defined(_NETBSD_SOURCE)
+#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
+#endif
+#define PF_COIP AF_COIP
+#define PF_CNT AF_CNT
+#define PF_INET6 AF_INET6
+#define PF_IPX AF_IPX /* same format as AF_NS */
+#if defined(_NETBSD_SOURCE)
+#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
+#define PF_PIP pseudo_AF_PIP
+#endif
+#define PF_ISDN AF_ISDN /* same as E164 */
+#define PF_E164 AF_E164
+#define PF_NATM AF_NATM
+#define PF_ARP AF_ARP
+#if defined(_NETBSD_SOURCE)
+#define PF_KEY pseudo_AF_KEY /* like PF_ROUTE, only for key mgmt */
+#endif
+#define PF_BLUETOOTH AF_BLUETOOTH
+
+#define PF_MAX AF_MAX
+
+#if defined(_NETBSD_SOURCE)
+
+#ifndef gid_t
+typedef __gid_t gid_t; /* group id */
+#define gid_t __gid_t
+#endif
+
+#ifndef uid_t
+typedef __uid_t uid_t; /* user id */
+#define uid_t __uid_t
+#endif
+
+/*
+ * Socket credentials.
+ */
+struct sockcred {
+ uid_t sc_uid; /* real user id */
+ uid_t sc_euid; /* effective user id */
+ gid_t sc_gid; /* real group id */
+ gid_t sc_egid; /* effective group id */
+ int sc_ngroups; /* number of supplemental groups */
+ gid_t sc_groups[1]; /* variable length */
+};
+
+/*
+ * Compute size of a sockcred structure with groups.
+ */
+#define SOCKCREDSIZE(ngrps) \
+ (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
+#endif /* _NETBSD_SOURCE */
+
+
+#if defined(_NETBSD_SOURCE)
+/*
+ * Definitions for network related sysctl, CTL_NET.
+ *
+ * Second level is protocol family.
+ * Third level is protocol number.
+ *
+ * Further levels are defined by the individual families below.
+ */
+#define NET_MAXID AF_MAX
+
+#define CTL_NET_NAMES { \
+ { 0, 0 }, \
+ { "local", CTLTYPE_NODE }, \
+ { "inet", CTLTYPE_NODE }, \
+ { "implink", CTLTYPE_NODE }, \
+ { "pup", CTLTYPE_NODE }, \
+ { "chaos", CTLTYPE_NODE }, \
+ { "xerox_ns", CTLTYPE_NODE }, \
+ { "iso", CTLTYPE_NODE }, \
+ { "emca", CTLTYPE_NODE }, \
+ { "datakit", CTLTYPE_NODE }, \
+ { "ccitt", CTLTYPE_NODE }, \
+ { "ibm_sna", CTLTYPE_NODE }, \
+ { "decnet", CTLTYPE_NODE }, \
+ { "dec_dli", CTLTYPE_NODE }, \
+ { "lat", CTLTYPE_NODE }, \
+ { "hylink", CTLTYPE_NODE }, \
+ { "appletalk", CTLTYPE_NODE }, \
+ { "route", CTLTYPE_NODE }, \
+ { "link_layer", CTLTYPE_NODE }, \
+ { "xtp", CTLTYPE_NODE }, \
+ { "coip", CTLTYPE_NODE }, \
+ { "cnt", CTLTYPE_NODE }, \
+ { "rtip", CTLTYPE_NODE }, \
+ { "ipx", CTLTYPE_NODE }, \
+ { "inet6", CTLTYPE_NODE }, \
+ { "pip", CTLTYPE_NODE }, \
+ { "isdn", CTLTYPE_NODE }, \
+ { "natm", CTLTYPE_NODE }, \
+ { "arp", CTLTYPE_NODE }, \
+ { "key", CTLTYPE_NODE }, \
+}
+
+struct kinfo_pcb {
+ __uint64_t ki_pcbaddr; /* PTR: pcb addr */
+ __uint64_t ki_ppcbaddr; /* PTR: ppcb addr */
+ __uint64_t ki_sockaddr; /* PTR: socket addr */
+
+ __uint32_t ki_family; /* INT: protocol family */
+ __uint32_t ki_type; /* INT: socket type */
+ __uint32_t ki_protocol; /* INT: protocol */
+ __uint32_t ki_pflags; /* INT: generic protocol flags */
+
+ __uint32_t ki_sostate; /* INT: socket state */
+ __uint32_t ki_prstate; /* INT: protocol state */
+ __int32_t ki_tstate; /* INT: tcp state */
+ __uint32_t ki_tflags; /* INT: tcp flags */
+
+ __uint64_t ki_rcvq; /* U_LONG: receive queue len */
+ __uint64_t ki_sndq; /* U_LONG: send queue len */
+
+ union {
+ struct sockaddr _kis_src; /* STRUCT: local address */
+ char _kis_pad[256 + 8]; /* pad to max addr length */
+ } ki_s;
+ union {
+ struct sockaddr _kid_dst; /* STRUCT: remote address */
+ char _kid_pad[256 + 8]; /* pad to max addr length */
+ } ki_d;
+
+ __uint64_t ki_inode; /* INO_T: fake inode number */
+ __uint64_t ki_vnode; /* PTR: if associated with file */
+ __uint64_t ki_conn; /* PTR: control block of peer */
+ __uint64_t ki_refs; /* PTR: referencing socket */
+ __uint64_t ki_nextref; /* PTR: link in refs list */
+};
+
+#define ki_src ki_s._kis_src
+#define ki_dst ki_d._kid_dst
+
+#define PCB_SLOP 20
+#define PCB_ALL 0
+
+#endif /* _NETBSD_SOURCE */
+
+#if defined(_NETBSD_SOURCE)
+/*
+ * PF_ROUTE - Routing table
+ *
+ * Three additional levels are defined:
+ * Fourth: address family, 0 is wildcard
+ * Fifth: type of info, defined below
+ * Sixth: flag(s) to mask with for NET_RT_FLAGS
+ */
+#define NET_RT_DUMP 1 /* dump; may limit to a.f. */
+#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
+#define NET_RT_OIFLIST 3 /* old NET_RT_IFLIST (pre 1.5) */
+#define NET_RT_IFLIST 4 /* survey interface list */
+#define NET_RT_MAXID 5
+
+#define CTL_NET_RT_NAMES { \
+ { 0, 0 }, \
+ { "dump", CTLTYPE_STRUCT }, \
+ { "flags", CTLTYPE_STRUCT }, \
+ { 0, 0 }, \
+ { "iflist", CTLTYPE_STRUCT }, \
+}
+#endif /* _NETBSD_SOURCE */
+
+/*
+ * Maximum queue length specifiable by listen(2).
+ */
+#ifndef SOMAXCONN
+#define SOMAXCONN 128
+#endif
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ * Used value-result for recvmsg, value only for sendmsg.
+ */
+struct msghdr {
+ void *msg_name; /* optional address */
+ socklen_t msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ void *msg_control; /* ancillary data, see below */
+ socklen_t msg_controllen; /* ancillary data buffer len */
+ int msg_flags; /* flags on received message */
+};
+
+#define MSG_OOB 0x0001 /* process out-of-band data */
+#define MSG_PEEK 0x0002 /* peek at incoming message */
+#define MSG_DONTROUTE 0x0004 /* send without using routing tables */
+#define MSG_EOR 0x0008 /* data completes record */
+#define MSG_TRUNC 0x0010 /* data discarded before delivery */
+#define MSG_CTRUNC 0x0020 /* control data lost before delivery */
+#define MSG_WAITALL 0x0040 /* wait for full request or error */
+#define MSG_DONTWAIT 0x0080 /* this message should be nonblocking */
+#define MSG_BCAST 0x0100 /* this message was rcvd using link-level brdcst */
+#define MSG_MCAST 0x0200 /* this message was rcvd using link-level mcast */
+#define MSG_NOSIGNAL 0x0400 /* do not generate SIGPIPE on EOF */
+
+/*
+ * Header for ancillary data objects in msg_control buffer.
+ * Used for additional information with/about a datagram
+ * not expressible by flags. The format is a sequence
+ * of message elements headed by cmsghdr structures.
+ */
+struct cmsghdr {
+ socklen_t cmsg_len; /* data byte count, including hdr */
+ int cmsg_level; /* originating protocol */
+ int cmsg_type; /* protocol-specific type */
+/* followed by u_char cmsg_data[]; */
+};
+
+/* given pointer to struct cmsghdr, return pointer to data */
+#define CMSG_DATA(cmsg) \
+ ((u_char *)(void *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr)))
+#define CCMSG_DATA(cmsg) \
+ ((const u_char *)(const void *)(cmsg) + \
+ __CMSG_ALIGN(sizeof(struct cmsghdr)))
+
+/*
+ * Alignment requirement for CMSG struct manipulation.
+ * This basically behaves the same as ALIGN() ARCH/include/param.h.
+ * We declare it separately for two reasons:
+ * (1) avoid dependency between machine/param.h, and (2) to sync with kernel's
+ * idea of ALIGNBYTES at runtime.
+ * without (2), we can't guarantee binary compatibility in case of future
+ * changes in ALIGNBYTES.
+ */
+#define __CMSG_ALIGN(n) (((n) + __cmsg_alignbytes()) & ~__cmsg_alignbytes())
+#ifdef _KERNEL
+#define CMSG_ALIGN(n) __CMSG_ALIGN(n)
+#endif
+
+/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ (((__caddr_t)(cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len) + \
+ __CMSG_ALIGN(sizeof(struct cmsghdr)) > \
+ (((__caddr_t)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \
+ (struct cmsghdr *)0 : \
+ (struct cmsghdr *)((__caddr_t)(cmsg) + \
+ __CMSG_ALIGN((cmsg)->cmsg_len)))
+
+/*
+ * RFC 2292 requires to check msg_controllen, in case that the kernel returns
+ * an empty list for some reasons.
+ */
+#define CMSG_FIRSTHDR(mhdr) \
+ ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
+ (struct cmsghdr *)(mhdr)->msg_control : \
+ (struct cmsghdr *)0)
+
+#define CMSG_SPACE(l) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(l))
+#define CMSG_LEN(l) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (l))
+
+/* "Socket"-level control message types: */
+#define SCM_RIGHTS 0x01 /* access rights (array of int) */
+#if defined(_NETBSD_SOURCE)
+#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */
+#define SCM_CREDS 0x04 /* credentials (struct sockcred) */
+#endif
+
+/*
+ * Types of socket shutdown(2).
+ */
+#define SHUT_RD 0 /* Disallow further receives. */
+#define SHUT_WR 1 /* Disallow further sends. */
+#define SHUT_RDWR 2 /* Disallow further sends/receives. */
+
+#include <sys/EfiCdefs.h>
+
+__BEGIN_DECLS
+int __cmsg_alignbytes(void);
+__END_DECLS
+
+#ifndef _KERNEL
+
+__BEGIN_DECLS
+int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
+int bind(int, const struct sockaddr *, socklen_t);
+int connect(int, const struct sockaddr *, socklen_t);
+int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
+int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
+int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
+int listen(int, int);
+ssize_t recv(int, void *, size_t, int);
+ssize_t recvfrom(int, void * __restrict, size_t, int,
+ struct sockaddr * __restrict, socklen_t * __restrict);
+ssize_t recvmsg(int, struct msghdr *, int);
+ssize_t send(int, const void *, size_t, int);
+ssize_t sendto(int, const void *,
+ size_t, int, const struct sockaddr *, socklen_t);
+ssize_t sendmsg(int, const struct msghdr *, int);
+int setsockopt(int, int, int, const void *, socklen_t);
+int shutdown(int, int);
+int sockatmark(int);
+int socket(int, int, int)
+#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
+__RENAME(__socket30)
+#endif
+ ;
+int socketpair(int, int, int, int *);
+__END_DECLS
+#endif /* !_KERNEL */
+
+#endif /* !_SYS_SOCKET_H_ */
diff --git a/StdLib/Include/sys/stat.h b/StdLib/Include/sys/stat.h
new file mode 100644
index 0000000000..adc61ecf80
--- /dev/null
+++ b/StdLib/Include/sys/stat.h
@@ -0,0 +1,213 @@
+/** @file
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made
+ available under the terms and conditions of the BSD License that
+ accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Copyright (c) 1982, 1986, 1989, 1993
+ The Regents of the University of California. All rights reserved.
+ (c) UNIX System Laboratories, Inc.
+ All or some portions of this file are derived from material licensed
+ to the University of California by American Telephone and Telegraph
+ Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ the permission of UNIX System Laboratories, Inc.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ stat.h 8.12 (Berkeley) 8/17/94
+ NetBSD: stat.h,v 1.54 2006/02/24 22:01:30 thorpej Exp
+ */
+#ifndef _SYS_STAT_H_
+#define _SYS_STAT_H_
+
+#include <sys/featuretest.h>
+#include <sys/types.h> /* XXX */
+#include <sys/time.h>
+
+struct stat {
+ off_t st_size; /* file size, in bytes */
+ off_t st_physsize; /* physical space the file consumes */
+ dtime_t st_birthtime; /* time of creation */
+ dtime_t st_atime; /* time of last access */
+ dtime_t st_mtime; /* time of last data modification */
+ mode_t st_mode; /* file attributes */
+
+ blksize_t st_blksize; /* optimal blocksize for I/O */
+#if 0
+ uint32_t st_flags; /* user defined flags for file */
+ blkcnt_t st_blocks; /* blocks allocated for file */
+ ino_t st_ino; /* inode's number */
+ time_t st_ctime; /* time of last file status change */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_dev; /* inode's device */
+ dev_t st_rdev; /* device type */
+ uint32_t st_gen; /* file generation number */
+#endif
+ uint32_t st_spare[1];
+};
+
+#if 0
+#define st_atime st_atimespec.tv_sec
+#define st_atimensec st_atimespec.tv_nsec
+#define st_mtime st_mtimespec.tv_sec
+#define st_mtimensec st_mtimespec.tv_nsec
+#define st_ctime st_ctimespec.tv_sec
+#define st_ctimensec st_ctimespec.tv_nsec
+#define st_birthtime st_birthtimespec.tv_sec
+#define st_birthtimensec st_birthtimespec.tv_nsec
+#endif
+
+#define S_ISUID 0004000 /* set user id on execution */
+#define S_ISGID 0002000 /* set group id on execution */
+#define S_ISTXT 0001000 /* sticky bit */
+
+#define S_IRWXU 0000700 /* RWX mask for owner */
+#define S_IRUSR 0000400 /* R for owner */
+#define S_IWUSR 0000200 /* W for owner */
+#define S_IXUSR 0000100 /* X for owner */
+
+#define S_IREAD S_IRUSR
+#define S_IWRITE S_IWUSR
+#define S_IEXEC S_IXUSR
+
+#define S_IRWXG 0000070 /* RWX mask for group */
+#define S_IRGRP 0000040 /* R for group */
+#define S_IWGRP 0000020 /* W for group */
+#define S_IXGRP 0000010 /* X for group */
+
+#define S_IRWXO 0000007 /* RWX mask for other */
+#define S_IROTH 0000004 /* R for other */
+#define S_IWOTH 0000002 /* W for other */
+#define S_IXOTH 0000001 /* X for other */
+
+/* The Octal access modes, above, fall into the Hex mask 0x00000FFF.
+ Traditionally, the remainder of the flags are specified in Octal
+ but they are expressed in Hex here for modern clarity.
+*/
+#define _S_IFMT 0x0001F000 /* type-of-file mask */
+#define _S_IFCHR 0x00002000 /* character special */
+#define _S_IFDIR 0x00004000 /* directory */
+#define _S_IFBLK 0x00006000 /* block special */
+#define _S_IFREG 0x00008000 /* regular */
+#define _S_IFSOCK 0x0000C000 /* socket */
+#define _S_ITTY 0x00010000 /* File connects to a TTY device */
+#define _S_IWTTY 0x00020000 /* TTY receives Wide characters */
+
+/* UEFI specific (FAT file system) File attributes.
+ Specifiec in Hexadecimal instead of Octal.
+ These bits correspond to the xx portion of _S_IFMT
+*/
+#define S_IREADONLY 0x00100000 // Read Only File
+#define S_IHIDDEN 0x00200000 // Hidden File
+#define S_ISYSTEM 0x00400000 // System File
+#define S_IDIRECTORY 0x01000000 // Directory
+#define S_IARCHIVE 0x02000000 // Archive Bit
+#define S_IROFS 0x08000000 /* Read Only File System */
+
+#define S_EFISHIFT 20 // LS bit of the UEFI attributes
+
+//#define _S_IFIFO 0010000 /* named pipe (fifo) */
+//#define _S_IFLNK 0120000 /* symbolic link */
+//#define _S_IFWHT 0160000 /* whiteout */
+//#define _S_ARCH1 0200000 /* Archive state 1, ls -l shows 'a' */
+//#define _S_ARCH2 0400000 /* Archive state 2, ls -l shows 'A' */
+//#define _S_ISVTX 0001000 /* ???? save swapped text even after use */
+
+
+#define S_IFMT _S_IFMT
+#define S_IFBLK _S_IFBLK
+#define S_IFREG _S_IFREG
+//#define S_IFIFO _S_IFIFO
+//#define S_IFCHR _S_IFCHR
+//#define S_IFDIR _S_IFDIR
+//#define S_IFLNK _S_IFLNK
+//#define S_ISVTX _S_ISVTX
+//#define S_IFSOCK _S_IFSOCK
+//#define S_IFWHT _S_IFWHT
+
+//#define S_ARCH1 _S_ARCH1
+//#define S_ARCH2 _S_ARCH2
+
+#define S_ISDIR(m) ((m & _S_IFMT) == _S_IFDIR) /* directory */
+#define S_ISCHR(m) ((m & _S_IFMT) == _S_IFCHR) /* char special */
+#define S_ISREG(m) ((m & _S_IFMT) == _S_IFREG) /* regular file */
+#define S_ISBLK(m) ((m & _S_IFMT) == _S_IFBLK) /* block special */
+#define S_ISSOCK(m) ((m & _S_IFMT) == _S_IFSOCK) /* socket */
+
+//#define S_ISFIFO(m) ((m & _S_IFMT) == _S_IFIFO) /* fifo */
+//#define S_ISLNK(m) ((m & _S_IFMT) == _S_IFLNK) /* symbolic link */
+//#define S_ISWHT(m) ((m & _S_IFMT) == _S_IFWHT) /* whiteout */
+
+/* The following three macros have been changed to reflect
+ access permissions that better reflect the UEFI FAT file system.
+ UEFI only supports Read or Read+Write instead of the *nix
+ rwx paradigm. Thus, using 0777 is the closest analog.
+*/
+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
+#define ALLPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
+#define DEFFILEMODE (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
+
+#define S_BLKSIZE 512 /* block size used in the stat struct */
+
+/*
+ * Definitions of flags stored in file flags word.
+ *
+ * Super-user and owner changeable flags.
+ */
+#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
+#define UF_NODUMP 0x00000001 /* do not dump file */
+#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
+#define UF_APPEND 0x00000004 /* writes to file may only append */
+/* UF_NOUNLINK 0x00000010 [NOT IMPLEMENTED] */
+/*
+ * Super-user changeable flags.
+ */
+#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
+#define SF_ARCHIVED 0x00010000 /* file is archived */
+#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
+#define SF_APPEND 0x00040000 /* writes to file may only append */
+/* SF_NOUNLINK 0x00100000 [NOT IMPLEMENTED] */
+
+#include <sys/EfiCdefs.h>
+
+__BEGIN_DECLS
+#ifndef __STAT_SYSCALLS_DECLARED
+ #define __STAT_SYSCALLS_DECLARED
+ extern int mkdir (const char *, mode_t);
+ extern int fstat (int, struct stat *);
+ extern int lstat (const char *, struct stat *);
+ extern int stat (const char *, void *);
+// extern int chmod (const char *, mode_t);
+#endif // __STAT_SYSCALLS_DECLARED
+__END_DECLS
+
+#endif /* !_SYS_STAT_H_ */
diff --git a/StdLib/Include/sys/stdint.h b/StdLib/Include/sys/stdint.h
new file mode 100644
index 0000000000..7989fe0156
--- /dev/null
+++ b/StdLib/Include/sys/stdint.h
@@ -0,0 +1,107 @@
+/* $NetBSD: stdint.h,v 1.5 2005/12/11 12:25:21 christos Exp $ */
+
+/*-
+ * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_STDINT_H_
+#define _SYS_STDINT_H_
+
+#include <sys/EfiCdefs.h>
+#include <machine/int_types.h>
+
+#ifndef int8_t
+typedef __int8_t int8_t;
+#define int8_t __int8_t
+#endif
+
+#ifndef uint8_t
+typedef __uint8_t uint8_t;
+#define uint8_t __uint8_t
+#endif
+
+#ifndef int16_t
+typedef __int16_t int16_t;
+#define int16_t __int16_t
+#endif
+
+#ifndef uint16_t
+typedef __uint16_t uint16_t;
+#define uint16_t __uint16_t
+#endif
+
+#ifndef int32_t
+typedef __int32_t int32_t;
+#define int32_t __int32_t
+#endif
+
+#ifndef uint32_t
+typedef __uint32_t uint32_t;
+#define uint32_t __uint32_t
+#endif
+
+#ifndef int64_t
+typedef __int64_t int64_t;
+#define int64_t __int64_t
+#endif
+
+#ifndef uint64_t
+typedef __uint64_t uint64_t;
+#define uint64_t __uint64_t
+#endif
+
+#ifndef intptr_t
+typedef __intptr_t intptr_t;
+#define intptr_t __intptr_t
+#endif
+
+#ifndef uintptr_t
+typedef __uintptr_t uintptr_t;
+#define uintptr_t __uintptr_t
+#endif
+
+#include <machine/int_mwgwtypes.h>
+
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
+#include <machine/int_limits.h>
+#endif
+
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
+#include <machine/int_const.h>
+#endif
+
+//#include <machine/wchar_limits.h>
+
+#endif /* !_SYS_STDINT_H_ */
diff --git a/StdLib/Include/sys/syslimits.h b/StdLib/Include/sys/syslimits.h
new file mode 100644
index 0000000000..a26104c7f6
--- /dev/null
+++ b/StdLib/Include/sys/syslimits.h
@@ -0,0 +1,53 @@
+/* $NetBSD: syslimits.h,v 1.23 2005/12/11 12:25:21 christos Exp $ */
+
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)syslimits.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _SYS_SYSLIMITS_H_
+#define _SYS_SYSLIMITS_H_
+
+#include <sys/featuretest.h>
+
+#define ARG_MAX (2 * 1024) /* max bytes for an exec function */
+#ifndef CHILD_MAX
+ #define CHILD_MAX 128 /* max simultaneous processes */
+#endif
+#define MAX_INPUT 255 /* max bytes in terminal input */
+#define NAME_MAX 255 /* max bytes in a file name */
+#ifndef OPEN_MAX
+ #define OPEN_MAX 20 /* max open files per process */
+#endif
+#define PATH_MAX 1024 /* max bytes in pathname */
+#define PIPE_BUF 512 /* max bytes for atomic pipe writes */
+
+#define LOGIN_NAME_MAX 17 /* max login name length incl. NUL */
+
+#endif /* !_SYS_SYSLIMITS_H_ */
diff --git a/StdLib/Include/sys/termios.h b/StdLib/Include/sys/termios.h
new file mode 100644
index 0000000000..b1373dea2b
--- /dev/null
+++ b/StdLib/Include/sys/termios.h
@@ -0,0 +1,304 @@
+/* $NetBSD: termios.h,v 1.29 2005/12/11 12:25:21 christos Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)termios.h 8.3 (Berkeley) 3/28/94
+ */
+
+#ifndef _SYS_TERMIOS_H_
+#define _SYS_TERMIOS_H_
+
+#include <sys/ansi.h>
+#include <sys/featuretest.h>
+
+/*
+ * Special Control Characters
+ *
+ * Index into c_cc[] character array.
+ *
+ * Name Subscript Enabled by
+ */
+#define VEOF 0 /* ICANON */
+#define VEOL 1 /* ICANON */
+#if defined(_NETBSD_SOURCE)
+#define VEOL2 2 /* ICANON */
+#endif
+#define VERASE 3 /* ICANON */
+#if defined(_NETBSD_SOURCE)
+#define VWERASE 4 /* ICANON */
+#endif
+#define VKILL 5 /* ICANON */
+#if defined(_NETBSD_SOURCE)
+#define VREPRINT 6 /* ICANON */
+#endif
+/* 7 spare 1 */
+#define VINTR 8 /* ISIG */
+#define VQUIT 9 /* ISIG */
+#define VSUSP 10 /* ISIG */
+#if defined(_NETBSD_SOURCE)
+#define VDSUSP 11 /* ISIG */
+#endif
+#define VSTART 12 /* IXON, IXOFF */
+#define VSTOP 13 /* IXON, IXOFF */
+#if defined(_NETBSD_SOURCE)
+#define VLNEXT 14 /* IEXTEN */
+#define VDISCARD 15 /* IEXTEN */
+#endif
+#define VMIN 16 /* !ICANON */
+#define VTIME 17 /* !ICANON */
+#if defined(_NETBSD_SOURCE)
+#define VSTATUS 18 /* ICANON */
+/* 19 spare 2 */
+#endif
+#define NCCS 20
+
+#define _POSIX_VDISABLE ((unsigned char)'\377')
+
+#if defined(_NETBSD_SOURCE)
+#define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0)
+#endif
+
+/*
+ * Input flags - software input processing
+ */
+#define IGNBRK 0x00000001 /* ignore BREAK condition */
+#define BRKINT 0x00000002 /* map BREAK to SIGINTR */
+#define IGNPAR 0x00000004 /* ignore (discard) parity errors */
+#define PARMRK 0x00000008 /* mark parity and framing errors */
+#define INPCK 0x00000010 /* enable checking of parity errors */
+#define ISTRIP 0x00000020 /* strip 8th bit off chars */
+#define INLCR 0x00000040 /* map NL into CR */
+#define IGNCR 0x00000080 /* ignore CR */
+#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
+#define IXON 0x00000200 /* enable output flow control */
+#define IXOFF 0x00000400 /* enable input flow control */
+#if defined(_NETBSD_SOURCE)
+#define IXANY 0x00000800 /* any char will restart after stop */
+#endif
+#if defined(_NETBSD_SOURCE)
+#define IMAXBEL 0x00002000 /* ring bell on input queue full */
+#endif
+
+/*
+ * Output flags - software output processing
+ */
+#define OPOST 0x00000001 /* enable following output processing */
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+#define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */
+#endif
+#if defined(_NETBSD_SOURCE)
+#define OXTABS 0x00000004 /* expand tabs to spaces */
+#define ONOEOT 0x00000008 /* discard EOT's (^D) on output */
+#endif
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+#define OCRNL 0x00000010 /* map CR to NL */
+#define ONOCR 0x00000020 /* discard CR's when on column 0 */
+#define ONLRET 0x00000040 /* move to column 0 on CR */
+#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
+
+/*
+ * Control flags - hardware control of terminal
+ */
+#if defined(_NETBSD_SOURCE)
+#define CIGNORE 0x00000001 /* ignore control flags */
+#endif
+#define CSIZE 0x00000300 /* character size mask */
+#define CS5 0x00000000 /* 5 bits (pseudo) */
+#define CS6 0x00000100 /* 6 bits */
+#define CS7 0x00000200 /* 7 bits */
+#define CS8 0x00000300 /* 8 bits */
+#define CSTOPB 0x00000400 /* send 2 stop bits */
+#define CREAD 0x00000800 /* enable receiver */
+#define PARENB 0x00001000 /* parity enable */
+#define PARODD 0x00002000 /* odd parity, else even */
+#define HUPCL 0x00004000 /* hang up on last close */
+#define CLOCAL 0x00008000 /* ignore modem status lines */
+#if defined(_NETBSD_SOURCE)
+#define CRTSCTS 0x00010000 /* RTS/CTS full-duplex flow control */
+#define CRTS_IFLOW CRTSCTS /* XXX compat */
+#define CCTS_OFLOW CRTSCTS /* XXX compat */
+#define CDTRCTS 0x00020000 /* DTR/CTS full-duplex flow control */
+#define MDMBUF 0x00100000 /* DTR/DCD hardware flow control */
+#define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* all types of hw flow control */
+#endif
+
+
+/*
+ * "Local" flags - dumping ground for other state
+ *
+ * Warning: some flags in this structure begin with
+ * the letter "I" and look like they belong in the
+ * input flag.
+ */
+
+#if defined(_NETBSD_SOURCE)
+#define ECHOKE 0x00000001 /* visual erase for line kill */
+#endif
+#define ECHOE 0x00000002 /* visually erase chars */
+#define ECHOK 0x00000004 /* echo NL after line kill */
+#define ECHO 0x00000008 /* enable echoing */
+#define ECHONL 0x00000010 /* echo NL even if ECHO is off */
+#if defined(_NETBSD_SOURCE)
+#define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */
+#define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */
+#endif /* defined(_NETBSD_SOURCE) */
+#define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */
+#define ICANON 0x00000100 /* canonicalize input lines */
+#if defined(_NETBSD_SOURCE)
+#define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */
+#endif /* defined(_NETBSD_SOURCE) */
+#define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */
+#if defined(_NETBSD_SOURCE)
+#define EXTPROC 0x00000800 /* external processing */
+#endif /* defined(_NETBSD_SOURCE) */
+#define TOSTOP 0x00400000 /* stop background jobs on output */
+#if defined(_NETBSD_SOURCE)
+#define FLUSHO 0x00800000 /* output being flushed (state) */
+#define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */
+#define PENDIN 0x20000000 /* re-echo input buffer at next read */
+#endif /* defined(_NETBSD_SOURCE) */
+#define NOFLSH 0x80000000 /* don't flush output on signal */
+
+typedef unsigned int tcflag_t;
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+
+struct termios {
+ tcflag_t c_iflag; /* input flags */
+ tcflag_t c_oflag; /* output flags */
+ tcflag_t c_cflag; /* control flags */
+ tcflag_t c_lflag; /* local flags */
+ cc_t c_cc[NCCS]; /* control chars */
+ int c_ispeed; /* input speed */
+ int c_ospeed; /* output speed */
+};
+
+/*
+ * Commands passed to tcsetattr() for setting the termios structure.
+ */
+#define TCSANOW 0 /* make change immediate */
+#define TCSADRAIN 1 /* drain output, then change */
+#define TCSAFLUSH 2 /* drain output, flush input */
+#if defined(_NETBSD_SOURCE)
+#define TCSASOFT 0x10 /* flag - don't alter h.w. state */
+#endif
+
+/*
+ * Standard speeds
+ */
+#define B0 0
+#define B50 50
+#define B75 75
+#define B110 110
+#define B134 134
+#define B150 150
+#define B200 200
+#define B300 300
+#define B600 600
+#define B1200 1200
+#define B1800 1800
+#define B2400 2400
+#define B4800 4800
+#define B9600 9600
+#define B19200 19200
+#define B38400 38400
+#if defined(_NETBSD_SOURCE)
+#define B7200 7200
+#define B14400 14400
+#define B28800 28800
+#define B57600 57600
+#define B76800 76800
+#define B115200 115200
+#define B230400 230400
+#define B460800 460800
+#define B921600 921600
+#define EXTA 19200
+#define EXTB 38400
+#endif /* defined(_NETBSD_SOURCE) */
+
+#ifndef _KERNEL
+
+#define TCIFLUSH 1
+#define TCOFLUSH 2
+#define TCIOFLUSH 3
+#define TCOOFF 1
+#define TCOON 2
+#define TCIOFF 3
+#define TCION 4
+
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+#ifndef pid_t
+typedef __pid_t pid_t;
+#define pid_t __pid_t
+#endif
+#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
+#include <sys/EfiCdefs.h>
+
+__BEGIN_DECLS
+speed_t cfgetispeed(const struct termios *);
+speed_t cfgetospeed(const struct termios *);
+int cfsetispeed(struct termios *, speed_t);
+int cfsetospeed(struct termios *, speed_t);
+int tcgetattr(int, struct termios *);
+int tcsetattr(int, int, const struct termios *);
+int tcdrain(int);
+int tcflow(int, int);
+int tcflush(int, int);
+int tcsendbreak(int, int);
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+pid_t tcgetsid(int);
+#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
+
+
+#if defined(_NETBSD_SOURCE)
+void cfmakeraw(struct termios *);
+int cfsetspeed(struct termios *, speed_t);
+#endif /* defined(_NETBSD_SOURCE) */
+__END_DECLS
+
+#endif /* !_KERNEL */
+
+#if defined(_NETBSD_SOURCE)
+
+/*
+ * Include tty ioctl's that aren't just for backwards compatibility
+ * with the old tty driver. These ioctl definitions were previously
+ * in <sys/ioctl.h>.
+ */
+//#include <sys/ttycom.h>
+#endif
+
+/*
+ * END OF PROTECTED INCLUDE.
+ */
+#endif /* !_SYS_TERMIOS_H_ */
+
+#if defined(_NETBSD_SOURCE)
+//#include <sys/ttydefaults.h>
+#endif
diff --git a/StdLib/Include/sys/time.h b/StdLib/Include/sys/time.h
new file mode 100644
index 0000000000..1dd10b598f
--- /dev/null
+++ b/StdLib/Include/sys/time.h
@@ -0,0 +1,183 @@
+/** @file
+ System-specific declarations and macros related to time.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Copyright (c) 1982, 1986, 1993
+ The Regents of the University of California. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ time.h 8.5 (Berkeley) 5/4/95
+ NetBSD: time.h,v 1.56 2006/06/18 21:09:24 uwe Exp
+ */
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#include <Uefi.h>
+#include <sys/featuretest.h>
+#include <sys/types.h>
+
+/*
+ * Traditional *nix structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+ LONG32 tv_sec; /* seconds */
+ LONG32 tv_usec; /* and microseconds */
+};
+
+/*
+ * Structure defined by POSIX.1b to be like a timeval.
+ * This works within EFI since the times really are time_t.
+ * Note that this is not exactly POSIX compliant since tv_nsec
+ * is a UINT32 instead of the compliant long.
+ */
+struct timespec {
+ time_t tv_sec; /* seconds */
+ UINT32 tv_nsec; /* and nanoseconds */
+};
+
+#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+} while (/*CONSTCOND*/0)
+#define TIMESPEC_TO_TIMEVAL(tv, ts) do { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+} while (/*CONSTCOND*/0)
+
+/* Operations on timevals. */
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timercmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#define timeradd(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if ((vvp)->tv_usec >= 1000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= 1000000; \
+ } \
+ } while (/* CONSTCOND */ 0)
+#define timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (/* CONSTCOND */ 0)
+
+/* Operations on timespecs. */
+#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
+#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
+#define timespeccmp(tsp, usp, cmp) \
+ (((tsp)->tv_sec == (usp)->tv_sec) ? \
+ ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
+ ((tsp)->tv_sec cmp (usp)->tv_sec))
+#define timespecadd(tsp, usp, vsp) \
+ do { \
+ (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
+ (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
+ if ((vsp)->tv_nsec >= 1000000000L) { \
+ (vsp)->tv_sec++; \
+ (vsp)->tv_nsec -= 1000000000L; \
+ } \
+ } while (/* CONSTCOND */ 0)
+#define timespecsub(tsp, usp, vsp) \
+ do { \
+ (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
+ (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
+ if ((vsp)->tv_nsec < 0) { \
+ (vsp)->tv_sec--; \
+ (vsp)->tv_nsec += 1000000000L; \
+ } \
+ } while (/* CONSTCOND */ 0)
+
+/*
+ * Names of the interval timers, and structure
+ * defining a timer setting.
+ */
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+};
+
+/*
+ * Structure defined by POSIX.1b to be like a itimerval, but with
+ * timespecs. Used in the timer_*() system calls.
+ */
+struct itimerspec {
+ struct timespec it_interval;
+ struct timespec it_value;
+};
+
+#define CLOCK_REALTIME 0
+#define CLOCK_VIRTUAL 1
+#define CLOCK_PROF 2
+#define CLOCK_MONOTONIC 3
+
+#define TIMER_RELTIME 0x0 /* relative timer */
+#define TIMER_ABSTIME 0x1 /* absolute timer */
+
+#if 0
+ #if (_POSIX_C_SOURCE - 0) >= 200112L || \
+ (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
+ (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
+ #include <sys/select.h>
+ #endif
+#endif /* if 0 */
+
+#include <sys/EfiCdefs.h>
+#include <time.h>
+
+/* Functions useful for dealing with EFI */
+__BEGIN_DECLS
+
+/* Convert an EFI_TIME structure into a time_t value. */
+time_t Efi2Time( EFI_TIME *EfiBDtime);
+
+/* Convert an EFI_TIME structure into a C Standard tm structure. */
+void Efi2Tm( EFI_TIME *EfiBDtime, struct tm *NewTime);
+
+__END_DECLS
+
+#endif /* !_SYS_TIME_H_ */
diff --git a/StdLib/Include/sys/types.h b/StdLib/Include/sys/types.h
new file mode 100644
index 0000000000..9e95fd3ea3
--- /dev/null
+++ b/StdLib/Include/sys/types.h
@@ -0,0 +1,301 @@
+/** @file
+ System type declarations.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License that accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Copyright (c) 1990, 1993
+ The Regents of the University of California. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ - Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ NetBSD: types.h,v 1.71.12.1 2007/09/27 13:40:47 xtraeme Exp
+ types.h 8.4 (Berkeley) 1/21/94
+**/
+#ifndef _SYS_TYPES_H_
+#define _SYS_TYPES_H_
+
+#include <sys/EfiCdefs.h>
+
+/* Machine type dependent parameters. */
+#include <machine/types.h>
+
+#include <machine/ansi.h>
+#include <machine/int_types.h>
+
+
+#include <sys/ansi.h>
+
+#ifndef int8_t
+ typedef __int8_t int8_t;
+ #define int8_t __int8_t
+#endif
+
+#ifndef uint8_t
+ typedef __uint8_t uint8_t;
+ #define uint8_t __uint8_t
+#endif
+
+#ifndef int16_t
+ typedef __int16_t int16_t;
+ #define int16_t __int16_t
+#endif
+
+#ifndef uint16_t
+ typedef __uint16_t uint16_t;
+ #define uint16_t __uint16_t
+#endif
+
+#ifndef int32_t
+ typedef __int32_t int32_t;
+ #define int32_t __int32_t
+#endif
+
+#ifndef uint32_t
+ typedef __uint32_t uint32_t;
+ #define uint32_t __uint32_t
+#endif
+
+#ifndef int64_t
+ typedef __int64_t int64_t;
+ #define int64_t __int64_t
+#endif
+
+#ifndef uint64_t
+ typedef __uint64_t uint64_t;
+ #define uint64_t __uint64_t
+#endif
+
+typedef uint8_t u_int8_t;
+typedef uint16_t u_int16_t;
+typedef uint32_t u_int32_t;
+typedef uint64_t u_int64_t;
+
+#include <machine/endian.h>
+
+#if defined(_NETBSD_SOURCE)
+ typedef UINT8 u_char;
+ typedef UINT16 u_short;
+ typedef UINTN u_int;
+ typedef ULONGN u_long;
+
+ typedef UINT8 unchar; /* Sys V compatibility */
+ typedef UINT16 ushort; /* Sys V compatibility */
+ typedef UINTN uint; /* Sys V compatibility */
+ typedef ULONGN ulong; /* Sys V compatibility */
+
+ typedef u_long cpuid_t;
+#endif
+
+typedef uint64_t u_quad_t; /* quads */
+typedef int64_t quad_t;
+typedef quad_t * qaddr_t;
+
+/*
+ * The types longlong_t and u_longlong_t exist for use with the
+ * Sun-derived XDR routines involving these types, and their usage
+ * in other contexts is discouraged. Further note that these types
+ * may not be equivalent to "long long" and "unsigned long long",
+ * they are only guaranteed to be signed and unsigned 64-bit types
+ * respectively. Portable programs that need 64-bit types should use
+ * the C99 types int64_t and uint64_t instead.
+ */
+
+typedef int64_t longlong_t; /* for XDR */
+typedef uint64_t u_longlong_t; /* for XDR */
+
+typedef int64_t blkcnt_t; /* fs block count */
+typedef uint32_t blksize_t; /* fs optimal block size */
+
+#ifndef fsblkcnt_t
+ typedef __fsblkcnt_t fsblkcnt_t; /* fs block count (statvfs) */
+ #define fsblkcnt_t __fsblkcnt_t
+#endif
+
+#ifndef fsfilcnt_t
+ typedef __fsfilcnt_t fsfilcnt_t; /* fs file count */
+ #define fsfilcnt_t __fsfilcnt_t
+#endif
+
+#ifndef caddr_t
+ typedef __caddr_t caddr_t; /* core address */
+ #define caddr_t __caddr_t
+#endif
+
+#ifdef __daddr_t
+ typedef __daddr_t daddr_t; /* disk address */
+ #undef __daddr_t
+#else
+ typedef int64_t daddr_t; /* disk address */
+#endif
+
+typedef uint32_t dev_t; /* device number */
+typedef uint32_t fixpt_t; /* fixed point number */
+
+#ifndef gid_t
+ typedef __gid_t gid_t; /* group id */
+ #define gid_t __gid_t
+#endif
+
+typedef uint32_t id_t; /* group id, process id or user id */
+typedef uint64_t ino_t; /* inode number */
+typedef EFI_LONG_T key_t; /* IPC key (for Sys V IPC) */
+
+#ifndef mode_t
+ typedef __mode_t mode_t; /* permissions */
+ #define mode_t __mode_t
+#endif
+
+typedef uint32_t nlink_t; /* link count */
+
+#ifndef off_t
+ typedef __off_t off_t; /* file offset */
+ #define off_t __off_t
+#endif
+
+#ifndef pid_t
+ typedef __pid_t pid_t; /* process id */
+ #define pid_t __pid_t
+#endif
+typedef int32_t lwpid_t; /* LWP id */
+typedef quad_t rlim_t; /* resource limit */
+typedef int32_t segsz_t; /* segment size */
+typedef int32_t swblk_t; /* swap offset */
+
+#ifndef uid_t
+ typedef __uid_t uid_t; /* user id */
+ #define uid_t __uid_t
+#endif
+
+typedef int64_t dtime_t; /* on-disk time_t */
+
+#if defined(_LIBC)
+ /*
+ * semctl(2)'s argument structure. This is here for the benefit of
+ * <sys/syscallargs.h>. It is not in the user's namespace in SUSv2.
+ * The SUSv2 semctl(2) takes variable arguments.
+ */
+ union __semun {
+ int val; /* value for SETVAL */
+ struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
+ unsigned short *array; /* array for GETALL & SETALL */
+ };
+ /* For the same reason as above */
+ #include <sys/stdint.h>
+ typedef intptr_t semid_t;
+#endif /* _LIBC */
+
+/*
+ * These belong in EfiSysCall.h, but are also placed here to ensure that
+ * long arguments will be promoted to off_t if the program fails to
+ * include that header or explicitly cast them to off_t.
+ */
+#ifndef __OFF_T_SYSCALLS_DECLARED
+ #define __OFF_T_SYSCALLS_DECLARED
+ __BEGIN_DECLS
+ extern off_t lseek (int, off_t, int);
+ extern int truncate (const char *, off_t);
+ extern int ftruncate (int, off_t);
+ __END_DECLS
+#endif /* __OFF_T_SYSCALLS_DECLARED */
+
+#if defined(_NETBSD_SOURCE)
+ /* Major, minor numbers, dev_t's. */
+ #define major(x) ((int32_t)((((x) & 0x000fff00) >> 8)))
+ #define minor(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \
+ (((x) & 0x000000ff) >> 0)))
+ #define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
+ (((y) << 12) & 0xfff00000) | \
+ (((y) << 0) & 0x000000ff)))
+#endif
+
+#if defined(_BSD_CLOCK_T_) && defined(_EFI_CLOCK_T)
+ typedef _BSD_CLOCK_T_ clock_t;
+ #undef _BSD_CLOCK_T_
+ #undef _EFI_CLOCK_T
+#endif
+
+#if defined(_BSD_SIZE_T_) && defined(_EFI_SIZE_T_)
+ typedef _BSD_SIZE_T_ size_t;
+ #define _SIZE_T
+ #undef _BSD_SIZE_T_
+ #undef _EFI_SIZE_T_
+#endif
+
+#ifdef _BSD_SSIZE_T_
+ typedef _BSD_SSIZE_T_ ssize_t;
+ #undef _BSD_SSIZE_T_
+#endif
+
+#if defined(_BSD_TIME_T_) && defined(_EFI_TIME_T)
+ typedef _BSD_TIME_T_ time_t;
+ #undef _BSD_TIME_T_
+ #undef _EFI_TIME_T
+#endif
+
+#ifdef _BSD_CLOCKID_T_
+ typedef _BSD_CLOCKID_T_ clockid_t;
+ #undef _BSD_CLOCKID_T_
+#endif
+
+#ifdef _BSD_TIMER_T_
+ typedef _BSD_TIMER_T_ timer_t;
+ #undef _BSD_TIMER_T_
+#endif
+
+#ifdef _BSD_SUSECONDS_T_
+ typedef _BSD_SUSECONDS_T_ suseconds_t;
+ #undef _BSD_SUSECONDS_T_
+#endif
+
+#ifdef _BSD_USECONDS_T_
+ typedef _BSD_USECONDS_T_ useconds_t;
+ #undef _BSD_USECONDS_T_
+#endif
+
+#ifdef _NETBSD_SOURCE
+ #include <sys/fd_set.h>
+ #define NBBY __NBBY
+
+ typedef struct kauth_cred *kauth_cred_t;
+
+#endif
+
+#if 0
+ #if !defined(_KERNEL) && !defined(_STANDALONE)
+ #if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
+ defined(_NETBSD_SOURCE)
+ #include <pthread_types.h>
+ #endif
+ #endif
+#endif /* if 0 */
+
+#endif /* !_SYS_TYPES_H_ */
diff --git a/StdLib/Include/sys/uio.h b/StdLib/Include/sys/uio.h
new file mode 100644
index 0000000000..8c3ee8fbf9
--- /dev/null
+++ b/StdLib/Include/sys/uio.h
@@ -0,0 +1,123 @@
+/* $NetBSD: uio.h,v 1.34 2006/03/01 12:38:32 yamt Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)uio.h 8.5 (Berkeley) 2/22/94
+ */
+
+#ifndef _SYS_UIO_H_
+#define _SYS_UIO_H_
+
+#ifdef _KERNEL
+#ifndef __UIO_EXPOSE
+#define __UIO_EXPOSE
+#endif
+#endif
+
+#include <machine/ansi.h>
+#include <sys/featuretest.h>
+
+#ifdef _BSD_SIZE_T_
+typedef _BSD_SIZE_T_ size_t;
+#undef _BSD_SIZE_T_
+#endif
+
+#ifdef _BSD_SSIZE_T_
+typedef _BSD_SSIZE_T_ ssize_t;
+#undef _BSD_SSIZE_T_
+#endif
+
+struct iovec {
+ void *iov_base; /* Base address. */
+ size_t iov_len; /* Length. */
+};
+
+#if defined(_NETBSD_SOURCE)
+#include <sys/ansi.h>
+
+#ifndef off_t
+typedef __off_t off_t; /* file offset */
+#define off_t __off_t
+#endif
+
+enum uio_rw { UIO_READ, UIO_WRITE };
+
+/* Segment flag values. */
+enum uio_seg {
+ UIO_USERSPACE, /* from user data space */
+ UIO_SYSSPACE /* from system space */
+};
+
+#ifdef __UIO_EXPOSE
+
+struct uio {
+ struct iovec *uio_iov; /* pointer to array of iovecs */
+ int uio_iovcnt; /* number of iovecs in array */
+ off_t uio_offset; /* offset into file this uio corresponds to */
+ size_t uio_resid; /* residual i/o count */
+ enum uio_rw uio_rw; /* see above */
+ struct vmspace *uio_vmspace;
+};
+#define UIO_SETUP_SYSSPACE(uio) uio_setup_sysspace(uio)
+
+#endif /* __UIO_EXPOSE */
+
+/*
+ * Limits
+ */
+/* Deprecated: use IOV_MAX from <limits.h> instead. */
+#define UIO_MAXIOV 1024 /* max 1K of iov's */
+#endif /* _NETBSD_SOURCE */
+
+#ifdef _KERNEL
+#include <sys/mallocvar.h>
+
+MALLOC_DECLARE(M_IOV);
+
+#define UIO_SMALLIOV 8 /* 8 on stack, else malloc */
+
+void uio_setup_sysspace(struct uio *);
+#endif
+
+#ifndef _KERNEL
+#include <sys/EfiCdefs.h>
+
+__BEGIN_DECLS
+#if defined(_NETBSD_SOURCE)
+ssize_t preadv(int, const struct iovec *, int, off_t);
+ssize_t pwritev(int, const struct iovec *, int, off_t);
+#endif /* _NETBSD_SOURCE */
+ssize_t readv(int, const struct iovec *, int);
+ssize_t writev(int, const struct iovec *, int);
+__END_DECLS
+#else
+int ureadc(int, struct uio *);
+#endif /* !_KERNEL */
+
+#endif /* !_SYS_UIO_H_ */