DragonFly submit List (threaded) for 2007-06
DragonFly BSD
DragonFly submit List (threaded) for 2007-06
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[patch] merge emulation/posix4 into kernel


From: Joe Talbott <josepht@xxxxxxxxxx>
Date: Mon, 25 Jun 2007 22:55:18 -0400
Mail-followup-to: "submit@crater.dragonflybsd.org" <submit@crater.dragonflybsd.org>

Here's a patch to merge sys/emulation/posix4 into the kernel proper.
This stems from my needing to use pthread_*() in the vkernel and was
recommended by corecode in #dragonflybsd.  Please review.

Thanks,
Joe
diff --git a/include/Makefile b/include/Makefile
index 8c0bdf9..cdb7552 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -48,7 +48,6 @@ LDIRS=	net netgraph netinet netinet6 sys vm
 # when buildworld is run.
 #
 LSUBDIRS=	bus/cam bus/cam/scsi \
-	emulation/posix4 \
 	emulation/linux \
 	vfs/msdosfs vfs/nfs vfs/ntfs vfs/nwfs \
 	vfs/smbfs vfs/udf vfs/ufs \
diff --git a/include/pthread.h b/include/pthread.h
index b5dd6f0..a465cbe 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -44,7 +44,7 @@
 #include <sys/time.h>
 #include <sys/signal.h>
 #include <limits.h>
-#include <sched.h>
+#include <sys/sched.h>
 
 /*
  * Run-time invariant values:
diff --git a/lib/libc_r/test/mutex_d.c b/lib/libc_r/test/mutex_d.c
index 4d416b9..b673f46 100644
--- a/lib/libc_r/test/mutex_d.c
+++ b/lib/libc_r/test/mutex_d.c
@@ -39,7 +39,7 @@
 #include <assert.h>
 #include <errno.h>
 #include "pthread.h"
-#include <sched.h>
+#include <sys/sched.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
diff --git a/lib/libc_r/test/sem_d.c b/lib/libc_r/test/sem_d.c
index 00c22e5..0646a83 100644
--- a/lib/libc_r/test/sem_d.c
+++ b/lib/libc_r/test/sem_d.c
@@ -36,11 +36,12 @@
  *
  ****************************************************************************/
 
+#include <sys/semaphore.h>
+
 #include <assert.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <semaphore.h>
 #include <pthread.h>
 
 #define NTHREADS 10
diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h
index fb953b1..773f2bd 100644
--- a/lib/libc_r/uthread/pthread_private.h
+++ b/lib/libc_r/uthread/pthread_private.h
@@ -57,7 +57,7 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/cdefs.h>
-#include <sched.h>
+#include <sys/sched.h>
 #include <spinlock.h>
 #include <pthread_np.h>
 
diff --git a/lib/libc_r/uthread/uthread_sem.c b/lib/libc_r/uthread/uthread_sem.c
index c75cfea..5ab29ec 100644
--- a/lib/libc_r/uthread/uthread_sem.c
+++ b/lib/libc_r/uthread/uthread_sem.c
@@ -30,10 +30,12 @@
  * $DragonFly: src/lib/libc_r/uthread/uthread_sem.c,v 1.3 2005/05/30 22:50:53 joerg Exp $
  */
 
+#include <sys/semaphore.h>
+
 #include <stdlib.h>
 #include <errno.h>
-#include <semaphore.h>
 #include <pthread.h>
+
 #include "pthread_private.h"
 
 #define _SEM_CHECK_VALIDITY(sem)		\
diff --git a/lib/libc_r/uthread/uthread_spinlock.c b/lib/libc_r/uthread/uthread_spinlock.c
index 033eba1..f92da7c 100644
--- a/lib/libc_r/uthread/uthread_spinlock.c
+++ b/lib/libc_r/uthread/uthread_spinlock.c
@@ -36,7 +36,7 @@
 
 #include <sys/fcntl.h>
 #include <stdio.h>
-#include <sched.h>
+#include <sys/sched.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <string.h>
diff --git a/lib/libthread_xu/thread/thr_private.h b/lib/libthread_xu/thread/thr_private.h
index 3fc1874..2ca6255 100644
--- a/lib/libthread_xu/thread/thr_private.h
+++ b/lib/libthread_xu/thread/thr_private.h
@@ -50,7 +50,7 @@
 #include <limits.h>
 #include <signal.h>
 #include <stdio.h>
-#include <sched.h>
+#include <sys/sched.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <pthread_np.h>
diff --git a/lib/libthread_xu/thread/thr_sem.c b/lib/libthread_xu/thread/thr_sem.c
index 21fd1dd..931d2bf 100644
--- a/lib/libthread_xu/thread/thr_sem.c
+++ b/lib/libthread_xu/thread/thr_sem.c
@@ -32,11 +32,11 @@
 
 #include "namespace.h"
 #include <machine/tls.h>
+#include <sys/semaphore.h>
 
 #include <errno.h>
 #include <fcntl.h>
 #include <pthread.h>
-#include <semaphore.h>
 #include <stdlib.h>
 #include <time.h>
 #include "un-namespace.h"
diff --git a/sys/conf/files b/sys/conf/files
index 06f0ef0..7226979 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1103,9 +1103,9 @@ bus/pci/pci_if.m		optional pci
 bus/pci/pcib_if.m		optional pci
 dev/powermng/i386/alpm/alpm.c	optional alpm
 dev/misc/xrpu/xrpu.c		optional xrpu
-emulation/posix4/posix4_mib.c	standard
-emulation/posix4/p1003_1b.c	standard
-emulation/posix4/ksched.c	optional _kposix_priority_scheduling
+kern/kern_posix4_mib.c		standard
+kern/kern_p1003_1b.c		standard
+kern/kern_sched.c		optional _kposix_priority_scheduling
 vfs/ufs/ffs_alloc.c		optional ffs
 vfs/ufs/ffs_alloc.c		optional mfs
 vfs/ufs/ffs_balloc.c		optional ffs
diff --git a/sys/emulation/linux/linux_misc.c b/sys/emulation/linux/linux_misc.c
index a1bd5e2..6c52e4f 100644
--- a/sys/emulation/linux/linux_misc.c
+++ b/sys/emulation/linux/linux_misc.c
@@ -75,7 +75,7 @@
 #include <machine/segments.h>
 #endif
 
-#include <emulation/posix4/sched.h>
+#include <sys/sched.h>
 
 #include <emulation/linux/linux_sysproto.h>
 #include <arch_linux/linux.h>
