summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-12-22 00:42:08 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-12-22 00:42:08 +0000
commit95cfcfbb6bd8d425a1a71c9f2cfdcc7fa472f232 (patch)
tree441386465b7d7de595fafdacd131f162cac7d15c
parentd9368ef69de420c7613a640d9d62c5376674eb5a (diff)
Add pthread_mutex_{get,set}prioceiling()
-rw-r--r--lib/librthread/Makefile4
-rw-r--r--lib/librthread/rthread_mutex_prio.c55
2 files changed, 57 insertions, 2 deletions
diff --git a/lib/librthread/Makefile b/lib/librthread/Makefile
index 768cd36dadd..3586e8179a7 100644
--- a/lib/librthread/Makefile
+++ b/lib/librthread/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.21 2011/12/21 23:59:03 guenther Exp $
+# $OpenBSD: Makefile,v 1.22 2011/12/22 00:42:07 guenther Exp $
LIB=rthread
WANTLINT=
@@ -15,7 +15,7 @@ SRCS= rthread.c rthread_attr.c rthread_sched.c rthread_sync.c rthread_tls.c \
rthread_sig.c rthread_np.c rthread_debug.c rthread_stack.c \
rthread_libc.c rthread_fork.c rthread_file.c sched_prio.c \
rthread_cancel.c rthread_mutexattr.c rthread_once.c \
- rthread_rwlock.c rthread_rwlockattr.c
+ rthread_rwlock.c rthread_rwlockattr.c rthread_mutex_prio.c
OBJS+= _atomic_lock.o rfork_thread.o cerror.o
diff --git a/lib/librthread/rthread_mutex_prio.c b/lib/librthread/rthread_mutex_prio.c
new file mode 100644
index 00000000000..5dca967e33f
--- /dev/null
+++ b/lib/librthread/rthread_mutex_prio.c
@@ -0,0 +1,55 @@
+/* $OpenBSD: rthread_mutex_prio.c,v 1.1 2011/12/22 00:42:07 guenther Exp $ */
+/*
+ * Copyright (c) 2011 Philip Guenther <guenther@openbsd.org>
+ * All Rights Reserved.
+ *
+ * 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>
+
+#include <pthread.h>
+#include "rthread.h"
+
+int
+pthread_mutex_getprioceiling(pthread_mutex_t *mutexp, int *prioceiling)
+{
+ pthread_mutex_t mutex = *mutexp;
+
+ if (mutex->prioceiling == -1)
+ return (EINVAL);
+ *prioceiling = mutex->prioceiling;
+
+ return (0);
+}
+
+int
+pthread_mutex_setprioceiling(pthread_mutex_t *mutexp, int prioceiling,
+ int *old_ceiling)
+{
+ pthread_mutex_t mutex = *mutexp;
+ int ret;
+
+ if (mutex->prioceiling == -1 ||
+ prioceiling < PTHREAD_MIN_PRIORITY ||
+ prioceiling > PTHREAD_MAX_PRIORITY) {
+ ret = EINVAL;
+ } else if ((ret = pthread_mutex_lock(mutexp)) == 0) {
+ *old_ceiling = mutex->prioceiling;
+ mutex->prioceiling = prioceiling;
+ pthread_mutex_unlock(mutexp);
+ }
+
+ return (ret);
+}