It's possible that we should just pull setprop back out of toybox to
live with getprop in system/core/, but this lets us build the same toybox
configuration for device and host in AOSP.

(Longer term we'd like to use host bionic, but if we enable this we
can start experimenting on the tobyox side before the bionic side is
finished.)
---
 lib/portability.h      | 26 +++++++++++++++++++++++++-
 toys/android/log.c     |  1 -
 toys/android/setprop.c |  2 --
 toys/android/start.c   |  2 --
 4 files changed, 25 insertions(+), 6 deletions(-)
From e7324f31d0136a7e780105de9d9b7529dc974179 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Thu, 27 Sep 2018 16:34:49 -0700
Subject: [PATCH] Make it possible to build the AOSP .config against glibc.

It's possible that we should just pull setprop back out of toybox to
live with getprop in system/core/, but this lets us build the same toybox
configuration for device and host in AOSP.

(Longer term we'd like to use host bionic, but if we enable this we
can start experimenting on the tobyox side before the bionic side is
finished.)
---
 lib/portability.h      | 26 +++++++++++++++++++++++++-
 toys/android/log.c     |  1 -
 toys/android/setprop.c |  2 --
 toys/android/start.c   |  2 --
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/lib/portability.h b/lib/portability.h
index 8e1049f..d20e409 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -240,11 +240,35 @@ pid_t xfork(void);
 //#define strncpy(...) @@strncpyisbadmmkay@@
 //#define strncat(...) @@strncatisbadmmkay@@
 
-#if CFG_TOYBOX_ANDROID_SCHEDPOLICY
+// Support building the Android tools on glibc, so hermetic AOSP builds can
+// use toybox before they're ready to switch to host bionic.
+#ifdef __BIONIC__
+#include <android/log.h>
 #include <cutils/sched_policy.h>
+#include <sys/system_properties.h>
 #else
+typedef enum android_LogPriority {
+  ANDROID_LOG_UNKNOWN = 0,
+  ANDROID_LOG_DEFAULT,
+  ANDROID_LOG_VERBOSE,
+  ANDROID_LOG_DEBUG,
+  ANDROID_LOG_INFO,
+  ANDROID_LOG_WARN,
+  ANDROID_LOG_ERROR,
+  ANDROID_LOG_FATAL,
+  ANDROID_LOG_SILENT,
+} android_LogPriority;
+static inline int __android_log_write(int pri, const char *tag, const char *msg)
+{
+  return -1;
+}
 static inline int get_sched_policy(int tid, void *policy) {return 0;}
 static inline char *get_sched_policy_name(int policy) {return "unknown";}
+#define PROP_VALUE_MAX 92
+static inline int __system_property_set(const char *key, const char *value)
+{
+  return -1;
+}
 #endif
 
 #ifndef SYSLOG_NAMES
diff --git a/toys/android/log.c b/toys/android/log.c
index cc800e7..09e36d7 100644
--- a/toys/android/log.c
+++ b/toys/android/log.c
@@ -20,7 +20,6 @@ config LOG
 
 #define FOR_log
 #include "toys.h"
-#include <android/log.h>
 
 GLOBALS(
   char *tag;
diff --git a/toys/android/setprop.c b/toys/android/setprop.c
index 14c24d9..cda34a5 100644
--- a/toys/android/setprop.c
+++ b/toys/android/setprop.c
@@ -17,8 +17,6 @@ config SETPROP
 #define FOR_setprop
 #include "toys.h"
 
-#include <sys/system_properties.h>
-
 void setprop_main(void)
 {
   char *name = toys.optargs[0], *value = toys.optargs[1];
diff --git a/toys/android/start.c b/toys/android/start.c
index f6b3c37..5df847a 100644
--- a/toys/android/start.c
+++ b/toys/android/start.c
@@ -27,8 +27,6 @@ config STOP
 #define FOR_start
 #include "toys.h"
 
-#include <sys/system_properties.h>
-
 static void start_stop(int start)
 {
   char *property = start ? "ctl.start" : "ctl.stop";
-- 
2.19.0.605.g01d371f741-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to