Use syscall(2) instead of ioprio_get/ioprio_set.
Change-Id: Ibfd0bdd3dd0bad9804ec9fd9292f4b68a510afdb
diff --git a/libcutils/iosched_policy.c b/libcutils/iosched_policy.c
index 67e101d..3e80cb2 100644
--- a/libcutils/iosched_policy.c
+++ b/libcutils/iosched_policy.c
@@ -19,33 +19,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/syscall.h>
#include <unistd.h>
-#ifdef HAVE_SCHED_H
-
#include <cutils/iosched_policy.h>
#ifdef HAVE_ANDROID_OS
-/* #include <linux/ioprio.h> */
-extern int ioprio_set(int which, int who, int ioprio);
-extern int ioprio_get(int which, int who);
+#include <linux/ioprio.h>
#define __android_unused
#else
#define __android_unused __attribute__((__unused__))
#endif
-enum {
- WHO_PROCESS = 1,
- WHO_PGRP,
- WHO_USER,
-};
-
-#define CLASS_SHIFT 13
-#define IOPRIO_NORM 4
-
int android_set_ioprio(int pid __android_unused, IoSchedClass clazz __android_unused, int ioprio __android_unused) {
#ifdef HAVE_ANDROID_OS
- if (ioprio_set(WHO_PROCESS, pid, ioprio | (clazz << CLASS_SHIFT))) {
+ if (syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, pid, ioprio | (clazz << IOPRIO_CLASS_SHIFT))) {
return -1;
}
#endif
@@ -56,11 +44,11 @@
#ifdef HAVE_ANDROID_OS
int rc;
- if ((rc = ioprio_get(WHO_PROCESS, pid)) < 0) {
+ if ((rc = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, pid)) < 0) {
return -1;
}
- *clazz = (rc >> CLASS_SHIFT);
+ *clazz = (rc >> IOPRIO_CLASS_SHIFT);
*ioprio = (rc & 0xff);
#else
*clazz = IoSchedClass_NONE;
@@ -68,5 +56,3 @@
#endif
return 0;
}
-
-#endif /* HAVE_SCHED_H */