From a0998009c10950426c20f65801f0d2e12114202e Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 9 Mar 2020 01:50:30 -0700 Subject: [PATCH] Small native code reorganization --- .gitattributes | 4 + native/jni/Android.mk | 4 - native/jni/core/applet_stub.cpp | 2 +- native/jni/core/applets.cpp | 6 +- native/jni/core/bootstages.cpp | 12 +- native/jni/core/daemon.cpp | 12 +- native/jni/core/db.cpp | 8 +- native/jni/core/magisk.cpp | 8 +- native/jni/core/scripting.cpp | 6 +- native/jni/core/socket.cpp | 6 +- native/jni/include/{daemon.h => daemon.hpp} | 0 native/jni/include/{db.h => db.hpp} | 0 native/jni/include/{magisk.h => magisk.hpp} | 2 +- .../{magiskpolicy.h => magiskpolicy.hpp} | 2 +- .../include/{resetprop.h => resetprop.hpp} | 0 native/jni/init/getinfo.cpp | 6 +- native/jni/init/init.cpp | 8 +- native/jni/init/{init.h => init.hpp} | 2 +- native/jni/init/{magiskrc.h => magiskrc.inc} | 4 +- native/jni/init/mount.cpp | 10 +- native/jni/init/rootdir.cpp | 10 +- native/jni/magiskboot/bootimg.cpp | 10 +- .../jni/magiskboot/{bootimg.h => bootimg.hpp} | 2 +- native/jni/magiskboot/compress.cpp | 8 +- .../magiskboot/{compress.h => compress.hpp} | 4 +- native/jni/magiskboot/dtb.cpp | 6 +- native/jni/magiskboot/{dtb.h => dtb.hpp} | 0 native/jni/magiskboot/format.cpp | 2 +- .../jni/magiskboot/{format.h => format.hpp} | 0 native/jni/magiskboot/hexpatch.cpp | 4 +- .../{magiskboot.h => magiskboot.hpp} | 0 native/jni/magiskboot/main.cpp | 8 +- native/jni/magiskboot/pattern.cpp | 4 +- native/jni/magiskboot/ramdisk.cpp | 8 +- native/jni/magiskhide/hide_policy.cpp | 10 +- native/jni/magiskhide/hide_utils.cpp | 8 +- native/jni/magiskhide/magiskhide.cpp | 6 +- .../{magiskhide.h => magiskhide.hpp} | 2 +- native/jni/magiskhide/proc_monitor.cpp | 6 +- native/jni/magiskpolicy/api.cpp | 2 +- native/jni/magiskpolicy/magiskpolicy.cpp | 6 +- native/jni/magiskpolicy/policydb.cpp | 8 +- native/jni/magiskpolicy/rules.cpp | 4 +- native/jni/magiskpolicy/sepolicy.c | 2 +- native/jni/magiskpolicy/statement.cpp | 6 +- .../{private/resetprop.h => _resetprop.hpp} | 4 +- native/jni/resetprop/persist_properties.cpp | 4 +- native/jni/resetprop/private/bionic_macros.h | 105 ------------------ native/jni/resetprop/private/redefs.h | 21 ---- native/jni/resetprop/resetprop.cpp | 12 +- native/jni/su/connect.cpp | 8 +- native/jni/su/pts.cpp | 4 +- native/jni/su/{pts.h => pts.hpp} | 2 +- native/jni/su/su.cpp | 8 +- native/jni/su/{su.h => su.hpp} | 4 +- native/jni/su/su_daemon.cpp | 12 +- native/jni/systemproperties/Android.mk | 2 + .../include}/_system_properties.h | 0 native/jni/systemproperties/include/hacks.h | 14 --- .../include}/private/bionic_defs.h | 0 .../systemproperties/include/private/hacks.h | 35 ++++++ .../include}/system_properties.h | 3 +- .../include/system_properties/prop_info.h | 4 +- .../system_properties/system_properties.h | 3 +- .../system_property_api.cpp | 2 +- .../system_property_set.cpp | 4 +- native/jni/utils/cpio.cpp | 6 +- native/jni/utils/file.cpp | 4 +- native/jni/utils/{files.h => files.hpp} | 2 +- .../{blocking_queue.h => blocking_queue.hpp} | 2 +- native/jni/utils/include/{cpio.h => cpio.hpp} | 2 +- .../utils/include/{logging.h => logging.hpp} | 0 .../utils/include/{selinux.h => selinux.hpp} | 0 .../utils/include/{stream.h => stream.hpp} | 2 +- native/jni/utils/include/utils.h | 6 - native/jni/utils/include/utils.hpp | 6 + native/jni/utils/logging.cpp | 2 +- native/jni/utils/misc.cpp | 4 +- native/jni/utils/{misc.h => misc.hpp} | 0 native/jni/utils/missing.cpp | 2 +- native/jni/utils/{missing.h => missing.hpp} | 0 native/jni/utils/selinux.cpp | 6 +- native/jni/utils/stream.cpp | 6 +- native/jni/utils/xwrap.cpp | 4 +- native/jni/utils/{xwrap.h => xwrap.hpp} | 0 85 files changed, 216 insertions(+), 317 deletions(-) rename native/jni/include/{daemon.h => daemon.hpp} (100%) rename native/jni/include/{db.h => db.hpp} (100%) rename native/jni/include/{magisk.h => magisk.hpp} (98%) rename native/jni/include/{magiskpolicy.h => magiskpolicy.hpp} (98%) rename native/jni/include/{resetprop.h => resetprop.hpp} (100%) rename native/jni/init/{init.h => init.hpp} (99%) rename native/jni/init/{magiskrc.h => magiskrc.inc} (93%) rename native/jni/magiskboot/{bootimg.h => bootimg.hpp} (99%) rename native/jni/magiskboot/{compress.h => compress.hpp} (85%) rename native/jni/magiskboot/{dtb.h => dtb.hpp} (100%) rename native/jni/magiskboot/{format.h => format.hpp} (100%) rename native/jni/magiskboot/{magiskboot.h => magiskboot.hpp} (100%) rename native/jni/magiskhide/{magiskhide.h => magiskhide.hpp} (98%) rename native/jni/resetprop/{private/resetprop.h => _resetprop.hpp} (95%) delete mode 100644 native/jni/resetprop/private/bionic_macros.h delete mode 100644 native/jni/resetprop/private/redefs.h rename native/jni/su/{pts.h => pts.hpp} (99%) rename native/jni/su/{su.h => su.hpp} (97%) rename native/jni/{resetprop/private => systemproperties/include}/_system_properties.h (100%) delete mode 100644 native/jni/systemproperties/include/hacks.h rename native/jni/{resetprop => systemproperties/include}/private/bionic_defs.h (100%) create mode 100644 native/jni/systemproperties/include/private/hacks.h rename native/jni/{resetprop/private => systemproperties/include}/system_properties.h (99%) rename native/jni/{resetprop => systemproperties}/system_property_api.cpp (99%) rename native/jni/{resetprop => systemproperties}/system_property_set.cpp (99%) rename native/jni/utils/{files.h => files.hpp} (99%) rename native/jni/utils/include/{blocking_queue.h => blocking_queue.hpp} (98%) rename native/jni/utils/include/{cpio.h => cpio.hpp} (98%) rename native/jni/utils/include/{logging.h => logging.hpp} (100%) rename native/jni/utils/include/{selinux.h => selinux.hpp} (100%) rename native/jni/utils/include/{stream.h => stream.hpp} (98%) delete mode 100644 native/jni/utils/include/utils.h create mode 100644 native/jni/utils/include/utils.hpp rename native/jni/utils/{misc.h => misc.hpp} (100%) rename native/jni/utils/{missing.h => missing.hpp} (100%) rename native/jni/utils/{xwrap.h => xwrap.hpp} (100%) diff --git a/.gitattributes b/.gitattributes index ad2d62815..852441530 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,3 +18,7 @@ tools/** binary *.png binary *.jpg binary *.ttf binary + +# Help GitHub detect languages +native/jni/external/** linguist-vendored +native/jni/systemproperties/** linguist-language=C++ diff --git a/native/jni/Android.mk b/native/jni/Android.mk index 06ee01240..b5fa3b084 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -45,8 +45,6 @@ LOCAL_SRC_FILES := \ magiskhide/hide_policy.cpp \ resetprop/persist_properties.cpp \ resetprop/resetprop.cpp \ - resetprop/system_property_api.cpp \ - resetprop/system_property_set.cpp \ su/su.cpp \ su/connect.cpp \ su/pts.cpp \ @@ -167,8 +165,6 @@ LOCAL_SRC_FILES := \ core/applet_stub.cpp \ resetprop/persist_properties.cpp \ resetprop/resetprop.cpp \ - resetprop/system_property_api.cpp \ - resetprop/system_property_set.cpp LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=resetprop_main LOCAL_LDFLAGS := -static diff --git a/native/jni/core/applet_stub.cpp b/native/jni/core/applet_stub.cpp index 1ac5c7328..37ac47be8 100644 --- a/native/jni/core/applet_stub.cpp +++ b/native/jni/core/applet_stub.cpp @@ -1,6 +1,6 @@ #include -#include +#include int main(int argc, char *argv[]) { umask(0); diff --git a/native/jni/core/applets.cpp b/native/jni/core/applets.cpp index fdeec2536..0b076b4f1 100644 --- a/native/jni/core/applets.cpp +++ b/native/jni/core/applets.cpp @@ -4,9 +4,9 @@ #include #include -#include -#include -#include +#include +#include +#include using namespace std::literals; diff --git a/native/jni/core/bootstages.cpp b/native/jni/core/bootstages.cpp index 01ec76edd..76d974e91 100644 --- a/native/jni/core/bootstages.cpp +++ b/native/jni/core/bootstages.cpp @@ -9,12 +9,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include using namespace std; diff --git a/native/jni/core/daemon.cpp b/native/jni/core/daemon.cpp index 9897f0b71..2c1604417 100644 --- a/native/jni/core/daemon.cpp +++ b/native/jni/core/daemon.cpp @@ -8,12 +8,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include int SDK_INT = -1; diff --git a/native/jni/core/db.cpp b/native/jni/core/db.cpp index f4d1955ca..8a559c879 100644 --- a/native/jni/core/db.cpp +++ b/native/jni/core/db.cpp @@ -6,10 +6,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #define DB_VERSION 10 diff --git a/native/jni/core/magisk.cpp b/native/jni/core/magisk.cpp index 01641355a..94ce92c33 100644 --- a/native/jni/core/magisk.cpp +++ b/native/jni/core/magisk.cpp @@ -5,10 +5,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include using namespace std::literals; diff --git a/native/jni/core/scripting.cpp b/native/jni/core/scripting.cpp index 3f4888133..37fd23898 100644 --- a/native/jni/core/scripting.cpp +++ b/native/jni/core/scripting.cpp @@ -4,9 +4,9 @@ #include #include -#include -#include -#include +#include +#include +#include using namespace std; diff --git a/native/jni/core/socket.cpp b/native/jni/core/socket.cpp index 217ee0498..9dc654615 100644 --- a/native/jni/core/socket.cpp +++ b/native/jni/core/socket.cpp @@ -6,9 +6,9 @@ #include #include -#include -#include -#include +#include +#include +#include #define ABS_SOCKET_LEN(sun) (sizeof(sa_family_t) + strlen(sun->sun_path + 1) + 1) diff --git a/native/jni/include/daemon.h b/native/jni/include/daemon.hpp similarity index 100% rename from native/jni/include/daemon.h rename to native/jni/include/daemon.hpp diff --git a/native/jni/include/db.h b/native/jni/include/db.hpp similarity index 100% rename from native/jni/include/db.h rename to native/jni/include/db.hpp diff --git a/native/jni/include/magisk.h b/native/jni/include/magisk.hpp similarity index 98% rename from native/jni/include/magisk.h rename to native/jni/include/magisk.hpp index 9fd368b17..dcffd7110 100644 --- a/native/jni/include/magisk.h +++ b/native/jni/include/magisk.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591" #define JAVA_PACKAGE_NAME "com.topjohnwu.magisk" diff --git a/native/jni/include/magiskpolicy.h b/native/jni/include/magiskpolicy.hpp similarity index 98% rename from native/jni/include/magiskpolicy.h rename to native/jni/include/magiskpolicy.hpp index bb484564f..9413b2b29 100644 --- a/native/jni/include/magiskpolicy.h +++ b/native/jni/include/magiskpolicy.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #define ALL NULL diff --git a/native/jni/include/resetprop.h b/native/jni/include/resetprop.hpp similarity index 100% rename from native/jni/include/resetprop.h rename to native/jni/include/resetprop.hpp diff --git a/native/jni/init/getinfo.cpp b/native/jni/init/getinfo.cpp index 7a082e2c8..92101b244 100644 --- a/native/jni/init/getinfo.cpp +++ b/native/jni/init/getinfo.cpp @@ -5,10 +5,10 @@ #include #include -#include -#include +#include +#include -#include "init.h" +#include "init.hpp" using namespace std; diff --git a/native/jni/init/init.cpp b/native/jni/init/init.cpp index 394a4dded..7e8114827 100644 --- a/native/jni/init/init.cpp +++ b/native/jni/init/init.cpp @@ -8,9 +8,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include "binaries.h" @@ -20,7 +20,7 @@ #include "binaries_arch.h" #endif -#include "init.h" +#include "init.hpp" using namespace std; diff --git a/native/jni/init/init.h b/native/jni/init/init.hpp similarity index 99% rename from native/jni/init/init.h rename to native/jni/init/init.hpp index f9ebf5a56..804d7be31 100644 --- a/native/jni/init/init.h +++ b/native/jni/init/init.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include struct cmdline { bool skip_initramfs; diff --git a/native/jni/init/magiskrc.h b/native/jni/init/magiskrc.inc similarity index 93% rename from native/jni/init/magiskrc.h rename to native/jni/init/magiskrc.inc index 44290506a..a2196e104 100644 --- a/native/jni/init/magiskrc.h +++ b/native/jni/init/magiskrc.inc @@ -1,5 +1,5 @@ -#include -#include +#include +#include constexpr char magiskrc[] = "\n" diff --git a/native/jni/init/mount.cpp b/native/jni/init/mount.cpp index 929c0f3ae..b2768c293 100644 --- a/native/jni/init/mount.cpp +++ b/native/jni/init/mount.cpp @@ -3,12 +3,12 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "init.h" +#include "init.hpp" using namespace std; diff --git a/native/jni/init/rootdir.cpp b/native/jni/init/rootdir.cpp index 3b6b8b94d..3dc20f560 100644 --- a/native/jni/init/rootdir.cpp +++ b/native/jni/init/rootdir.cpp @@ -3,12 +3,12 @@ #include #include -#include -#include -#include +#include +#include +#include -#include "init.h" -#include "magiskrc.h" +#include "init.hpp" +#include "magiskrc.inc" #ifdef USE_64BIT #define LIBNAME "lib64" diff --git a/native/jni/magiskboot/bootimg.cpp b/native/jni/magiskboot/bootimg.cpp index cf067e5ce..0571d4904 100644 --- a/native/jni/magiskboot/bootimg.cpp +++ b/native/jni/magiskboot/bootimg.cpp @@ -9,12 +9,12 @@ #include #include -#include -#include +#include +#include -#include "bootimg.h" -#include "magiskboot.h" -#include "compress.h" +#include "bootimg.hpp" +#include "magiskboot.hpp" +#include "compress.hpp" using namespace std; diff --git a/native/jni/magiskboot/bootimg.h b/native/jni/magiskboot/bootimg.hpp similarity index 99% rename from native/jni/magiskboot/bootimg.h rename to native/jni/magiskboot/bootimg.hpp index 8afccb9a4..b37e5d2ac 100644 --- a/native/jni/magiskboot/bootimg.h +++ b/native/jni/magiskboot/bootimg.hpp @@ -2,7 +2,7 @@ #include #include -#include "format.h" +#include "format.hpp" /**************** * Other Headers diff --git a/native/jni/magiskboot/compress.cpp b/native/jni/magiskboot/compress.cpp index 4cc7a6b5d..9fded1a8d 100644 --- a/native/jni/magiskboot/compress.cpp +++ b/native/jni/magiskboot/compress.cpp @@ -13,11 +13,11 @@ #include #include -#include -#include +#include +#include -#include "magiskboot.h" -#include "compress.h" +#include "magiskboot.hpp" +#include "compress.hpp" using namespace std; diff --git a/native/jni/magiskboot/compress.h b/native/jni/magiskboot/compress.hpp similarity index 85% rename from native/jni/magiskboot/compress.h rename to native/jni/magiskboot/compress.hpp index 7a8ab9c23..4963687ef 100644 --- a/native/jni/magiskboot/compress.h +++ b/native/jni/magiskboot/compress.hpp @@ -1,8 +1,8 @@ #pragma once -#include +#include -#include "format.h" +#include "format.hpp" stream_ptr get_encoder(format_t type, stream_ptr &&base); diff --git a/native/jni/magiskboot/dtb.cpp b/native/jni/magiskboot/dtb.cpp index 2a1d09725..07a5b7b9e 100644 --- a/native/jni/magiskboot/dtb.cpp +++ b/native/jni/magiskboot/dtb.cpp @@ -7,10 +7,10 @@ extern "C" { #include } -#include +#include -#include "magiskboot.h" -#include "dtb.h" +#include "magiskboot.hpp" +#include "dtb.hpp" using namespace std; diff --git a/native/jni/magiskboot/dtb.h b/native/jni/magiskboot/dtb.hpp similarity index 100% rename from native/jni/magiskboot/dtb.h rename to native/jni/magiskboot/dtb.hpp diff --git a/native/jni/magiskboot/format.cpp b/native/jni/magiskboot/format.cpp index 6d2d86b3a..748dedc93 100644 --- a/native/jni/magiskboot/format.cpp +++ b/native/jni/magiskboot/format.cpp @@ -1,6 +1,6 @@ #include -#include "format.h" +#include "format.hpp" std::map name2fmt; Fmt2Name fmt2name; diff --git a/native/jni/magiskboot/format.h b/native/jni/magiskboot/format.hpp similarity index 100% rename from native/jni/magiskboot/format.h rename to native/jni/magiskboot/format.hpp diff --git a/native/jni/magiskboot/hexpatch.cpp b/native/jni/magiskboot/hexpatch.cpp index 8e1375352..edcd34f8f 100644 --- a/native/jni/magiskboot/hexpatch.cpp +++ b/native/jni/magiskboot/hexpatch.cpp @@ -3,9 +3,9 @@ #include #include -#include +#include -#include "magiskboot.h" +#include "magiskboot.hpp" static void hex2byte(uint8_t *hex, uint8_t *str) { char high, low; diff --git a/native/jni/magiskboot/magiskboot.h b/native/jni/magiskboot/magiskboot.hpp similarity index 100% rename from native/jni/magiskboot/magiskboot.h rename to native/jni/magiskboot/magiskboot.hpp diff --git a/native/jni/magiskboot/main.cpp b/native/jni/magiskboot/main.cpp index 825d4d255..7d68592a1 100644 --- a/native/jni/magiskboot/main.cpp +++ b/native/jni/magiskboot/main.cpp @@ -5,12 +5,12 @@ #include #include -#include -#include +#include +#include #include -#include "magiskboot.h" -#include "compress.h" +#include "magiskboot.hpp" +#include "compress.hpp" using namespace std; diff --git a/native/jni/magiskboot/pattern.cpp b/native/jni/magiskboot/pattern.cpp index e95a35453..852e59159 100644 --- a/native/jni/magiskboot/pattern.cpp +++ b/native/jni/magiskboot/pattern.cpp @@ -1,9 +1,9 @@ #include #include -#include +#include -#include "magiskboot.h" +#include "magiskboot.hpp" #define MATCH(p) else if (strncmp(s + skip, p, sizeof(p) - 1) == 0) skip += (sizeof(p) - 1) diff --git a/native/jni/magiskboot/ramdisk.cpp b/native/jni/magiskboot/ramdisk.cpp index c6811abd9..ca8222f7a 100644 --- a/native/jni/magiskboot/ramdisk.cpp +++ b/native/jni/magiskboot/ramdisk.cpp @@ -2,11 +2,11 @@ #include #include -#include -#include +#include +#include -#include "magiskboot.h" -#include "compress.h" +#include "magiskboot.hpp" +#include "compress.hpp" using namespace std; diff --git a/native/jni/magiskhide/hide_policy.cpp b/native/jni/magiskhide/hide_policy.cpp index 91cac2be6..ee12f0d9f 100644 --- a/native/jni/magiskhide/hide_policy.cpp +++ b/native/jni/magiskhide/hide_policy.cpp @@ -1,11 +1,11 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "magiskhide.h" +#include "magiskhide.hpp" using namespace std; diff --git a/native/jni/magiskhide/hide_utils.cpp b/native/jni/magiskhide/hide_utils.cpp index b451fa386..1bb4f4549 100644 --- a/native/jni/magiskhide/hide_utils.cpp +++ b/native/jni/magiskhide/hide_utils.cpp @@ -7,11 +7,11 @@ #include #include -#include -#include -#include +#include +#include +#include -#include "magiskhide.h" +#include "magiskhide.hpp" using namespace std; diff --git a/native/jni/magiskhide/magiskhide.cpp b/native/jni/magiskhide/magiskhide.cpp index 5c2ea2615..888a78860 100644 --- a/native/jni/magiskhide/magiskhide.cpp +++ b/native/jni/magiskhide/magiskhide.cpp @@ -8,11 +8,11 @@ #include #include -#include -#include +#include +#include #include -#include "magiskhide.h" +#include "magiskhide.hpp" using namespace std::literals; diff --git a/native/jni/magiskhide/magiskhide.h b/native/jni/magiskhide/magiskhide.hpp similarity index 98% rename from native/jni/magiskhide/magiskhide.h rename to native/jni/magiskhide/magiskhide.hpp index 832d9e8e9..7ddaa9568 100644 --- a/native/jni/magiskhide/magiskhide.h +++ b/native/jni/magiskhide/magiskhide.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #define SIGTERMTHRD SIGUSR1 #define SIGZYGOTE SIGUSR2 diff --git a/native/jni/magiskhide/proc_monitor.cpp b/native/jni/magiskhide/proc_monitor.cpp index c9d92fa2e..8fa67b2e6 100644 --- a/native/jni/magiskhide/proc_monitor.cpp +++ b/native/jni/magiskhide/proc_monitor.cpp @@ -13,10 +13,10 @@ #include #include -#include -#include +#include +#include -#include "magiskhide.h" +#include "magiskhide.hpp" using namespace std; diff --git a/native/jni/magiskpolicy/api.cpp b/native/jni/magiskpolicy/api.cpp index 896ee0846..5faf555db 100644 --- a/native/jni/magiskpolicy/api.cpp +++ b/native/jni/magiskpolicy/api.cpp @@ -1,4 +1,4 @@ -#include +#include #include "sepolicy.h" diff --git a/native/jni/magiskpolicy/magiskpolicy.cpp b/native/jni/magiskpolicy/magiskpolicy.cpp index 6a7640f0d..42bf95a11 100644 --- a/native/jni/magiskpolicy/magiskpolicy.cpp +++ b/native/jni/magiskpolicy/magiskpolicy.cpp @@ -1,10 +1,10 @@ #include #include -#include -#include +#include +#include #include -#include +#include #include "sepolicy.h" diff --git a/native/jni/magiskpolicy/policydb.cpp b/native/jni/magiskpolicy/policydb.cpp index 14730faaf..ffd3f1a38 100644 --- a/native/jni/magiskpolicy/policydb.cpp +++ b/native/jni/magiskpolicy/policydb.cpp @@ -5,10 +5,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "sepolicy.h" diff --git a/native/jni/magiskpolicy/rules.cpp b/native/jni/magiskpolicy/rules.cpp index d930ae69f..edf1db44d 100644 --- a/native/jni/magiskpolicy/rules.cpp +++ b/native/jni/magiskpolicy/rules.cpp @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include "sepolicy.h" diff --git a/native/jni/magiskpolicy/sepolicy.c b/native/jni/magiskpolicy/sepolicy.c index c94a2bae3..a688b24aa 100644 --- a/native/jni/magiskpolicy/sepolicy.c +++ b/native/jni/magiskpolicy/sepolicy.c @@ -1,7 +1,7 @@ #include #include -#include +#include #include "sepolicy.h" diff --git a/native/jni/magiskpolicy/statement.cpp b/native/jni/magiskpolicy/statement.cpp index cfda7b900..6583f83e6 100644 --- a/native/jni/magiskpolicy/statement.cpp +++ b/native/jni/magiskpolicy/statement.cpp @@ -2,9 +2,9 @@ #include #include -#include -#include -#include +#include +#include +#include using namespace std; diff --git a/native/jni/resetprop/private/resetprop.h b/native/jni/resetprop/_resetprop.hpp similarity index 95% rename from native/jni/resetprop/private/resetprop.h rename to native/jni/resetprop/_resetprop.hpp index 3246917be..dc24f07a6 100644 --- a/native/jni/resetprop/private/resetprop.h +++ b/native/jni/resetprop/_resetprop.hpp @@ -1,9 +1,9 @@ #pragma once #include -#include +#include -#include "system_properties.h" +#include struct prop_t { char *name; diff --git a/native/jni/resetprop/persist_properties.cpp b/native/jni/resetprop/persist_properties.cpp index b4819a628..c38974c20 100644 --- a/native/jni/resetprop/persist_properties.cpp +++ b/native/jni/resetprop/persist_properties.cpp @@ -9,9 +9,9 @@ #include #include #include -#include +#include -#include "private/resetprop.h" +#include "_resetprop.hpp" using namespace std; diff --git a/native/jni/resetprop/private/bionic_macros.h b/native/jni/resetprop/private/bionic_macros.h deleted file mode 100644 index 0a36cdb18..000000000 --- a/native/jni/resetprop/private/bionic_macros.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _BIONIC_MACROS_H_ -#define _BIONIC_MACROS_H_ - -#include - -// Frameworks OpenGL code currently leaks this header and allows -// collisions with other declarations, e.g., from libnativehelper. -// TODO: Remove once cleaned up. b/18334516 -#if !defined(DISALLOW_COPY_AND_ASSIGN) -// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. -// It goes in the private: declarations in a class. -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&) = delete; \ - void operator=(const TypeName&) = delete -#endif // !defined(DISALLOW_COPY_AND_ASSIGN) - -// A macro to disallow all the implicit constructors, namely the -// default constructor, copy constructor and operator= functions. -// -// This should be used in the private: declarations for a class -// that wants to prevent anyone from instantiating it. This is -// especially useful for classes containing only static methods. -#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ - TypeName() = delete; \ - DISALLOW_COPY_AND_ASSIGN(TypeName) - -#define BIONIC_ROUND_UP_POWER_OF_2(value) \ - ((sizeof(value) == 8) \ - ? (1UL << (64 - __builtin_clzl(static_cast(value)))) \ - : (1UL << (32 - __builtin_clz(static_cast(value))))) - -static constexpr uintptr_t align_down(uintptr_t p, size_t align) { - return p & ~(align - 1); -} - -static constexpr uintptr_t align_up(uintptr_t p, size_t align) { - return (p + align - 1) & ~(align - 1); -} - -template -static inline T* align_down(T* p, size_t align) { - return reinterpret_cast(align_down(reinterpret_cast(p), align)); -} - -template -static inline T* align_up(T* p, size_t align) { - return reinterpret_cast(align_up(reinterpret_cast(p), align)); -} - -#if defined(__arm__) -// Do not emit anything for arm, clang does not allow emiting an arm unwind -// directive. -// #define BIONIC_STOP_UNWIND asm volatile(".cantunwind") -#define BIONIC_STOP_UNWIND -#elif defined(__aarch64__) -#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined x30") -#elif defined(__i386__) -#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined \%eip") -#elif defined(__x86_64__) -#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined \%rip") -#elif defined (__mips__) -#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined $ra") -#endif - -// The arraysize(arr) macro returns the # of elements in an array arr. -// The expression is a compile-time constant, and therefore can be -// used in defining new arrays, for example. If you use arraysize on -// a pointer by mistake, you will get a compile-time error. -// -// One caveat is that arraysize() doesn't accept any array of an -// anonymous type or a type defined inside a function. -// -// This template function declaration is used in defining arraysize. -// Note that the function doesn't need an implementation, as we only -// use its type. -template -char (&ArraySizeHelper(T (&array)[N]))[N]; // NOLINT(readability/casting) - -#define arraysize(array) (sizeof(ArraySizeHelper(array))) - -// Used to inform clang's -Wimplicit-fallthrough that a fallthrough is intended. There's no way to -// silence (or enable, apparently) -Wimplicit-fallthrough in C yet. -#ifdef __cplusplus -#define __BIONIC_FALLTHROUGH [[clang::fallthrough]] -#else -#define __BIONIC_FALLTHROUGH -#endif - -#endif // _BIONIC_MACROS_H_ diff --git a/native/jni/resetprop/private/redefs.h b/native/jni/resetprop/private/redefs.h deleted file mode 100644 index 61b7a8e81..000000000 --- a/native/jni/resetprop/private/redefs.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef REDEFS_H -#define REDEFS_H - -#define __system_property_set _system_property_set2 -#define __system_property_find _system_property_find2 -#define __system_property_read_callback _system_property_read_callback2 -#define __system_property_foreach __system_property_foreach2 -#define __system_property_wait __system_property_wait2 -#define __system_property_read __system_property_read2 -#define __system_property_get __system_property_get2 -#define __system_property_find_nth __system_property_find_nth2 -#define __system_property_set_filename __system_property_set_filename2 -#define __system_property_area_init __system_property_area_init2 -#define __system_property_area_serial __system_property_area_serial2 -#define __system_property_add __system_property_add2 -#define __system_property_update __system_property_update2 -#define __system_property_serial __system_property_serial2 -#define __system_properties_init __system_properties_init2 -#define __system_property_wait_any __system_property_wait_any2 - -#endif //REDEFS_H diff --git a/native/jni/resetprop/resetprop.cpp b/native/jni/resetprop/resetprop.cpp index 44d424f47..a88d90f8a 100644 --- a/native/jni/resetprop/resetprop.cpp +++ b/native/jni/resetprop/resetprop.cpp @@ -9,15 +9,15 @@ #include #include -#include -#include -#include +#include +#include +#include #include #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ -#include "private/_system_properties.h" -#include "private/system_properties.h" -#include "private/resetprop.h" +#include <_system_properties.h> + +#include "_resetprop.hpp" using namespace std; diff --git a/native/jni/su/connect.cpp b/native/jni/su/connect.cpp index fb405ae47..08126c201 100644 --- a/native/jni/su/connect.cpp +++ b/native/jni/su/connect.cpp @@ -5,11 +5,11 @@ #include #include -#include -#include -#include +#include +#include +#include -#include "su.h" +#include "su.hpp" using namespace std; diff --git a/native/jni/su/pts.cpp b/native/jni/su/pts.cpp index 99b7c535c..a766e42ea 100644 --- a/native/jni/su/pts.cpp +++ b/native/jni/su/pts.cpp @@ -17,9 +17,9 @@ #include #include -#include +#include -#include "pts.h" +#include "pts.hpp" /** * Helper functions diff --git a/native/jni/su/pts.h b/native/jni/su/pts.hpp similarity index 99% rename from native/jni/su/pts.h rename to native/jni/su/pts.hpp index 57900489d..2eb721415 100644 --- a/native/jni/su/pts.h +++ b/native/jni/su/pts.hpp @@ -3,7 +3,7 @@ */ /* - * pts.h + * pts.hpp * * Manages the pseudo-terminal driver on Linux/Android and provides some * helper functions to handle raw input mode and terminal window resizing diff --git a/native/jni/su/su.cpp b/native/jni/su/su.cpp index 175941a85..043334a8a 100644 --- a/native/jni/su/su.cpp +++ b/native/jni/su/su.cpp @@ -21,12 +21,12 @@ #include #include -#include -#include +#include +#include #include -#include "su.h" -#include "pts.h" +#include "su.hpp" +#include "pts.hpp" int quit_signals[] = { SIGALRM, SIGABRT, SIGHUP, SIGPIPE, SIGQUIT, SIGTERM, SIGINT, 0 }; diff --git a/native/jni/su/su.h b/native/jni/su/su.hpp similarity index 97% rename from native/jni/su/su.h rename to native/jni/su/su.hpp index 02fc0aebc..280affd1e 100644 --- a/native/jni/su/su.h +++ b/native/jni/su/su.hpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +#include #define DEFAULT_SHELL "/system/bin/sh" diff --git a/native/jni/su/su_daemon.cpp b/native/jni/su/su_daemon.cpp index 660ca1175..31ae9cd3b 100644 --- a/native/jni/su/su_daemon.cpp +++ b/native/jni/su/su_daemon.cpp @@ -12,13 +12,13 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "su.h" -#include "pts.h" +#include "su.hpp" +#include "pts.hpp" using namespace std; diff --git a/native/jni/systemproperties/Android.mk b/native/jni/systemproperties/Android.mk index 1f0dbbb11..223d15388 100644 --- a/native/jni/systemproperties/Android.mk +++ b/native/jni/systemproperties/Android.mk @@ -10,6 +10,8 @@ LOCAL_SRC_FILES := \ prop_area.cpp \ prop_info.cpp \ system_properties.cpp \ + system_property_api.cpp \ + system_property_set.cpp \ property_info_parser.cpp include $(BUILD_STATIC_LIBRARY) diff --git a/native/jni/resetprop/private/_system_properties.h b/native/jni/systemproperties/include/_system_properties.h similarity index 100% rename from native/jni/resetprop/private/_system_properties.h rename to native/jni/systemproperties/include/_system_properties.h diff --git a/native/jni/systemproperties/include/hacks.h b/native/jni/systemproperties/include/hacks.h deleted file mode 100644 index ddcf13b85..000000000 --- a/native/jni/systemproperties/include/hacks.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include -#include - -#ifndef PR_SET_VMA -#define PR_SET_VMA 0x53564d41 -#endif -#ifndef PR_SET_VMA_ANON_NAME -#define PR_SET_VMA_ANON_NAME 0 -#endif -#define getline __getline -#define fsetxattr(...) syscall(__NR_fsetxattr, __VA_ARGS__) -ssize_t __getline(char **, size_t *, FILE *); diff --git a/native/jni/resetprop/private/bionic_defs.h b/native/jni/systemproperties/include/private/bionic_defs.h similarity index 100% rename from native/jni/resetprop/private/bionic_defs.h rename to native/jni/systemproperties/include/private/bionic_defs.h diff --git a/native/jni/systemproperties/include/private/hacks.h b/native/jni/systemproperties/include/private/hacks.h new file mode 100644 index 000000000..65f7feb5d --- /dev/null +++ b/native/jni/systemproperties/include/private/hacks.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include + +// Missing defines +#ifndef PR_SET_VMA +#define PR_SET_VMA 0x53564d41 +#endif +#ifndef PR_SET_VMA_ANON_NAME +#define PR_SET_VMA_ANON_NAME 0 +#endif + +// Missing functions +#define fsetxattr(...) syscall(__NR_fsetxattr, __VA_ARGS__) +#define getline __getline +ssize_t __getline(char **, size_t *, FILE *); + +// Rename symbols +#pragma redefine_extname __system_property_set _system_property_set2 +#pragma redefine_extname __system_property_find _system_property_find2 +#pragma redefine_extname __system_property_read_callback _system_property_read_callback2 +#pragma redefine_extname __system_property_foreach __system_property_foreach2 +#pragma redefine_extname __system_property_wait __system_property_wait2 +#pragma redefine_extname __system_property_read __system_property_read2 +#pragma redefine_extname __system_property_get __system_property_get2 +#pragma redefine_extname __system_property_find_nth __system_property_find_nth2 +#pragma redefine_extname __system_property_set_filename __system_property_set_filename2 +#pragma redefine_extname __system_property_area_init __system_property_area_init2 +#pragma redefine_extname __system_property_area_serial __system_property_area_serial2 +#pragma redefine_extname __system_property_add __system_property_add2 +#pragma redefine_extname __system_property_update __system_property_update2 +#pragma redefine_extname __system_property_serial __system_property_serial2 +#pragma redefine_extname __system_properties_init __system_properties_init2 +#pragma redefine_extname __system_property_wait_any __system_property_wait_any2 diff --git a/native/jni/resetprop/private/system_properties.h b/native/jni/systemproperties/include/system_properties.h similarity index 99% rename from native/jni/resetprop/private/system_properties.h rename to native/jni/systemproperties/include/system_properties.h index ad70d4dc4..a0966e410 100644 --- a/native/jni/resetprop/private/system_properties.h +++ b/native/jni/systemproperties/include/system_properties.h @@ -33,7 +33,8 @@ #include #include #include -#include "redefs.h" + +#include "private/hacks.h" __BEGIN_DECLS diff --git a/native/jni/systemproperties/include/system_properties/prop_info.h b/native/jni/systemproperties/include/system_properties/prop_info.h index 326a7b82d..34eff4874 100644 --- a/native/jni/systemproperties/include/system_properties/prop_info.h +++ b/native/jni/systemproperties/include/system_properties/prop_info.h @@ -30,10 +30,10 @@ #include #include -#include +//#include +#include "../system_properties.h" #include "private/bionic_macros.h" -#include "hacks.h" // The C11 standard doesn't allow atomic loads from const fields, // though C++11 does. Fudge it until standards get straightened out. diff --git a/native/jni/systemproperties/include/system_properties/system_properties.h b/native/jni/systemproperties/include/system_properties/system_properties.h index 6ada37763..8182ebf83 100644 --- a/native/jni/systemproperties/include/system_properties/system_properties.h +++ b/native/jni/systemproperties/include/system_properties/system_properties.h @@ -30,7 +30,8 @@ #include #include -#include +//#include +#include "../system_properties.h" #include "contexts.h" #include "contexts_pre_split.h" diff --git a/native/jni/resetprop/system_property_api.cpp b/native/jni/systemproperties/system_property_api.cpp similarity index 99% rename from native/jni/resetprop/system_property_api.cpp rename to native/jni/systemproperties/system_property_api.cpp index e2c5471d1..f8656532d 100644 --- a/native/jni/resetprop/system_property_api.cpp +++ b/native/jni/systemproperties/system_property_api.cpp @@ -28,7 +28,7 @@ #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ //#include -#include "private/_system_properties.h" +#include <_system_properties.h> #include #include diff --git a/native/jni/resetprop/system_property_set.cpp b/native/jni/systemproperties/system_property_set.cpp similarity index 99% rename from native/jni/resetprop/system_property_set.cpp rename to native/jni/systemproperties/system_property_set.cpp index 9311e7854..b32321448 100644 --- a/native/jni/resetprop/system_property_set.cpp +++ b/native/jni/systemproperties/system_property_set.cpp @@ -39,7 +39,7 @@ #include #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ //#include -#include "private/_system_properties.h" +#include <_system_properties.h> #include #include @@ -173,7 +173,7 @@ class SocketWriter { uint32_t uint_buf_[kUintBufSize]; size_t uint_buf_index_; - DISALLOW_IMPLICIT_CONSTRUCTORS(SocketWriter); + BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketWriter); }; struct prop_msg { diff --git a/native/jni/utils/cpio.cpp b/native/jni/utils/cpio.cpp index a62754f58..7a0b15ab9 100644 --- a/native/jni/utils/cpio.cpp +++ b/native/jni/utils/cpio.cpp @@ -4,9 +4,9 @@ #include #include -#include -#include -#include +#include +#include +#include using namespace std; diff --git a/native/jni/utils/file.cpp b/native/jni/utils/file.cpp index 9af4365b3..7e338830c 100644 --- a/native/jni/utils/file.cpp +++ b/native/jni/utils/file.cpp @@ -7,8 +7,8 @@ #include #include -#include -#include +#include +#include using namespace std; diff --git a/native/jni/utils/files.h b/native/jni/utils/files.hpp similarity index 99% rename from native/jni/utils/files.h rename to native/jni/utils/files.hpp index a53f632c5..bc061f726 100644 --- a/native/jni/utils/files.h +++ b/native/jni/utils/files.hpp @@ -6,7 +6,7 @@ #include #include -#include "xwrap.h" +#include "xwrap.hpp" #define do_align(p, a) (((p) + (a) - 1) / (a) * (a)) #define align_off(p, a) (do_align(p, a) - (p)) diff --git a/native/jni/utils/include/blocking_queue.h b/native/jni/utils/include/blocking_queue.hpp similarity index 98% rename from native/jni/utils/include/blocking_queue.h rename to native/jni/utils/include/blocking_queue.hpp index f907da1f3..a97b95618 100644 --- a/native/jni/utils/include/blocking_queue.h +++ b/native/jni/utils/include/blocking_queue.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include <../misc.hpp> template class blocking_queue { diff --git a/native/jni/utils/include/cpio.h b/native/jni/utils/include/cpio.hpp similarity index 98% rename from native/jni/utils/include/cpio.h rename to native/jni/utils/include/cpio.hpp index 51a2514d3..dd877d904 100644 --- a/native/jni/utils/include/cpio.h +++ b/native/jni/utils/include/cpio.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include struct cpio_newc_header; diff --git a/native/jni/utils/include/logging.h b/native/jni/utils/include/logging.hpp similarity index 100% rename from native/jni/utils/include/logging.h rename to native/jni/utils/include/logging.hpp diff --git a/native/jni/utils/include/selinux.h b/native/jni/utils/include/selinux.hpp similarity index 100% rename from native/jni/utils/include/selinux.h rename to native/jni/utils/include/selinux.hpp diff --git a/native/jni/utils/include/stream.h b/native/jni/utils/include/stream.hpp similarity index 98% rename from native/jni/utils/include/stream.h rename to native/jni/utils/include/stream.hpp index 4e07dce25..3ee6d5d82 100644 --- a/native/jni/utils/include/stream.h +++ b/native/jni/utils/include/stream.hpp @@ -3,7 +3,7 @@ #include #include -#include "../files.h" +#include "../files.hpp" class stream { public: diff --git a/native/jni/utils/include/utils.h b/native/jni/utils/include/utils.h deleted file mode 100644 index e2c71fede..000000000 --- a/native/jni/utils/include/utils.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include "../missing.h" -#include "../xwrap.h" -#include "../files.h" -#include "../misc.h" diff --git a/native/jni/utils/include/utils.hpp b/native/jni/utils/include/utils.hpp new file mode 100644 index 000000000..1498b6514 --- /dev/null +++ b/native/jni/utils/include/utils.hpp @@ -0,0 +1,6 @@ +#pragma once + +#include "../missing.hpp" +#include "../xwrap.hpp" +#include "../files.hpp" +#include "../misc.hpp" diff --git a/native/jni/utils/logging.cpp b/native/jni/utils/logging.cpp index def930461..57fdb77cf 100644 --- a/native/jni/utils/logging.cpp +++ b/native/jni/utils/logging.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include int nop_log(const char *fmt, va_list ap) { diff --git a/native/jni/utils/misc.cpp b/native/jni/utils/misc.cpp index 2db95f556..9c05b9408 100644 --- a/native/jni/utils/misc.cpp +++ b/native/jni/utils/misc.cpp @@ -14,8 +14,8 @@ #include #include -#include -#include +#include +#include int fork_dont_care() { int pid = xfork(); diff --git a/native/jni/utils/misc.h b/native/jni/utils/misc.hpp similarity index 100% rename from native/jni/utils/misc.h rename to native/jni/utils/misc.hpp diff --git a/native/jni/utils/missing.cpp b/native/jni/utils/missing.cpp index 9f05a2e33..f9d828005 100644 --- a/native/jni/utils/missing.cpp +++ b/native/jni/utils/missing.cpp @@ -8,7 +8,7 @@ #include #include -#include "missing.h" +#include "missing.hpp" /* Original source: https://opensource.apple.com/source/cvs/cvs-19/cvs/lib/getline.c * License: GPL 2 or later diff --git a/native/jni/utils/missing.h b/native/jni/utils/missing.hpp similarity index 100% rename from native/jni/utils/missing.h rename to native/jni/utils/missing.hpp diff --git a/native/jni/utils/selinux.cpp b/native/jni/utils/selinux.cpp index 616f1a954..c9eb6997b 100644 --- a/native/jni/utils/selinux.cpp +++ b/native/jni/utils/selinux.cpp @@ -6,9 +6,9 @@ #include #include -#include -#include -#include +#include +#include +#include using namespace std::literals; diff --git a/native/jni/utils/stream.cpp b/native/jni/utils/stream.cpp index ee80cb0a5..3461decd5 100644 --- a/native/jni/utils/stream.cpp +++ b/native/jni/utils/stream.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include static int strm_read(void *v, char *buf, int len) { auto strm = reinterpret_cast(v); diff --git a/native/jni/utils/xwrap.cpp b/native/jni/utils/xwrap.cpp index 4abce6b2d..120521cae 100644 --- a/native/jni/utils/xwrap.cpp +++ b/native/jni/utils/xwrap.cpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include FILE *xfopen(const char *pathname, const char *mode) { FILE *fp = fopen(pathname, mode); diff --git a/native/jni/utils/xwrap.h b/native/jni/utils/xwrap.hpp similarity index 100% rename from native/jni/utils/xwrap.h rename to native/jni/utils/xwrap.hpp