diff --git a/sys/emulation/posix4/aio.h b/sys/emulation/posix4/aio.h
deleted file mode 100644
index 466b3f7..0000000
--- a/sys/emulation/posix4/aio.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* 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.
- *
- * $FreeBSD: src/sys/posix4/aio.h,v 1.6 1999/12/29 04:55:01 peter Exp $
- * $DragonFly: src/sys/emulation/posix4/aio.h,v 1.3 2003/08/27 08:30:04 rob Exp $
- */
-
-/* aio.h: P1003.1B-1993 Asynchronous I/O */
-
-#ifndef _P1003_1B_AIO_H_
-#define _P1003_1B_AIO_H_
-
-#include <sys/_posix.h>
-#include <sys/types.h>
-
-/* For struct sigevent:
- */
-#ifdef _KERNEL
-#include <sys/signal.h>
-#else
-#include <signal.h>
-
-#ifdef _P1003_1B_INCLUDE_MAYBES
-#include <time.h>
-#include <fcntl.h>
-#else
-struct timespec;
-#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>
-
-__BEGIN_DECLS
-int aio_read (struct aiocb *);
-int aio_write (struct aiocb *);
-
-int lio_listio (int, aio_listio_ctl[], int, struct sigevent *);
-
-int aio_error (const struct aiocb *);
-ssize_t aio_return (struct aiocb *);
-int aio_cancel (int, struct aiocb *);
-
-int aio_suspend (caio_listio_ctl[], int, const struct timespec *);
-
-int aio_fsync (int, struct aiocb *);
-__END_DECLS
-
-#endif /* _KERNEL */
-
-#endif /* _P1003_1B_AIO_H_ */
diff --git a/sys/emulation/posix4/ksched.c b/sys/emulation/posix4/ksched.c
deleted file mode 100644
index 0dbc684..0000000
--- a/sys/emulation/posix4/ksched.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * 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.
- *
- * $FreeBSD: src/sys/posix4/ksched.c,v 1.7.2.1 2000/05/16 06:58:13 dillon Exp $
- * $DragonFly: src/sys/emulation/posix4/ksched.c,v 1.8 2007/02/03 18:05:57 corecode Exp $
- */
-
-/* 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 <sys/resource.h>
-#include <machine/cpu.h>	/* For need_user_resched */
-
-#include "posix4.h"
-
-/* ksched: Real-time extension to support POSIX priority scheduling.
- */
-
-struct ksched {
-	struct timespec rr_interval;
-};
-
-int ksched_attach(struct ksched **p)
-{
-	struct ksched *ksched= p31b_malloc(sizeof(*ksched));
-
-	ksched->rr_interval.tv_sec = 0;
-	ksched->rr_interval.tv_nsec = 1000000000L / 10;	/* XXX */
-
-	*p = ksched;
-	return 0;
-}
-
-int ksched_detach(struct ksched *p)
-{
-	p31b_free(p);
-
-	return 0;
-}
-
-/*
- * XXX About priorities
- *
- *	POSIX 1003.1b 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 POSIX 1003.1b (higher numerically is higher priority)
- */
-
-#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
-#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
-
-/* These improve readability a bit for me:
- */
-#define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX)
-#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
-
-static __inline int
-getscheduler(register_t *ret, struct ksched *ksched, struct lwp *lp)
-{
-	int e = 0;
-
-	switch (lp->lwp_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(register_t *ret, struct ksched *ksched,
-	struct lwp *lp, const struct sched_param *param)
-{
-	register_t policy;
-	int e;
-
-	e = getscheduler(&policy, ksched, lp);
-
-	if (e == 0)
-	{
-		if (policy == SCHED_OTHER)
-			e = EINVAL;
-		else
-			e = ksched_setscheduler(ret, ksched, lp, policy, param);
-	}
-
-	return e;
-}
-
-int ksched_getparam(register_t *ret, struct ksched *ksched,
-	struct lwp *lp, struct sched_param *param)
-{
-	if (RTP_PRIO_IS_REALTIME(lp->lwp_rtprio.type))
-		param->sched_priority = rtpprio_to_p4prio(lp->lwp_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 "p31b_proc()".
- *
- */
-int ksched_setscheduler(register_t *ret, struct ksched *ksched,
-	struct lwp *lp, 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 >= P1B_PRIO_MIN &&
-		param->sched_priority <= P1B_PRIO_MAX)
-		{
-			rtp.prio = p4prio_to_rtpprio(param->sched_priority);
-			rtp.type = (policy == SCHED_FIFO)
-				? RTP_PRIO_FIFO : RTP_PRIO_REALTIME;
-
-			lp->lwp_rtprio = rtp;
-			need_user_resched();
-		}
-		else
-			e = EPERM;
-
-
-		break;
-
-		case SCHED_OTHER:
-		{
-			rtp.type = RTP_PRIO_NORMAL;
-			rtp.prio = p4prio_to_rtpprio(param->sched_priority);
-			lp->lwp_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.
-			 */
-			need_user_resched();
-		}
-		break;
-	}
-
-	return e;
-}
-
-int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct lwp *lp)
-{
-	return getscheduler(ret, ksched, lp);
-}
-
-/* ksched_yield: Yield the CPU.
- */
-int ksched_yield(register_t *ret, struct ksched *ksched)
-{
-	need_user_resched();
-	return 0;
-}
-
-int ksched_get_priority_max(register_t*ret, struct ksched *ksched, 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(register_t *ret, struct ksched *ksched, int policy)
-{
-	int e = 0;
-
-	switch (policy)
-	{
-		case SCHED_FIFO:
-		case SCHED_RR:
-		*ret = P1B_PRIO_MIN;
-		break;
-
-		case SCHED_OTHER:
-		*ret =  PRIO_MIN;
-		break;
-
-		default:
-		e = EINVAL;
-	}
-
-	return e;
-}
-
-int ksched_rr_get_interval(register_t *ret, struct ksched *ksched,
-	struct lwp *lp, struct timespec *timespec)
-{
-	*timespec = ksched->rr_interval;
-
-	return 0;
-}
diff --git a/sys/emulation/posix4/mqueue.h b/sys/emulation/posix4/mqueue.h
deleted file mode 100644
index 5970c47..0000000
--- a/sys/emulation/posix4/mqueue.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef _MQUEUE_H_
-#define _MQUEUE_H_
-
-/* mqueue.h: POSIX 1003.1b 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.
- *
- * $FreeBSD: src/sys/posix4/mqueue.h,v 1.4 1999/12/29 04:55:02 peter Exp $
- * $DragonFly: src/sys/emulation/posix4/mqueue.h,v 1.3 2003/08/27 08:30:04 rob Exp $
- */
-
-#include <sys/_posix.h>
-
-#ifdef _P1003_1B_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>
-
-__BEGIN_DECLS
-mqd_t mq_open (const char *, int oflag, ...);
-int mq_close (mqd_t);
-int mq_unlink (const char *);
-int mq_send (mqd_t, const char *, size_t, unsigned int);
-ssize_t mq_receive (mqd_t, char *, size_t, unsigned int *);
-int mq_notify (mqd_t, const struct sigevent *);
-int mq_setattr (mqd_t, const struct mq_attr *, struct mq_attr *);
-int mq_getattr (mqd_t, struct mq_attr *);
-__END_DECLS
-
-#endif
-
-#endif /* _MQUEUE_H_ */
diff --git a/sys/emulation/posix4/p1003_1b.c b/sys/emulation/posix4/p1003_1b.c
deleted file mode 100644
index 37a3767..0000000
--- a/sys/emulation/posix4/p1003_1b.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * 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.
- *
- * $FreeBSD: src/sys/posix4/p1003_1b.c,v 1.5.2.2 2003/03/25 06:13:35 rwatson Exp $
- * $DragonFly: src/sys/emulation/posix4/p1003_1b.c,v 1.9 2007/02/03 18:05:57 corecode Exp $
- */
-
-/* p1003_1b: Real Time common code.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sysent.h>
-#include <sys/proc.h>
-#include <sys/syslog.h>
-#include <sys/module.h>
-#include <sys/sysproto.h>
-#include <sys/sysctl.h>
-
-#include "posix4.h"
-
-MALLOC_DEFINE(M_P31B, "p1003.1b", "Posix 1003.1B");
-
-/* p31b_proc: Return a proc struct corresponding to a pid to operate on.
- *
- * Enforce permission policy.
- *
- * The policy is the same as for sending signals except there
- * is no notion of process groups.
- *
- * pid == 0 means my process.
- *
- * This is disabled until I've got a permission gate in again:
- * only root can do this.
- */
-
-#if 0
-/*
- * This is stolen from CANSIGNAL in kern_sig:
- *
- * Can process p, with pcred pc, do "write flavor" operations to process q?
- */
-#define CAN_AFFECT(p, cr, q) \
-	((cr)->cr_uid == 0 || \
-	    (cr)->cr_ruid == (q)->p_ucred->cr_ruid || \
-	    (cr)->cr_uid == (q)->p_ucred->cr_ruid || \
-	    (cr)->cr_ruid == (q)->p_ucred->cr_uid || \
-	    (cr)->cr_uid == (q)->p_ucred->cr_uid)
-#else
-#define CAN_AFFECT(p, cr, q) ((cr)->cr_uid == 0)
-#endif
-
-/*
- * p31b_proc: Look up a proc from a PID.  If proc is 0 it is
- * my own proc.
- */
-int p31b_proc(struct proc *p, pid_t pid, struct proc **pp)
-{
-	int ret = 0;
-	struct proc *other_proc = 0;
-
-	if (pid == 0)
-		other_proc = p;
-	else
-		other_proc = pfind(pid);
-
-	if (other_proc)
-	{
-		/* Enforce permission policy.
-		 */
-		if (CAN_AFFECT(p, p->p_ucred, other_proc))
-			*pp = other_proc;
-		else
-			ret = EPERM;
-	}
-	else
-		ret = ESRCH;
-
-	return ret;
-}
-
-
-#if !defined(_KPOSIX_PRIORITY_SCHEDULING)
-
-int syscall_not_present(const char *s);
-
-/* The system calls return ENOSYS if an entry is called that is
- * not run-time supported.  I am also logging since some programs
- * start to use this when they shouldn't.  That will be removed if annoying.
- */
-int syscall_not_present(const char *s)
-{
-	struct proc *p = curproc;
-	log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n",
-			p->p_comm, p->p_pid, s);
-
-	/* a " return nosys(p, uap); " here causes a core dump.
-	 */
-
-	return ENOSYS;
-}
-
-/* Not configured but loadable via a module:
- */
-
-static int sched_attach(void)
-{
-	return 0;
-}
-
-#define SYSCALL_NOT_PRESENT_GEN(SC) \
-int SC (struct SC##_args *uap) \
-{ \
-	return syscall_not_present(#SC); \
-}
-
-SYSCALL_NOT_PRESENT_GEN(sched_setparam)
-SYSCALL_NOT_PRESENT_GEN(sched_getparam)
-SYSCALL_NOT_PRESENT_GEN(sched_setscheduler)
-SYSCALL_NOT_PRESENT_GEN(sched_getscheduler)
-SYSCALL_NOT_PRESENT_GEN(sched_yield)
-SYSCALL_NOT_PRESENT_GEN(sched_get_priority_max)
-SYSCALL_NOT_PRESENT_GEN(sched_get_priority_min)
-SYSCALL_NOT_PRESENT_GEN(sched_rr_get_interval)
-
-#else
-
-/* Configured in kernel version:
- */
-static struct ksched *ksched;
-
-static int sched_attach(void)
-{
-	int ret = ksched_attach(&ksched);
-
-	if (ret == 0)
-		p31b_setcfg(CTL_P1003_1B_PRIORITY_SCHEDULING, 1);
-
-	return ret;
-}
-
-int
-sys_sched_setparam(struct sched_setparam_args *uap)
-{
-	struct proc *p = curproc;
-	struct lwp *lp;
-	int e;
-
-	struct sched_param sched_param;
-	copyin(uap->param, &sched_param, sizeof(sched_param));
-
-	if ((e = p31b_proc(p, uap->pid, &p)) == 0) {
-		lp = FIRST_LWP_IN_PROC(p); /* XXX lwp */
-		e = ksched_setparam(&uap->sysmsg_result, ksched, lp,
-		    (const struct sched_param *)&sched_param);
-	}
-	return e;
-}
-
-int
-sys_sched_getparam(struct sched_getparam_args *uap)
-{
-	struct proc *p = curproc;
-	struct proc *targetp;
-	struct lwp *lp;
-	struct sched_param sched_param;
-	int e;
- 
-	if (uap->pid != 0 && uap->pid != p->p_pid) {
-		e = p31b_proc(p, uap->pid, &targetp);
-		if (e)
-			return e;
-	} else {
-		targetp = p;
-	}
- 
-	lp = FIRST_LWP_IN_PROC(targetp); /* XXX lwp */
-	e = ksched_getparam(&uap->sysmsg_result, ksched, lp, &sched_param);
-
-	if (!e)
-		copyout(&sched_param, uap->param, sizeof(sched_param));
-
-	return e;
-}
-
-int
-sys_sched_setscheduler(struct sched_setscheduler_args *uap)
-{
-	struct proc *p = curproc;
-	struct lwp *lp;
-	int e;
-
-	struct sched_param sched_param;
-	copyin(uap->param, &sched_param, sizeof(sched_param));
-
-	if ((e = p31b_proc(p, uap->pid, &p)) == 0) {
-		lp = FIRST_LWP_IN_PROC(p); /* XXX lwp */
-		e = ksched_setscheduler(&uap->sysmsg_result, ksched, lp,
-		    uap->policy, (const struct sched_param *)&sched_param);
-	}
-	return e;
-}
-
-int
-sys_sched_getscheduler(struct sched_getscheduler_args *uap)
-{
-	struct proc *p = curproc;
-	struct proc *targetp;
-	struct lwp *lp;
-	int e;
- 
-	if (uap->pid != 0 && uap->pid != p->p_pid) {
-		e = p31b_proc(p, uap->pid, &targetp);
-		if (e)
-			return e;
-	} else {
-		targetp = p;
-	}
- 
-	lp = FIRST_LWP_IN_PROC(targetp); /* XXX lwp */
-	e = ksched_getscheduler(&uap->sysmsg_result, ksched, lp);
-
-	return e;
-}
-
-int
-sys_sched_yield(struct sched_yield_args *uap)
-{
-	return ksched_yield(&uap->sysmsg_result, ksched);
-}
-
-int
-sys_sched_get_priority_max(struct sched_get_priority_max_args *uap)
-{
-	return ksched_get_priority_max(&uap->sysmsg_result, ksched, uap->policy);
-}
-
-int
-sys_sched_get_priority_min(struct sched_get_priority_min_args *uap)
-{
-	return ksched_get_priority_min(&uap->sysmsg_result, ksched, uap->policy);
-}
-
-int
-sys_sched_rr_get_interval(struct sched_rr_get_interval_args *uap)
-{
-	int e;
-	struct proc *p = curproc;
-	struct lwp *lp = curthread->td_lwp;
-
-	if ((e = p31b_proc(p, uap->pid, &p)) == 0) {
-	    e = ksched_rr_get_interval(&uap->sysmsg_result, ksched,
-		    lp, uap->interval);
-	}
-	return e;
-}
-
-#endif
-
-static void p31binit(void *notused)
-{
-	(void) sched_attach();
-	p31b_setcfg(CTL_P1003_1B_PAGESIZE, PAGE_SIZE);
-}
-
-SYSINIT(p31b, SI_SUB_P1003_1B, SI_ORDER_FIRST, p31binit, NULL);
diff --git a/sys/emulation/posix4/posix4.h b/sys/emulation/posix4/posix4.h
deleted file mode 100644
index 2e01fc0..0000000
--- a/sys/emulation/posix4/posix4.h
+++ /dev/null
@@ -1,105 +0,0 @@
-#ifndef _P1003_1B_P1003_1B_H_
-#define _P1003_1B_P1003_1B_H_
-/*-
- * Copyright (c) 1996, 1997, 1998
- *
- * 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.
- *
- * $FreeBSD: src/sys/posix4/posix4.h,v 1.6 1999/12/27 10:22:09 bde Exp $
- * $DragonFly: src/sys/emulation/posix4/posix4.h,v 1.7 2007/02/03 18:05:57 corecode Exp $
- */
-
-#include "opt_posix.h"
-
-#include <sys/param.h>
-#include <sys/ioccom.h>
-#include <sys/malloc.h>
-#include "sched.h"
-
-MALLOC_DECLARE(M_P31B);
-
-#define p31b_malloc(SIZE) kmalloc((SIZE), M_P31B, M_WAITOK)
-#define p31b_free(P) kfree((P), M_P31B)
-
-struct proc;
-struct lwp;
-
-int p31b_proc (struct proc *, pid_t, struct proc **);
-
-void p31b_setcfg (int, int);
-
-#ifdef _KPOSIX_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;
-
-int ksched_attach(struct ksched **);
-int ksched_detach(struct ksched *);
-
-int ksched_setparam(register_t *, struct ksched *,
-	struct lwp *, const struct sched_param *);
-int ksched_getparam(register_t *, struct ksched *,
-	struct lwp *, struct sched_param *);
-
-int ksched_setscheduler(register_t *, struct ksched *,
-	struct lwp *, int, const struct sched_param *);
-int ksched_getscheduler(register_t *, struct ksched *, struct lwp *);
-
-int ksched_yield(register_t *, struct ksched *);
-
-int ksched_get_priority_max(register_t *, struct ksched *, int);
-int ksched_get_priority_min(register_t *, struct ksched *, int);
-
-int ksched_rr_get_interval(register_t *, struct ksched *,
-	struct lwp *, struct timespec *);
-
-#endif /* _KPOSIX_PRIORITY_SCHEDULING */
-
-#endif /* _P1003_1B_P1003_1B_H_ */
diff --git a/sys/emulation/posix4/posix4_mib.c b/sys/emulation/posix4/posix4_mib.c
deleted file mode 100644
index 302e881..0000000
--- a/sys/emulation/posix4/posix4_mib.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-
- * 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.
- *
- * $FreeBSD: src/sys/posix4/posix4_mib.c,v 1.3.2.1 2000/08/03 01:09:59 peter Exp $
- * $DragonFly: src/sys/emulation/posix4/posix4_mib.c,v 1.3 2003/08/07 23:17:19 dillon Exp $
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/queue.h>
-#include <sys/sysctl.h>
-#include "posix4.h"
-
-static int facility[CTL_P1003_1B_MAXID - 1];
-
-/* OID_AUTO isn't working with sysconf(3).  I guess I'd have to
- * modify it to do a lookup by name from the index.
- * For now I've left it a top-level sysctl.
- */
-
-#if 1
-
-SYSCTL_DECL(_p1003_1b);
-
-#define P1B_SYSCTL(num, name)  \
-SYSCTL_INT(_p1003_1b, num, \
-	name, CTLFLAG_RD, facility + num - 1, 0, "");
-
-#else
-
-SYSCTL_DECL(_kern_p1003_1b);
-
-#define P1B_SYSCTL(num, name)  \
-SYSCTL_INT(_kern_p1003_1b, OID_AUTO, \
-	name, CTLFLAG_RD, facility + num - 1, 0, "");
-SYSCTL_NODE(_kern, OID_AUTO, p1003_1b, CTLFLAG_RW, 0, "P1003.1B");
-
-#endif
-
-P1B_SYSCTL(CTL_P1003_1B_ASYNCHRONOUS_IO, asynchronous_io);
-P1B_SYSCTL(CTL_P1003_1B_MAPPED_FILES, mapped_files);
-P1B_SYSCTL(CTL_P1003_1B_MEMLOCK, memlock);
-P1B_SYSCTL(CTL_P1003_1B_MEMLOCK_RANGE, memlock_range);
-P1B_SYSCTL(CTL_P1003_1B_MEMORY_PROTECTION, memory_protection);
-P1B_SYSCTL(CTL_P1003_1B_MESSAGE_PASSING, message_passing);
-P1B_SYSCTL(CTL_P1003_1B_PRIORITIZED_IO, prioritized_io);
-P1B_SYSCTL(CTL_P1003_1B_PRIORITY_SCHEDULING, priority_scheduling);
-P1B_SYSCTL(CTL_P1003_1B_REALTIME_SIGNALS, realtime_signals);
-P1B_SYSCTL(CTL_P1003_1B_SEMAPHORES, semaphores);
-P1B_SYSCTL(CTL_P1003_1B_FSYNC, fsync);
-P1B_SYSCTL(CTL_P1003_1B_SHARED_MEMORY_OBJECTS, shared_memory_objects);
-P1B_SYSCTL(CTL_P1003_1B_SYNCHRONIZED_IO, synchronized_io);
-P1B_SYSCTL(CTL_P1003_1B_TIMERS, timers);
-P1B_SYSCTL(CTL_P1003_1B_AIO_LISTIO_MAX, aio_listio_max);
-P1B_SYSCTL(CTL_P1003_1B_AIO_MAX, aio_max);
-P1B_SYSCTL(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, aio_prio_delta_max);
-P1B_SYSCTL(CTL_P1003_1B_DELAYTIMER_MAX, delaytimer_max);
-P1B_SYSCTL(CTL_P1003_1B_MQ_OPEN_MAX, mq_open_max);
-P1B_SYSCTL(CTL_P1003_1B_PAGESIZE, pagesize);
-P1B_SYSCTL(CTL_P1003_1B_RTSIG_MAX, rtsig_max);
-P1B_SYSCTL(CTL_P1003_1B_SEM_NSEMS_MAX, sem_nsems_max);
-P1B_SYSCTL(CTL_P1003_1B_SEM_VALUE_MAX, sem_value_max);
-P1B_SYSCTL(CTL_P1003_1B_SIGQUEUE_MAX, sigqueue_max);
-P1B_SYSCTL(CTL_P1003_1B_TIMER_MAX, timer_max);
-
-/* p31b_setcfg: Set the configuration
- */
-void p31b_setcfg(int num, int value)
-{
-	if (num >= 1 && num < CTL_P1003_1B_MAXID)
-		facility[num - 1] = value;
-}
diff --git a/sys/emulation/posix4/sched.h b/sys/emulation/posix4/sched.h
deleted file mode 100644
index 77aad49..0000000
--- a/sys/emulation/posix4/sched.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef _SCHED_H_
-#define _SCHED_H_
-
-/* sched.h: POSIX 1003.1b 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.
- *
- * $FreeBSD: src/sys/posix4/sched.h,v 1.4 1999/12/29 04:55:02 peter Exp $
- * $DragonFly: src/sys/emulation/posix4/sched.h,v 1.3 2003/08/27 08:30:04 rob Exp $
- */
-
-#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>
-
-__BEGIN_DECLS
-int sched_setparam (pid_t, const struct sched_param *);
-int sched_getparam (pid_t, struct sched_param *);
-
-int sched_setscheduler (pid_t, int, const struct sched_param *);
-int sched_getscheduler (pid_t);
-
-int sched_yield (void);
-int sched_get_priority_max (int);
-int sched_get_priority_min (int);
-int sched_rr_get_interval (pid_t, struct timespec *);
-__END_DECLS
-
-#endif
-
-#endif /* _SCHED_H_ */
diff --git a/sys/emulation/posix4/semaphore.h b/sys/emulation/posix4/semaphore.h
deleted file mode 100644
index de4c190..0000000
--- a/sys/emulation/posix4/semaphore.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef _SEMAPHORE_H_
-#define _SEMAPHORE_H_
-
-/* semaphore.h: POSIX 1003.1b 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.
- *
- * $FreeBSD: src/sys/posix4/semaphore.h,v 1.6 2000/01/20 07:55:42 jasone Exp $
- * $DragonFly: src/sys/emulation/posix4/semaphore.h,v 1.3 2003/08/27 08:30:04 rob Exp $
- */
-
-#include <sys/_posix.h>
-#include <machine/limits.h>
-
-#ifdef _P1003_1B_INCLUDE_MAYBES
-#include <sys/types.h>
-#include <fcntl.h>
-#endif
-
-/* Opaque type definition. */
-struct sem;
-typedef struct sem *sem_t;
-
-#define SEM_FAILED	((sem_t *)0)
-#define SEM_VALUE_MAX	UINT_MAX
-
-#ifndef _KERNEL
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-int	 sem_init (sem_t *, int, unsigned int);
-int	 sem_destroy (sem_t *);
-sem_t	*sem_open (const char *, int, ...);
-int	 sem_close (sem_t *);
-int	 sem_unlink (const char *);
-int	 sem_wait (sem_t *);
-int	 sem_trywait (sem_t *);
-int	 sem_post (sem_t *);
-int	 sem_getvalue (sem_t *, int *);
-__END_DECLS
-
-#endif
-
-#endif /* _SEMAPHORE_H_ */
diff --git a/sys/kern/kern_p1003_1b.c b/sys/kern/kern_p1003_1b.c
new file mode 100644
index 0000000..b0d9ab2
--- /dev/null
+++ b/sys/kern/kern_p1003_1b.c
@@ -0,0 +1,294 @@
+/*
+ * 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.
+ *
+ * $FreeBSD: src/sys/posix4/p1003_1b.c,v 1.5.2.2 2003/03/25 06:13:35 rwatson Exp $
+ * $DragonFly: src/sys/emulation/posix4/p1003_1b.c,v 1.9 2007/02/03 18:05:57 corecode Exp $
+ */
+
+/* p1003_1b: Real Time common code.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/sysent.h>
+#include <sys/posix4.h>
+#include <sys/proc.h>
+#include <sys/syslog.h>
+#include <sys/module.h>
+#include <sys/sysproto.h>
+#include <sys/sysctl.h>
+
+MALLOC_DEFINE(M_P31B, "p1003.1b", "Posix 1003.1B");
+
+/* p31b_proc: Return a proc struct corresponding to a pid to operate on.
+ *
+ * Enforce permission policy.
+ *
+ * The policy is the same as for sending signals except there
+ * is no notion of process groups.
+ *
+ * pid == 0 means my process.
+ *
+ * This is disabled until I've got a permission gate in again:
+ * only root can do this.
+ */
+
+#if 0
+/*
+ * This is stolen from CANSIGNAL in kern_sig:
+ *
+ * Can process p, with pcred pc, do "write flavor" operations to process q?
+ */
+#define CAN_AFFECT(p, cr, q) \
+	((cr)->cr_uid == 0 || \
+	    (cr)->cr_ruid == (q)->p_ucred->cr_ruid || \
+	    (cr)->cr_uid == (q)->p_ucred->cr_ruid || \
+	    (cr)->cr_ruid == (q)->p_ucred->cr_uid || \
+	    (cr)->cr_uid == (q)->p_ucred->cr_uid)
+#else
+#define CAN_AFFECT(p, cr, q) ((cr)->cr_uid == 0)
+#endif
+
+/*
+ * p31b_proc: Look up a proc from a PID.  If proc is 0 it is
+ * my own proc.
+ */
+int p31b_proc(struct proc *p, pid_t pid, struct proc **pp)
+{
+	int ret = 0;
+	struct proc *other_proc = 0;
+
+	if (pid == 0)
+		other_proc = p;
+	else
+		other_proc = pfind(pid);
+
+	if (other_proc)
+	{
+		/* Enforce permission policy.
+		 */
+		if (CAN_AFFECT(p, p->p_ucred, other_proc))
+			*pp = other_proc;
+		else
+			ret = EPERM;
+	}
+	else
+		ret = ESRCH;
+
+	return ret;
+}
+
+
+#if !defined(_KPOSIX_PRIORITY_SCHEDULING)
+
+int syscall_not_present(const char *s);
+
+/* The system calls return ENOSYS if an entry is called that is
+ * not run-time supported.  I am also logging since some programs
+ * start to use this when they shouldn't.  That will be removed if annoying.
+ */
+int syscall_not_present(const char *s)
+{
+	struct proc *p = curproc;
+	log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n",
+			p->p_comm, p->p_pid, s);
+
+	/* a " return nosys(p, uap); " here causes a core dump.
+	 */
+
+	return ENOSYS;
+}
+
+/* Not configured but loadable via a module:
+ */
+
+static int sched_attach(void)
+{
+	return 0;
+}
+
+#define SYSCALL_NOT_PRESENT_GEN(SC) \
+int SC (struct SC##_args *uap) \
+{ \
+	return syscall_not_present(#SC); \
+}
+
+SYSCALL_NOT_PRESENT_GEN(sched_setparam)
+SYSCALL_NOT_PRESENT_GEN(sched_getparam)
+SYSCALL_NOT_PRESENT_GEN(sched_setscheduler)
+SYSCALL_NOT_PRESENT_GEN(sched_getscheduler)
+SYSCALL_NOT_PRESENT_GEN(sched_yield)
+SYSCALL_NOT_PRESENT_GEN(sched_get_priority_max)
+SYSCALL_NOT_PRESENT_GEN(sched_get_priority_min)
+SYSCALL_NOT_PRESENT_GEN(sched_rr_get_interval)
+
+#else
+
+/* Configured in kernel version:
+ */
+static struct ksched *ksched;
+
+static int sched_attach(void)
+{
+	int ret = ksched_attach(&ksched);
+
+	if (ret == 0)
+		p31b_setcfg(CTL_P1003_1B_PRIORITY_SCHEDULING, 1);
+
+	return ret;
+}
+
+int
+sys_sched_setparam(struct sched_setparam_args *uap)
+{
+	struct proc *p = curproc;
+	struct lwp *lp;
+	int e;
+
+	struct sched_param sched_param;
+	copyin(uap->param, &sched_param, sizeof(sched_param));
+
+	if ((e = p31b_proc(p, uap->pid, &p)) == 0) {
+		lp = FIRST_LWP_IN_PROC(p); /* XXX lwp */
+		e = ksched_setparam(&uap->sysmsg_result, ksched, lp,
+		    (const struct sched_param *)&sched_param);
+	}
+	return e;
+}
+
+int
+sys_sched_getparam(struct sched_getparam_args *uap)
+{
+	struct proc *p = curproc;
+	struct proc *targetp;
+	struct lwp *lp;
+	struct sched_param sched_param;
+	int e;
+ 
+	if (uap->pid != 0 && uap->pid != p->p_pid) {
+		e = p31b_proc(p, uap->pid, &targetp);
+		if (e)
+			return e;
+	} else {
+		targetp = p;
+	}
+ 
+	lp = FIRST_LWP_IN_PROC(targetp); /* XXX lwp */
+	e = ksched_getparam(&uap->sysmsg_result, ksched, lp, &sched_param);
+
+	if (!e)
+		copyout(&sched_param, uap->param, sizeof(sched_param));
+
+	return e;
+}
+
+int
+sys_sched_setscheduler(struct sched_setscheduler_args *uap)
+{
+	struct proc *p = curproc;
+	struct lwp *lp;
+	int e;
+
+	struct sched_param sched_param;
+	copyin(uap->param, &sched_param, sizeof(sched_param));
+
+	if ((e = p31b_proc(p, uap->pid, &p)) == 0) {
+		lp = FIRST_LWP_IN_PROC(p); /* XXX lwp */
+		e = ksched_setscheduler(&uap->sysmsg_result, ksched, lp,
+		    uap->policy, (const struct sched_param *)&sched_param);
+	}
+	return e;
+}
+
+int
+sys_sched_getscheduler(struct sched_getscheduler_args *uap)
+{
+	struct proc *p = curproc;
+	struct proc *targetp;
+	struct lwp *lp;
+	int e;
+ 
+	if (uap->pid != 0 && uap->pid != p->p_pid) {
+		e = p31b_proc(p, uap->pid, &targetp);
+		if (e)
+			return e;
+	} else {
+		targetp = p;
+	}
+ 
+	lp = FIRST_LWP_IN_PROC(targetp); /* XXX lwp */
+	e = ksched_getscheduler(&uap->sysmsg_result, ksched, lp);
+
+	return e;
+}
+
+int
+sys_sched_yield(struct sched_yield_args *uap)
+{
+	return ksched_yield(&uap->sysmsg_result, ksched);
+}
+
+int
+sys_sched_get_priority_max(struct sched_get_priority_max_args *uap)
+{
+	return ksched_get_priority_max(&uap->sysmsg_result, ksched, uap->policy);
+}
+
+int
+sys_sched_get_priority_min(struct sched_get_priority_min_args *uap)
+{
+	return ksched_get_priority_min(&uap->sysmsg_result, ksched, uap->policy);
+}
+
+int
+sys_sched_rr_get_interval(struct sched_rr_get_interval_args *uap)
+{
+	int e;
+	struct proc *p = curproc;
+	struct lwp *lp = curthread->td_lwp;
+
+	if ((e = p31b_proc(p, uap->pid, &p)) == 0) {
+	    e = ksched_rr_get_interval(&uap->sysmsg_result, ksched,
+		    lp, uap->interval);
+	}
+	return e;
+}
+
+#endif
+
+static void p31binit(void *notused)
+{
+	(void) sched_attach();
+	p31b_setcfg(CTL_P1003_1B_PAGESIZE, PAGE_SIZE);
+}
+
+SYSINIT(p31b, SI_SUB_P1003_1B, SI_ORDER_FIRST, p31binit, NULL);
diff --git a/sys/kern/kern_posix4_mib.c b/sys/kern/kern_posix4_mib.c
new file mode 100644
index 0000000..698c9fc
--- /dev/null
+++ b/sys/kern/kern_posix4_mib.c
@@ -0,0 +1,100 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD: src/sys/posix4/posix4_mib.c,v 1.3.2.1 2000/08/03 01:09:59 peter Exp $
+ * $DragonFly: src/sys/emulation/posix4/posix4_mib.c,v 1.3 2003/08/07 23:17:19 dillon Exp $
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/queue.h>
+#include <sys/sysctl.h>
+#include <sys/posix4.h>
+
+static int facility[CTL_P1003_1B_MAXID - 1];
+
+/* OID_AUTO isn't working with sysconf(3).  I guess I'd have to
+ * modify it to do a lookup by name from the index.
+ * For now I've left it a top-level sysctl.
+ */
+
+#if 1
+
+SYSCTL_DECL(_p1003_1b);
+
+#define P1B_SYSCTL(num, name)  \
+SYSCTL_INT(_p1003_1b, num, \
+	name, CTLFLAG_RD, facility + num - 1, 0, "");
+
+#else
+
+SYSCTL_DECL(_kern_p1003_1b);
+
+#define P1B_SYSCTL(num, name)  \
+SYSCTL_INT(_kern_p1003_1b, OID_AUTO, \
+	name, CTLFLAG_RD, facility + num - 1, 0, "");
+SYSCTL_NODE(_kern, OID_AUTO, p1003_1b, CTLFLAG_RW, 0, "P1003.1B");
+
+#endif
+
+P1B_SYSCTL(CTL_P1003_1B_ASYNCHRONOUS_IO, asynchronous_io);
+P1B_SYSCTL(CTL_P1003_1B_MAPPED_FILES, mapped_files);
+P1B_SYSCTL(CTL_P1003_1B_MEMLOCK, memlock);
+P1B_SYSCTL(CTL_P1003_1B_MEMLOCK_RANGE, memlock_range);
+P1B_SYSCTL(CTL_P1003_1B_MEMORY_PROTECTION, memory_protection);
+P1B_SYSCTL(CTL_P1003_1B_MESSAGE_PASSING, message_passing);
+P1B_SYSCTL(CTL_P1003_1B_PRIORITIZED_IO, prioritized_io);
+P1B_SYSCTL(CTL_P1003_1B_PRIORITY_SCHEDULING, priority_scheduling);
+P1B_SYSCTL(CTL_P1003_1B_REALTIME_SIGNALS, realtime_signals);
+P1B_SYSCTL(CTL_P1003_1B_SEMAPHORES, semaphores);
+P1B_SYSCTL(CTL_P1003_1B_FSYNC, fsync);
+P1B_SYSCTL(CTL_P1003_1B_SHARED_MEMORY_OBJECTS, shared_memory_objects);
+P1B_SYSCTL(CTL_P1003_1B_SYNCHRONIZED_IO, synchronized_io);
+P1B_SYSCTL(CTL_P1003_1B_TIMERS, timers);
+P1B_SYSCTL(CTL_P1003_1B_AIO_LISTIO_MAX, aio_listio_max);
+P1B_SYSCTL(CTL_P1003_1B_AIO_MAX, aio_max);
+P1B_SYSCTL(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, aio_prio_delta_max);
+P1B_SYSCTL(CTL_P1003_1B_DELAYTIMER_MAX, delaytimer_max);
+P1B_SYSCTL(CTL_P1003_1B_MQ_OPEN_MAX, mq_open_max);
+P1B_SYSCTL(CTL_P1003_1B_PAGESIZE, pagesize);
+P1B_SYSCTL(CTL_P1003_1B_RTSIG_MAX, rtsig_max);
+P1B_SYSCTL(CTL_P1003_1B_SEM_NSEMS_MAX, sem_nsems_max);
+P1B_SYSCTL(CTL_P1003_1B_SEM_VALUE_MAX, sem_value_max);
+P1B_SYSCTL(CTL_P1003_1B_SIGQUEUE_MAX, sigqueue_max);
+P1B_SYSCTL(CTL_P1003_1B_TIMER_MAX, timer_max);
+
+/* p31b_setcfg: Set the configuration
+ */
+void p31b_setcfg(int num, int value)
+{
+	if (num >= 1 && num < CTL_P1003_1B_MAXID)
+		facility[num - 1] = value;
+}
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
new file mode 100644
index 0000000..45cc726
--- /dev/null
+++ b/sys/kern/kern_sched.c
@@ -0,0 +1,265 @@
+/*
+ * 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.
+ *
+ * $FreeBSD: src/sys/posix4/ksched.c,v 1.7.2.1 2000/05/16 06:58:13 dillon Exp $
+ * $DragonFly: src/sys/emulation/posix4/ksched.c,v 1.8 2007/02/03 18:05:57 corecode Exp $
+ */
+
+/* ksched: Soft real time scheduling based on "rtprio".
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/posix4.h>
+#include <sys/proc.h>
+#include <sys/kernel.h>
+#include <sys/resource.h>
+#include <machine/cpu.h>	/* For need_user_resched */
+
+
+/* ksched: Real-time extension to support POSIX priority scheduling.
+ */
+
+struct ksched {
+	struct timespec rr_interval;
+};
+
+int ksched_attach(struct ksched **p)
+{
+	struct ksched *ksched= p31b_malloc(sizeof(*ksched));
+
+	ksched->rr_interval.tv_sec = 0;
+	ksched->rr_interval.tv_nsec = 1000000000L / 10;	/* XXX */
+
+	*p = ksched;
+	return 0;
+}
+
+int ksched_detach(struct ksched *p)
+{
+	p31b_free(p);
+
+	return 0;
+}
+
+/*
+ * XXX About priorities
+ *
+ *	POSIX 1003.1b 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 POSIX 1003.1b (higher numerically is higher priority)
+ */
+
+#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
+#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
+
+/* These improve readability a bit for me:
+ */
+#define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX)
+#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
+
+static __inline int
+getscheduler(register_t *ret, struct ksched *ksched, struct lwp *lp)
+{
+	int e = 0;
+
+	switch (lp->lwp_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(register_t *ret, struct ksched *ksched,
+	struct lwp *lp, const struct sched_param *param)
+{
+	register_t policy;
+	int e;
+
+	e = getscheduler(&policy, ksched, lp);
+
+	if (e == 0)
+	{
+		if (policy == SCHED_OTHER)
+			e = EINVAL;
+		else
+			e = ksched_setscheduler(ret, ksched, lp, policy, param);
+	}
+
+	return e;
+}
+
+int ksched_getparam(register_t *ret, struct ksched *ksched,
+	struct lwp *lp, struct sched_param *param)
+{
+	if (RTP_PRIO_IS_REALTIME(lp->lwp_rtprio.type))
+		param->sched_priority = rtpprio_to_p4prio(lp->lwp_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 "p31b_proc()".
+ *
+ */
+int ksched_setscheduler(register_t *ret, struct ksched *ksched,
+	struct lwp *lp, 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 >= P1B_PRIO_MIN &&
+		param->sched_priority <= P1B_PRIO_MAX)
+		{
+			rtp.prio = p4prio_to_rtpprio(param->sched_priority);
+			rtp.type = (policy == SCHED_FIFO)
+				? RTP_PRIO_FIFO : RTP_PRIO_REALTIME;
+
+			lp->lwp_rtprio = rtp;
+			need_user_resched();
+		}
+		else
+			e = EPERM;
+
+
+		break;
+
+		case SCHED_OTHER:
+		{
+			rtp.type = RTP_PRIO_NORMAL;
+			rtp.prio = p4prio_to_rtpprio(param->sched_priority);
+			lp->lwp_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.
+			 */
+			need_user_resched();
+		}
+		break;
+	}
+
+	return e;
+}
+
+int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct lwp *lp)
+{
+	return getscheduler(ret, ksched, lp);
+}
+
+/* ksched_yield: Yield the CPU.
+ */
+int ksched_yield(register_t *ret, struct ksched *ksched)
+{
+	need_user_resched();
+	return 0;
+}
+
+int ksched_get_priority_max(register_t*ret, struct ksched *ksched, 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(register_t *ret, struct ksched *ksched, int policy)
+{
+	int e = 0;
+
+	switch (policy)
+	{
+		case SCHED_FIFO:
+		case SCHED_RR:
+		*ret = P1B_PRIO_MIN;
+		break;
+
+		case SCHED_OTHER:
+		*ret =  PRIO_MIN;
+		break;
+
+		default:
+		e = EINVAL;
+	}
+
+	return e;
+}
+
+int ksched_rr_get_interval(register_t *ret, struct ksched *ksched,
+	struct lwp *lp, struct timespec *timespec)
+{
+	*timespec = ksched->rr_interval;
+
+	return 0;
+}
diff --git a/sys/sys/mqueue.h b/sys/sys/mqueue.h
new file mode 100644
index 0000000..5970c47
--- /dev/null
+++ b/sys/sys/mqueue.h
@@ -0,0 +1,78 @@
+#ifndef _MQUEUE_H_
+#define _MQUEUE_H_
+
+/* mqueue.h: POSIX 1003.1b 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.
+ *
+ * $FreeBSD: src/sys/posix4/mqueue.h,v 1.4 1999/12/29 04:55:02 peter Exp $
+ * $DragonFly: src/sys/emulation/posix4/mqueue.h,v 1.3 2003/08/27 08:30:04 rob Exp $
+ */
+
+#include <sys/_posix.h>
+
+#ifdef _P1003_1B_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>
+
+__BEGIN_DECLS
+mqd_t mq_open (const char *, int oflag, ...);
+int mq_close (mqd_t);
+int mq_unlink (const char *);
+int mq_send (mqd_t, const char *, size_t, unsigned int);
+ssize_t mq_receive (mqd_t, char *, size_t, unsigned int *);
+int mq_notify (mqd_t, const struct sigevent *);
+int mq_setattr (mqd_t, const struct mq_attr *, struct mq_attr *);
+int mq_getattr (mqd_t, struct mq_attr *);
+__END_DECLS
+
+#endif
+
+#endif /* _MQUEUE_H_ */
diff --git a/sys/sys/posix4.h b/sys/sys/posix4.h
new file mode 100644
index 0000000..0ce536c
--- /dev/null
+++ b/sys/sys/posix4.h
@@ -0,0 +1,105 @@
+#ifndef _P1003_1B_P1003_1B_H_
+#define _P1003_1B_P1003_1B_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.
+ *
+ * $FreeBSD: src/sys/posix4/posix4.h,v 1.6 1999/12/27 10:22:09 bde Exp $
+ * $DragonFly: src/sys/emulation/posix4/posix4.h,v 1.7 2007/02/03 18:05:57 corecode Exp $
+ */
+
+#include "opt_posix.h"
+
+#include <sys/param.h>
+#include <sys/ioccom.h>
+#include <sys/malloc.h>
+#include <sys/sched.h>
+
+MALLOC_DECLARE(M_P31B);
+
+#define p31b_malloc(SIZE) kmalloc((SIZE), M_P31B, M_WAITOK)
+#define p31b_free(P) kfree((P), M_P31B)
+
+struct proc;
+struct lwp;
+
+int p31b_proc (struct proc *, pid_t, struct proc **);
+
+void p31b_setcfg (int, int);
+
+#ifdef _KPOSIX_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;
+
+int ksched_attach(struct ksched **);
+int ksched_detach(struct ksched *);
+
+int ksched_setparam(register_t *, struct ksched *,
+	struct lwp *, const struct sched_param *);
+int ksched_getparam(register_t *, struct ksched *,
+	struct lwp *, struct sched_param *);
+
+int ksched_setscheduler(register_t *, struct ksched *,
+	struct lwp *, int, const struct sched_param *);
+int ksched_getscheduler(register_t *, struct ksched *, struct lwp *);
+
+int ksched_yield(register_t *, struct ksched *);
+
+int ksched_get_priority_max(register_t *, struct ksched *, int);
+int ksched_get_priority_min(register_t *, struct ksched *, int);
+
+int ksched_rr_get_interval(register_t *, struct ksched *,
+	struct lwp *, struct timespec *);
+
+#endif /* _KPOSIX_PRIORITY_SCHEDULING */
+
+#endif /* _P1003_1B_P1003_1B_H_ */
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
new file mode 100644
index 0000000..77aad49
--- /dev/null
+++ b/sys/sys/sched.h
@@ -0,0 +1,77 @@
+#ifndef _SCHED_H_
+#define _SCHED_H_
+
+/* sched.h: POSIX 1003.1b 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.
+ *
+ * $FreeBSD: src/sys/posix4/sched.h,v 1.4 1999/12/29 04:55:02 peter Exp $
+ * $DragonFly: src/sys/emulation/posix4/sched.h,v 1.3 2003/08/27 08:30:04 rob Exp $
+ */
+
+#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>
+
+__BEGIN_DECLS
+int sched_setparam (pid_t, const struct sched_param *);
+int sched_getparam (pid_t, struct sched_param *);
+
+int sched_setscheduler (pid_t, int, const struct sched_param *);
+int sched_getscheduler (pid_t);
+
+int sched_yield (void);
+int sched_get_priority_max (int);
+int sched_get_priority_min (int);
+int sched_rr_get_interval (pid_t, struct timespec *);
+__END_DECLS
+
+#endif
+
+#endif /* _SCHED_H_ */
diff --git a/sys/sys/semaphore.h b/sys/sys/semaphore.h
new file mode 100644
index 0000000..de4c190
--- /dev/null
+++ b/sys/sys/semaphore.h
@@ -0,0 +1,73 @@
+#ifndef _SEMAPHORE_H_
+#define _SEMAPHORE_H_
+
+/* semaphore.h: POSIX 1003.1b 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.
+ *
+ * $FreeBSD: src/sys/posix4/semaphore.h,v 1.6 2000/01/20 07:55:42 jasone Exp $
+ * $DragonFly: src/sys/emulation/posix4/semaphore.h,v 1.3 2003/08/27 08:30:04 rob Exp $
+ */
+
+#include <sys/_posix.h>
+#include <machine/limits.h>
+
+#ifdef _P1003_1B_INCLUDE_MAYBES
+#include <sys/types.h>
+#include <fcntl.h>
+#endif
+
+/* Opaque type definition. */
+struct sem;
+typedef struct sem *sem_t;
+
+#define SEM_FAILED	((sem_t *)0)
+#define SEM_VALUE_MAX	UINT_MAX
+
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int	 sem_init (sem_t *, int, unsigned int);
+int	 sem_destroy (sem_t *);
+sem_t	*sem_open (const char *, int, ...);
+int	 sem_close (sem_t *);
+int	 sem_unlink (const char *);
+int	 sem_wait (sem_t *);
+int	 sem_trywait (sem_t *);
+int	 sem_post (sem_t *);
+int	 sem_getvalue (sem_t *, int *);
+__END_DECLS
+
+#endif
+
+#endif /* _SEMAPHORE_H_ */
diff --git a/tools/regression/p1003_1b/fifo.c b/tools/regression/p1003_1b/fifo.c
index 70b1887..bf098b9 100644
--- a/tools/regression/p1003_1b/fifo.c
+++ b/tools/regression/p1003_1b/fifo.c
@@ -41,7 +41,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/time.h>
-#include <sched.h>
+#include <sys/sched.h>
 #include <signal.h>
 
 volatile int ticked;
diff --git a/tools/regression/p1003_1b/prutil.c b/tools/regression/p1003_1b/prutil.c
index bbbaf9d..3674d60 100644
--- a/tools/regression/p1003_1b/prutil.c
+++ b/tools/regression/p1003_1b/prutil.c
@@ -1,6 +1,6 @@
 #include <errno.h>
 #include <unistd.h>
-#include <sched.h>
+#include <sys/sched.h>
 #include <stdio.h>
 
 #include <err.h>
diff --git a/tools/regression/p1003_1b/sched.c b/tools/regression/p1003_1b/sched.c
index 94a5033..53cd6cd 100644
--- a/tools/regression/p1003_1b/sched.c
+++ b/tools/regression/p1003_1b/sched.c
@@ -51,7 +51,7 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 
-#include <sched.h>
+#include <sys/sched.h>
 
 #include "prutil.h"
 
diff --git a/tools/regression/p1003_1b/yield.c b/tools/regression/p1003_1b/yield.c
index 8a8bd56..e03479e 100644
--- a/tools/regression/p1003_1b/yield.c
+++ b/tools/regression/p1003_1b/yield.c
@@ -41,7 +41,7 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/mman.h>
-#include <sched.h>
+#include <sys/sched.h>
 #include <stdlib.h>
 #include <sys/wait.h>
 
diff --git a/usr.sbin/clog/clog.c b/usr.sbin/clog/clog.c
index 98e4dfd..c0295b6 100644
--- a/usr.sbin/clog/clog.c
+++ b/usr.sbin/clog/clog.c
@@ -33,7 +33,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <poll.h>
-#include <sched.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -41,6 +40,7 @@
 #include <unistd.h>
 
 #include <sys/mman.h>
+#include <sys/sched.h>
 #include <sys/stat.h>
 #include <sys/uio.h>
 


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]