summaryrefslogtreecommitdiff
path: root/StdLib/Include/sys
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/sys
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/sys')
-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
16 files changed, 513 insertions, 58 deletions
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_ */