[Toybox] [PATCH] Android moved the scheduler policy functions in Q.

enh enh at google.com
Wed May 1 15:40:56 PDT 2019


They're forwarded to libprocessgroup, but we may as well go straight to
the source since neither library is in the NDK anyway.

This code is unfortunate because it means that even `toybox true` ends
up pulling in a JSON parser at runtime, because ps might call
get_sched_policy/get_sched_policy_name. I'll experiment with
dlopen-on-demand in portability.c and see whether the savings are
worthwhile, but for now at least use the current library directly so we
can save *one* dlopen!
---
 lib/portability.h    | 4 ++--
 scripts/genconfig.sh | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/portability.h b/lib/portability.h
index 07160e9d..96458266 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -272,9 +272,9 @@ static inline int __system_property_set(const char
*key, const char *value)
 }
 #endif

-// libcutils is in AOSP but not Android NDK r18
+// libprocessgroup is an Android platform library not included in the NDK.
 #if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
-#include <cutils/sched_policy.h>
+#include <processgroup/sched_policy.h>
 #else
 static inline int get_sched_policy(int tid, void *policy) {return 0;}
 static inline char *get_sched_policy_name(int policy) {return "unknown";}
diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh
index 21e6c7b7..e1eff09f 100755
--- a/scripts/genconfig.sh
+++ b/scripts/genconfig.sh
@@ -85,7 +85,7 @@ EOF
 EOF

   probesymbol TOYBOX_ANDROID_SCHEDPOLICY << EOF
-    #include <cutils/sched_policy.h>
+    #include <processgroup/sched_policy.h>

     int main(int argc,char *argv[]) { get_sched_policy_name(0); }
 EOF
-- 
2.21.0.1020.gf2820cf01a-goog
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Android-moved-the-scheduler-policy-functions-in-Q.patch
Type: text/x-patch
Size: 1870 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190501/49d59ced/attachment-0002.bin>


More information about the Toybox mailing list