From a62bb17df44139f493e05962e669eaa8c51a6ef1 Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Wed, 17 Dec 2014 11:20:09 -0500 Subject: [PATCH] Bug 1113200 - Use sysconf to get the page size. r=dhylands --- hal/gonk/GonkHal.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hal/gonk/GonkHal.cpp b/hal/gonk/GonkHal.cpp index 69b40766f289..15a442da0847 100644 --- a/hal/gonk/GonkHal.cpp +++ b/hal/gonk/GonkHal.cpp @@ -27,11 +27,7 @@ #include #include #include -#if ANDROID_VERSION >= 21 -#include -#else -#include -#endif +#include #include "mozilla/DebugOnly.h" @@ -1321,6 +1317,8 @@ EnsureKernelLowMemKillerParamsSet() int32_t lowerBoundOfNextKillUnderKB = 0; int32_t countOfLowmemorykillerParametersSets = 0; + long page_size = sysconf(_SC_PAGESIZE); + for (int i = NUM_PROCESS_PRIORITY - 1; i >= 0; i--) { // The system doesn't function correctly if we're missing these prefs, so // crash loudly. @@ -1358,7 +1356,7 @@ EnsureKernelLowMemKillerParamsSet() adjParams.AppendPrintf("%d,", OomAdjOfOomScoreAdj(oomScoreAdj)); // minfree is in pages. - minfreeParams.AppendPrintf("%d,", killUnderKB * 1024 / PAGE_SIZE); + minfreeParams.AppendPrintf("%ld,", killUnderKB * 1024 / page_size); lowerBoundOfNextOomScoreAdj = oomScoreAdj; lowerBoundOfNextKillUnderKB = killUnderKB; @@ -1381,7 +1379,7 @@ EnsureKernelLowMemKillerParamsSet() // notify_trigger is in pages. WriteToFile("/sys/module/lowmemorykiller/parameters/notify_trigger", - nsPrintfCString("%d", lowMemNotifyThresholdKB * 1024 / PAGE_SIZE).get()); + nsPrintfCString("%ld", lowMemNotifyThresholdKB * 1024 / page_size).get()); } // Ensure OOM events appear in logcat