summaryrefslogtreecommitdiff
path: root/StdLib/Include/sys
diff options
context:
space:
mode:
Diffstat (limited to 'StdLib/Include/sys')
-rw-r--r--StdLib/Include/sys/EfiCdefs.h25
-rw-r--r--StdLib/Include/sys/EfiSysCall.h7
-rw-r--r--StdLib/Include/sys/_posix.h97
-rw-r--r--StdLib/Include/sys/cdefs_aout.h7
-rw-r--r--StdLib/Include/sys/file.h102
-rw-r--r--StdLib/Include/sys/select.h1
-rw-r--r--StdLib/Include/sys/signal.h10
-rw-r--r--StdLib/Include/sys/sockio.h100
-rw-r--r--StdLib/Include/sys/stat.h2
-rw-r--r--StdLib/Include/sys/sysctl.h505
-rw-r--r--StdLib/Include/sys/syslimits.h2
-rw-r--r--StdLib/Include/sys/time.h10
-rw-r--r--StdLib/Include/sys/unistd.h68
-rw-r--r--StdLib/Include/sys/wait.h170
14 files changed, 1038 insertions, 68 deletions
diff --git a/StdLib/Include/sys/EfiCdefs.h b/StdLib/Include/sys/EfiCdefs.h
index 46aaf6e744..c3a2772bfc 100644
--- a/StdLib/Include/sys/EfiCdefs.h
+++ b/StdLib/Include/sys/EfiCdefs.h
@@ -17,16 +17,16 @@
that the library can be easily tuned for different compilers.
__inline Defined to the appropriate keyword or not defined.
__func__ Defined to __FUNC__, __FUNCTION__, or NULL as appropriate.
- __restrict Defined to nothing for VC++ or to restrict for C99 compliant compilers.
+ __restrict Defined to nothing for VC++ or to restrict for GCC and C99 compliant compilers.
This file and its contents are inspired by the <sys/cdefs.h> files in Berkeley
Unix. They have been re-implemented to be specific to the EFI environment.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ 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.
@@ -261,22 +261,7 @@
#endif
#endif /* !(__STDC_VERSION__ >= 199901L) */
-// <DVM 12/21/2010> Experiment to disable RENAME for GCC
-#if 0
-#ifdef __GNUC__
- #define __RENAME(x) ___RENAME(x)
-#else
- #ifdef __lint__
- #define __RENAME(x) __symbolrename(x)
- #else
- /*DVM To see where this might be used... */
- //#error "No function renaming possible"
- #define __RENAME(x)
- #endif /* __lint__ */
-#endif /* __GNUC__ */
-#else /* if 0 */
- #define __RENAME(x)
-#endif /* if 0 */
+#define __RENAME(x)
/*
* A barrier to stop the optimizer from moving code or assume live
@@ -362,6 +347,4 @@ typedef UINT32 ULONG32;
typedef INT64 LONG64;
typedef UINT64 ULONG64;
-//extern int EFIAPI main();
-
#endif /* _EFI_CDEFS_H */
diff --git a/StdLib/Include/sys/EfiSysCall.h b/StdLib/Include/sys/EfiSysCall.h
index 7b299108e6..a49eeda1fc 100644
--- a/StdLib/Include/sys/EfiSysCall.h
+++ b/StdLib/Include/sys/EfiSysCall.h
@@ -75,7 +75,7 @@ int isatty (int);
int fstat (int, struct stat *);
int lstat (const char *, struct stat *);
int stat (const char *, void *);
-// int chmod (const char *, mode_t);
+ int chmod (const char *, mode_t);
#endif // __STAT_SYSCALLS_DECLARED
// These are also declared in sys/types.h
@@ -110,10 +110,11 @@ int FindFreeFD (int MinFd);
*/
BOOLEAN ValidateFD (int fd, int IsOpen);
+char *getcwd (char *, size_t);
+int chdir (const char *);
+
/* These system calls don't YET have EFI implementations. */
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/_posix.h b/StdLib/Include/sys/_posix.h
new file mode 100644
index 0000000000..706cf7edb4
--- /dev/null
+++ b/StdLib/Include/sys/_posix.h
@@ -0,0 +1,97 @@
+#ifndef _SYS__POSIX_H_
+#define _SYS__POSIX_H_
+
+/*-
+ * Copyright (c) 1998 HD Associates, Inc.
+ * All rights reserved.
+ * contact: dufault@hda.com
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $Id: _posix.h,v 1.1.1.1 2006/05/30 06:13:04 hhzhou Exp $
+ */
+
+/*
+ * This is a stand alone header file to set up for feature specification
+ * defined to take place before the inclusion of any standard header.
+ * It should only handle pre-processor defines.
+ *
+ * See section B.2.7 of 1003.1b-1993
+ *
+ */
+
+#ifdef KERNEL
+
+#if !defined(ACTUALLY_LKM_NOT_KERNEL) && !defined(KLD_MODULE)
+#include "opt_posix.h"
+#endif
+
+/* Only kern_mib.c uses _POSIX_VERSION. Introduce a kernel
+ * one to avoid other pieces of the kernel getting dependant
+ * on that.
+ * XXX Complain if you think this dumb.
+ */
+
+/* Make P1003 structures visible for the kernel if
+ * the P1003_1B option is in effect.
+ */
+#ifdef P1003_1B
+#define _P1003_1B_VISIBLE
+#ifndef _KPOSIX_VERSION
+#define _KPOSIX_VERSION 199309L
+#endif
+#endif
+
+#ifndef _KPOSIX_VERSION
+#define _KPOSIX_VERSION 199009L
+#endif
+
+#define _P1003_1B_VISIBLE_HISTORICALLY
+
+#else
+
+/* Default to existing user space version.
+ */
+#ifndef _POSIX_VERSION
+#define _POSIX_VERSION 199009L
+#endif
+
+/* Test for visibility of P1003.1B features:
+ * If _POSIX_SOURCE and POSIX_C_SOURCE are completely undefined
+ * they show up.
+ *
+ * If they specify a version including P1003.1B then they show up.
+ *
+ * (Two macros are added to permit hiding new extensions while
+ * keeping historic BSD features - that is not done now)
+ *
+ */
+
+#if (!defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)) || \
+ (_POSIX_VERSION >= 199309L && defined(_POSIX_C_SOURCE) && \
+ _POSIX_C_SOURCE >= 199309L)
+#define _P1003_1B_VISIBLE
+#define _P1003_1B_VISIBLE_HISTORICALLY
+#endif
+
+#endif /* not KERNEL */
+#endif /* _SYS__POSIX_H_ */
diff --git a/StdLib/Include/sys/cdefs_aout.h b/StdLib/Include/sys/cdefs_aout.h
index c7920a02b1..0ce4fd9d2d 100644
--- a/StdLib/Include/sys/cdefs_aout.h
+++ b/StdLib/Include/sys/cdefs_aout.h
@@ -11,12 +11,7 @@
#define _C_LABEL(x) __CONCAT(_,x)
#define _C_LABEL_STRING(x) "_"x
-#if __STDC__
-#define ___RENAME(x) __asm(___STRING(_C_LABEL(x)))
-#else
-#define ___RENAME(x) ____RENAME(_/**/x)
-#define ____RENAME(x) __asm(___STRING(x))
-#endif
+#define ___RENAME(x)
#define __indr_reference(sym,alias) /* nada, since we do weak refs */
diff --git a/StdLib/Include/sys/file.h b/StdLib/Include/sys/file.h
new file mode 100644
index 0000000000..cce35f1637
--- /dev/null
+++ b/StdLib/Include/sys/file.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 1982, 1986, 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)file.h 8.3 (Berkeley) 1/9/95
+ * $Id: file.h,v 1.1.1.1 2006/05/30 06:12:53 hhzhou Exp $
+ */
+
+#ifndef _SYS_FILE_H_
+#define _SYS_FILE_H_
+
+#ifndef KERNEL
+#include <sys/fcntl.h>
+#include <sys/unistd.h>
+#endif
+
+#ifdef KERNEL
+#include <sys/queue.h>
+
+struct proc;
+struct uio;
+
+/*
+ * Kernel descriptor table.
+ * One entry for each open kernel vnode and socket.
+ */
+struct file {
+ LIST_ENTRY(file) f_list;/* list of active files */
+ short f_flag; /* see fcntl.h */
+#define DTYPE_VNODE 1 /* file */
+#define DTYPE_SOCKET 2 /* communications endpoint */
+#define DTYPE_PIPE 3 /* pipe */
+#define DTYPE_FIFO 4 /* fifo (named pipe) */
+ short f_type; /* descriptor type */
+ short f_count; /* reference count */
+ short f_msgcount; /* references from message queue */
+ struct ucred *f_cred; /* credentials associated with descriptor */
+ struct fileops {
+ int (*fo_read) __P((struct file *fp, struct uio *uio,
+ struct ucred *cred, int flags));
+ int (*fo_write) __P((struct file *fp, struct uio *uio,
+ struct ucred *cred, int flags));
+#define FOF_OFFSET 1
+ int (*fo_ioctl) __P((struct file *fp, u_long com,
+ caddr_t data, struct proc *p));
+ int (*fo_poll) __P((struct file *fp, int events,
+ struct ucred *cred, struct proc *p));
+ int (*fo_close) __P((struct file *fp, struct proc *p));
+ } *f_ops;
+ int f_seqcount; /*
+ * count of sequential accesses -- cleared
+ * by most seek operations.
+ */
+ off_t f_nextread; /*
+ * offset of next expected read
+ */
+ off_t f_offset;
+ caddr_t f_data; /* vnode or socket */
+};
+
+#ifdef MALLOC_DECLARE
+MALLOC_DECLARE(M_FILE);
+#endif
+
+LIST_HEAD(filelist, file);
+extern struct filelist filehead; /* head of list of open files */
+extern struct fileops vnops;
+extern int maxfiles; /* kernel limit on number of open files */
+extern int maxfilesperproc; /* per process limit on number of open files */
+extern int nfiles; /* actual number of open files */
+
+#endif /* KERNEL */
+
+#endif /* !SYS_FILE_H */
diff --git a/StdLib/Include/sys/select.h b/StdLib/Include/sys/select.h
index e1e5de1d5f..5166a0552f 100644
--- a/StdLib/Include/sys/select.h
+++ b/StdLib/Include/sys/select.h
@@ -38,6 +38,7 @@
#include <sys/fd_set.h>
#include <sys/sigtypes.h>
+#include <sys/time.h>
#include <time.h>
__BEGIN_DECLS
diff --git a/StdLib/Include/sys/signal.h b/StdLib/Include/sys/signal.h
index e945a62bfe..6f21fcd0a2 100644
--- a/StdLib/Include/sys/signal.h
+++ b/StdLib/Include/sys/signal.h
@@ -1,5 +1,5 @@
/**
-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
@@ -22,6 +22,14 @@ enum {
__SigSegv,
__SigTerm,
__SigBreak,
+ __SigAlrm,
+ __SigVtAlrm,
+ __SigProf,
+ __SigUsr1,
+ __SigUsr2,
+ __SigWinch,
+ __SigPipe,
+ __SigQuit,
__Sig_Last
};
diff --git a/StdLib/Include/sys/sockio.h b/StdLib/Include/sys/sockio.h
new file mode 100644
index 0000000000..5711ed2014
--- /dev/null
+++ b/StdLib/Include/sys/sockio.h
@@ -0,0 +1,100 @@
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Portions copyright (c) 1999, 2000
+ * Intel Corporation.
+ * 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 the University of
+ * California, Berkeley, Intel Corporation, and its contributors.
+ *
+ * 4. Neither the name of University, Intel Corporation, or their respective
+ * 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, INTEL CORPORATION 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,
+ * INTEL CORPORATION 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.
+ *
+ * @(#)sockio.h 8.1 (Berkeley) 3/28/94
+ * $Id: sockio.h,v 1.1.1.1 2006/05/30 06:12:59 hhzhou Exp $
+ */
+
+#ifndef _SYS_SOCKIO_H_
+#define _SYS_SOCKIO_H_
+
+#include <sys/ioccom.h>
+
+/* Socket ioctl's. */
+#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
+#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
+#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
+#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
+#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
+#define SIOCSPGRP _IOW('s', 8, int) /* set process group */
+#define SIOCGPGRP _IOR('s', 9, int) /* get process group */
+#ifndef _ORG_FREEBSD_
+#define SIOCUPCALL _IOW('s', 10, struct upcall_req)/* register upcall req */
+#endif
+
+#define SIOCADDRT _IOW('r', 10, struct ortentry) /* add route */
+#define SIOCDELRT _IOW('r', 11, struct ortentry) /* delete route */
+#define SIOCGETVIFCNT _IOWR('r', 15, struct sioc_vif_req)/* get vif pkt cnt */
+#define SIOCGETSGCNT _IOWR('r', 16, struct sioc_sg_req) /* get s,g pkt cnt */
+
+#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */
+#define OSIOCGIFADDR _IOWR('i', 13, struct ifreq) /* get ifnet address */
+#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */
+#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */
+#define OSIOCGIFDSTADDR _IOWR('i', 15, struct ifreq) /* get p-p address */
+#define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */
+#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */
+#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */
+#define OSIOCGIFBRDADDR _IOWR('i', 18, struct ifreq) /* get broadcast addr */
+#define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */
+#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */
+#define OSIOCGIFCONF _IOWR('i', 20, struct ifconf) /* get ifnet list */
+#define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */
+#define OSIOCGIFNETMASK _IOWR('i', 21, struct ifreq) /* get net addr mask */
+#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */
+#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */
+#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */
+#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */
+#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */
+#define SIOCAIFADDR _IOW('i', 26, struct ifaliasreq)/* add/chg IF alias */
+
+#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */
+#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */
+#define SIOCGIFMTU _IOWR('i', 51, struct ifreq) /* get IF mtu */
+#define SIOCSIFMTU _IOW('i', 52, struct ifreq) /* set IF mtu */
+#define SIOCGIFPHYS _IOWR('i', 53, struct ifreq) /* get IF wire */
+#define SIOCSIFPHYS _IOW('i', 54, struct ifreq) /* set IF wire */
+#define SIOCSIFMEDIA _IOWR('i', 55, struct ifreq) /* set net media */
+#define SIOCGIFMEDIA _IOWR('i', 56, struct ifmediareq) /* get net media */
+#define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */
+#define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */
+
+#endif /* !_SYS_SOCKIO_H_ */
diff --git a/StdLib/Include/sys/stat.h b/StdLib/Include/sys/stat.h
index 47e993b8be..b87f3f12e6 100644
--- a/StdLib/Include/sys/stat.h
+++ b/StdLib/Include/sys/stat.h
@@ -210,7 +210,7 @@ __BEGIN_DECLS
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);
+ extern int chmod (const char *, mode_t);
#endif // __STAT_SYSCALLS_DECLARED
__END_DECLS
diff --git a/StdLib/Include/sys/sysctl.h b/StdLib/Include/sys/sysctl.h
new file mode 100644
index 0000000000..2382900bae
--- /dev/null
+++ b/StdLib/Include/sys/sysctl.h
@@ -0,0 +1,505 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Karels at Berkeley Software Design, Inc.
+ *
+ * Portions copyright (c) 1999, 2000
+ * Intel Corporation.
+ * 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 the University of
+ * California, Berkeley, Intel Corporation, and its contributors.
+ *
+ * 4. Neither the name of University, Intel Corporation, or their respective
+ * 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, INTEL CORPORATION 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,
+ * INTEL CORPORATION 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.
+ *
+ * @(#)sysctl.h 8.1 (Berkeley) 6/2/93
+ * $Id: sysctl.h,v 1.1.1.1 2006/05/30 06:13:00 hhzhou Exp $
+ */
+
+#ifndef _SYS_SYSCTL_H_
+#define _SYS_SYSCTL_H_
+
+#include <sys/_posix.h>
+
+/*
+ * Definitions for sysctl call. The sysctl call uses a hierarchical name
+ * for objects that can be examined or modified. The name is expressed as
+ * a sequence of integers. Like a file path name, the meaning of each
+ * component depends on its place in the hierarchy. The top-level and kern
+ * identifiers are defined here, and other identifiers are defined in the
+ * respective subsystem header files.
+ */
+
+#define CTL_MAXNAME 12 /* largest number of components supported */
+
+/*
+ * Each subsystem defined by sysctl defines a list of variables
+ * for that subsystem. Each name is either a node with further
+ * levels defined below it, or it is a leaf of some particular
+ * type given below. Each sysctl level defines a set of name/type
+ * pairs to be used by sysctl(1) in manipulating the subsystem.
+ */
+struct ctlname {
+ char *ctl_name; /* subsystem name */
+ int ctl_type; /* type of name */
+};
+
+#define CTLTYPE 0xf /* Mask for the type */
+#define CTLTYPE_NODE 1 /* name is a node */
+#define CTLTYPE_INT 2 /* name describes an integer */
+#define CTLTYPE_STRING 3 /* name describes a string */
+#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
+#define CTLTYPE_OPAQUE 5 /* name describes a structure */
+#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */
+
+#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
+#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
+#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
+#define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */
+#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
+#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
+
+/*
+ * USE THIS instead of a hardwired number from the categories below
+ * to get dynamically assigned sysctl entries using the linker-set
+ * technology. This is the way nearly all new sysctl variables should
+ * be implemented.
+ * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
+ */
+#define OID_AUTO (-1)
+
+#ifdef KERNEL
+#define SYSCTL_HANDLER_ARGS (struct sysctl_oid *oidp, void *arg1, int arg2, \
+ struct sysctl_req *req)
+
+/*
+ * This describes the access space for a sysctl request. This is needed
+ * so that we can use the interface from the kernel or from user-space.
+ */
+struct sysctl_req {
+ struct proc *p;
+ int lock;
+ void *oldptr;
+ size_t oldlen;
+ size_t oldidx;
+ int (*oldfunc)(struct sysctl_req *, const void *, size_t);
+ void *newptr;
+ size_t newlen;
+ size_t newidx;
+ int (*newfunc)(struct sysctl_req *, void *, size_t);
+};
+
+#ifndef _ORG_FREEBSD_
+#include <sys/ioccom.h>
+/*
+ * Pseudo sysctl call through ioctl(2) interface
+ */
+#define IOCSYSCTL _IOWR('X', 0, struct sysctl_req)
+
+struct pseudo_sysctl {
+ int *name;
+ u_int namelen;
+ struct sysctl_req req;
+};
+
+#endif
+
+/*
+ * This describes one "oid" in the MIB tree. Potentially more nodes can
+ * be hidden behind it, expanded by the handler.
+ */
+struct sysctl_oid {
+ int oid_number;
+ int oid_kind;
+ void *oid_arg1;
+ int oid_arg2;
+ const char *oid_name;
+ int (*oid_handler) SYSCTL_HANDLER_ARGS;
+ const char *oid_fmt;
+};
+
+#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
+#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
+
+int sysctl_handle_int SYSCTL_HANDLER_ARGS;
+int sysctl_handle_long SYSCTL_HANDLER_ARGS;
+int sysctl_handle_intptr SYSCTL_HANDLER_ARGS;
+int sysctl_handle_string SYSCTL_HANDLER_ARGS;
+int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
+
+#ifdef _ORG_FREEBSD_
+/* This constructs a "raw" MIB oid. */
+#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
+ static struct sysctl_oid sysctl__##parent##_##name = { \
+ nbr, kind, a1, a2, #name, handler, fmt }; \
+ DATA_SET(sysctl_##parent, sysctl__##parent##_##name)
+
+/* This constructs a node from which other oids can hang. */
+#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \
+ extern struct linker_set sysctl_##parent##_##name; \
+ SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|access, \
+ (void*)&sysctl_##parent##_##name, 0, handler, "N", descr); \
+ DATA_SET(sysctl_##parent##_##name, sysctl__##parent##_##name)
+#else
+#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr)
+#define SYSCTL_NODE(parent, nbr, name, access, handler, descr)
+#endif
+
+/* Oid for a string. len can be 0 to indicate '\0' termination. */
+#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \
+ SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|access, \
+ arg, len, sysctl_handle_string, "A", descr)
+
+/* Oid for an int. If ptr is NULL, val is returned. */
+#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
+ SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
+ ptr, val, sysctl_handle_int, "I", descr)
+
+/* Oid for a long. The pointer must be non NULL. */
+#define SYSCTL_LONG(parent, nbr, name, access, ptr, descr) \
+ SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
+ ptr, 0, sysctl_handle_long, "L", descr)
+
+/* Oid for an opaque object. Specified by a pointer and a length. */
+#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
+ SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
+ ptr, len, sysctl_handle_opaque, fmt, descr)
+
+/* Oid for a struct. Specified by a pointer and a type. */
+#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \
+ SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
+ ptr, sizeof(struct type), sysctl_handle_opaque, \
+ "S," #type, descr)
+
+/* Oid for a procedure. Specified by a pointer and an arg. */
+#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
+ SYSCTL_OID(parent, nbr, name, access, \
+ ptr, arg, handler, fmt, descr)
+#endif /* KERNEL */
+
+/*
+ * Top-level identifiers
+ */
+#define CTL_UNSPEC 0 /* unused */
+#define CTL_KERN 1 /* "high kernel": proc, limits */
+#define CTL_VM 2 /* virtual memory */
+#define CTL_VFS 3 /* file system, mount type is next */
+#define CTL_NET 4 /* network, see socket.h */
+#define CTL_DEBUG 5 /* debugging parameters */
+#define CTL_HW 6 /* generic cpu/io */
+#define CTL_MACHDEP 7 /* machine dependent */
+#define CTL_USER 8 /* user-level */
+#define CTL_P1003_1B 9 /* POSIX 1003.1B */
+#define CTL_MAXID 10 /* number of valid top-level ids */
+
+#define CTL_NAMES { \
+ { 0, 0 }, \
+ { "kern", CTLTYPE_NODE }, \
+ { "vm", CTLTYPE_NODE }, \
+ { "vfs", CTLTYPE_NODE }, \
+ { "net", CTLTYPE_NODE }, \
+ { "debug", CTLTYPE_NODE }, \
+ { "hw", CTLTYPE_NODE }, \
+ { "machdep", CTLTYPE_NODE }, \
+ { "user", CTLTYPE_NODE }, \
+ { "p1003_1b", CTLTYPE_NODE }, \
+}
+
+/*
+ * CTL_KERN identifiers
+ */
+#define KERN_OSTYPE 1 /* string: system version */
+#define KERN_OSRELEASE 2 /* string: system release */
+#define KERN_OSREV 3 /* int: system revision */
+#define KERN_VERSION 4 /* string: compile time info */
+#define KERN_MAXVNODES 5 /* int: max vnodes */
+#define KERN_MAXPROC 6 /* int: max processes */
+#define KERN_MAXFILES 7 /* int: max open files */
+#define KERN_ARGMAX 8 /* int: max arguments to exec */
+#define KERN_SECURELVL 9 /* int: system security level */
+#define KERN_HOSTNAME 10 /* string: hostname */
+#define KERN_HOSTID 11 /* int: host identifier */
+#define KERN_CLOCKRATE 12 /* struct: struct clockrate */
+#define KERN_VNODE 13 /* struct: vnode structures */
+#define KERN_PROC 14 /* struct: process entries */
+#define KERN_FILE 15 /* struct: file entries */
+#define KERN_PROF 16 /* node: kernel profiling info */
+#define KERN_POSIX1 17 /* int: POSIX.1 version */
+#define KERN_NGROUPS 18 /* int: # of supplemental group ids */
+#define KERN_JOB_CONTROL 19 /* int: is job control available */
+#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
+#define KERN_BOOTTIME 21 /* struct: time kernel was booted */
+#define KERN_NISDOMAINNAME 22 /* string: YP domain name */
+#define KERN_UPDATEINTERVAL 23 /* int: update process sleep time */
+#define KERN_OSRELDATE 24 /* int: OS release date */
+#define KERN_NTP_PLL 25 /* node: NTP PLL control */
+#define KERN_BOOTFILE 26 /* string: name of booted kernel */
+#define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */
+#define KERN_MAXPROCPERUID 28 /* int: max processes per uid */
+#define KERN_DUMPDEV 29 /* dev_t: device to dump on */
+#define KERN_IPC 30 /* node: anything related to IPC */
+#define KERN_DUMMY 31 /* unused */
+#define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */
+#define KERN_USRSTACK 33 /* int: address of USRSTACK */
+#define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */
+#define KERN_MAXID 35 /* number of valid kern ids */
+
+#define CTL_KERN_NAMES { \
+ { 0, 0 }, \
+ { "ostype", CTLTYPE_STRING }, \
+ { "osrelease", CTLTYPE_STRING }, \
+ { "osrevision", CTLTYPE_INT }, \
+ { "version", CTLTYPE_STRING }, \
+ { "maxvnodes", CTLTYPE_INT }, \
+ { "maxproc", CTLTYPE_INT }, \
+ { "maxfiles", CTLTYPE_INT }, \
+ { "argmax", CTLTYPE_INT }, \
+ { "securelevel", CTLTYPE_INT }, \
+ { "hostname", CTLTYPE_STRING }, \
+ { "hostid", CTLTYPE_INT }, \
+ { "clockrate", CTLTYPE_STRUCT }, \
+ { "vnode", CTLTYPE_STRUCT }, \
+ { "proc", CTLTYPE_STRUCT }, \
+ { "file", CTLTYPE_STRUCT }, \
+ { "profiling", CTLTYPE_NODE }, \
+ { "posix1version", CTLTYPE_INT }, \
+ { "ngroups", CTLTYPE_INT }, \
+ { "job_control", CTLTYPE_INT }, \
+ { "saved_ids", CTLTYPE_INT }, \
+ { "boottime", CTLTYPE_STRUCT }, \
+ { "nisdomainname", CTLTYPE_STRING }, \
+ { "update", CTLTYPE_INT }, \
+ { "osreldate", CTLTYPE_INT }, \
+ { "ntp_pll", CTLTYPE_NODE }, \
+ { "bootfile", CTLTYPE_STRING }, \
+ { "maxfilesperproc", CTLTYPE_INT }, \
+ { "maxprocperuid", CTLTYPE_INT }, \
+ { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \
+ { "ipc", CTLTYPE_NODE }, \
+ { "dummy", CTLTYPE_INT }, \
+ { "ps_strings", CTLTYPE_INT }, \
+ { "usrstack", CTLTYPE_INT }, \
+ { "logsigexit", CTLTYPE_INT }, \
+}
+
+/*
+ * CTL_VFS identifiers
+ */
+#define CTL_VFS_NAMES { \
+ { "vfsconf", CTLTYPE_STRUCT }, \
+}
+
+/*
+ * KERN_PROC subtypes
+ */
+#define KERN_PROC_ALL 0 /* everything */
+#define KERN_PROC_PID 1 /* by process id */
+#define KERN_PROC_PGRP 2 /* by process group id */
+#define KERN_PROC_SESSION 3 /* by session of pid */
+#define KERN_PROC_TTY 4 /* by controlling tty */
+#define KERN_PROC_UID 5 /* by effective uid */
+#define KERN_PROC_RUID 6 /* by real uid */
+
+/*
+ * KERN_IPC identifiers
+ */
+#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */
+#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */
+#define KIPC_SOMAXCONN 3 /* int: max length of connection q */
+#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */
+#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */
+#define KIPC_MAX_HDR 6 /* int: max total length of headers */
+#define KIPC_MAX_DATALEN 7 /* int: max length of data? */
+#define KIPC_MBSTAT 8 /* struct: mbuf usage statistics */
+#define KIPC_NMBCLUSTERS 9 /* int: maximum mbuf clusters */
+
+/*
+ * CTL_HW identifiers
+ */
+#define HW_MACHINE 1 /* string: machine class */
+#define HW_MODEL 2 /* string: specific machine model */
+#define HW_NCPU 3 /* int: number of cpus */
+#define HW_BYTEORDER 4 /* int: machine byte order */
+#define HW_PHYSMEM 5 /* int: total memory */
+#define HW_USERMEM 6 /* int: non-kernel memory */
+#define HW_PAGESIZE 7 /* int: software page size */
+#define HW_DISKNAMES 8 /* strings: disk drive names */
+#define HW_DISKSTATS 9 /* struct: diskstats[] */
+#define HW_FLOATINGPT 10 /* int: has HW floating point? */
+#define HW_MACHINE_ARCH 11 /* string: machine architecture */
+#define HW_MAXID 12 /* number of valid hw ids */
+
+#define CTL_HW_NAMES { \
+ { 0, 0 }, \
+ { "machine", CTLTYPE_STRING }, \
+ { "model", CTLTYPE_STRING }, \
+ { "ncpu", CTLTYPE_INT }, \
+ { "byteorder", CTLTYPE_INT }, \
+ { "physmem", CTLTYPE_INT }, \
+ { "usermem", CTLTYPE_INT }, \
+ { "pagesize", CTLTYPE_INT }, \
+ { "disknames", CTLTYPE_STRUCT }, \
+ { "diskstats", CTLTYPE_STRUCT }, \
+ { "floatingpoint", CTLTYPE_INT }, \
+}
+
+/*
+ * CTL_USER definitions
+ */
+#define USER_CS_PATH 1 /* string: _CS_PATH */
+#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */
+#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */
+#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */
+#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */
+#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */
+#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */
+#define USER_LINE_MAX 8 /* int: LINE_MAX */
+#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */
+#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */
+#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */
+#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */
+#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */
+#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */
+#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */
+#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */
+#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */
+#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
+#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
+#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */
+#define USER_MAXID 21 /* number of valid user ids */
+
+#define CTL_USER_NAMES { \
+ { 0, 0 }, \
+ { "cs_path", CTLTYPE_STRING }, \
+ { "bc_base_max", CTLTYPE_INT }, \
+ { "bc_dim_max", CTLTYPE_INT }, \
+ { "bc_scale_max", CTLTYPE_INT }, \
+ { "bc_string_max", CTLTYPE_INT }, \
+ { "coll_weights_max", CTLTYPE_INT }, \
+ { "expr_nest_max", CTLTYPE_INT }, \
+ { "line_max", CTLTYPE_INT }, \
+ { "re_dup_max", CTLTYPE_INT }, \
+ { "posix2_version", CTLTYPE_INT }, \
+ { "posix2_c_bind", CTLTYPE_INT }, \
+ { "posix2_c_dev", CTLTYPE_INT }, \
+ { "posix2_char_term", CTLTYPE_INT }, \
+ { "posix2_fort_dev", CTLTYPE_INT }, \
+ { "posix2_fort_run", CTLTYPE_INT }, \
+ { "posix2_localedef", CTLTYPE_INT }, \
+ { "posix2_sw_dev", CTLTYPE_INT }, \
+ { "posix2_upe", CTLTYPE_INT }, \
+ { "stream_max", CTLTYPE_INT }, \
+ { "tzname_max", CTLTYPE_INT }, \
+}
+
+#define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */
+#define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */
+#define CTL_P1003_1B_MEMLOCK 3 /* boolean */
+#define CTL_P1003_1B_MEMLOCK_RANGE 4 /* boolean */
+#define CTL_P1003_1B_MEMORY_PROTECTION 5 /* boolean */
+#define CTL_P1003_1B_MESSAGE_PASSING 6 /* boolean */
+#define CTL_P1003_1B_PRIORITIZED_IO 7 /* boolean */
+#define CTL_P1003_1B_PRIORITY_SCHEDULING 8 /* boolean */
+#define CTL_P1003_1B_REALTIME_SIGNALS 9 /* boolean */
+#define CTL_P1003_1B_SEMAPHORES 10 /* boolean */
+#define CTL_P1003_1B_FSYNC 11 /* boolean */
+#define CTL_P1003_1B_SHARED_MEMORY_OBJECTS 12 /* boolean */
+#define CTL_P1003_1B_SYNCHRONIZED_IO 13 /* boolean */
+#define CTL_P1003_1B_TIMERS 14 /* boolean */
+#define CTL_P1003_1B_AIO_LISTIO_MAX 15 /* int */
+#define CTL_P1003_1B_AIO_MAX 16 /* int */
+#define CTL_P1003_1B_AIO_PRIO_DELTA_MAX 17 /* int */
+#define CTL_P1003_1B_DELAYTIMER_MAX 18 /* int */
+#define CTL_P1003_1B_MQ_OPEN_MAX 19 /* int */
+#define CTL_P1003_1B_PAGESIZE 20 /* int */
+#define CTL_P1003_1B_RTSIG_MAX 21 /* int */
+#define CTL_P1003_1B_SEM_NSEMS_MAX 22 /* int */
+#define CTL_P1003_1B_SEM_VALUE_MAX 23 /* int */
+#define CTL_P1003_1B_SIGQUEUE_MAX 24 /* int */
+#define CTL_P1003_1B_TIMER_MAX 25 /* int */
+
+#define CTL_P1003_1B_MAXID 26
+
+#define CTL_P1003_1B_NAMES { \
+ { 0, 0 }, \
+ { "asynchronous_io", CTLTYPE_INT }, \
+ { "mapped_files", CTLTYPE_INT }, \
+ { "memlock", CTLTYPE_INT }, \
+ { "memlock_range", CTLTYPE_INT }, \
+ { "memory_protection", CTLTYPE_INT }, \
+ { "message_passing", CTLTYPE_INT }, \
+ { "prioritized_io", CTLTYPE_INT }, \
+ { "priority_scheduling", CTLTYPE_INT }, \
+ { "realtime_signals", CTLTYPE_INT }, \
+ { "semaphores", CTLTYPE_INT }, \
+ { "fsync", CTLTYPE_INT }, \
+ { "shared_memory_objects", CTLTYPE_INT }, \
+ { "synchronized_io", CTLTYPE_INT }, \
+ { "timers", CTLTYPE_INT }, \
+ { "aio_listio_max", CTLTYPE_INT }, \
+ { "aio_max", CTLTYPE_INT }, \
+ { "aio_prio_delta_max", CTLTYPE_INT }, \
+ { "delaytimer_max", CTLTYPE_INT }, \
+ { "mq_open_max", CTLTYPE_INT }, \
+ { "pagesize", CTLTYPE_INT }, \
+ { "rtsig_max", CTLTYPE_INT }, \
+ { "nsems_max", CTLTYPE_INT }, \
+ { "sem_value_max", CTLTYPE_INT }, \
+ { "sigqueue_max", CTLTYPE_INT }, \
+ { "timer_max", CTLTYPE_INT }, \
+}
+
+#ifdef KERNEL
+
+extern char machine[];
+extern char osrelease[];
+extern char ostype[];
+
+int kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old,
+ size_t *oldlenp, void *new, size_t newlen,
+ size_t *retval);
+void sysctl_order_all(void);
+int userland_sysctl(struct proc *p, int *name, u_int namelen, void *old,
+ size_t *oldlenp, int inkernel, void *new, size_t newlen,
+ size_t *retval);
+
+#else /* !KERNEL */
+#include <sys/EfiCdefs.h>
+
+__BEGIN_DECLS
+int sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
+int sysctlbyname __P((const char *, void *, size_t *, void *, size_t));
+__END_DECLS
+#endif /* KERNEL */
+
+#endif /* !_SYS_SYSCTL_H_ */
diff --git a/StdLib/Include/sys/syslimits.h b/StdLib/Include/sys/syslimits.h
index 80b18c3917..d308387f2a 100644
--- a/StdLib/Include/sys/syslimits.h
+++ b/StdLib/Include/sys/syslimits.h
@@ -37,7 +37,7 @@
#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 */
+#define ARGC_MAX (64) /* Maximum value for argc */
#ifndef CHILD_MAX
#define CHILD_MAX 128 /* max simultaneous processes */
diff --git a/StdLib/Include/sys/time.h b/StdLib/Include/sys/time.h
index 4b17317200..b8957f4c41 100644
--- a/StdLib/Include/sys/time.h
+++ b/StdLib/Include/sys/time.h
@@ -71,6 +71,7 @@ struct timespec {
(ts)->tv_sec = (tv)->tv_sec; \
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
} while (/*CONSTCOND*/0)
+
#define TIMESPEC_TO_TIMEVAL(tv, ts) do { \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
@@ -79,10 +80,12 @@ struct timespec {
/* Operations on timevals. */
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+
#define timercmp(tvp, uvp, cmp) \
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
+
#define timeradd(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
@@ -92,6 +95,7 @@ struct timespec {
(vvp)->tv_usec -= 1000000; \
} \
} while (/* CONSTCOND */ 0)
+
#define timersub(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
@@ -105,10 +109,12 @@ struct timespec {
/* Operations on timespecs. */
#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
+
#define timespeccmp(tsp, usp, cmp) \
(((tsp)->tv_sec == (usp)->tv_sec) ? \
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
((tsp)->tv_sec cmp (usp)->tv_sec))
+
#define timespecadd(tsp, usp, vsp) \
do { \
(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
@@ -118,6 +124,7 @@ struct timespec {
(vsp)->tv_nsec -= 1000000000L; \
} \
} while (/* CONSTCOND */ 0)
+
#define timespecsub(tsp, usp, vsp) \
do { \
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
@@ -182,5 +189,8 @@ __END_DECLS
/* BSD compatibility functions */
int gettimeofday (struct timeval *tp, void *ignore);
+/* POSIX compatibility functions */
+int getitimer (int which, struct itimerval *value);
+int setitimer (int which, const struct itimerval *value, struct itimerval *ovalue);
#endif /* !_SYS_TIME_H_ */
diff --git a/StdLib/Include/sys/unistd.h b/StdLib/Include/sys/unistd.h
index 0e7158c7c8..a63d88df55 100644
--- a/StdLib/Include/sys/unistd.h
+++ b/StdLib/Include/sys/unistd.h
@@ -37,7 +37,7 @@
#include <sys/featuretest.h>
/* compile-time symbolic constants */
-#define _POSIX_JOB_CONTROL /* implementation supports job control */
+//#define _POSIX_JOB_CONTROL /* implementation supports job control */
/*
* According to POSIX 1003.1:
@@ -62,43 +62,42 @@
/* 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
+//#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
+//#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
@@ -115,7 +114,6 @@
#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
diff --git a/StdLib/Include/sys/wait.h b/StdLib/Include/sys/wait.h
new file mode 100644
index 0000000000..64200aa999
--- /dev/null
+++ b/StdLib/Include/sys/wait.h
@@ -0,0 +1,170 @@
+/* $NetBSD: wait.h,v 1.24 2005/12/11 12:25:21 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)wait.h 8.2 (Berkeley) 7/10/94
+ */
+#ifndef _SYS_WAIT_H_
+#define _SYS_WAIT_H_
+
+#include <sys/featuretest.h>
+#include <sys/types.h>
+
+/*
+ * This file holds definitions relevent to the wait4 system call
+ * and the alternate interfaces that use it (wait, wait3, waitpid).
+ */
+
+/*
+ * Macros to test the exit status returned by wait
+ * and extract the relevant values.
+ */
+#define _W_INT(w) (*(int *)(void *)&(w)) /* convert union wait to int */
+
+#define _WSTATUS(x) (_W_INT(x) & 0177)
+#define _WSTOPPED 0177 /* _WSTATUS if process is stopped */
+#define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED)
+#define WSTOPSIG(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff)
+#define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
+#define WTERMSIG(x) (_WSTATUS(x))
+#define WIFEXITED(x) (_WSTATUS(x) == 0)
+#define WEXITSTATUS(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff)
+#define WCOREFLAG 0200
+#define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
+
+#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
+#define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
+
+/*
+ * Option bits for the third argument of wait4. WNOHANG causes the
+ * wait to not hang if there are no stopped or terminated processes, rather
+ * returning an error indication in this case (pid==0). WUNTRACED
+ * indicates that the caller should receive status about untraced children
+ * which stop due to signals. If children are stopped and a wait without
+ * this option is done, it is as though they were still running... nothing
+ * about them is returned.
+ */
+#define WNOHANG 0x00000001 /* don't hang in wait */
+#define WUNTRACED 0x00000002 /* tell about stopped,
+ untraced children */
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+#define WALTSIG 0x00000004 /* wait for processes that exit
+ with an alternate signal (i.e.
+ not SIGCHLD) */
+#define WALLSIG 0x00000008 /* wait for processes that exit
+ with any signal, i.e. SIGCHLD
+ and alternates */
+
+/*
+ * These are the Linux names of some of the above flags, for compatibility
+ * with Linux's clone(2) API.
+ */
+#define __WCLONE WALTSIG
+#define __WALL WALLSIG
+
+/*
+ * These bits are used in order to support SVR4 (etc) functionality
+ * without replicating sys_wait4 5 times.
+ */
+#define WNOWAIT 0x00010000 /* Don't mark child 'P_WAITED' */
+#define WNOZOMBIE 0x00020000 /* Ignore zombies */
+#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
+
+/* POSIX extensions and 4.2/4.3 compatibility: */
+
+/*
+ * Tokens for special values of the "pid" parameter to wait4.
+ */
+#define WAIT_ANY (-1) /* any process */
+#define WAIT_MYPGRP 0 /* any process in my process group */
+
+/*
+ * Deprecated:
+ * Structure of the information in the status word returned by wait4.
+ * If w_stopval==WSTOPPED, then the second structure describes
+ * the information returned, else the first.
+ */
+union wait {
+ int w_status; /* used in syscall */
+ /*
+ * Terminated process status.
+ */
+ struct {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ unsigned int w_Termsig:7, /* termination signal */
+ w_Coredump:1, /* core dump indicator */
+ w_Retcode:8, /* exit code if w_termsig==0 */
+ w_Filler:16; /* upper bits filler */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ unsigned int w_Filler:16, /* upper bits filler */
+ w_Retcode:8, /* exit code if w_termsig==0 */
+ w_Coredump:1, /* core dump indicator */
+ w_Termsig:7; /* termination signal */
+#endif
+ } w_T;
+ /*
+ * Stopped process status. Returned
+ * only for traced children unless requested
+ * with the WUNTRACED option bit.
+ */
+ struct {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ unsigned int w_Stopval:8, /* == W_STOPPED if stopped */
+ w_Stopsig:8, /* signal that stopped us */
+ w_Filler:16; /* upper bits filler */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ unsigned int w_Filler:16, /* upper bits filler */
+ w_Stopsig:8, /* signal that stopped us */
+ w_Stopval:8; /* == W_STOPPED if stopped */
+#endif
+ } w_S;
+};
+#define w_termsig w_T.w_Termsig
+#define w_coredump w_T.w_Coredump
+#define w_retcode w_T.w_Retcode
+#define w_stopval w_S.w_Stopval
+#define w_stopsig w_S.w_Stopsig
+
+#define WSTOPPED _WSTOPPED
+
+__BEGIN_DECLS
+pid_t wait(int *);
+
+#if 0 /* Normally declared here but not implemented for UEFI. */
+struct rusage; /* forward declaration */
+
+pid_t waitpid(pid_t, int *, int);
+pid_t wait3(int *, int, struct rusage *);
+pid_t wait4(pid_t, int *, int, struct rusage *);
+#endif
+__END_DECLS
+
+#endif /* !_SYS_WAIT_H_ */