summaryrefslogtreecommitdiffstats
path: root/libcutils/sched_policy.cpp
diff options
context:
space:
mode:
authorStephen Crane <sjc@immunant.com>2017-06-06 15:35:51 -0700
committerStephen Crane <sjc@immunant.com>2017-06-07 17:25:00 -0700
commitf5b8e3466055952449a499c6b0634018980d759b (patch)
treef99a9a4eac08786a6cb4896bf13c5f7352bfe32b /libcutils/sched_policy.cpp
parent3160a250107e3971cb52b0c2706afc5b928f755b (diff)
downloadsystem_core-f5b8e3466055952449a499c6b0634018980d759b.tar.gz
system_core-f5b8e3466055952449a499c6b0634018980d759b.tar.bz2
system_core-f5b8e3466055952449a499c6b0634018980d759b.zip
Fix prctl argument type
Although prctl is declared as a varargs function, in actuality it takes unsigned long arguments (after the first int argument). This patch ensures that the slack value passed to prctl is correctly sized. Without this change, the 32-bit ARM compiler places the 64-bit slack value in registers r2 and r3, but prctl expects the first argument to be in r1. For kernel versions < 4.6, set_sched_policy has not been correctly setting the timer slack value in 32-bit ARM code. Test: Run on bullhead device. Verified assembly of libcutils.so Change-Id: Ie0e22cbf74a74ff168b257b2e58d0c252449d6c9
Diffstat (limited to 'libcutils/sched_policy.cpp')
-rw-r--r--libcutils/sched_policy.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libcutils/sched_policy.cpp b/libcutils/sched_policy.cpp
index e29a8444c..7e385355f 100644
--- a/libcutils/sched_policy.cpp
+++ b/libcutils/sched_policy.cpp
@@ -340,7 +340,7 @@ int set_cpuset_policy(int tid, SchedPolicy policy)
return 0;
}
-static void set_timerslack_ns(int tid, unsigned long long slack) {
+static void set_timerslack_ns(int tid, unsigned long slack) {
// v4.6+ kernels support the /proc/<tid>/timerslack_ns interface.
// TODO: once we've backported this, log if the open(2) fails.
if (__sys_supports_timerslack) {
@@ -348,7 +348,7 @@ static void set_timerslack_ns(int tid, unsigned long long slack) {
snprintf(buf, sizeof(buf), "/proc/%d/timerslack_ns", tid);
int fd = open(buf, O_WRONLY | O_CLOEXEC);
if (fd != -1) {
- int len = snprintf(buf, sizeof(buf), "%llu", slack);
+ int len = snprintf(buf, sizeof(buf), "%lu", slack);
if (write(fd, buf, len) != len) {
SLOGE("set_timerslack_ns write failed: %s\n", strerror(errno));
}