summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/uthread
diff options
context:
space:
mode:
authorfgsch <fgsch@openbsd.org>2010-11-07 13:29:21 +0000
committerfgsch <fgsch@openbsd.org>2010-11-07 13:29:21 +0000
commit372e44f40178587a228dc01a8230fe2993bb26a3 (patch)
treeec2a2decf60187fa0a7fd42a62d3cff2259483f6 /lib/libpthread/uthread
parentregen (diff)
downloadwireguard-openbsd-372e44f40178587a228dc01a8230fe2993bb26a3.tar.xz
wireguard-openbsd-372e44f40178587a228dc01a8230fe2993bb26a3.zip
Add sched_get_priority_{min,max}. tested in a bulk by landry@.
input and ok from phessler@ and guenther@
Diffstat (limited to 'lib/libpthread/uthread')
-rw-r--r--lib/libpthread/uthread/Makefile.inc3
-rw-r--r--lib/libpthread/uthread/sched_prio.c45
2 files changed, 47 insertions, 1 deletions
diff --git a/lib/libpthread/uthread/Makefile.inc b/lib/libpthread/uthread/Makefile.inc
index 66908ef5a21..7b457350353 100644
--- a/lib/libpthread/uthread/Makefile.inc
+++ b/lib/libpthread/uthread/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.22 2010/02/03 20:49:00 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.23 2010/11/07 13:29:21 fgsch Exp $
# $FreeBSD: Makefile.inc,v 1.19 1999/08/28 00:03:19 peter Exp $
# uthread sources
@@ -7,6 +7,7 @@
CFLAGS += -I${SRCDIR}/arch/${MACHINE_CPU}
SRCS+= \
+ sched_prio.c \
uthread_accept.c \
uthread_atfork.c \
uthread_attr_destroy.c \
diff --git a/lib/libpthread/uthread/sched_prio.c b/lib/libpthread/uthread/sched_prio.c
new file mode 100644
index 00000000000..1e48a747554
--- /dev/null
+++ b/lib/libpthread/uthread/sched_prio.c
@@ -0,0 +1,45 @@
+/* $OpenBSD: sched_prio.c,v 1.1 2010/11/07 13:29:21 fgsch Exp $ */
+
+/*
+ * Copyright (c) 2010 Federico G. Schwindt <fgsch@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose with or without fee is hereby granted, provided that
+ * the above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
+ * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+
+int
+sched_get_priority_max(int policy)
+{
+ if (policy < SCHED_FIFO || policy > SCHED_RR) {
+ errno = EINVAL;
+ return (-1);
+ }
+ return (PTHREAD_MAX_PRIORITY);
+}
+
+int
+sched_get_priority_min(int policy)
+{
+ if (policy < SCHED_FIFO || policy > SCHED_RR) {
+ errno = EINVAL;
+ return (-1);
+ }
+ return (PTHREAD_MIN_PRIORITY);
+}
+#endif