Use syscall(2) instead of ioprio_get/ioprio_set.

Change-Id: Ibfd0bdd3dd0bad9804ec9fd9292f4b68a510afdb
This commit is contained in:
Dan Albert 2014-06-12 17:53:03 -07:00
parent 304d31f05e
commit 167c0ed6da
1 changed files with 5 additions and 19 deletions

View File

@ -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 @@ int android_get_ioprio(int pid __android_unused, IoSchedClass *clazz, int *iopri
#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 @@ int android_get_ioprio(int pid __android_unused, IoSchedClass *clazz, int *iopri
#endif
return 0;
}
#endif /* HAVE_SCHED_H */