summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordufault <dufault@FreeBSD.org>1998-03-04 10:27:00 +0000
committerdufault <dufault@FreeBSD.org>1998-03-04 10:27:00 +0000
commite28788f2a420e093ade000eeb0ba96634af0e177 (patch)
treeed01e5e208cef9b87e2f87e523c53a779b5e241b
parent8893ec06df8a340a0fd561e62ae140190cf3c832 (diff)
downloadFreeBSD-src-e28788f2a420e093ade000eeb0ba96634af0e177.zip
FreeBSD-src-e28788f2a420e093ade000eeb0ba96634af0e177.tar.gz
Reviewed by: msmith, bde long ago
POSIX.4 headers and sysctl variables. Nothing should change unless POSIX4 is defined or _POSIX_VERSION is set to 199309.
-rw-r--r--etc/mtree/BSD.include.dist4
-rw-r--r--include/Makefile17
-rw-r--r--include/limits.h18
-rw-r--r--include/signal.h5
-rw-r--r--lib/libc/gen/sysconf.c107
-rw-r--r--share/man/man9/Makefile4
-rw-r--r--share/man/man9/posix4.9119
-rw-r--r--sys/conf/files2
-rw-r--r--sys/conf/options5
-rw-r--r--sys/kern/ksched.c252
-rw-r--r--sys/kern/posix4_mib.c77
-rw-r--r--sys/posix4/aio.h107
-rw-r--r--sys/posix4/ksched.c252
-rw-r--r--sys/posix4/mqueue.h71
-rw-r--r--sys/posix4/posix4.h300
-rw-r--r--sys/posix4/posix4_mib.c77
-rw-r--r--sys/posix4/sched.h74
-rw-r--r--sys/posix4/semaphore.h61
-rw-r--r--sys/sys/mman.h26
-rw-r--r--sys/sys/posix4.h300
-rw-r--r--sys/sys/proc.h3
-rw-r--r--sys/sys/rtprio.h21
-rw-r--r--sys/sys/semaphore.h61
-rw-r--r--sys/sys/sysctl.h12
-rw-r--r--sys/sys/time.h8
-rw-r--r--sys/sys/timetc.h8
-rw-r--r--sys/sys/unistd.h87
-rw-r--r--sys/vm/vm_glue.c4
28 files changed, 2062 insertions, 20 deletions
diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist
index bf7bc09..479136c 100644
--- a/etc/mtree/BSD.include.dist
+++ b/etc/mtree/BSD.include.dist
@@ -1,4 +1,4 @@
-# $Id: BSD.include.dist,v 1.14 1997/09/28 09:20:48 markm Exp $
+# $Id: BSD.include.dist,v 1.15 1998/01/17 15:52:32 bde Exp $
#
/set type=dir uname=bin gname=bin mode=0755
@@ -35,6 +35,8 @@
..
pccard
..
+ posix4
+ ..
protocols
..
readline
diff --git a/include/Makefile b/include/Makefile
index 6ce2fe1..9fe38c7 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -1,5 +1,5 @@
# From: @(#)Makefile 8.2 (Berkeley) 1/4/94
-# $Id: Makefile,v 1.71 1998/02/11 04:57:24 jdp Exp $
+# $Id: Makefile,v 1.72 1998/02/13 03:10:26 bde Exp $
#
# Doing a make install builds /usr/include
#
@@ -14,7 +14,8 @@ FILES= a.out.h ar.h assert.h bitstring.h ctype.h db.h dirent.h disktab.h \
dlfcn.h elf.h err.h fnmatch.h fstab.h \
fts.h glob.h grp.h strhash.h histedit.h \
kvm.h limits.h link.h locale.h malloc.h memory.h mpool.h \
- ndbm.h netdb.h nl_types.h nlist.h paths.h pthread.h pthread_np.h pwd.h \
+ ndbm.h netdb.h nl_types.h nlist.h \
+ paths.h pthread.h pthread_np.h pwd.h \
ranlib.h regex.h regexp.h resolv.h rune.h runetype.h setjmp.h sgtty.h \
signal.h stab.h stddef.h stdio.h stdlib.h string.h stringlist.h \
strings.h struct.h sysexits.h tar.h time.h timers.h ttyent.h unistd.h \
@@ -32,9 +33,15 @@ RPCFILES= auth.h auth_unix.h clnt.h pmap_clnt.h pmap_prot.h pmap_rmt.h \
auth_des.h des.h des_crypt.h
MFILES= float.h floatingpoint.h stdarg.h varargs.h
+
+# posix4/aio.h conflicts with dysons and isn't installed:
+PFILES= mqueue.h posix4.h sched.h semaphore.h \
+ # aio.h
+
LFILES= errno.h fcntl.h poll.h syslog.h termios.h
-LDIRS= msdosfs net netns netatalk netinet netipx netkey nfs pccard sys vm \
+LDIRS= msdosfs net netns netatalk netinet netipx netkey nfs \
+ pccard posix4 sys vm \
# netccitt netiso
LNOHEADERDIRS= isofs ufs
@@ -87,6 +94,10 @@ beforeinstall: ${SHARED}
.for i in ${MFILES}
ln -sf machine/$i ${DESTDIR}/usr/include/$i
.endfor
+.for i in ${PFILES}
+ ln -sf posix4/$i ${DESTDIR}/usr/include/$i
+.endfor
+
copies:
.for i in ${LDIRS} ${LNOHEADERDIRS} machine
diff --git a/include/limits.h b/include/limits.h
index 2e2b293..df120e6 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)limits.h 8.2 (Berkeley) 1/4/94
- * $Id$
+ * $Id: limits.h,v 1.5 1997/12/27 22:56:41 steve Exp $
*/
#ifndef _LIMITS_H_
@@ -60,6 +60,22 @@
#define _POSIX2_EXPR_NEST_MAX 32
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX 255
+
+#ifdef POSIX4_VISIBLE
+
+#define _POSIX_AIO_LISTIO_MAX 2
+#define _POSIX_AIO_MAX 1
+#define _POSIX_DELAYTIMER_MAX 32
+#define _POSIX_MQ_OPEN_MAX 8
+#define _POSIX_MQ_PRIO_MAX 32
+#define _POSIX_RTSIG_MAX 8
+#define _POSIX_SEM_NSEMS_MAX 256
+#define _POSIX_SEM_VALUE_MAX 32767
+#define _POSIX_SIGQUEUE_MAX 32
+#define _POSIX_TIMER_MAX 32
+
+#endif
+
#endif /* !_ANSI_SOURCE */
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
diff --git a/include/signal.h b/include/signal.h
index aea7322..dd6dc8a 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -63,6 +63,11 @@ int signanosleep __P((const struct timespec *, struct timespec *,
int sigpending __P((sigset_t *));
int sigprocmask __P((int, const sigset_t *, sigset_t *));
int sigsuspend __P((const sigset_t *));
+#ifdef POSIX4_VISIBLE
+int sigqueue __P((_BSD_PID_T_, int, const union sigval));
+int sigtimedwait __P((const sig_set_t *, siginfo_t *));
+int sigwaitinfo __P((const sig_set_t *, siginfo_t *));
+#endif
#ifndef _POSIX_SOURCE
int killpg __P((_BSD_PID_T_, int));
int sigaltstack __P((const struct sigaltstack *, struct sigaltstack *));
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c
index 16a3efa..df67581 100644
--- a/lib/libc/gen/sysconf.c
+++ b/lib/libc/gen/sysconf.c
@@ -174,6 +174,113 @@ sysconf(name)
case _SC_2_UPE:
mib[0] = CTL_USER;
mib[1] = USER_POSIX2_UPE;
+ goto yesno;
+
+#ifdef POSIX4
+ /* POSIX.4 */
+
+ case _SC_ASYNCHRONOUS_IO:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_ASYNCHRONOUS_IO;
+ goto yesno;
+ case _SC_MAPPED_FILES:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_MAPPED_FILES;
+ goto yesno;
+ case _SC_MEMLOCK:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_MEMLOCK;
+ goto yesno;
+ case _SC_MEMLOCK_RANGE:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_MEMLOCK_RANGE;
+ goto yesno;
+ case _SC_MEMORY_PROTECTION:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_MEMORY_PROTECTION;
+ goto yesno;
+ case _SC_MESSAGE_PASSING:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_MESSAGE_PASSING;
+ goto yesno;
+ case _SC_PRIORITIZED_IO:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_PRIORITIZED_IO;
+ goto yesno;
+ case _SC_PRIORITY_SCHEDULING:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_PRIORITY_SCHEDULING;
+ goto yesno;
+ case _SC_REALTIME_SIGNALS:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_REALTIME_SIGNALS;
+ goto yesno;
+ case _SC_SEMAPHORES:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_SEMAPHORES;
+ goto yesno;
+ case _SC_FSYNC:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_FSYNC;
+ goto yesno;
+ case _SC_SHARED_MEMORY_OBJECTS:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_SHARED_MEMORY_OBJECTS;
+ goto yesno;
+ case _SC_SYNCHRONIZED_IO:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_SYNCHRONIZED_IO;
+ goto yesno;
+ case _SC_TIMERS:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_TIMERS;
+ goto yesno;
+ case _SC_AIO_LISTIO_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_AIO_LISTIO_MAX;
+ goto yesno;
+ case _SC_AIO_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_AIO_MAX;
+ goto yesno;
+ case _SC_AIO_PRIO_DELTA_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_AIO_PRIO_DELTA_MAX;
+ goto yesno;
+ case _SC_DELAYTIMER_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_DELAYTIMER_MAX;
+ goto yesno;
+ case _SC_MQ_OPEN_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_MQ_OPEN_MAX;
+ goto yesno;
+ case _SC_PAGESIZE:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_PAGESIZE;
+ goto yesno;
+ case _SC_RTSIG_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_RTSIG_MAX;
+ goto yesno;
+ case _SC_SEM_NSEMS_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_SEM_NSEMS_MAX;
+ goto yesno;
+ case _SC_SEM_VALUE_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_SEM_VALUE_MAX;
+ goto yesno;
+ case _SC_SIGQUEUE_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_SIGQUEUE_MAX;
+ goto yesno;
+ case _SC_TIMER_MAX:
+ mib[0] = CTL_POSIX4;
+ mib[1] = CTL_POSIX4_TIMER_MAX;
+ goto yesno;
+#endif /* POSIX4 */
+
yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
return (-1);
if (value == 0)
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index 0451f05..5f42ff6 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.33 1998/01/01 10:12:14 bde Exp $
+# $Id: Makefile,v 1.34 1998/01/16 18:49:42 bde Exp $
MAN9= MD5.9 \
VFS.9 VFS_FHTOVP.9 VFS_INIT.9 VFS_MOUNT.9 VFS_QUOTACTL.9 \
@@ -14,7 +14,7 @@ MAN9= MD5.9 \
at_exit.9 at_fork.9 at_shutdown.9 bios.9 boot.9 cd.9 copy.9 \
devfs_add_devswf.9 devfs_link.9 devfs_remove_dev.9 \
fetch.9 ifnet.9 inittodr.9 intro.9 kernacc.9 malloc.9 \
- mi_switch.9 panic.9 physio.9 psignal.9 \
+ mi_switch.9 panic.9 physio.9 posix4.9 psignal.9 \
resettodr.9 rtalloc.9 rtentry.9 scsiconf.9 sd.9 sleep.9 spl.9 st.9 \
store.9 style.9 suser.9 time.9 timeout.9 uio.9 \
vget.9 vnode.9 vput.9 vref.9 vrele.9 vslock.9
diff --git a/share/man/man9/posix4.9 b/share/man/man9/posix4.9
new file mode 100644
index 0000000..e5256b5
--- /dev/null
+++ b/share/man/man9/posix4.9
@@ -0,0 +1,119 @@
+.\" Copyright (c) 1998 HD Associates, Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" 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: posix4.9,v 1.8 1998/01/02 19:22:52 alex Exp $
+.Dd March 1, 1998
+.Dt POSIX.4 9
+.Os FreeBSD 3.0
+.Sh NAME
+.Nm posix4
+.Nd "POSIX.4 extensions"
+.Sh DESCRIPTION
+POSIX.4 adds real time extensions and some commonly used
+Berkeley extensions to POSIX.1
+This section contains information about the the
+POSIX.4 extensions to the system.
+.Sh STATUS
+March 1, 1998 adds the header file changes to 3.0. There should be no
+visible differences as long as _POSIX_VERSION is left at 199009L and
+no one builds kernels with a POSIX4 option.
+.Pp
+If you are working with something defined in POSIX.4 then there is a good
+chance we conflict. If you have the time then set
+_POSIX_VERSION to 199309L in /etc/make.conf and see that your work
+fits with mine.
+.Pp
+Since this only brings in the headers I'm only explaining the feature
+test options.
+.Sh SPECIFYING THE VERSION
+There are three manifest constants that set the version and programming interface
+for POSIX.4.
+.Bd -literal -offset 0i
+_POSIX_VERSION
+.Ed
+specifies the system for which the system is built. The default
+is POSIX.1 and is 199009L. POSIX.4 is 199309L. This defines
+the base features of the operating system.
+.Bd -literal -offset 0i
+_POSIX_SOURCE
+.Ed
+is a macro from POSIX.1 that can
+be defined to specify that only POSIX and ANSI functionality should occur
+in the name space.
+.Bd -literal -offset 0i
+_POSIX_C_SOURCE
+.Ed
+is a macro from POSIX.4 that can be defined to specify that only
+POSIX and ANSI functionality from a specific POSIX version should occur
+in the name space, i.e., if _POSIX_VERSION is 199309L (POSIX.4) but
+_POSIX_C_SOURCE is 199009L (POSIX.1) then only POSIX.1 features should
+appear.
+.Sh PROPERLY HIDING EXTENSIONS
+.Bd -literal -offset 0i
+POSIX4_VISIBLE
+.Ed
+is a test macro that tries to sort out when extensions should be
+visible.
+.Pp
+In normal C program development
+only _POSIX_VERSION is set, permitting BSD extensions to
+appear to the programs. However, when adding new functionality mandated
+by POSIX.4, it
+is important to satisfy the requirements added by the
+new _POSIX_C_SOURCE macro. POSIX4_VISIBLE (not a standard feature test macro)
+is defined in sys/unistd.h when the combination of _POSIX_VERSION,
+_POSIX_SOURCE, and _POSIX_C_SOURCE indicate the extensions are in scope.
+.Pp
+Since for POSIX to work you must include <unistd.h> which ultimately
+sets this up header files can always assume this is visible without
+including anything.
+.Pp
+Some traditional BSD headers (e.g., mmap.h) are now specified in POSIX.4.
+This means that functionality not present in POSIX.4 should now be
+hidden by testing _POSIX_SOURCE or _POSIX_C_SOURCE. The safest thing
+is to hide them when _POSIX_C_SOURCE is defined and less than 199309L.
+Don't bracket the extensions with the POSIX.4 feature test macros.
+For example, don't conditionalize new memory locking flags with
+_POSIX_MEMLOCK. It will be too easy for conflicting implementations
+that don't pay heed to the POSIX.4 flags to sneak into the system.
+.Sh NON STANDARD TEST MACROS
+.Bd -literal -offset 0i
+POSIX4_INCLUDE_MAYBES
+.Ed
+requests that all header files that the POSIX.4 spec says a standard
+header may include should be included. Normally no non-required
+headers are included. Setting this pre-processor definition should
+make any compliant program compile without issues of header file
+inclusion.
+.Bd -literal -offset 0i
+POSIX4
+.Ed
+is a config option and (currently) a request to build POSIX.4 by
+setting the _POSIX_VERSION to 199309L in sys/unistd.h.
+.Sh SEE ALSO
+.Sh HISTORY
+The
+.Nm posix4
+section manual page appeared in
+.Fx 3.0 .
diff --git a/sys/conf/files b/sys/conf/files
index 096a8a2..36d1b23 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -392,6 +392,8 @@ pci/pci_compat.c optional pci
pci/pcisupport.c optional pci
pci/tek390.c optional amd device-driver
pci/wdc_p.c optional wdc device-driver
+posix4/posix4_mib.c optional posix4
+posix4/ksched.c optional posix4
scsi/cd.c optional cd
scsi/ch.c optional ch
scsi/od.c optional od
diff --git a/sys/conf/options b/sys/conf/options
index 9034850..48a5c33 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -1,4 +1,4 @@
-# $Id: options,v 1.62 1998/02/23 07:42:43 dyson Exp $
+# $Id: options,v 1.63 1998/02/27 10:02:37 itojun Exp $
# Format:
# Option name filename
@@ -30,6 +30,9 @@ SYSVSEM opt_sysvipc.h
SYSVSHM opt_sysvipc.h
UCONSOLE
+# POSIX 4.
+POSIX4 opt_posix4.h
+
# Do we want the config file compiled into the kernel?
INCLUDE_CONFIG_FILE opt_config.h
diff --git a/sys/kern/ksched.c b/sys/kern/ksched.c
new file mode 100644
index 0000000..7ff85d6
--- /dev/null
+++ b/sys/kern/ksched.c
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+/* ksched: Soft real time scheduling based on "rtprio".
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/kernel.h>
+#include <machine/cpu.h> /* For need_resched */
+#include <fcntl.h>
+
+#include <sys/posix4.h>
+
+/* ksched: Real-time extension to support POSIX priority scheduling.
+ */
+
+static struct timespec rr_interval;
+
+int ksched_attach(int p4_instance, int fac_code, void **p)
+{
+ rr_interval.tv_sec = 0;
+ rr_interval.tv_nsec = 1000000000L / roundrobin_interval();
+
+ *p = 0;
+
+ return 0;
+}
+
+int ksched_detach(void *p)
+{
+ return 0;
+}
+
+/*
+ * XXX About priorities
+ *
+ * POSIX4 requires that numerically higher priorities be of
+ * higher priority. It also permits sched_setparam to be
+ * implementation defined for SCHED_OTHER. I don't like
+ * the notion of inverted priorites for normal processes when
+ * you can use "setpriority" for that.
+ *
+ * I'm rejecting sched_setparam for SCHED_OTHER with EINVAL.
+ */
+
+/* Macros to convert between the unix (lower numerically is higher priority)
+ * and POSIX4 (higher numerically is higher priority)
+ */
+
+#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
+#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
+
+static inline int
+getscheduler(int *ret, void *hook, struct proc *p)
+{
+ int e = 0;
+
+ switch (p->p_rtprio.type)
+ {
+ case RTP_PRIO_FIFO:
+ *ret = SCHED_FIFO;
+ break;
+
+ case RTP_PRIO_REALTIME:
+ *ret = SCHED_RR;
+ break;
+
+ default:
+ *ret = SCHED_OTHER;
+ break;
+ }
+
+ return e;
+}
+
+int ksched_setparam(int *ret, void *hook,
+ struct proc *p, const struct sched_param *param)
+{
+ int e, policy;
+
+ e = getscheduler(&policy, hook, p);
+
+ if (e == 0)
+ {
+ if (policy == SCHED_OTHER)
+ e = EINVAL;
+ else
+ e = ksched_setscheduler(ret, hook, p, policy, param);
+ }
+
+ return e;
+}
+
+int ksched_getparam(int *ret, void *hook,
+ struct proc *p, struct sched_param *param)
+{
+ if (RTP_PRIO_IS_REALTIME(p->p_rtprio.type))
+ param->sched_priority = rtpprio_to_p4prio(p->p_rtprio.prio);
+
+ return 0;
+}
+
+/*
+ * XXX The priority and scheduler modifications should
+ * be moved into published interfaces in kern/kern_sync.
+ *
+ * The permissions to modify process p were checked in "posix4proc()".
+ *
+ */
+int ksched_setscheduler(int *ret, void *hook,
+ struct proc *p, int policy, const struct sched_param *param)
+{
+ int e = 0;
+ struct rtprio rtp;
+
+ switch(policy)
+ {
+ case SCHED_RR:
+ case SCHED_FIFO:
+
+ if (param->sched_priority >= RTP_PRIO_MIN &&
+ param->sched_priority <= RTP_PRIO_MAX)
+ {
+ rtp.type = (policy == SCHED_FIFO)
+ ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME;
+
+ rtp.prio = p4prio_to_rtpprio(RTP_PRIO_MAX);
+ p->p_rtprio = rtp;
+ (void)resetpriority(p);
+ }
+ else
+ e = EPERM;
+
+
+ break;
+
+ case SCHED_OTHER:
+ {
+ rtp.type = RTP_PRIO_NORMAL;
+ rtp.prio = p4prio_to_rtpprio(RTP_PRIO_MIN);
+ p->p_rtprio = rtp;
+
+ /* XXX Simply revert to whatever we had for last
+ * normal scheduler priorities.
+ * This puts a requirement
+ * on the scheduling code: You must leave the
+ * scheduling info alone.
+ */
+ (void)resetpriority(p);
+ }
+ break;
+ }
+
+ return e;
+}
+
+int ksched_getscheduler(int *ret, void *hook, struct proc *p)
+{
+ return getscheduler(ret, hook, p);
+}
+
+/* ksched_yield: Yield the CPU.
+ */
+int ksched_yield(int *ret, void *hook)
+{
+ need_resched();
+ return 0;
+}
+
+int ksched_get_priority_max(int *ret, void *hook, int policy)
+{
+ int e = 0;
+
+ switch (policy)
+ {
+ case SCHED_FIFO:
+ case SCHED_RR:
+ *ret = RTP_PRIO_MAX;
+ break;
+
+ case SCHED_OTHER:
+ *ret = PRIO_MAX;
+ break;
+
+ default:
+ e = EINVAL;
+ }
+
+ return e;
+}
+
+int ksched_get_priority_min(int *ret, void *hook, int policy)
+{
+ int e = 0;
+
+ switch (policy)
+ {
+ case SCHED_FIFO:
+ case SCHED_RR:
+ *ret = RTP_PRIO_MIN;
+ break;
+
+ case SCHED_OTHER:
+ *ret = PRIO_MIN;
+ break;
+
+ default:
+ e = EINVAL;
+ }
+
+ return e;
+}
+
+int ksched_rr_get_interval(int *ret, void *hook,
+ struct proc *p, struct timespec *timespec)
+{
+ *timespec = rr_interval;
+
+ return 0;
+}
diff --git a/sys/kern/posix4_mib.c b/sys/kern/posix4_mib.c
new file mode 100644
index 0000000..84532b8
--- /dev/null
+++ b/sys/kern/posix4_mib.c
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 1998
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
+#include <sys/unistd.h>
+
+static int facility[CTL_POSIX4_N_CTLS];
+
+#define P4_SYSCTL(num, name) \
+ SYSCTL_INT(_posix4, num, name, CTLFLAG_RD, facility + num - 1, 0, "");
+
+P4_SYSCTL(CTL_POSIX4_ASYNCHRONOUS_IO, asynchronous_io);
+P4_SYSCTL(CTL_POSIX4_MAPPED_FILES, mapped_files);
+P4_SYSCTL(CTL_POSIX4_MEMLOCK, memlock);
+P4_SYSCTL(CTL_POSIX4_MEMLOCK_RANGE, memlock_range);
+P4_SYSCTL(CTL_POSIX4_MEMORY_PROTECTION, memory_protection);
+P4_SYSCTL(CTL_POSIX4_MESSAGE_PASSING, message_passing);
+P4_SYSCTL(CTL_POSIX4_PRIORITIZED_IO, prioritized_io);
+P4_SYSCTL(CTL_POSIX4_PRIORITY_SCHEDULING, priority_scheduling);
+P4_SYSCTL(CTL_POSIX4_REALTIME_SIGNALS, realtime_signals);
+P4_SYSCTL(CTL_POSIX4_SEMAPHORES, semaphores);
+P4_SYSCTL(CTL_POSIX4_FSYNC, fsync);
+P4_SYSCTL(CTL_POSIX4_SHARED_MEMORY_OBJECTS, shared_memory_objects);
+P4_SYSCTL(CTL_POSIX4_SYNCHRONIZED_IO, synchronized_io);
+P4_SYSCTL(CTL_POSIX4_TIMERS, timers);
+P4_SYSCTL(CTL_POSIX4_AIO_LISTIO_MAX, aio_listio_max);
+P4_SYSCTL(CTL_POSIX4_AIO_MAX, aio_max);
+P4_SYSCTL(CTL_POSIX4_AIO_PRIO_DELTA_MAX, aio_prio_delta_max);
+P4_SYSCTL(CTL_POSIX4_DELAYTIMER_MAX, delaytimer_max);
+P4_SYSCTL(CTL_POSIX4_MQ_OPEN_MAX, mq_open_max);
+P4_SYSCTL(CTL_POSIX4_PAGESIZE, pagesize);
+P4_SYSCTL(CTL_POSIX4_RTSIG_MAX, rtsig_max);
+P4_SYSCTL(CTL_POSIX4_SEM_NSEMS_MAX, sem_nsems_max);
+P4_SYSCTL(CTL_POSIX4_SEM_VALUE_MAX, sem_value_max);
+P4_SYSCTL(CTL_POSIX4_SIGQUEUE_MAX, sigqueue_max);
+P4_SYSCTL(CTL_POSIX4_TIMER_MAX, timer_max);
+
+/* posix4_facility: Set a facility to a value. This is
+ * probably a temporary measure until the LKM code is combined with this.
+ */
+void posix4_facility(int num, int value)
+{
+ if (num >= 1 && num <= CTL_POSIX4_N_CTLS)
+ facility[num - 1] = value;
+}
diff --git a/sys/posix4/aio.h b/sys/posix4/aio.h
new file mode 100644
index 0000000..6cd47bc
--- /dev/null
+++ b/sys/posix4/aio.h
@@ -0,0 +1,107 @@
+/* XXX Conflicts with John's - not installed.
+ */
+/*-
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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:$
+ */
+
+/* aio.h: P1003.1B-1993 Asynchronous I/O */
+
+#ifndef _POSIX4_AIO_H_
+#define _POSIX4_AIO_H_
+
+#ifdef POSIX4_INCLUDE_MAYBES
+#include <sys/types.h>
+#include <signal.h>
+#include <time.h>
+#include <fcntl.h>
+#else
+struct timespec;
+#include <sys/types.h>
+#ifdef KERNEL
+#include <sys/signal.h>
+#else
+#include <signal.h>
+#endif
+#endif
+
+/* Return values: */
+
+#define AIO_CANCELED 0x01 /* All operations cancelled */
+#define AIO_NOTCANCELLED 0x02 /* Some not cancelled */
+#define AIO_ALLDONE 0x04 /* None were cancelled */
+
+/* lio_listio synchronization options */
+
+#define LIO_WAIT 0x08 /* Suspend until complete */
+#define LIO_NOWAIT 0x10 /* Continue operation */
+
+/* lio_listio element operations */
+
+#define LIO_READ 0x20
+#define LIO_WRITE 0x40
+#define LIO_NOP 0x80
+
+typedef struct aiocb * const aio_listio_ctl;
+typedef const struct aiocb * const caio_listio_ctl;
+
+struct aiocb {
+ int aio_fildes; /* File descriptor */
+ off_t aio_offset; /* File offset */
+ volatile void * aio_buf; /* Location of buffer */
+ size_t aio_nbytes; /* Length of transfer */
+ int aio_reqprio; /* Request priority offset */
+ struct sigevent aio_sigevent; /* Signal number and value */
+ int aio_lio_opcode; /* Operation to be performed */
+};
+
+#ifndef KERNEL
+#include <sys/cdefs.h>
+
+int aio_read __P((struct aiocb *));
+int aio_write __P((struct aiocb *));
+
+int lio_listio __P((int, aio_listio_ctl [_POSIX_AIO_LISTIO_MAX],
+ int, struct sigevent *));
+
+int aio_error __P((const struct aiocb *));
+ssize_t aio_return __P((struct aiocb *));
+int aio_cancel __P((int, struct aiocb *));
+
+int aio_suspend __P((caio_listio_ctl [_POSIX_AIO_LISTIO_MAX],
+ int, const struct timespec *));
+
+int aio_fsync __P((int, struct aiocb *));
+
+#endif /* KERNEL */
+
+#endif /* _POSIX4_AIO_H_ */
diff --git a/sys/posix4/ksched.c b/sys/posix4/ksched.c
new file mode 100644
index 0000000..7ff85d6
--- /dev/null
+++ b/sys/posix4/ksched.c
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+/* ksched: Soft real time scheduling based on "rtprio".
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/kernel.h>
+#include <machine/cpu.h> /* For need_resched */
+#include <fcntl.h>
+
+#include <sys/posix4.h>
+
+/* ksched: Real-time extension to support POSIX priority scheduling.
+ */
+
+static struct timespec rr_interval;
+
+int ksched_attach(int p4_instance, int fac_code, void **p)
+{
+ rr_interval.tv_sec = 0;
+ rr_interval.tv_nsec = 1000000000L / roundrobin_interval();
+
+ *p = 0;
+
+ return 0;
+}
+
+int ksched_detach(void *p)
+{
+ return 0;
+}
+
+/*
+ * XXX About priorities
+ *
+ * POSIX4 requires that numerically higher priorities be of
+ * higher priority. It also permits sched_setparam to be
+ * implementation defined for SCHED_OTHER. I don't like
+ * the notion of inverted priorites for normal processes when
+ * you can use "setpriority" for that.
+ *
+ * I'm rejecting sched_setparam for SCHED_OTHER with EINVAL.
+ */
+
+/* Macros to convert between the unix (lower numerically is higher priority)
+ * and POSIX4 (higher numerically is higher priority)
+ */
+
+#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
+#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
+
+static inline int
+getscheduler(int *ret, void *hook, struct proc *p)
+{
+ int e = 0;
+
+ switch (p->p_rtprio.type)
+ {
+ case RTP_PRIO_FIFO:
+ *ret = SCHED_FIFO;
+ break;
+
+ case RTP_PRIO_REALTIME:
+ *ret = SCHED_RR;
+ break;
+
+ default:
+ *ret = SCHED_OTHER;
+ break;
+ }
+
+ return e;
+}
+
+int ksched_setparam(int *ret, void *hook,
+ struct proc *p, const struct sched_param *param)
+{
+ int e, policy;
+
+ e = getscheduler(&policy, hook, p);
+
+ if (e == 0)
+ {
+ if (policy == SCHED_OTHER)
+ e = EINVAL;
+ else
+ e = ksched_setscheduler(ret, hook, p, policy, param);
+ }
+
+ return e;
+}
+
+int ksched_getparam(int *ret, void *hook,
+ struct proc *p, struct sched_param *param)
+{
+ if (RTP_PRIO_IS_REALTIME(p->p_rtprio.type))
+ param->sched_priority = rtpprio_to_p4prio(p->p_rtprio.prio);
+
+ return 0;
+}
+
+/*
+ * XXX The priority and scheduler modifications should
+ * be moved into published interfaces in kern/kern_sync.
+ *
+ * The permissions to modify process p were checked in "posix4proc()".
+ *
+ */
+int ksched_setscheduler(int *ret, void *hook,
+ struct proc *p, int policy, const struct sched_param *param)
+{
+ int e = 0;
+ struct rtprio rtp;
+
+ switch(policy)
+ {
+ case SCHED_RR:
+ case SCHED_FIFO:
+
+ if (param->sched_priority >= RTP_PRIO_MIN &&
+ param->sched_priority <= RTP_PRIO_MAX)
+ {
+ rtp.type = (policy == SCHED_FIFO)
+ ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME;
+
+ rtp.prio = p4prio_to_rtpprio(RTP_PRIO_MAX);
+ p->p_rtprio = rtp;
+ (void)resetpriority(p);
+ }
+ else
+ e = EPERM;
+
+
+ break;
+
+ case SCHED_OTHER:
+ {
+ rtp.type = RTP_PRIO_NORMAL;
+ rtp.prio = p4prio_to_rtpprio(RTP_PRIO_MIN);
+ p->p_rtprio = rtp;
+
+ /* XXX Simply revert to whatever we had for last
+ * normal scheduler priorities.
+ * This puts a requirement
+ * on the scheduling code: You must leave the
+ * scheduling info alone.
+ */
+ (void)resetpriority(p);
+ }
+ break;
+ }
+
+ return e;
+}
+
+int ksched_getscheduler(int *ret, void *hook, struct proc *p)
+{
+ return getscheduler(ret, hook, p);
+}
+
+/* ksched_yield: Yield the CPU.
+ */
+int ksched_yield(int *ret, void *hook)
+{
+ need_resched();
+ return 0;
+}
+
+int ksched_get_priority_max(int *ret, void *hook, int policy)
+{
+ int e = 0;
+
+ switch (policy)
+ {
+ case SCHED_FIFO:
+ case SCHED_RR:
+ *ret = RTP_PRIO_MAX;
+ break;
+
+ case SCHED_OTHER:
+ *ret = PRIO_MAX;
+ break;
+
+ default:
+ e = EINVAL;
+ }
+
+ return e;
+}
+
+int ksched_get_priority_min(int *ret, void *hook, int policy)
+{
+ int e = 0;
+
+ switch (policy)
+ {
+ case SCHED_FIFO:
+ case SCHED_RR:
+ *ret = RTP_PRIO_MIN;
+ break;
+
+ case SCHED_OTHER:
+ *ret = PRIO_MIN;
+ break;
+
+ default:
+ e = EINVAL;
+ }
+
+ return e;
+}
+
+int ksched_rr_get_interval(int *ret, void *hook,
+ struct proc *p, struct timespec *timespec)
+{
+ *timespec = rr_interval;
+
+ return 0;
+}
diff --git a/sys/posix4/mqueue.h b/sys/posix4/mqueue.h
new file mode 100644
index 0000000..0872ddf
--- /dev/null
+++ b/sys/posix4/mqueue.h
@@ -0,0 +1,71 @@
+#ifndef _MQUEUE_H_
+#define _MQUEUE_H_
+
+/* mqueue.h: POSIX.4 Message Queues */
+
+/*-
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+#ifdef POSIX4_INCLUDE_MAYBES
+#include <sys/types.h>
+#include <fcntl.h>
+#include <time.h>
+#include <signal.h>
+#else
+struct sigevent;
+#endif
+
+typedef int mqd_t; /* message queue descriptors */
+
+struct mq_attr {
+ long mq_flags; /* message queue flags */
+ long mq_maxmsg; /* maximum number of messages */
+ long mq_msgsize; /* maximum message size */
+ long mq_curmsgs; /* number of messages currently queued */
+};
+
+#ifndef KERNEL
+#include <sys/cdefs.h>
+
+mqd_t mq_open __P((const char *, int oflag, ...));
+int mq_close __P((mqd_t));
+int mq_unlink __P((const char *));
+int mq_send __P((mqd_t, const char *, size_t, unsigned int));
+ssize_t mq_receive __P((mqd_t, char *, size_t, unsigned int *));
+int mq_notify __P((mqd_t, const struct sigevent *));
+int mq_setattr __P((mqd_t, const struct mq_attr *, struct mq_attr *));
+int mq_getattr __P((mqd_t, struct mq_attr *));
+
+#endif /* KERNEL */
+
+#endif /* _MQUEUE_H_ */
diff --git a/sys/posix4/posix4.h b/sys/posix4/posix4.h
new file mode 100644
index 0000000..5037b03
--- /dev/null
+++ b/sys/posix4/posix4.h
@@ -0,0 +1,300 @@
+#ifndef _POSIX4_POSIX4_H_
+#define _POSIX4_POSIX4_H_
+/*-
+ * Copyright (c) 1996, 1997, 1998
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+#if defined(_POSIX_VERSION) && _POSIX_VERSION >= 199309L
+#include <sys/param.h>
+#include <sys/ioccom.h>
+#include <sched.h>
+
+/*
+ * This defines POSIX4_VISIBLE to indicate posix4 extensions should show up.
+ * You should test this when you add a posix4 extension to a header
+ * that exists in POSIX.1. Try "man 9 posix4".
+ */
+
+#if !defined(_POSIX_C_SOURCE) || \
+ defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L
+#define POSIX4_VISIBLE
+#endif
+
+/*
+ *
+ * March 1, 1998: Details from here on change and this header file
+ * is volatile.
+ *
+ * Locally I've got PRIORITY SCHEDULING
+ * set as a system call available only to root
+ * and I'm still using a pseudo device to gate everything else.
+ *
+ * This interface vectors us into the kernel through a
+ * POSIX4 pseudo device with some user privilege authorization along
+ * the way.
+ *
+ * XXX I'm going with option 3.
+ *
+ * This has drawbacks from the point of view of ktrace. There
+ * are (at least) three ways to do this:
+ *
+ * 1. As it is being done, which is bad for ktrace and is hokey
+ * but is easy to extend during development;
+ * 2. Add a system call for every POSIX4 entry point, which
+ * will result in many more system calls (on the order of 64)
+ * 3. Add a system call for each POSIX4 option, which is a bit more
+ * useful for ktrace and will add only about 14 new system calls.
+ *
+ */
+
+#define POSIX4_FACILITIES 16
+#define POSIX4_ONE_ONLY
+
+/*
+ * All facility request structures have a posix4_dispatch header
+ * at the front. Return values are always an indication of
+ * success or failure and are automatically converted into an errno
+ * by the kernel. "Non-errno" return codes are handled via ret.
+ */
+struct posix4_dispatch {
+ int op;
+ int ret;
+};
+
+#if defined(_POSIX_PRIORITY_SCHEDULING)
+
+/*
+ * KSCHED_OP_RW is a vector of read/write flags for each entry indexed
+ * by the enum ksched_op.
+ *
+ * 1 means you need write access, 0 means read is sufficient.
+ */
+
+enum ksched_op {
+
+#define KSCHED_OP_RW { 1, 0, 1, 0, 0, 0, 0, 0 }
+
+ SCHED_SETPARAM,
+ SCHED_GETPARAM,
+ SCHED_SETSCHEDULER,
+ SCHED_GETSCHEDULER,
+ SCHED_YIELD,
+ SCHED_GET_PRIORITY_MAX,
+ SCHED_GET_PRIORITY_MIN,
+ SCHED_RR_GET_INTERVAL,
+ SCHED_OP_MAX
+};
+
+struct ksched
+{
+ struct posix4_dispatch dispatch;
+ pid_t pid;
+ int policy;
+ struct sched_param param;
+ struct timespec interval;
+};
+
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+
+#if defined(_POSIX_MEMLOCK) ^ defined(_POSIX_MEMLOCK_RANGE)
+/* This implementation expects these two options to always be together.
+ * If one isn't handled it should be disabled at
+ * run time.
+ */
+#error _POSIX_MEMLOCK and _POSIX_MEMLOCK_RANGE should always be together
+#endif
+
+#if defined(_POSIX_MEMLOCK) && defined(_POSIX_MEMLOCK_RANGE)
+
+enum kmemlock_op {
+
+#define KMEMLOCK_OP_RW { 1, 1, 1, 1 }
+
+ MEMLOCK_MLOCKALL,
+ MEMLOCK_MUNLOCKALL,
+ MEMLOCK_MLOCK,
+ MEMLOCK_MUNLOCK,
+ MEMLOCK_OP_MAX
+};
+
+struct kmemlock
+{
+ struct posix4_dispatch dispatch;
+ int flags;
+ void *addr;
+ size_t len;
+};
+
+#endif /* _POSIX_MEMLOCK && _POSIX_MEMLOCK_RANGE */
+
+#if defined(KERNEL)
+
+struct proc;
+
+void *posix4malloc __P((int *, size_t));
+void posix4free __P((int *, void *));
+int posix4proc __P((struct proc *, pid_t, struct proc **));
+int posix4ioctl __P((dev_t, int, caddr_t, int, struct proc *));
+void posix4attach __P((int));
+void posix4_facility __P((int, int));
+
+struct lkm_table;
+int posix4_init __P((struct lkm_table *, int , int ));
+
+#ifdef _POSIX_PRIORITY_SCHEDULING
+
+int ksched_attach(int, int, void **);
+int ksched_detach(void *);
+
+int ksched_setparam(int *, void *,
+ struct proc *, const struct sched_param *);
+int ksched_getparam(int *, void *,
+ struct proc *, struct sched_param *);
+
+int ksched_setscheduler(int *, void *,
+ struct proc *, int, const struct sched_param *);
+int ksched_getscheduler(int *, void *, struct proc *);
+
+int ksched_yield(int *, void *);
+
+int ksched_get_priority_max(int *, void *, int);
+int ksched_get_priority_min(int *, void *, int);
+
+int ksched_rr_get_interval(int *, void *, struct proc *, struct timespec *);
+
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+
+#if defined(_POSIX_MEMLOCK) && defined(_POSIX_MEMLOCK_RANGE)
+
+int kmemlock_attach(int, int, void **);
+int kmemlock_detach(void *);
+int kmlockall(int *, void *, int);
+int kmunlockall(int *, void *);
+int kmlock(int *, void *, const void *, size_t);
+int kmunlock(int *, void *, const void *, size_t );
+
+#endif /* _POSIX_MEMLOCK && _POSIX_MEMLOCK_RANGE */
+
+#endif /* KERNEL */
+
+/* A facility is an implementation of one of the optional portions of
+ * POSIX4 as selected by the feature test macros, such as the fixed
+ * priority scheduler or the realtime signals.
+ */
+
+/* Each facility has a facility code, an opcode, and r-w attributes.
+ * To exercise the operation associated with an opcode you need the
+ * appropriate privileges on the POSIX4 device with the facility
+ * bit set in the minor number. This means that every facility has
+ * a protection bit: Probably more than we need, but it may have
+ * advantages.
+ *
+ */
+
+#define posix4encode(FACILITY, RW) (FACILITY)
+#define posix4decode(X, FACILITY_P) \
+ do { \
+ *(FACILITY_P) = ((X) & 0xff); \
+ } while (0)
+
+/*
+ * The dispatch codes:
+ */
+#define IO_POSIX4_PRIORITY_SCHEDULING _IOWR('r', \
+ CTL_POSIX4_PRIORITY_SCHEDULING, struct ksched)
+
+#define IO_POSIX4_MEMLOCK _IOWR('r', \
+ CTL_POSIX4_MEMLOCK, struct ksched)
+
+/*
+ * CTL_POSIX4 definitions for syscfg
+ */
+
+#define CTL_POSIX4_ASYNCHRONOUS_IO 1 /* boolean */
+#define CTL_POSIX4_MAPPED_FILES 2 /* boolean */
+#define CTL_POSIX4_MEMLOCK 3 /* boolean */
+#define CTL_POSIX4_MEMLOCK_RANGE 4 /* boolean */
+#define CTL_POSIX4_MEMORY_PROTECTION 5 /* boolean */
+#define CTL_POSIX4_MESSAGE_PASSING 6 /* boolean */
+#define CTL_POSIX4_PRIORITIZED_IO 7 /* boolean */
+#define CTL_POSIX4_PRIORITY_SCHEDULING 8 /* boolean */
+#define CTL_POSIX4_REALTIME_SIGNALS 9 /* boolean */
+#define CTL_POSIX4_SEMAPHORES 10 /* boolean */
+#define CTL_POSIX4_FSYNC 11 /* boolean */
+#define CTL_POSIX4_SHARED_MEMORY_OBJECTS 12 /* boolean */
+#define CTL_POSIX4_SYNCHRONIZED_IO 13 /* boolean */
+#define CTL_POSIX4_TIMERS 14 /* boolean */
+#define CTL_POSIX4_AIO_LISTIO_MAX 15 /* int */
+#define CTL_POSIX4_AIO_MAX 16 /* int */
+#define CTL_POSIX4_AIO_PRIO_DELTA_MAX 17 /* int */
+#define CTL_POSIX4_DELAYTIMER_MAX 18 /* int */
+#define CTL_POSIX4_MQ_OPEN_MAX 19 /* int */
+#define CTL_POSIX4_PAGESIZE 20 /* int */
+#define CTL_POSIX4_RTSIG_MAX 21 /* int */
+#define CTL_POSIX4_SEM_NSEMS_MAX 22 /* int */
+#define CTL_POSIX4_SEM_VALUE_MAX 23 /* int */
+#define CTL_POSIX4_SIGQUEUE_MAX 24 /* int */
+#define CTL_POSIX4_TIMER_MAX 25 /* int */
+
+#define CTL_POSIX4_N_CTLS 25
+
+#define CTL_POSIX4_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 }, \
+}
+
+#endif /* _POSIX_VERSION >= 199309L */
+#endif /* _POSIX4_POSIX4_H_ */
diff --git a/sys/posix4/posix4_mib.c b/sys/posix4/posix4_mib.c
new file mode 100644
index 0000000..84532b8
--- /dev/null
+++ b/sys/posix4/posix4_mib.c
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 1998
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
+#include <sys/unistd.h>
+
+static int facility[CTL_POSIX4_N_CTLS];
+
+#define P4_SYSCTL(num, name) \
+ SYSCTL_INT(_posix4, num, name, CTLFLAG_RD, facility + num - 1, 0, "");
+
+P4_SYSCTL(CTL_POSIX4_ASYNCHRONOUS_IO, asynchronous_io);
+P4_SYSCTL(CTL_POSIX4_MAPPED_FILES, mapped_files);
+P4_SYSCTL(CTL_POSIX4_MEMLOCK, memlock);
+P4_SYSCTL(CTL_POSIX4_MEMLOCK_RANGE, memlock_range);
+P4_SYSCTL(CTL_POSIX4_MEMORY_PROTECTION, memory_protection);
+P4_SYSCTL(CTL_POSIX4_MESSAGE_PASSING, message_passing);
+P4_SYSCTL(CTL_POSIX4_PRIORITIZED_IO, prioritized_io);
+P4_SYSCTL(CTL_POSIX4_PRIORITY_SCHEDULING, priority_scheduling);
+P4_SYSCTL(CTL_POSIX4_REALTIME_SIGNALS, realtime_signals);
+P4_SYSCTL(CTL_POSIX4_SEMAPHORES, semaphores);
+P4_SYSCTL(CTL_POSIX4_FSYNC, fsync);
+P4_SYSCTL(CTL_POSIX4_SHARED_MEMORY_OBJECTS, shared_memory_objects);
+P4_SYSCTL(CTL_POSIX4_SYNCHRONIZED_IO, synchronized_io);
+P4_SYSCTL(CTL_POSIX4_TIMERS, timers);
+P4_SYSCTL(CTL_POSIX4_AIO_LISTIO_MAX, aio_listio_max);
+P4_SYSCTL(CTL_POSIX4_AIO_MAX, aio_max);
+P4_SYSCTL(CTL_POSIX4_AIO_PRIO_DELTA_MAX, aio_prio_delta_max);
+P4_SYSCTL(CTL_POSIX4_DELAYTIMER_MAX, delaytimer_max);
+P4_SYSCTL(CTL_POSIX4_MQ_OPEN_MAX, mq_open_max);
+P4_SYSCTL(CTL_POSIX4_PAGESIZE, pagesize);
+P4_SYSCTL(CTL_POSIX4_RTSIG_MAX, rtsig_max);
+P4_SYSCTL(CTL_POSIX4_SEM_NSEMS_MAX, sem_nsems_max);
+P4_SYSCTL(CTL_POSIX4_SEM_VALUE_MAX, sem_value_max);
+P4_SYSCTL(CTL_POSIX4_SIGQUEUE_MAX, sigqueue_max);
+P4_SYSCTL(CTL_POSIX4_TIMER_MAX, timer_max);
+
+/* posix4_facility: Set a facility to a value. This is
+ * probably a temporary measure until the LKM code is combined with this.
+ */
+void posix4_facility(int num, int value)
+{
+ if (num >= 1 && num <= CTL_POSIX4_N_CTLS)
+ facility[num - 1] = value;
+}
diff --git a/sys/posix4/sched.h b/sys/posix4/sched.h
new file mode 100644
index 0000000..50bc3c6
--- /dev/null
+++ b/sys/posix4/sched.h
@@ -0,0 +1,74 @@
+#ifndef _SCHED_H_
+#define _SCHED_H_
+
+/* sched.h: POSIX.4 Process Scheduling header */
+
+/*-
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * and Jukka Antero Ukkonen.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+#include <unistd.h>
+#include <sys/types.h> /* For pid_t */
+
+#ifndef KERNEL
+#include <time.h> /* Per P1003.4 */
+#endif
+
+/* Scheduling policies
+ */
+#define SCHED_FIFO 1
+#define SCHED_OTHER 2
+#define SCHED_RR 3
+
+struct sched_param
+{
+ int sched_priority;
+};
+
+#ifndef KERNEL
+#include <sys/cdefs.h>
+
+int sched_setparam __P((pid_t, const struct sched_param *));
+int sched_getparam __P((pid_t, struct sched_param *));
+
+int sched_setscheduler __P((pid_t, int, const struct sched_param *));
+int sched_getscheduler __P((pid_t));
+
+int sched_yield __P((void));
+int sched_get_priority_max __P((int));
+int sched_get_priority_min __P((int));
+int sched_rr_get_interval __P((pid_t, struct timespec *));
+
+#endif /* KERNEL */
+
+#endif /* _SCHED_H_ */
diff --git a/sys/posix4/semaphore.h b/sys/posix4/semaphore.h
new file mode 100644
index 0000000..fbcab13
--- /dev/null
+++ b/sys/posix4/semaphore.h
@@ -0,0 +1,61 @@
+#ifndef _SEMAPHORE_H_
+#define _SEMAPHORE_H_
+
+/* semaphore.h: POSIX.4 semaphores */
+
+/*-
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+#ifdef POSIX4_INCLUDE_MAYBES
+#include <sys/types.h>
+#include <fcntl.h>
+#endif
+
+typedef int sem_t;
+
+#ifndef KERNEL
+#include <sys/cdefs.h>
+
+int sem_init __P(sem_t *, int, unsigned int));
+int sem_destroy __P((sem_t *));
+sem_t sem_open __P((const char *, int, ...));
+int sem_close __P((sem_t *));
+int sem_unlink __P((const char *));
+int sem_wait((sem_t *));
+int sem_trywait((sem_t *));
+int sem_post((sem_t *));
+int sem_getvalue((sem_t *, int *));
+
+#endif /* KERNEL */
+
+#endif /* _SEMAPHORE_H_ */
diff --git a/sys/sys/mman.h b/sys/sys/mman.h
index f1a054b..f0b609f 100644
--- a/sys/sys/mman.h
+++ b/sys/sys/mman.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)mman.h 8.2 (Berkeley) 1/9/95
- * $Id: mman.h,v 1.19 1997/12/02 21:30:03 dyson Exp $
+ * $Id: mman.h,v 1.20 1997/12/31 01:22:00 alex Exp $
*/
#ifndef _SYS_MMAN_H_
@@ -63,6 +63,15 @@
#define MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */
#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */
+#ifdef POSIX4_VISIBLE
+/*
+ * Process memory locking
+ */
+#define MCL_CURRENT 0x0001 /* Lock only current memory */
+#define MCL_FUTURE 0x0002 /* Lock all future memory as well */
+
+#endif /* POSIX4_VISIBLE */
+
/*
* Error return from mmap()
*/
@@ -75,6 +84,7 @@
#define MS_ASYNC 0x0001 /* return immediately */
#define MS_INVALIDATE 0x0002 /* invalidate all cached data */
+
/*
* Mapping type
*/
@@ -105,9 +115,12 @@
#include <sys/cdefs.h>
__BEGIN_DECLS
-int madvise __P((void *, size_t, int));
-int mincore __P((const void *, size_t, char *));
-int minherit __P((void *, size_t, int));
+#ifdef POSIX4_VISIBLE
+int mlockall __P((int));
+int munlockall __P((void));
+int shm_open __P((const char *, int, mode_t));
+int shm_unlink __P((const char *));
+#endif /* POSIX4_VISIBLE */
int mlock __P((const void *, size_t));
#ifndef _MMAP_DECLARED
#define _MMAP_DECLARED
@@ -117,6 +130,11 @@ int mprotect __P((const void *, size_t, int));
int msync __P((void *, size_t, int));
int munlock __P((const void *, size_t));
int munmap __P((void *, size_t));
+#ifndef _POSIX_SOURCE
+int madvise __P((void *, size_t, int));
+int mincore __P((const void *, size_t, char *));
+int minherit __P((void *, size_t, int));
+#endif
__END_DECLS
#endif /* !KERNEL */
diff --git a/sys/sys/posix4.h b/sys/sys/posix4.h
new file mode 100644
index 0000000..5037b03
--- /dev/null
+++ b/sys/sys/posix4.h
@@ -0,0 +1,300 @@
+#ifndef _POSIX4_POSIX4_H_
+#define _POSIX4_POSIX4_H_
+/*-
+ * Copyright (c) 1996, 1997, 1998
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+#if defined(_POSIX_VERSION) && _POSIX_VERSION >= 199309L
+#include <sys/param.h>
+#include <sys/ioccom.h>
+#include <sched.h>
+
+/*
+ * This defines POSIX4_VISIBLE to indicate posix4 extensions should show up.
+ * You should test this when you add a posix4 extension to a header
+ * that exists in POSIX.1. Try "man 9 posix4".
+ */
+
+#if !defined(_POSIX_C_SOURCE) || \
+ defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L
+#define POSIX4_VISIBLE
+#endif
+
+/*
+ *
+ * March 1, 1998: Details from here on change and this header file
+ * is volatile.
+ *
+ * Locally I've got PRIORITY SCHEDULING
+ * set as a system call available only to root
+ * and I'm still using a pseudo device to gate everything else.
+ *
+ * This interface vectors us into the kernel through a
+ * POSIX4 pseudo device with some user privilege authorization along
+ * the way.
+ *
+ * XXX I'm going with option 3.
+ *
+ * This has drawbacks from the point of view of ktrace. There
+ * are (at least) three ways to do this:
+ *
+ * 1. As it is being done, which is bad for ktrace and is hokey
+ * but is easy to extend during development;
+ * 2. Add a system call for every POSIX4 entry point, which
+ * will result in many more system calls (on the order of 64)
+ * 3. Add a system call for each POSIX4 option, which is a bit more
+ * useful for ktrace and will add only about 14 new system calls.
+ *
+ */
+
+#define POSIX4_FACILITIES 16
+#define POSIX4_ONE_ONLY
+
+/*
+ * All facility request structures have a posix4_dispatch header
+ * at the front. Return values are always an indication of
+ * success or failure and are automatically converted into an errno
+ * by the kernel. "Non-errno" return codes are handled via ret.
+ */
+struct posix4_dispatch {
+ int op;
+ int ret;
+};
+
+#if defined(_POSIX_PRIORITY_SCHEDULING)
+
+/*
+ * KSCHED_OP_RW is a vector of read/write flags for each entry indexed
+ * by the enum ksched_op.
+ *
+ * 1 means you need write access, 0 means read is sufficient.
+ */
+
+enum ksched_op {
+
+#define KSCHED_OP_RW { 1, 0, 1, 0, 0, 0, 0, 0 }
+
+ SCHED_SETPARAM,
+ SCHED_GETPARAM,
+ SCHED_SETSCHEDULER,
+ SCHED_GETSCHEDULER,
+ SCHED_YIELD,
+ SCHED_GET_PRIORITY_MAX,
+ SCHED_GET_PRIORITY_MIN,
+ SCHED_RR_GET_INTERVAL,
+ SCHED_OP_MAX
+};
+
+struct ksched
+{
+ struct posix4_dispatch dispatch;
+ pid_t pid;
+ int policy;
+ struct sched_param param;
+ struct timespec interval;
+};
+
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+
+#if defined(_POSIX_MEMLOCK) ^ defined(_POSIX_MEMLOCK_RANGE)
+/* This implementation expects these two options to always be together.
+ * If one isn't handled it should be disabled at
+ * run time.
+ */
+#error _POSIX_MEMLOCK and _POSIX_MEMLOCK_RANGE should always be together
+#endif
+
+#if defined(_POSIX_MEMLOCK) && defined(_POSIX_MEMLOCK_RANGE)
+
+enum kmemlock_op {
+
+#define KMEMLOCK_OP_RW { 1, 1, 1, 1 }
+
+ MEMLOCK_MLOCKALL,
+ MEMLOCK_MUNLOCKALL,
+ MEMLOCK_MLOCK,
+ MEMLOCK_MUNLOCK,
+ MEMLOCK_OP_MAX
+};
+
+struct kmemlock
+{
+ struct posix4_dispatch dispatch;
+ int flags;
+ void *addr;
+ size_t len;
+};
+
+#endif /* _POSIX_MEMLOCK && _POSIX_MEMLOCK_RANGE */
+
+#if defined(KERNEL)
+
+struct proc;
+
+void *posix4malloc __P((int *, size_t));
+void posix4free __P((int *, void *));
+int posix4proc __P((struct proc *, pid_t, struct proc **));
+int posix4ioctl __P((dev_t, int, caddr_t, int, struct proc *));
+void posix4attach __P((int));
+void posix4_facility __P((int, int));
+
+struct lkm_table;
+int posix4_init __P((struct lkm_table *, int , int ));
+
+#ifdef _POSIX_PRIORITY_SCHEDULING
+
+int ksched_attach(int, int, void **);
+int ksched_detach(void *);
+
+int ksched_setparam(int *, void *,
+ struct proc *, const struct sched_param *);
+int ksched_getparam(int *, void *,
+ struct proc *, struct sched_param *);
+
+int ksched_setscheduler(int *, void *,
+ struct proc *, int, const struct sched_param *);
+int ksched_getscheduler(int *, void *, struct proc *);
+
+int ksched_yield(int *, void *);
+
+int ksched_get_priority_max(int *, void *, int);
+int ksched_get_priority_min(int *, void *, int);
+
+int ksched_rr_get_interval(int *, void *, struct proc *, struct timespec *);
+
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+
+#if defined(_POSIX_MEMLOCK) && defined(_POSIX_MEMLOCK_RANGE)
+
+int kmemlock_attach(int, int, void **);
+int kmemlock_detach(void *);
+int kmlockall(int *, void *, int);
+int kmunlockall(int *, void *);
+int kmlock(int *, void *, const void *, size_t);
+int kmunlock(int *, void *, const void *, size_t );
+
+#endif /* _POSIX_MEMLOCK && _POSIX_MEMLOCK_RANGE */
+
+#endif /* KERNEL */
+
+/* A facility is an implementation of one of the optional portions of
+ * POSIX4 as selected by the feature test macros, such as the fixed
+ * priority scheduler or the realtime signals.
+ */
+
+/* Each facility has a facility code, an opcode, and r-w attributes.
+ * To exercise the operation associated with an opcode you need the
+ * appropriate privileges on the POSIX4 device with the facility
+ * bit set in the minor number. This means that every facility has
+ * a protection bit: Probably more than we need, but it may have
+ * advantages.
+ *
+ */
+
+#define posix4encode(FACILITY, RW) (FACILITY)
+#define posix4decode(X, FACILITY_P) \
+ do { \
+ *(FACILITY_P) = ((X) & 0xff); \
+ } while (0)
+
+/*
+ * The dispatch codes:
+ */
+#define IO_POSIX4_PRIORITY_SCHEDULING _IOWR('r', \
+ CTL_POSIX4_PRIORITY_SCHEDULING, struct ksched)
+
+#define IO_POSIX4_MEMLOCK _IOWR('r', \
+ CTL_POSIX4_MEMLOCK, struct ksched)
+
+/*
+ * CTL_POSIX4 definitions for syscfg
+ */
+
+#define CTL_POSIX4_ASYNCHRONOUS_IO 1 /* boolean */
+#define CTL_POSIX4_MAPPED_FILES 2 /* boolean */
+#define CTL_POSIX4_MEMLOCK 3 /* boolean */
+#define CTL_POSIX4_MEMLOCK_RANGE 4 /* boolean */
+#define CTL_POSIX4_MEMORY_PROTECTION 5 /* boolean */
+#define CTL_POSIX4_MESSAGE_PASSING 6 /* boolean */
+#define CTL_POSIX4_PRIORITIZED_IO 7 /* boolean */
+#define CTL_POSIX4_PRIORITY_SCHEDULING 8 /* boolean */
+#define CTL_POSIX4_REALTIME_SIGNALS 9 /* boolean */
+#define CTL_POSIX4_SEMAPHORES 10 /* boolean */
+#define CTL_POSIX4_FSYNC 11 /* boolean */
+#define CTL_POSIX4_SHARED_MEMORY_OBJECTS 12 /* boolean */
+#define CTL_POSIX4_SYNCHRONIZED_IO 13 /* boolean */
+#define CTL_POSIX4_TIMERS 14 /* boolean */
+#define CTL_POSIX4_AIO_LISTIO_MAX 15 /* int */
+#define CTL_POSIX4_AIO_MAX 16 /* int */
+#define CTL_POSIX4_AIO_PRIO_DELTA_MAX 17 /* int */
+#define CTL_POSIX4_DELAYTIMER_MAX 18 /* int */
+#define CTL_POSIX4_MQ_OPEN_MAX 19 /* int */
+#define CTL_POSIX4_PAGESIZE 20 /* int */
+#define CTL_POSIX4_RTSIG_MAX 21 /* int */
+#define CTL_POSIX4_SEM_NSEMS_MAX 22 /* int */
+#define CTL_POSIX4_SEM_VALUE_MAX 23 /* int */
+#define CTL_POSIX4_SIGQUEUE_MAX 24 /* int */
+#define CTL_POSIX4_TIMER_MAX 25 /* int */
+
+#define CTL_POSIX4_N_CTLS 25
+
+#define CTL_POSIX4_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 }, \
+}
+
+#endif /* _POSIX_VERSION >= 199309L */
+#endif /* _POSIX4_POSIX4_H_ */
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index c4acd8c..bed9f51 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.15 (Berkeley) 5/19/95
- * $Id: proc.h,v 1.53 1998/01/22 17:30:11 dyson Exp $
+ * $Id: proc.h,v 1.54 1998/02/20 13:52:15 bde Exp $
*/
#ifndef _SYS_PROC_H_
@@ -329,6 +329,7 @@ int leavepgrp __P((struct proc *p));
void mi_switch __P((void));
void procinit __P((void));
void resetpriority __P((struct proc *));
+int roundrobin_interval __P((void));
void setrunnable __P((struct proc *));
void setrunqueue __P((struct proc *));
void sleepinit __P((void));
diff --git a/sys/sys/rtprio.h b/sys/sys/rtprio.h
index dd9521e..5b6830d 100644
--- a/sys/sys/rtprio.h
+++ b/sys/sys/rtprio.h
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: rtprio.h,v 1.4 1997/02/22 09:45:48 peter Exp $
*/
#ifndef _SYS_RTPRIO_H_
@@ -39,10 +39,29 @@
*/
/* priority types */
+
#define RTP_PRIO_REALTIME 0
#define RTP_PRIO_NORMAL 1
#define RTP_PRIO_IDLE 2
+/* RTP_PRIO_FIFO is Posix 4 SCHED_FIFO.
+ * Careful: These are based on the kernel config POSIX4 and not
+ * the compile time test _POSIX_PRIORITY_SCHEDULING since they
+ * set the behavior of the system.
+ */
+
+#ifdef POSIX4
+#define RTP_PRIO_FIFO_BIT 4
+#define RTP_PRIO_FIFO (RTP_PRIO_REALTIME | RTP_PRIO_FIFO_BIT)
+#define RTP_PRIO_BASE(P) ((P) & ~RTP_PRIO_FIFO_BIT)
+#define RTP_PRIO_IS_REALTIME(P) (RTP_PRIO_BASE(P) == RTP_PRIO_REALTIME)
+#define RTP_PRIO_NEED_RR(P) ((P) != RTP_PRIO_FIFO)
+#else
+#define RTP_PRIO_BASE(P) (P)
+#define RTP_PRIO_IS_REALTIME(P) (P == RTP_PRIO_REALTIME)
+#define RTP_PRIO_NEED_RR(P) (1)
+#endif
+
/* priority range */
#define RTP_PRIO_MIN 0 /* Highest priority */
#define RTP_PRIO_MAX 31 /* Lowest priority */
diff --git a/sys/sys/semaphore.h b/sys/sys/semaphore.h
new file mode 100644
index 0000000..fbcab13
--- /dev/null
+++ b/sys/sys/semaphore.h
@@ -0,0 +1,61 @@
+#ifndef _SEMAPHORE_H_
+#define _SEMAPHORE_H_
+
+/* semaphore.h: POSIX.4 semaphores */
+
+/*-
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
+ *
+ */
+
+#ifdef POSIX4_INCLUDE_MAYBES
+#include <sys/types.h>
+#include <fcntl.h>
+#endif
+
+typedef int sem_t;
+
+#ifndef KERNEL
+#include <sys/cdefs.h>
+
+int sem_init __P(sem_t *, int, unsigned int));
+int sem_destroy __P((sem_t *));
+sem_t sem_open __P((const char *, int, ...));
+int sem_close __P((sem_t *));
+int sem_unlink __P((const char *));
+int sem_wait((sem_t *));
+int sem_trywait((sem_t *));
+int sem_post((sem_t *));
+int sem_getvalue((sem_t *, int *));
+
+#endif /* KERNEL */
+
+#endif /* _SEMAPHORE_H_ */
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index a92749f..cd8f293 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93
- * $Id: sysctl.h,v 1.56 1997/09/07 05:27:26 bde Exp $
+ * $Id: sysctl.h,v 1.57 1997/09/07 16:53:52 bde Exp $
*/
#ifndef _SYS_SYSCTL_H_
@@ -180,7 +180,16 @@ int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
#define CTL_HW 6 /* generic cpu/io */
#define CTL_MACHDEP 7 /* machine dependent */
#define CTL_USER 8 /* user-level */
+
+#ifdef POSIX4
+#define CTL_POSIX4 9 /* user-level */
+#define CTL_MAXID 10 /* number of valid top-level ids */
+
+#define CTL_POSIX4_NAME { "posix4", CTLTYPE_NODE },
+#else
#define CTL_MAXID 9 /* number of valid top-level ids */
+#define CTL_POSIX4_NAME
+#endif /* POSIX4 */
#define CTL_NAMES { \
{ 0, 0 }, \
@@ -192,6 +201,7 @@ int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
{ "hw", CTLTYPE_NODE }, \
{ "machdep", CTLTYPE_NODE }, \
{ "user", CTLTYPE_NODE }, \
+ CTL_POSIX4_NAME \
}
/*
diff --git a/sys/sys/time.h b/sys/sys/time.h
index c68eec1..b3ec8b7 100644
--- a/sys/sys/time.h
+++ b/sys/sys/time.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
- * $Id: time.h,v 1.18 1998/02/21 03:20:46 jb Exp $
+ * $Id: time.h,v 1.19 1998/02/25 02:14:14 bde Exp $
*/
#ifndef _SYS_TIME_H_
@@ -194,12 +194,18 @@ struct clockinfo {
int profhz; /* profiling clock frequency */
};
+/* CLOCK_REALTIME and TIMER_ABSTIME are supposed to be in time.h */
+
+#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
+#endif
#define CLOCK_VIRTUAL 1
#define CLOCK_PROF 2
#define TIMER_RELTIME 0x0 /* relative timer */
+#ifndef TIMER_ABSTIME
#define TIMER_ABSTIME 0x1 /* absolute timer */
+#endif
#ifdef KERNEL
extern struct timecounter *timecounter;
diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h
index c68eec1..b3ec8b7 100644
--- a/sys/sys/timetc.h
+++ b/sys/sys/timetc.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
- * $Id: time.h,v 1.18 1998/02/21 03:20:46 jb Exp $
+ * $Id: time.h,v 1.19 1998/02/25 02:14:14 bde Exp $
*/
#ifndef _SYS_TIME_H_
@@ -194,12 +194,18 @@ struct clockinfo {
int profhz; /* profiling clock frequency */
};
+/* CLOCK_REALTIME and TIMER_ABSTIME are supposed to be in time.h */
+
+#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
+#endif
#define CLOCK_VIRTUAL 1
#define CLOCK_PROF 2
#define TIMER_RELTIME 0x0 /* relative timer */
+#ifndef TIMER_ABSTIME
#define TIMER_ABSTIME 0x1 /* absolute timer */
+#endif
#ifdef KERNEL
extern struct timecounter *timecounter;
diff --git a/sys/sys/unistd.h b/sys/sys/unistd.h
index efe6785..e31a7d3 100644
--- a/sys/sys/unistd.h
+++ b/sys/sys/unistd.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)unistd.h 8.2 (Berkeley) 1/7/94
- * $Id: unistd.h,v 1.13 1997/02/22 09:46:21 peter Exp $
+ * $Id: unistd.h,v 1.14 1997/06/16 00:29:26 dyson Exp $
*/
#ifndef _SYS_UNISTD_H_
@@ -50,7 +50,47 @@
#define _POSIX_SAVED_IDS /* saved set-user-ID and set-group-ID */
#endif
+#ifdef POSIX4
+
+/* Select POSIX.4 regardless.
+ * Don't undef first - we want an error on conflicts.
+ */
+
+#define _POSIX_VERSION 199309L
+#endif
+
+#ifndef _POSIX_VERSION
#define _POSIX_VERSION 199009L
+#endif
+
+#if _POSIX_VERSION > 199009L
+/*
+ * Set it up so that all new headers can assume _POSIX_C_SOURCE is the
+ * only thing that must be looked at to determine the feature set,
+ * and so that old headers don't have to change:
+ */
+#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
+/*
+ * Default to latest:
+ */
+#define _POSIX_C_SOURCE _POSIX_VERSION
+#endif
+
+#if defined(_POSIX_C_SOURCE) && !defined(_POSIX_SOURCE)
+/*
+ * Define _POSIX_SOURCE for older headers:
+ */
+#define _POSIX_SOURCE
+#endif
+
+#if _POSIX_VERSION >= 199309L
+#include <posix4/posix4.h>
+#endif
+
+#endif /* _POSIX_VERSION */
+
+
+
#define _POSIX2_VERSION 199212L
/* execution-time symbolic constants */
@@ -122,6 +162,51 @@
/* configurable system strings */
#define _CS_PATH 1
+#ifdef POSIX4_VISIBLE
+
+#if 0
+/* Not until the dust settles after the header commit
+ */
+#define _POSIX_PRIORITY_SCHEDULING
+#define _POSIX_ASYNCHRONOUS_IO
+#define _POSIX_MEMLOCK
+#define _POSIX_MEMLOCK_RANGE
+#endif
+
+/* POSIX 4 sysconf options */
+#define _SC_ASYNCHRONOUS_IO 28
+#define _SC_MAPPED_FILES 29
+#define _SC_MEMLOCK 30
+#define _SC_MEMLOCK_RANGE 31
+#define _SC_MEMORY_PROTECTION 32
+#define _SC_MESSAGE_PASSING 33
+#define _SC_PRIORITIZED_IO 34
+#define _SC_PRIORITY_SCHEDULING 35
+#define _SC_REALTIME_SIGNALS 36
+#define _SC_SEMAPHORES 37
+#define _SC_FSYNC 38
+#define _SC_SHARED_MEMORY_OBJECTS 39
+#define _SC_SYNCHRONIZED_IO 40
+#define _SC_TIMERS 41
+#define _SC_AIO_LISTIO_MAX 42
+#define _SC_AIO_MAX 43
+#define _SC_AIO_PRIO_DELTA_MAX 44
+#define _SC_DELAYTIMER_MAX 45
+#define _SC_MQ_OPEN_MAX 46
+#define _SC_PAGESIZE 47
+#define _SC_RTSIG_MAX 48
+#define _SC_SEM_NSEMS_MAX 49
+#define _SC_SEM_VALUE_MAX 50
+#define _SC_SIGQUEUE_MAX 51
+#define _SC_TIMER_MAX 52
+
+/* POSIX 4 pathconf and fpathconf options */
+#define _PC_ASYNC_IO 53
+#define _PC_PRIO_IO 54
+#define _PC_SYNC_IO 55
+
+#endif /* POSIX4_VISIBLE */
+
#ifndef _POSIX_SOURCE
/*
* rfork() options.
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 8bb9490..0e78a8a 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -59,7 +59,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_glue.c,v 1.73 1998/02/06 12:14:22 eivind Exp $
+ * $Id: vm_glue.c,v 1.74 1998/02/09 06:11:24 eivind Exp $
*/
#include "opt_rlimit.h"
@@ -425,7 +425,7 @@ retry:
/*
* do not swapout a realtime process
*/
- if (p->p_rtprio.type == RTP_PRIO_REALTIME)
+ if (RTP_PRIO_IS_REALTIME(p->p_rtprio.type))
continue;
/*
OpenPOWER on IntegriCloud