summaryrefslogtreecommitdiff
path: root/StdLib/Include
diff options
context:
space:
mode:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-28 02:34:10 +0000
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-28 02:34:10 +0000
commit53e1e5c647b73e45569ed6e8b8a0a5b276aa685e (patch)
treeffb715b3aa7f6299b7e370e2b8a3f50b3df903c5 /StdLib/Include
parentb00771f50a1f9d72852de544cff5cbfd951e71ac (diff)
downloadedk2-platforms-53e1e5c647b73e45569ed6e8b8a0a5b276aa685e.tar.xz
Add device abstraction code for the UEFI Console and UEFI Shell-based file systems.
Make argv use narrow characters instead of wide characters. Add setenv functionality. Add poll() system call. Change signal names into macros – required for standards compliance. The enums were renamed and moved to sys/signal.h and the new macros reference the enums. Added SIGBREAK, which is required for Python. Modify stdio functions to fail cleanly when called with a NULL File Pointer argument. Added <sys/cdefs.h> that just includes <sys/EfiCdefs.h>. By adding this wrapper, we improve compatibility with *nix files which assume <sys/cdefs> exists. Add <netdb.h> Added macros for bcopy(), bcmp() and strsep(). Modify the clock() function so that it does not hang when running under an emulation environment such as NT32. Move TM structure specific macros from the private tzfile.h into <time.h> Add strncasecmp function. Add strptime function. Add gettimeofday function. Add getcwd function. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11908 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/Include')
-rw-r--r--StdLib/Include/netdb.h362
-rw-r--r--StdLib/Include/netinet6/in6.h5
-rw-r--r--StdLib/Include/paths.h38
-rw-r--r--StdLib/Include/signal.h15
-rw-r--r--StdLib/Include/stdio.h1
-rw-r--r--StdLib/Include/stdlib.h134
-rw-r--r--StdLib/Include/string.h12
-rw-r--r--StdLib/Include/sys/EfiSysCall.h93
-rw-r--r--StdLib/Include/sys/ansi.h2
-rw-r--r--StdLib/Include/sys/cdefs.h15
-rw-r--r--StdLib/Include/sys/cdefs_aout.h3
-rw-r--r--StdLib/Include/sys/dirent.h11
-rw-r--r--StdLib/Include/sys/fcntl.h7
-rw-r--r--StdLib/Include/sys/ioctl.h101
-rw-r--r--StdLib/Include/sys/poll.h91
-rw-r--r--StdLib/Include/sys/signal.h11
-rw-r--r--StdLib/Include/sys/socket.h5
-rw-r--r--StdLib/Include/sys/stat.h22
-rw-r--r--StdLib/Include/sys/syslimits.h2
-rw-r--r--StdLib/Include/sys/time.h7
-rw-r--r--StdLib/Include/sys/types.h4
-rw-r--r--StdLib/Include/sys/uio.h5
-rw-r--r--StdLib/Include/sys/unistd.h192
-rw-r--r--StdLib/Include/time.h77
-rw-r--r--StdLib/Include/unistd.h170
-rw-r--r--StdLib/Include/wchar.h44
-rw-r--r--StdLib/Include/wctype.h23
27 files changed, 1343 insertions, 109 deletions
diff --git a/StdLib/Include/netdb.h b/StdLib/Include/netdb.h
new file mode 100644
index 0000000000..e645f77bd3
--- /dev/null
+++ b/StdLib/Include/netdb.h
@@ -0,0 +1,362 @@
+/* $NetBSD: netdb.h,v 1.55.2.1 2007/05/17 21:25:10 jdc Exp $ */
+
+/*
+ * Copyright (c) 1980, 1983, 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.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * Portions 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by WIDE Project and
+ * its contributors.
+ * 4. 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--
+ */
+
+/*
+ * @(#)netdb.h 8.1 (Berkeley) 6/2/93
+ * Id: netdb.h,v 1.15.18.6 2006/10/02 01:23:09 marka Exp
+ */
+
+#ifndef _NETDB_H_
+#define _NETDB_H_
+
+#include <machine/ansi.h>
+#include <machine/endian_machdep.h>
+#include <sys/ansi.h>
+#include <sys/cdefs.h>
+#include <sys/featuretest.h>
+#include <inttypes.h>
+/*
+ * Data types
+ */
+#ifndef socklen_t
+typedef __socklen_t socklen_t;
+#define socklen_t __socklen_t
+#endif
+
+#ifdef _EFI_SIZE_T_
+ typedef _EFI_SIZE_T_ size_t;
+ #undef _EFI_SIZE_T_
+ #undef _BSD_SIZE_T_
+#endif
+
+////#if defined(_NETBSD_SOURCE)
+////#ifndef _PATH_HEQUIV
+////#define _PATH_HEQUIV "/etc/hosts.equiv"
+////#endif
+#ifndef _PATH_HOSTS
+#define _PATH_HOSTS "/etc/hosts"
+#endif
+#ifndef _PATH_NETWORKS
+#define _PATH_NETWORKS "/etc/networks"
+#endif
+#ifndef _PATH_PROTOCOLS
+#define _PATH_PROTOCOLS "/etc/protocols"
+#endif
+#ifndef _PATH_SERVICES
+#define _PATH_SERVICES "/etc/services"
+#endif
+////#ifndef _PATH_SERVICES_DB
+////#define _PATH_SERVICES_DB "/var/db/services.db"
+////#endif
+////#endif
+
+__BEGIN_DECLS
+extern int h_errno;
+__END_DECLS
+
+/*%
+ * Structures returned by network data base library. All addresses are
+ * supplied in host order, and returned in network order (suitable for
+ * use in system calls).
+ */
+struct hostent {
+ char *h_name; /*%< official name of host */
+ char **h_aliases; /*%< alias list */
+ int h_addrtype; /*%< host address type */
+ int h_length; /*%< length of address */
+ char **h_addr_list; /*%< list of addresses from name server */
+#define h_addr h_addr_list[0] /*%< address, for backward compatiblity */
+};
+
+/*%
+ * Assumption here is that a network number
+ * fits in an unsigned long -- probably a poor one.
+ */
+struct netent {
+ char *n_name; /*%< official name of net */
+ char **n_aliases; /*%< alias list */
+ int n_addrtype; /*%< net address type */
+#if (defined(__sparc__) && defined(_LP64)) || \
+ (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _BIG_ENDIAN))
+ int __n_pad0; /* ABI compatibility */
+#endif
+ uint32_t n_net; /*%< network # */
+#if defined(__alpha__) || (defined(__i386__) && defined(_LP64)) || \
+ (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _LITTLE_ENDIAN))
+ int __n_pad0; /* ABI compatibility */
+#endif
+};
+
+struct servent {
+ char *s_name; /*%< official service name */
+ char **s_aliases; /*%< alias list */
+ int s_port; /*%< port # */
+ char *s_proto; /*%< protocol to use */
+};
+
+struct protoent {
+ char *p_name; /*%< official protocol name */
+ char **p_aliases; /*%< alias list */
+ int p_proto; /*%< protocol # */
+};
+
+/*
+ * Note: ai_addrlen used to be a size_t, per RFC 2553.
+ * In XNS5.2, and subsequently in POSIX-2001 and
+ * draft-ietf-ipngwg-rfc2553bis-02.txt it was changed to a socklen_t.
+ * To accommodate for this while preserving binary compatibility with the
+ * old interface, we prepend or append 32 bits of padding, depending on
+ * the (LP64) architecture's endianness.
+ *
+ * This should be deleted the next time the libc major number is
+ * incremented.
+ */
+#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
+ defined(_NETBSD_SOURCE)
+struct addrinfo {
+ int ai_flags; /*%< AI_PASSIVE, AI_CANONNAME */
+ int ai_family; /*%< PF_xxx */
+ int ai_socktype; /*%< SOCK_xxx */
+ int ai_protocol; /*%< 0 or IPPROTO_xxx for IPv4 and IPv6 */
+#if defined(__sparc__) && defined(_LP64)
+ int __ai_pad0; /* ABI compatibility */
+#endif
+ socklen_t ai_addrlen; /*%< length of ai_addr */
+#if defined(__alpha__) || (defined(__i386__) && defined(_LP64))
+ int __ai_pad0; /* ABI compatibility */
+#endif
+ char *ai_canonname; /*%< canonical name for hostname */
+ struct sockaddr *ai_addr; /*%< binary address */
+ struct addrinfo *ai_next; /*%< next structure in linked list */
+};
+#endif
+
+/*%
+ * Error return codes from gethostbyname() and gethostbyaddr()
+ * (left in extern int h_errno).
+ */
+
+#if defined(_NETBSD_SOURCE)
+#define NETDB_INTERNAL -1 /*%< see errno */
+#define NETDB_SUCCESS 0 /*%< no problem */
+#endif
+////#define NO_ADDRESS NO_DATA /* no address, look for MX record */
+#define HOST_NOT_FOUND 1 /*%< Authoritative Answer Host not found */
+#define TRY_AGAIN 2 /*%< Non-Authoritive Host not found, or SERVERFAIL */
+#define NO_RECOVERY 3 /*%< Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+////#define NO_DATA 4 /*%< Valid name, no data record of requested type */
+////#if defined(_NETBSD_SOURCE)
+////#define NO_ADDRESS NO_DATA /*%< no address, look for MX record */
+////#endif
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#if 0 // Not supported by UEFI
+#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
+ defined(_NETBSD_SOURCE)
+#define EAI_ADDRFAMILY 1 /*%< address family for hostname not supported */
+#define EAI_AGAIN 2 /*%< temporary failure in name resolution */
+#define EAI_BADFLAGS 3 /*%< invalid value for ai_flags */
+#define EAI_FAIL 4 /*%< non-recoverable failure in name resolution */
+#define EAI_FAMILY 5 /*%< ai_family not supported */
+#define EAI_MEMORY 6 /*%< memory allocation failure */
+#define EAI_NODATA 7 /*%< no address associated with hostname */
+#define EAI_NONAME 8 /*%< hostname nor servname provided, or not known */
+#define EAI_SERVICE 9 /*%< servname not supported for ai_socktype */
+#define EAI_SOCKTYPE 10 /*%< ai_socktype not supported */
+#define EAI_SYSTEM 11 /*%< system error returned in errno */
+#define EAI_BADHINTS 12 /* invalid value for hints */
+#define EAI_PROTOCOL 13 /* resolved protocol is unknown */
+#define EAI_OVERFLOW 14 /* argument buffer overflow */
+#define EAI_MAX 15
+#endif /* _POSIX_C_SOURCE >= 200112 || _XOPEN_SOURCE >= 520 || _NETBSD_SOURCE */
+#endif // 0 Not supported by UEFI
+
+/*%
+ * Flag values for getaddrinfo()
+ */
+#if 0 // Not supported by UEFI
+#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
+ defined(_NETBSD_SOURCE)
+#define AI_PASSIVE 0x00000001 /* get address to use bind() */
+#endif
+#endif // 0 Not supported by UEFI
+
+#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
+
+#if 0 // Not supported by UEFI
+#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
+ defined(_NETBSD_SOURCE)
+#define AI_NUMERICHOST 0x00000004 /* prevent host name resolution */
+#define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */
+/* valid flags for addrinfo (not a standard def, apps should not use it) */
+#define AI_MASK \
+ (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)
+#endif
+#endif // 0 Not supported by UEFI
+
+/*%
+ * Constants for getnameinfo()
+ */
+////#if defined(_NETBSD_SOURCE)
+#define NI_MAXHOST 1025
+#define NI_MAXSERV 32
+////#endif
+
+/*%
+ * Flag values for getnameinfo()
+ */
+////#define NI_NOFQDN 0x00000001
+#define NI_NUMERICHOST 0x00000002
+////#define NI_NAMEREQD 0x00000004
+#define NI_NUMERICSERV 0x00000008
+////#define NI_DGRAM 0x00000010
+////#define NI_NUMERICSCOPE 0x00000040
+
+#if 0 // Not supported by UEFI
+#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
+ defined(_NETBSD_SOURCE)
+/*%
+ * Scope delimit character
+ */
+#if defined(_NETBSD_SOURCE)
+#define SCOPE_DELIMITER '%'
+#endif
+#endif /* (_POSIX_C_SOURCE - 0) >= 200112L || ... */
+#endif // 0 Not supported by UEFI
+
+__BEGIN_DECLS
+void endhostent(void);
+void endnetent(void);
+void endprotoent(void);
+void endservent(void);
+#if 0 // Not supported by UEFI
+#if (_XOPEN_SOURCE - 0) >= 520 && (_XOPEN_SOURCE - 0) < 600 || \
+ defined(_NETBSD_SOURCE)
+#if 0 /* we do not ship this */
+void freehostent(struct hostent *);
+#endif
+#endif
+#endif // 0 Not supported by UEFI
+struct hostent *gethostbyaddr(const char *, socklen_t, int);
+struct hostent *gethostbyname(const char *);
+#if defined(_NETBSD_SOURCE)
+struct hostent *gethostbyname2(const char *, int);
+#endif
+struct hostent *gethostent(void);
+struct netent *getnetbyaddr(uint32_t, int);
+struct netent *getnetbyname(const char *);
+struct netent *getnetent(void);
+struct protoent *getprotobyname(const char *);
+struct protoent *getprotobynumber(int);
+struct protoent *getprotoent(void);
+struct servent *getservbyname(const char *, const char *);
+struct servent *getservbyport(int, const char *);
+struct servent *getservent(void);
+////#if defined(_NETBSD_SOURCE)
+////void herror(const char *);
+////const char *hstrerror(int);
+////#endif
+void sethostent(int);
+////#if defined(_NETBSD_SOURCE)
+/* void sethostfile(const char *); */
+////#endif
+void setnetent(int);
+void setprotoent(int);
+#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
+ defined(_NETBSD_SOURCE)
+void setservent(int);
+int getaddrinfo(const char * __restrict, const char * __restrict,
+ const struct addrinfo * __restrict,
+ struct addrinfo ** __restrict);
+int getnameinfo(const struct sockaddr * __restrict, socklen_t,
+ char * __restrict, socklen_t,
+ char * __restrict, socklen_t, int);
+void freeaddrinfo(struct addrinfo *);
+const char *gai_strerror(int);
+#endif
+void setservent(int);
+
+__END_DECLS
+
+#endif /* !_NETDB_H_ */
diff --git a/StdLib/Include/netinet6/in6.h b/StdLib/Include/netinet6/in6.h
index 7e81bb7084..f9a645aef1 100644
--- a/StdLib/Include/netinet6/in6.h
+++ b/StdLib/Include/netinet6/in6.h
@@ -736,9 +736,10 @@ extern u_char ip6_protox[];
#include <machine/ansi.h>
-#ifdef _BSD_SIZE_T_
-typedef _BSD_SIZE_T_ size_t;
+#ifdef _EFI_SIZE_T_
+typedef _EFI_SIZE_T_ size_t;
#define _SIZE_T
+#undef _EFI_SIZE_T_
#undef _BSD_SIZE_T_
#endif
diff --git a/StdLib/Include/paths.h b/StdLib/Include/paths.h
index 44c1dd1ece..389272f0d9 100644
--- a/StdLib/Include/paths.h
+++ b/StdLib/Include/paths.h
@@ -58,12 +58,9 @@
//#define _PATH_AUDIOCTL0 "/dev/audioctl0"
//#define _PATH_BPF "/dev/bpf"
//#define _PATH_CLOCKCTL "/dev/clockctl"
-#define _PATH_CONSOLE "console:"
-#define _PATH_CONSTTY "constty:"
//#define _PATH_CSMAPPER "/usr/share/i18n/csmapper"
//#define _PATH_DEFTAPE "/dev/nrst0"
//#define _PATH_DEVDB "/var/run/dev.db"
-#define _PATH_DEVNULL "null:"
//#define _PATH_DRUM "/dev/drum"
//#define _PATH_ESDB "/usr/share/i18n/esdb"
//#define _PATH_FTPUSERS "/etc/ftpusers"
@@ -72,7 +69,6 @@
//#define _PATH_KMEM "/dev/kmem"
//#define _PATH_KSYMS "/dev/ksyms"
//#define _PATH_KVMDB "/var/db/kvm.db"
-#define _PATH_LOCALE "/Efi/Locale"
//#define _PATH_MAILDIR "/var/mail"
//#define _PATH_MAN "/usr/share/man"
//#define _PATH_MEM "/dev/mem"
@@ -86,33 +82,51 @@
//#define _PATH_SOUND "/dev/sound"
//#define _PATH_SOUND0 "/dev/sound0"
//#define _PATH_SYSMON "/dev/sysmon"
-#define _PATH_TTY "tty:"
//#define _PATH_UNIX "/netbsd"
//#define _PATH_URANDOM "/dev/urandom"
//#define _PATH_VI "/usr/bin/vi"
+
+// DOS style device paths
+#define _PATH_TTYDEV "tty:"
+#define _PATH_NULLDEV "null:"
+#define _PATH_CONSOLE "console:"
+#define _PATH_CONSTTY "constty:"
#define _PATH_STDIN "stdin:"
#define _PATH_STDOUT "stdout:"
#define _PATH_STDERR "stderr:"
+#define _PATH_SOCKET "socket:"
+
+// *nix style device paths
+#define _PATH_DEVTTY "/dev/tty"
+#define _PATH_DEVNULL "/dev/null"
+#define _PATH_DEVCONSOLE "/dev/console"
+#define _PATH_DEVCONSTTY "/dev/constty"
+#define _PATH_DEVSTDIN "/dev/stdin"
+#define _PATH_DEVSTDOUT "/dev/stdout"
+#define _PATH_DEVSTDERR "/dev/stderr"
+#define _PATH_DEVSOCKET "/dev/socket"
+
+// Special files and locations
+#define _PATH_HOSTS "/Efi/etc/hosts"
+#define _PATH_SERVICES "/Efi/etc/services"
+#define _PATH_HOSTNAME "/Efi/etc/hostname"
+#define _PATH_LOCALE "/Efi/etc/Locale"
+#define _PATH_FSTAB "/Efi/etc/fstab"
/*
* Provide trailing slash, since mostly used for building pathnames.
* see the __CONCAT() macro from <sys/EfiCdefs.h> for cpp examples.
*/
-//#define _PATH_DEV "/dev/"
+#define _PATH_DEV "/dev/"
+#define _PATH_TMP "/Efi/Temp/"
//#define _PATH_DEV_PTS "/dev/pts/"
//#define _PATH_EMUL_AOUT "/emul/aout/"
-#define _PATH_TMP "/Efi/Temp/"
//#define _PATH_VARDB "/var/db/"
//#define _PATH_VARRUN "/var/run/"
//#define _PATH_VARTMP "/var/tmp/"
-//#ifdef RESCUEDIR
//#define _PATH_BSHELL RESCUEDIR "/sh"
//#define _PATH_CSHELL RESCUEDIR "/csh"
-//#else
-//#define _PATH_BSHELL "/bin/sh"
-//#define _PATH_CSHELL "/bin/csh"
-//#endif
#endif /* !_PATHS_H_ */
diff --git a/StdLib/Include/signal.h b/StdLib/Include/signal.h
index 52873c764d..a84369f310 100644
--- a/StdLib/Include/signal.h
+++ b/StdLib/Include/signal.h
@@ -50,13 +50,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
corresponding to the specified condition.
Many existing programs expect these to be macros.
**/
-#define SIGINT 1 ///< receipt of an interactive attention signal
-#define SIGILL 2 ///< detection of an invalid function image, such as an invalid instruction
-#define SIGABRT 3 ///< abnormal termination, such as is initiated by the abort function
-#define SIGFPE 4 ///< an erroneous arithmetic operation, such as zero divide or an operation resulting in overflow
-#define SIGSEGV 5 ///< an invalid access to storage
-#define SIGTERM 6 ///< a termination request sent to the program
-#define SIG_LAST 7 ///< One more than the largest signal number
+#define SIGINT __SigInt ///< receipt of an interactive attention signal
+#define SIGILL __SigIll ///< detection of an invalid function image, such as an invalid instruction
+#define SIGABRT __SigAbrt ///< abnormal termination, such as is initiated by the abort function
+#define SIGFPE __SigFpe ///< an erroneous arithmetic operation, such as zero divide or an operation resulting in overflow
+#define SIGSEGV __SigSegv ///< an invalid access to storage
+#define SIGTERM __SigTerm ///< a termination request sent to the program
+#define SIGBREAK __SigBreak ///< added for Python
+#define SIG_LAST __Sig_Last ///< One more than the largest signal number
__BEGIN_DECLS
diff --git a/StdLib/Include/stdio.h b/StdLib/Include/stdio.h
index d6eadf513c..7a60a290ac 100644
--- a/StdLib/Include/stdio.h
+++ b/StdLib/Include/stdio.h
@@ -44,6 +44,7 @@
#ifdef _EFI_SIZE_T_
typedef _EFI_SIZE_T_ size_t;
#undef _EFI_SIZE_T_
+ #undef _BSD_SIZE_T_
#endif
/*
diff --git a/StdLib/Include/stdlib.h b/StdLib/Include/stdlib.h
index 2b19fd224b..2cfc9fe1ff 100644
--- a/StdLib/Include/stdlib.h
+++ b/StdLib/Include/stdlib.h
@@ -2,7 +2,7 @@
The header <stdlib.h> declares five types and several functions of general
utility, and defines several macros.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ 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
@@ -133,10 +133,14 @@ void exit(int status) __noreturn;
buffered data are not flushed, open streams are not closed, and temporary
files are not removed by abort.
+ While this function does not return, it can NOT be marked as "__noreturn"
+ without causing a warning to be emitted because the compilers can not
+ determine that the function truly does not return.
+
The status returned to the host environment is determined in the same way
as for the exit function.
**/
-void _Exit(int status) __noreturn;
+void _Exit(int status);
/** The getenv function searches an environment list, provided by the host
environment, for a string that matches the string pointed to by name. The
@@ -151,6 +155,24 @@ void _Exit(int status) __noreturn;
**/
char *getenv(const char *name);
+/**
+ Add or update a variable in the environment list
+
+ @param name Address of a zero terminated name string
+ @param value Address of a zero terminated value string
+ @param rewrite TRUE allows overwriting existing values
+
+ @retval Returns 0 upon success
+ @retval Returns -1 upon failure, sets errno with more information
+
+**/
+int
+setenv (
+ register const char * name,
+ register const char * value,
+ int rewrite
+ );
+
/** If string is a null pointer, the system function determines whether the
host environment has a command processor. If string is not a null pointer,
the system function passes the string pointed to by string to that command
@@ -499,37 +521,125 @@ void qsort( void *base, size_t nmemb, size_t size,
/* ################ Multibyte/wide character conversion functions ####### */
-/**
+/** Determine the number of bytes comprising a multibyte character.
- @return
+ If s is not a null pointer, the mblen function determines the number of bytes
+ contained in the multibyte character pointed to by s. Except that the
+ conversion state of the mbtowc function is not affected, it is equivalent to
+ mbtowc((wchar_t *)0, s, n);
+
+ The implementation shall behave as if no library function calls the mblen
+ function.
+
+ @return If s is a null pointer, the mblen function returns a nonzero or
+ zero value, if multibyte character encodings, respectively, do
+ or do not have state-dependent encodings. If s is not a null
+ pointer, the mblen function either returns 0 (if s points to the
+ null character), or returns the number of bytes that are contained
+ in the multibyte character (if the next n or fewer bytes form a
+ valid multibyte character), or returns -1 (if they do not form a
+ valid multibyte character).
**/
int mblen(const char *, size_t);
-/**
+/** Convert a multibyte character into a wide character.
- @return
+ If s is not a null pointer, the mbtowc function inspects at most n bytes
+ beginning with the byte pointed to by s to determine the number of bytes
+ needed to complete the next multibyte character (including any shift
+ sequences). If the function determines that the next multibyte character
+ is complete and valid, it determines the value of the corresponding wide
+ character and then, if pwc is not a null pointer, stores that value in
+ the object pointed to by pwc. If the corresponding wide character is the
+ null wide character, the function is left in the initial conversion state.
+
+ The implementation shall behave as if no library function calls the
+ mbtowc function.
+
+ @return If s is a null pointer, the mbtowc function returns a nonzero or
+ zero value, if multibyte character encodings, respectively, do
+ or do not have state-dependent encodings. If s is not a null
+ pointer, the mbtowc function either returns 0 (if s points to
+ the null character), or returns the number of bytes that are
+ contained in the converted multibyte character (if the next n or
+ fewer bytes form a valid multibyte character), or returns -1
+ (if they do not form a valid multibyte character).
+
+ In no case will the value returned be greater than n or the value
+ of the MB_CUR_MAX macro.
**/
int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
/**
+The wctomb function determines the number of bytes needed to represent the multibyte
+character corresponding to the wide character given by wc (including any shift
+sequences), and stores the multibyte character representation in the array whose first
+element is pointed to by s (if s is not a null pointer). At most MB_CUR_MAX characters
+are stored. If wc is a null wide character, a null byte is stored, preceded by any shift
+sequence needed to restore the initial shift state, and the function is left in the initial
+conversion state.
+
+The implementation shall behave as if no library function calls the wctomb function.
@return
+If s is a null pointer, the wctomb function returns a nonzero or zero value, if multibyte
+character encodings, respectively, do or do not have state-dependent encodings. If s is
+not a null pointer, the wctomb function returns -1 if the value of wc does not correspond
+to a valid multibyte character, or returns the number of bytes that are contained in the
+multibyte character corresponding to the value of wc.
+
+In no case will the value returned be greater than the value of the MB_CUR_MAX macro.
+
**/
int wctomb(char *, wchar_t);
/* ################ Multibyte/wide string conversion functions ########## */
-/**
+/** Convert a multibyte character string into a wide-character string.
+
+ The mbstowcs function converts a sequence of multibyte characters that
+ begins in the initial shift state from the array pointed to by src into
+ a sequence of corresponding wide characters and stores not more than limit
+ wide characters into the array pointed to by dest. No multibyte
+ characters that follow a null character (which is converted into a null
+ wide character) will be examined or converted. Each multibyte character
+ is converted as if by a call to the mbtowc function, except that the
+ conversion state of the mbtowc function is not affected.
+
+ No more than limit elements will be modified in the array pointed to by dest.
+ If copying takes place between objects that overlap,
+ the behavior is undefined.
+
+ @return If an invalid multibyte character is encountered, the mbstowcs
+ function returns (size_t)(-1). Otherwise, the mbstowcs function
+ returns the number of array elements modified, not including a
+ terminating null wide character, if any.
- @return
**/
-size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
+size_t mbstowcs(wchar_t * __restrict dest, const char * __restrict src, size_t limit);
-/**
+/** Convert a wide-character string into a multibyte character string.
- @return
+ The wcstombs function converts a sequence of wide characters from the
+ array pointed to by src into a sequence of corresponding multibyte
+ characters that begins in the initial shift state, and stores these
+ multibyte characters into the array pointed to by dest, stopping if a
+ multibyte character would exceed the limit of limit total bytes or if a
+ null character is stored. Each wide character is converted as if by
+ a call to the wctomb function, except that the conversion state of
+ the wctomb function is not affected.
+
+ No more than limit bytes will be modified in the array pointed to by dest.
+ If copying takes place between objects that overlap,
+ the behavior is undefined.
+
+ @return If a wide character is encountered that does not correspond to a
+ valid multibyte character, the wcstombs function returns
+ (size_t)(-1). Otherwise, the wcstombs function returns the number
+ of bytes modified, not including a terminating null character,
+ if any.
**/
-size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
+size_t wcstombs(char * __restrict dest, const wchar_t * __restrict src, size_t limit);
__END_DECLS
diff --git a/StdLib/Include/string.h b/StdLib/Include/string.h
index 920d6c8dd6..992ca0ba18 100644
--- a/StdLib/Include/string.h
+++ b/StdLib/Include/string.h
@@ -15,7 +15,7 @@
interpreted as if it had the type unsigned char (and therefore every possible
object representation is valid and has a different value).
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+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
@@ -323,6 +323,16 @@ char *strdup (const char *);
int strerror_r(int, char *, size_t);
int strcasecmp(const char *s1, const char *s2);
void *memccpy (void *, const void *, int, size_t);
+int strncasecmp(const char *s1, const char *s2, size_t n);
+
+// bcopy is same as memcpy but it is a void function, being used in socket lib
+#define bcopy(a,b,c) ( memcpy((void *)a, (void *)b, (size_t)c))
+
+// bcmp is same as memcmp, returns 0 for successful compare, non-zero otherwise
+#define bcmp(a,b,c) ( memcmp((void *)a, (void *)b, (size_t)c))
+
+//strsep is the same as strtok, the only difference is for strsep the 1st parameter is a char**
+#define strsep(a,b) (strtok(*a,b))
__END_DECLS
diff --git a/StdLib/Include/sys/EfiSysCall.h b/StdLib/Include/sys/EfiSysCall.h
index 14ecb49890..7b299108e6 100644
--- a/StdLib/Include/sys/EfiSysCall.h
+++ b/StdLib/Include/sys/EfiSysCall.h
@@ -3,7 +3,7 @@
Concept derived from NetBSD's unistd.h file.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ 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
@@ -19,7 +19,7 @@
#include <sys/EfiCdefs.h>
#include <sys/types.h>
-struct stat; // Structure declared in <sys/stat.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 */
@@ -31,53 +31,90 @@ struct stat; // Structure declared in <sys/stat.h>
#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 */
+/* whence values for lseek(2)
+ 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
+
+// Parameters for the ValidateFD function.
+#define VALID_OPEN 1
+#define VALID_CLOSED 0
+#define VALID_DONT_CARE -1
__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);
+int close (int fd);
+ssize_t read (int fd, void *buf, size_t n);
+ssize_t write (int fd, const void *buf, size_t n);
+int unlink (const char *name);
+int dup2 (int, int);
+int rmdir (const char *);
+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, ...);
+ int open (const char *name, int oflags, int mode);
+ int creat (const char *, mode_t);
+ 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);
+ int mkdir (const char *, mode_t);
+ int fstat (int, struct stat *);
+ int lstat (const char *, struct stat *);
+ int stat (const char *, void *);
+// 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
+ off_t lseek (int, off_t, int);
+ int truncate (const char *, off_t);
+ int ftruncate (int, off_t); // IEEE Std 1003.1b-93
#endif /* __OFF_T_SYSCALLS_DECLARED */
+/* EFI-specific Functions. */
+int DeleteOnClose(int fd); /* Mark an open file to be deleted when closed. */
+
+/* Find and reserve a free File Descriptor.
+
+ Returns the first free File Descriptor greater than or equal to the,
+ already validated, fd specified by Minfd.
+
+ @return Returns -1 if there are no free FDs. Otherwise returns the
+ found fd.
+*/
+int FindFreeFD (int MinFd);
+
+/* Validate that fd refers to a valid file descriptor.
+ IsOpen is interpreted as follows:
+ - Positive fd must be OPEN
+ - Zero fd must be CLOSED
+ - Negative fd may be OPEN or CLOSED
+
+ @retval TRUE fd is VALID
+ @retval FALSE fd is INVALID
+*/
+BOOLEAN ValidateFD (int fd, int IsOpen);
+
/* 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 *);
+int access (const char *path, int amode);
+int chdir (const char *);
+char *getcwd (char *, size_t);
+int reboot (int, char *);
__END_DECLS
diff --git a/StdLib/Include/sys/ansi.h b/StdLib/Include/sys/ansi.h
index a52a9994c9..4fb12987a5 100644
--- a/StdLib/Include/sys/ansi.h
+++ b/StdLib/Include/sys/ansi.h
@@ -55,7 +55,7 @@ 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 __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 */
diff --git a/StdLib/Include/sys/cdefs.h b/StdLib/Include/sys/cdefs.h
new file mode 100644
index 0000000000..c6e3d7b120
--- /dev/null
+++ b/StdLib/Include/sys/cdefs.h
@@ -0,0 +1,15 @@
+/** @file
+ Wrapper to allow existing references to <sys/cdefs.h>,
+ in code being ported, to work.
+
+ 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.
+**/
+
+#include <sys/EfiCdefs.h>
diff --git a/StdLib/Include/sys/cdefs_aout.h b/StdLib/Include/sys/cdefs_aout.h
index ce4ca06193..c7920a02b1 100644
--- a/StdLib/Include/sys/cdefs_aout.h
+++ b/StdLib/Include/sys/cdefs_aout.h
@@ -88,7 +88,8 @@
#undef __KERNEL_RCSID
-#define __RCSID(_s) __IDSTRING(rcsid,_s)
+//#define __RCSID(_s) __IDSTRING(rcsid,_s)
+#define __RCSID(_s)
#define __SCCSID(_s)
#define __SCCSID2(_s)
#if 0 /* XXX userland __COPYRIGHTs have \ns in them */
diff --git a/StdLib/Include/sys/dirent.h b/StdLib/Include/sys/dirent.h
index 1d5f91185f..373664d091 100644
--- a/StdLib/Include/sys/dirent.h
+++ b/StdLib/Include/sys/dirent.h
@@ -4,7 +4,7 @@
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>
+ 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
which accompanies this distribution. The full text of the license may be found at
@@ -49,6 +49,7 @@
#include <sys/featuretest.h>
#include <time.h>
+#include <sys/time.h>
#define MAXNAMLEN 511
@@ -66,10 +67,10 @@ struct dirent {
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.
+ struct timespec CreateTime; // The time when the file was last accessed.
+ struct timespec LastAccessTime; // The time when the file’s contents were last modified.
+ struct timespec ModificationTime; // The attribute bits for the file. See below.
+ CHAR16 FileName[1]; // The Null-terminated name of the file.
};
/*
diff --git a/StdLib/Include/sys/fcntl.h b/StdLib/Include/sys/fcntl.h
index cd720c03d9..8b691b19f8 100644
--- a/StdLib/Include/sys/fcntl.h
+++ b/StdLib/Include/sys/fcntl.h
@@ -57,8 +57,7 @@
/*
* 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).
+ * which is a superset of the open/fcntl flags.
* Open/fcntl flags begin with O_; kernel-internal flags begin with F.
*/
/* open-only flags */
@@ -70,10 +69,6 @@
/*
* 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
diff --git a/StdLib/Include/sys/ioctl.h b/StdLib/Include/sys/ioctl.h
new file mode 100644
index 0000000000..2378fd2c84
--- /dev/null
+++ b/StdLib/Include/sys/ioctl.h
@@ -0,0 +1,101 @@
+/** @file
+ Device Control, ioctl, definitions and declarations.
+
+ 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.
+
+ * 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.
+
+ NetBSD: ioctl.h,v 1.34 2005/12/11 12:25:20 christos Exp
+ ioctl.h 8.6 (Berkeley) 3/28/94
+**/
+#ifndef _SYS_IOCTL_H_
+#define _SYS_IOCTL_H_
+
+
+//#include <sys/ttycom.h>
+
+/*
+ * Pun for SunOS prior to 3.2. SunOS 3.2 and later support TIOCGWINSZ
+ * and TIOCSWINSZ (yes, even 3.2-3.5, the fact that it wasn't documented
+ * nonwithstanding).
+ */
+struct ttysize {
+ unsigned short ts_lines;
+ unsigned short ts_cols;
+ unsigned short ts_xxx;
+ unsigned short ts_yyy;
+};
+//#define TIOCGSIZE TIOCGWINSZ
+//#define TIOCSSIZE TIOCSWINSZ
+
+//#include <sys/ioccom.h>
+
+//#include <sys/dkio.h>
+//#include <sys/filio.h>
+//#include <sys/sockio.h>
+
+/*
+ * Passthrough ioctl commands. These are passed through to devices
+ * as they are, it is expected that the device (an LKM, for example),
+ * will know how to deal with them. One for each emulation, so that
+ * no namespace clashes will occur between them, for devices that
+ * may be dealing with specific ioctls for multiple emulations.
+ */
+
+struct ioctl_pt {
+ unsigned long com;
+ void *data;
+};
+
+#define PTIOCNETBSD _IOW('Z', 0, struct ioctl_pt)
+#define PTIOCSUNOS _IOW('Z', 1, struct ioctl_pt)
+#define PTIOCSVR4 _IOW('Z', 2, struct ioctl_pt)
+#define PTIOCLINUX _IOW('Z', 3, struct ioctl_pt)
+#define PTIOCFREEBSD _IOW('Z', 4, struct ioctl_pt)
+#define PTIOCOSF1 _IOW('Z', 5, struct ioctl_pt)
+#define PTIOCULTRIX _IOW('Z', 6, struct ioctl_pt)
+#define PTIOCWIN32 _IOW('Z', 7, struct ioctl_pt)
+
+#include <sys/EfiCdefs.h>
+
+__BEGIN_DECLS
+int ioctl(int, unsigned long, ...);
+__END_DECLS
+#endif /* !_SYS_IOCTL_H_ */
diff --git a/StdLib/Include/sys/poll.h b/StdLib/Include/sys/poll.h
new file mode 100644
index 0000000000..ead648d490
--- /dev/null
+++ b/StdLib/Include/sys/poll.h
@@ -0,0 +1,91 @@
+/** @file
+ Definitions in support of the poll() function.
+
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * 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) 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.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.
+
+ NetBSD: poll.h,v 1.11 2005/12/11 12:25:20 christos Exp
+**/
+#ifndef _SYS_POLL_H_
+#define _SYS_POLL_H_
+
+#include <sys/featuretest.h>
+#include <sys/EfiCdefs.h>
+
+typedef unsigned int nfds_t;
+
+struct pollfd {
+ int fd; /* file descriptor */
+ short events; /* events to look for */
+ short revents; /* events returned */
+};
+
+/*
+ * Testable events (may be specified in events field).
+ */
+#define POLLIN 0x0001
+#define POLLPRI 0x0002
+#define POLLOUT 0x0004
+#define POLLRDNORM 0x0040
+#define POLLWRNORM POLLOUT
+#define POLLRDBAND 0x0080
+#define POLLWRBAND 0x0100
+
+/*
+ * Non-testable events (ignored in events field, valid in return only).
+ */
+#define POLLERR 0x0008
+#define POLLHUP 0x0010
+#define POLLNVAL 0x0020 // Invalid parameter in POLL call
+#define POLL_RETONLY (POLLERR | POLLHUP | POLLNVAL)
+
+/*
+ * Infinite timeout value.
+ */
+#define INFTIM -1
+
+__BEGIN_DECLS
+int poll(struct pollfd *, nfds_t, int);
+__END_DECLS
+
+#endif /* !_SYS_POLL_H_ */
diff --git a/StdLib/Include/sys/signal.h b/StdLib/Include/sys/signal.h
index 8cc32f08c9..e945a62bfe 100644
--- a/StdLib/Include/sys/signal.h
+++ b/StdLib/Include/sys/signal.h
@@ -14,6 +14,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <sys/EfiCdefs.h>
#include <machine/signal.h>
+enum {
+ __SigInt = 1,
+ __SigIll,
+ __SigAbrt,
+ __SigFpe,
+ __SigSegv,
+ __SigTerm,
+ __SigBreak,
+ __Sig_Last
+};
+
/** The type of a signal handler function. **/
typedef void __sighandler_t(int);
diff --git a/StdLib/Include/sys/socket.h b/StdLib/Include/sys/socket.h
index 8cc297d58b..11434ed641 100644
--- a/StdLib/Include/sys/socket.h
+++ b/StdLib/Include/sys/socket.h
@@ -86,8 +86,9 @@ typedef __socklen_t socklen_t;
#include <machine/ansi.h>
-#ifdef _BSD_SIZE_T_
-typedef _BSD_SIZE_T_ size_t;
+#ifdef _EFI_SIZE_T_
+typedef _EFI_SIZE_T_ size_t;
+#undef _EFI_SIZE_T_
#undef _BSD_SIZE_T_
#endif
diff --git a/StdLib/Include/sys/stat.h b/StdLib/Include/sys/stat.h
index adc61ecf80..47e993b8be 100644
--- a/StdLib/Include/sys/stat.h
+++ b/StdLib/Include/sys/stat.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ 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
@@ -54,6 +54,7 @@
struct stat {
off_t st_size; /* file size, in bytes */
off_t st_physsize; /* physical space the file consumes */
+ off_t st_curpos; /* current position within the file, or XY coord. for Console */
dtime_t st_birthtime; /* time of creation */
dtime_t st_atime; /* time of last access */
dtime_t st_mtime; /* time of last data modification */
@@ -113,7 +114,8 @@ struct stat {
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_IFMT 0x000FF000 /* type-of-file mask */
+#define _S_IFIFO 0x00001000 /* named pipe (fifo) */
#define _S_IFCHR 0x00002000 /* character special */
#define _S_IFDIR 0x00004000 /* directory */
#define _S_IFBLK 0x00006000 /* block special */
@@ -121,9 +123,10 @@ struct stat {
#define _S_IFSOCK 0x0000C000 /* socket */
#define _S_ITTY 0x00010000 /* File connects to a TTY device */
#define _S_IWTTY 0x00020000 /* TTY receives Wide characters */
+#define _S_ICONSOLE 0x00030000 /* UEFI Console Device */
/* UEFI specific (FAT file system) File attributes.
- Specifiec in Hexadecimal instead of Octal.
+ Specified in Hexadecimal instead of Octal.
These bits correspond to the xx portion of _S_IFMT
*/
#define S_IREADONLY 0x00100000 // Read Only File
@@ -133,9 +136,10 @@ struct stat {
#define S_IARCHIVE 0x02000000 // Archive Bit
#define S_IROFS 0x08000000 /* Read Only File System */
+#define S_EFIONLY 0xF0000000 /* Flags only used by the EFI system calls. */
+
#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' */
@@ -146,12 +150,12 @@ struct stat {
#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_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_IFSOCK _S_IFSOCK
//#define S_IFWHT _S_IFWHT
//#define S_ARCH1 _S_ARCH1
@@ -163,7 +167,7 @@ struct stat {
#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_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 */
diff --git a/StdLib/Include/sys/syslimits.h b/StdLib/Include/sys/syslimits.h
index a26104c7f6..80b18c3917 100644
--- a/StdLib/Include/sys/syslimits.h
+++ b/StdLib/Include/sys/syslimits.h
@@ -37,6 +37,8 @@
#include <sys/featuretest.h>
#define ARG_MAX (2 * 1024) /* max bytes for an exec function */
+#define ARGC_MAX (ARG_MAX / 2) /* Maximum value for argc */
+
#ifndef CHILD_MAX
#define CHILD_MAX 128 /* max simultaneous processes */
#endif
diff --git a/StdLib/Include/sys/time.h b/StdLib/Include/sys/time.h
index 1dd10b598f..4b17317200 100644
--- a/StdLib/Include/sys/time.h
+++ b/StdLib/Include/sys/time.h
@@ -1,11 +1,11 @@
/** @file
System-specific declarations and macros related to time.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ 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.php.
+ 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.
@@ -180,4 +180,7 @@ void Efi2Tm( EFI_TIME *EfiBDtime, struct tm *NewTime);
__END_DECLS
+/* BSD compatibility functions */
+int gettimeofday (struct timeval *tp, void *ignore);
+
#endif /* !_SYS_TIME_H_ */
diff --git a/StdLib/Include/sys/types.h b/StdLib/Include/sys/types.h
index 9e95fd3ea3..68e3ba3ddd 100644
--- a/StdLib/Include/sys/types.h
+++ b/StdLib/Include/sys/types.h
@@ -243,8 +243,8 @@ typedef int64_t dtime_t; /* on-disk time_t */
#undef _EFI_CLOCK_T
#endif
-#if defined(_BSD_SIZE_T_) && defined(_EFI_SIZE_T_)
- typedef _BSD_SIZE_T_ size_t;
+#ifdef _EFI_SIZE_T_
+ typedef _EFI_SIZE_T_ size_t;
#define _SIZE_T
#undef _BSD_SIZE_T_
#undef _EFI_SIZE_T_
diff --git a/StdLib/Include/sys/uio.h b/StdLib/Include/sys/uio.h
index 8c3ee8fbf9..e6d667ba30 100644
--- a/StdLib/Include/sys/uio.h
+++ b/StdLib/Include/sys/uio.h
@@ -43,8 +43,9 @@
#include <machine/ansi.h>
#include <sys/featuretest.h>
-#ifdef _BSD_SIZE_T_
-typedef _BSD_SIZE_T_ size_t;
+#ifdef _EFI_SIZE_T_
+typedef _EFI_SIZE_T_ size_t;
+#undef _EFI_SIZE_T_
#undef _BSD_SIZE_T_
#endif
diff --git a/StdLib/Include/sys/unistd.h b/StdLib/Include/sys/unistd.h
new file mode 100644
index 0000000000..0e7158c7c8
--- /dev/null
+++ b/StdLib/Include/sys/unistd.h
@@ -0,0 +1,192 @@
+/* $NetBSD: unistd.h,v 1.35 2006/08/14 18:17:48 rpaulo Exp $ */
+
+/*
+ * 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.
+ *
+ * @(#)unistd.h 8.2 (Berkeley) 1/7/94
+ */
+
+#ifndef _SYS_UNISTD_H_
+#define _SYS_UNISTD_H_
+
+#include <sys/featuretest.h>
+
+/* compile-time symbolic constants */
+#define _POSIX_JOB_CONTROL /* implementation supports job control */
+
+/*
+ * According to POSIX 1003.1:
+ * "The saved set-user-ID capability allows a program to regain the
+ * effective user ID established at the last exec call."
+ * However, the setuid/setgid function as specified by POSIX 1003.1 does
+ * not allow changing the effective ID from the super-user without also
+ * changed the saved ID, so it is impossible to get super-user privileges
+ * back later. Instead we provide this feature independent of the current
+ * effective ID through the seteuid/setegid function. In addition, we do
+ * not use the saved ID as specified by POSIX 1003.1 in setuid/setgid,
+ * because this would make it impossible for a set-user-ID executable
+ * owned by a user other than the super-user to permanently revoke its
+ * extra privileges.
+ */
+#ifdef _NOT_AVAILABLE
+#define _POSIX_SAVED_IDS /* saved set-user-ID and set-group-ID */
+#endif
+
+#define _POSIX_VERSION 199009L
+#define _POSIX2_VERSION 199212L
+
+/* execution-time symbolic constants */
+ /* chown requires appropriate privileges */
+#define _POSIX_CHOWN_RESTRICTED 1
+ /* clock selection */
+#define _POSIX_CLOCK_SELECTION -1
+ /* too-long path components generate errors */
+#define _POSIX_NO_TRUNC 1
+ /* may disable terminal special characters */
+#define _POSIX_VDISABLE ((unsigned char)'\377')
+ /* file synchronization is available */
+#define _POSIX_FSYNC 1
+ /* synchronized I/O is available */
+#define _POSIX_SYNCHRONIZED_IO 1
+ /* memory mapped files */
+#define _POSIX_MAPPED_FILES 1
+ /* memory locking of whole address space */
+#define _POSIX_MEMLOCK 1
+ /* memory locking address ranges */
+#define _POSIX_MEMLOCK_RANGE 1
+ /* memory access protections */
+#define _POSIX_MEMORY_PROTECTION 1
+ /* monotonic clock */
+#define _POSIX_MONOTONIC_CLOCK 200112L
+ /* threads */
+#define _POSIX_THREADS 200112L
+ /* semaphores */
+#define _POSIX_SEMAPHORES 0
+ /* barriers */
+#define _POSIX_BARRIERS 200112L
+ /* timers */
+#define _POSIX_TIMERS 200112L
+ /* spin locks */
+#define _POSIX_SPIN_LOCKS 200112L
+ /* read/write locks */
+#define _POSIX_READER_WRITER_LOCKS 200112L
+ /* XPG4.2 shared memory */
+#define _XOPEN_SHM 0
+
+#if defined(_NETBSD_SOURCE)
+/* whence values for lseek(2); renamed by POSIX 1003.1 */
+#define L_SET SEEK_SET
+#define L_INCR SEEK_CUR
+#define L_XTND SEEK_END
+
+/*
+ * fsync_range values.
+ *
+ * Note the following flag values were chosen to not overlap
+ * values for SEEK_XXX flags. While not currently implemented,
+ * it is possible to extend this call to respect SEEK_CUR and
+ * SEEK_END offset addressing modes.
+ */
+#define FDATASYNC 0x0010 /* sync data and minimal metadata */
+#define FFILESYNC 0x0020 /* sync data and metadata */
+#define FDISKSYNC 0x0040 /* flush disk caches after sync */
+#endif
+
+/* configurable pathname variables; use as argument to pathconf(3) */
+#define _PC_LINK_MAX 1
+#define _PC_MAX_CANON 2
+#define _PC_MAX_INPUT 3
+#define _PC_NAME_MAX 4
+#define _PC_PATH_MAX 5
+#define _PC_PIPE_BUF 6
+#define _PC_CHOWN_RESTRICTED 7
+#define _PC_NO_TRUNC 8
+#define _PC_VDISABLE 9
+#define _PC_SYNC_IO 10
+#define _PC_FILESIZEBITS 11
+
+/* configurable system variables; use as argument to sysconf(3) */
+/*
+ * XXX The value of _SC_CLK_TCK is embedded in <time.h>.
+ * XXX The value of _SC_PAGESIZE is embedded in <sys/shm.h>.
+ */
+#define _SC_ARG_MAX 1
+#define _SC_CHILD_MAX 2
+#define _O_SC_CLK_TCK 3 /* Old version, always 100 */
+#define _SC_NGROUPS_MAX 4
+#define _SC_OPEN_MAX 5
+#define _SC_JOB_CONTROL 6
+#define _SC_SAVED_IDS 7
+#define _SC_VERSION 8
+#define _SC_BC_BASE_MAX 9
+#define _SC_BC_DIM_MAX 10
+#define _SC_BC_SCALE_MAX 11
+#define _SC_BC_STRING_MAX 12
+#define _SC_COLL_WEIGHTS_MAX 13
+#define _SC_EXPR_NEST_MAX 14
+#define _SC_LINE_MAX 15
+#define _SC_RE_DUP_MAX 16
+#define _SC_2_VERSION 17
+#define _SC_2_C_BIND 18
+#define _SC_2_C_DEV 19
+#define _SC_2_CHAR_TERM 20
+#define _SC_2_FORT_DEV 21
+#define _SC_2_FORT_RUN 22
+#define _SC_2_LOCALEDEF 23
+#define _SC_2_SW_DEV 24
+#define _SC_2_UPE 25
+#define _SC_STREAM_MAX 26
+#define _SC_TZNAME_MAX 27
+#define _SC_PAGESIZE 28
+#define _SC_PAGE_SIZE _SC_PAGESIZE /* 1170 compatibility */
+#define _SC_FSYNC 29
+#define _SC_XOPEN_SHM 30
+#define _SC_SYNCHRONIZED_IO 31
+#define _SC_IOV_MAX 32
+#define _SC_MAPPED_FILES 33
+#define _SC_MEMLOCK 34
+#define _SC_MEMLOCK_RANGE 35
+#define _SC_MEMORY_PROTECTION 36
+#define _SC_LOGIN_NAME_MAX 37
+#define _SC_MONOTONIC_CLOCK 38
+#define _SC_CLK_TCK 39 /* New, variable version */
+#define _SC_ATEXIT_MAX 40
+#define _SC_THREADS 41
+#define _SC_SEMAPHORES 42
+#define _SC_BARRIERS 43
+#define _SC_TIMERS 44
+#define _SC_SPIN_LOCKS 45
+#define _SC_READER_WRITER_LOCKS 46
+#define _SC_GETGR_R_SIZE_MAX 47
+#define _SC_GETPW_R_SIZE_MAX 48
+#define _SC_CLOCK_SELECTION 49
+
+/* configurable system strings */
+#define _CS_PATH 1
+
+#endif /* !_SYS_UNISTD_H_ */
diff --git a/StdLib/Include/time.h b/StdLib/Include/time.h
index 386629cc6b..8c7b8e1422 100644
--- a/StdLib/Include/time.h
+++ b/StdLib/Include/time.h
@@ -33,11 +33,11 @@
if Daylight Saving Time is not in effect, and negative if the information
is not available.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ 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.php.
+ 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.
@@ -69,6 +69,39 @@
#undef _EFI_TIME_T
#endif
+/** Value added to tm_year to get the full year value. TM_YEAR_BASE + 110 --> 2010
+**/
+#define TM_YEAR_BASE 1900
+
+/** Values for the tm_wday member of struct tm.
+ @{
+**/
+#define TM_SUNDAY 0
+#define TM_MONDAY 1
+#define TM_TUESDAY 2
+#define TM_WEDNESDAY 3
+#define TM_THURSDAY 4
+#define TM_FRIDAY 5
+#define TM_SATURDAY 6
+/** @} **/
+
+/** Values for the tm_mon member of struct tm.
+ @{
+**/
+#define TM_JANUARY 0
+#define TM_FEBRUARY 1
+#define TM_MARCH 2
+#define TM_APRIL 3
+#define TM_MAY 4
+#define TM_JUNE 5
+#define TM_JULY 6
+#define TM_AUGUST 7
+#define TM_SEPTEMBER 8
+#define TM_OCTOBER 9
+#define TM_NOVEMBER 10
+#define TM_DECEMBER 11
+/** @} **/
+
/** A structure holding the components of a calendar time, called the
broken-down time. The first nine (9) members are as mandated by the
C95 standard. Additional fields have been added for EFI support.
@@ -115,7 +148,7 @@ double EFIAPI difftime(time_t time1, time_t time0);
same encoding as that of the values returned by the time function. The
original values of the tm_wday and tm_yday components of the structure are
ignored, and the original values of the other components are not
- restricted to the ranges indicated above.270) On successful completion,
+ restricted to the ranges indicated above. On successful completion,
the values of the tm_wday and tm_yday components of the structure are set
appropriately, and the other components are set to represent the specified
calendar time, but with their values forced to the ranges indicated above;
@@ -128,25 +161,50 @@ double EFIAPI difftime(time_t time1, time_t time0);
**/
time_t EFIAPI mktime(struct tm *timeptr);
-/**
+/** The time function determines the current calendar time.
+
+ The encoding of the value is unspecified.
+
+ @return The time function returns the implementation’s best approximation
+ of the current calendar time. The value (time_t)(-1) is returned
+ if the calendar time is not available. If timer is not a null
+ pointer, the return value is also assigned to the object it
+ points to.
**/
time_t EFIAPI time(time_t *timer);
/* ################# Time Conversion Functions ########################## */
-/**
+/** The asctime function converts the broken-down time in the structure pointed
+ to by timeptr into a string in the form
+ Sun Sep 16 01:03:52 1973\n\0
+
+ @return The asctime function returns a pointer to the string.
**/
char * EFIAPI asctime(const struct tm *timeptr);
-/**
+/** The ctime function converts the calendar time pointed to by timer to local
+ time in the form of a string. It is equivalent to asctime(localtime(timer))
+
+ @return The ctime function returns the pointer returned by the asctime
+ function with that broken-down time as argument.
**/
char * EFIAPI ctime(const time_t *timer);
-/**
+/** The gmtime function converts the calendar time pointed to by timer into a
+ brokendown time, expressed as UTC.
+
+ @return The gmtime function returns a pointer to the broken-down time,
+ or a null pointer if the specified time cannot be converted to UTC.
**/
struct tm * EFIAPI gmtime(const time_t *timer);
-/**
+/** The localtime function converts the calendar time pointed to by timer into
+ a broken-down time, expressed as local time.
+
+ @return The localtime function returns a pointer to the broken-down time,
+ or a null pointer if the specified time cannot be converted to
+ local time.
**/
struct tm * EFIAPI localtime(const time_t *timer);
@@ -304,6 +362,9 @@ size_t EFIAPI strftime( char * __restrict s, size_t maxsize,
const char * __restrict format,
const struct tm * __restrict timeptr);
+char *strptime(const char *, const char * format, struct tm*);
+
+
/* ################# Implementation Functions ########################### */
clock_t EFIAPI __getCPS(void);
diff --git a/StdLib/Include/unistd.h b/StdLib/Include/unistd.h
new file mode 100644
index 0000000000..fc8d7381b7
--- /dev/null
+++ b/StdLib/Include/unistd.h
@@ -0,0 +1,170 @@
+/** @file
+
+ 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 _UNISTD_H_
+#define _UNISTD_H_
+
+//#include <machine/ansi.h>
+//#include <machine/int_types.h>
+//#include <sys/featuretest.h>
+//#include <sys/types.h>
+#include <sys/unistd.h>
+#include <sys/EfiSysCall.h>
+
+#define F_ULOCK 0
+#define F_LOCK 1
+#define F_TLOCK 2
+#define F_TEST 3
+
+
+__BEGIN_DECLS
+int rename(const char *, const char *);
+
+// Networking
+long gethostid(void);
+int gethostname(char *, size_t);
+int getdomainname(char *, size_t);
+int setdomainname(const char *, size_t);
+int sethostid(long);
+int sethostname(const char *, size_t);
+
+// For Future implementation
+__dead void _exit(int) __attribute__((__noreturn__));
+ssize_t pread(int, void *, size_t, off_t);
+ssize_t pwrite(int, const void *, size_t, off_t);
+int syscall(int, ...);
+int dup(int);
+pid_t fork(void);
+
+// The following *nix functions are not implemented
+unsigned int alarm(unsigned int);
+int chown(const char *, uid_t, gid_t);
+size_t confstr(int, char *, size_t);
+int execl(const char *, const char *, ...);
+int execle(const char *, const char *, ...);
+int execlp(const char *, const char *, ...);
+int execv(const char *, char * const *);
+int execve(const char *, char * const *, char * const *);
+int execvp(const char *, char * const *);
+long fpathconf(int, int);
+gid_t getegid(void);
+uid_t geteuid(void);
+gid_t getgid(void);
+int getgroups(int, gid_t []);
+__aconst char *getlogin(void);
+pid_t getpgrp(void);
+pid_t getpid(void);
+pid_t getppid(void);
+uid_t getuid(void);
+int link(const char *, const char *);
+long pathconf(const char *, int);
+int pause(void);
+int pipe(int *);
+int setgid(gid_t);
+int setpgid(pid_t, pid_t);
+pid_t setsid(void);
+int setuid(uid_t);
+unsigned int sleep(unsigned int);
+long sysconf(int);
+pid_t tcgetpgrp(int);
+int tcsetpgrp(int, pid_t);
+__aconst char *ttyname(int);
+
+int getopt(int, char * const [], const char *);
+
+extern char *optarg; /* getopt(3) external variables */
+extern int opterr;
+extern int optind;
+extern int optopt;
+extern int optreset; /* getopt(3) external variable */
+extern char *suboptarg; /* getsubopt(3) external variable */
+
+int setegid(gid_t);
+int seteuid(uid_t);
+int fdatasync(int);
+int fsync(int);
+int ttyname_r(int, char *, size_t);
+int chroot(const char *);
+int nice(int);
+__aconst char *crypt(const char *, const char *);
+int encrypt(char *, int);
+char *getpass(const char *);
+pid_t getsid(pid_t);
+
+#ifndef intptr_t
+typedef __intptr_t intptr_t;
+#define intptr_t __intptr_t
+#endif
+
+int brk(void *);
+int fchdir(int);
+int fchown(int, uid_t, gid_t);
+int getdtablesize(void);
+__pure int getpagesize(void); /* legacy */
+pid_t getpgid(pid_t);
+int lchown(const char *, uid_t, gid_t);
+int lockf(int, int, off_t);
+ssize_t readlink(const char * __restrict, char * __restrict, size_t);
+void *sbrk(intptr_t);
+int setregid(gid_t, gid_t);
+int setreuid(uid_t, uid_t);
+void swab(const void *, void *, size_t);
+int symlink(const char *, const char *);
+void sync(void);
+useconds_t ualarm(useconds_t, useconds_t);
+int usleep(useconds_t);
+pid_t vfork(void) __RENAME(__vfork14);
+
+/*
+ * Implementation-defined extensions
+ */
+int acct(const char *);
+int closefrom(int);
+int des_cipher(const char *, char *, long, int);
+int des_setkey(const char *);
+void endusershell(void);
+int exect(const char *, char * const *, char * const *);
+int fchroot(int);
+int fsync_range(int, int, off_t, off_t);
+int getgrouplist(const char *, gid_t, gid_t *, int *);
+int getgroupmembership(const char *, gid_t, gid_t *, int, int *);
+mode_t getmode(const void *, mode_t);
+int getsubopt(char **, char * const *, char **);
+__aconst char *getusershell(void);
+int initgroups(const char *, gid_t);
+int iruserok(uint32_t, int, const char *, const char *);
+int issetugid(void);
+int nfssvc(int, void *);
+int profil(char *, size_t, u_long, u_int);
+void psignal(unsigned int, const char *);
+int rcmd(char **, int, const char *, const char *, const char *, int *);
+int revoke(const char *);
+int rresvport(int *);
+int ruserok(const char *, int, const char *, const char *);
+int setgroups(int, const gid_t *);
+int setlogin(const char *);
+void *setmode(const char *);
+int setrgid(gid_t);
+int setruid(uid_t);
+void setusershell(void);
+void strmode(mode_t, char *);
+__aconst char *strsignal(int);
+int swapctl(int, void *, int);
+quad_t __syscall(quad_t, ...);
+int undelete(const char *);
+int rcmd_af(char **, int, const char *, const char *, const char *, int *, int);
+int rresvport_af(int *, int);
+int iruserok_sa(const void *, int, int, const char *, const char *);
+
+__END_DECLS
+
+#endif /* !_UNISTD_H_ */
diff --git a/StdLib/Include/wchar.h b/StdLib/Include/wchar.h
index 360bdacc32..c42594787d 100644
--- a/StdLib/Include/wchar.h
+++ b/StdLib/Include/wchar.h
@@ -506,11 +506,23 @@ size_t wcsftime(wchar_t * __restrict s, size_t maxsize, const wchar_t * __restri
**/
wint_t btowc(int c);
-/**
+/** The wctob function determines whether c corresponds to a member of the extended
+ character set whose multibyte character representation is a single byte when in the initial
+ shift state.
+
+ @Returns The wctob function returns EOF if c does not correspond to a multibyte
+ character with length one in the initial shift state. Otherwise, it
+ returns the single-byte representation of that character as an
+ unsigned char converted to an int.
**/
int wctob(wint_t c);
-/**
+/** If ps is not a null pointer, the mbsinit function determines whether the
+ pointed-to mbstate_t object describes an initial conversion state.
+
+ @Returns The mbsinit function returns nonzero if ps is a null pointer
+ or if the pointed-to object describes an initial conversion
+ state; otherwise, it returns zero.
**/
int mbsinit(const mbstate_t *ps);
@@ -532,7 +544,33 @@ size_t wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps);
**/
size_t mbsrtowcs(wchar_t * __restrict dst, const char ** __restrict src, size_t len, mbstate_t * __restrict ps);
-/**
+/** The wcsrtombs function converts a sequence of wide characters from the array
+ indirectly pointed to by src into a sequence of corresponding multibyte
+ characters that begins in the conversion state described by the object
+ pointed to by ps. If dst is not a null pointer, the converted characters
+ are then stored into the array pointed to by dst. Conversion continues
+ up to and including a terminating null wide character, which is also
+ stored. Conversion stops earlier in two cases: when a wide character is
+ reached that does not correspond to a valid multibyte character, or
+ (if dst is not a null pointer) when the next multibyte character would
+ exceed the limit of len total bytes to be stored into the array pointed
+ to by dst. Each conversion takes place as if by a call to the wcrtomb
+ function.)
+
+ If dst is not a null pointer, the pointer object pointed to by src is
+ assigned either a null pointer (if conversion stopped due to reaching
+ a terminating null wide character) or the address just past the last wide
+ character converted (if any). If conversion stopped due to reaching a
+ terminating null wide character, the resulting state described is the
+ initial conversion state.
+
+ @Returns If conversion stops because a wide character is reached that
+ does not correspond to a valid multibyte character, an
+ encoding error occurs: the wcsrtombs function stores the
+ value of the macro EILSEQ in errno and returns (size_t)(-1);
+ the conversion state is unspecified. Otherwise, it returns
+ the number of bytes in the resulting multibyte character
+ sequence, not including the terminating null character (if any).
**/
size_t wcsrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t len, mbstate_t * __restrict ps);
diff --git a/StdLib/Include/wctype.h b/StdLib/Include/wctype.h
index 9aa89ef541..3df726a353 100644
--- a/StdLib/Include/wctype.h
+++ b/StdLib/Include/wctype.h
@@ -1,6 +1,15 @@
-/* $NetBSD: wctype.h,v 1.6 2005/02/03 04:39:32 perry Exp $ */
+/** @file
+ Wide character classification functions and macros.
+
+ 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)1999 Citrus Project,
* All rights reserved.
*
@@ -26,17 +35,19 @@
* SUCH DAMAGE.
*
* citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp
- */
+ NetBSD: wctype.h,v 1.6 2005/02/03 04:39:32 perry Exp
+**/
#ifndef _WCTYPE_H_
#define _WCTYPE_H_
#include <sys/EfiCdefs.h>
#include <machine/ansi.h>
-#ifdef _BSD_WINT_T_
-typedef _BSD_WINT_T_ wint_t;
-#undef _BSD_WINT_T_
+#ifdef _EFI_WINT_T
+ typedef _EFI_WINT_T wint_t;
+ #undef _BSD_WINT_T_
+ #undef _EFI_WINT_T
#endif
#ifdef _BSD_WCTRANS_T_