Add pthread_setschedprio.
Bug: http://b/26204555
Test: ran tests
Change-Id: Ic34062b9b6036a1ce2642a069514bab48a893338
diff --git a/libc/bionic/pthread_setschedparam.cpp b/libc/bionic/pthread_setschedparam.cpp
index 3e80959..10826d1 100644
--- a/libc/bionic/pthread_setschedparam.cpp
+++ b/libc/bionic/pthread_setschedparam.cpp
@@ -27,9 +27,10 @@
*/
#include <errno.h>
+#include <pthread.h>
+#include <sched.h>
#include "private/ErrnoRestorer.h"
-#include "pthread_internal.h"
int pthread_setschedparam(pthread_t t, int policy, const sched_param* param) {
ErrnoRestorer errno_restorer;
@@ -39,3 +40,13 @@
return (sched_setscheduler(tid, policy, param) == -1) ? errno : 0;
}
+
+int pthread_setschedprio(pthread_t t, int priority) {
+ ErrnoRestorer errno_restorer;
+
+ pid_t tid = pthread_gettid_np(t);
+ if (tid == -1) return ESRCH;
+
+ sched_param param = { .sched_priority = priority };
+ return (sched_setparam(tid, ¶m) == -1) ? errno : 0;
+}