diff options
| author | dimitry <dimitry@google.com> | 2017-08-23 10:25:22 +0200 |
|---|---|---|
| committer | dimitry <dimitry@google.com> | 2017-08-23 20:46:38 +0200 |
| commit | b6ba817de4b80ec2430383899b051e86dd2bec27 (patch) | |
| tree | d89607250656b47a2a55ac2a159e0f640ff84df1 /libnativebridge | |
| parent | 7f16cad877571ce8ef0808dcdb81234d61b771ca (diff) | |
| download | system_core-b6ba817de4b80ec2430383899b051e86dd2bec27.tar.gz system_core-b6ba817de4b80ec2430383899b051e86dd2bec27.tar.bz2 system_core-b6ba817de4b80ec2430383899b051e86dd2bec27.zip | |
Define current ABI string in android-base/macros.h
Test: make
Change-Id: I8200d7b3232edba43a583c5ff1e1b0f78c768f69
Diffstat (limited to 'libnativebridge')
| -rw-r--r-- | libnativebridge/Android.bp | 2 | ||||
| -rw-r--r-- | libnativebridge/native_bridge.cc | 20 | ||||
| -rw-r--r-- | libnativebridge/tests/Android.mk | 1 | ||||
| -rw-r--r-- | libnativebridge/tests/NeedsNativeBridge_test.cpp | 28 |
4 files changed, 11 insertions, 40 deletions
diff --git a/libnativebridge/Android.bp b/libnativebridge/Android.bp index 8b48a87e9..b3c42f072 100644 --- a/libnativebridge/Android.bp +++ b/libnativebridge/Android.bp @@ -11,7 +11,7 @@ cc_library { host_supported: true, srcs: ["native_bridge.cc"], - shared_libs: ["liblog"], + shared_libs: ["liblog", "libbase"], export_include_dirs=["include"], diff --git a/libnativebridge/native_bridge.cc b/libnativebridge/native_bridge.cc index 02b4fe7ad..e24307af5 100644 --- a/libnativebridge/native_bridge.cc +++ b/libnativebridge/native_bridge.cc @@ -28,6 +28,7 @@ #include <cstring> +#include <android-base/macros.h> #include <log/log.h> namespace android { @@ -243,29 +244,12 @@ bool LoadNativeBridge(const char* nb_library_filename, } } -#if defined(__arm__) -static const char* kRuntimeISA = "arm"; -#elif defined(__aarch64__) -static const char* kRuntimeISA = "arm64"; -#elif defined(__mips__) && !defined(__LP64__) -static const char* kRuntimeISA = "mips"; -#elif defined(__mips__) && defined(__LP64__) -static const char* kRuntimeISA = "mips64"; -#elif defined(__i386__) -static const char* kRuntimeISA = "x86"; -#elif defined(__x86_64__) -static const char* kRuntimeISA = "x86_64"; -#else -static const char* kRuntimeISA = "unknown"; -#endif - - bool NeedsNativeBridge(const char* instruction_set) { if (instruction_set == nullptr) { ALOGE("Null instruction set in NeedsNativeBridge."); return false; } - return strncmp(instruction_set, kRuntimeISA, strlen(kRuntimeISA) + 1) != 0; + return strncmp(instruction_set, ABI_STRING, strlen(ABI_STRING) + 1) != 0; } #ifdef __APPLE__ diff --git a/libnativebridge/tests/Android.mk b/libnativebridge/tests/Android.mk index c1e65ff98..b3861e080 100644 --- a/libnativebridge/tests/Android.mk +++ b/libnativebridge/tests/Android.mk @@ -29,6 +29,7 @@ test_src_files := \ shared_libraries := \ liblog \ + libbase \ libnativebridge \ libnativebridge-dummy diff --git a/libnativebridge/tests/NeedsNativeBridge_test.cpp b/libnativebridge/tests/NeedsNativeBridge_test.cpp index 2067ed205..c8ff743b0 100644 --- a/libnativebridge/tests/NeedsNativeBridge_test.cpp +++ b/libnativebridge/tests/NeedsNativeBridge_test.cpp @@ -16,34 +16,20 @@ #include "NativeBridgeTest.h" +#include <android-base/macros.h> + namespace android { static const char* kISAs[] = { "arm", "arm64", "mips", "mips64", "x86", "x86_64", "random", "64arm", "64_x86", "64_x86_64", "", "reallylongstringabcd", nullptr }; -#if defined(__arm__) -static const char* kRuntimeISA = "arm"; -#elif defined(__aarch64__) -static const char* kRuntimeISA = "arm64"; -#elif defined(__mips__) && !defined(__LP64__) -static const char* kRuntimeISA = "mips"; -#elif defined(__mips__) && defined(__LP64__) -static const char* kRuntimeISA = "mips64"; -#elif defined(__i386__) -static const char* kRuntimeISA = "x86"; -#elif defined(__x86_64__) -static const char* kRuntimeISA = "x86_64"; -#else -static const char* kRuntimeISA = "unknown"; -#endif - TEST_F(NativeBridgeTest, NeedsNativeBridge) { - EXPECT_EQ(false, NeedsNativeBridge(kRuntimeISA)); + EXPECT_EQ(false, NeedsNativeBridge(ABI_STRING)); - const size_t kISACount = sizeof(kISAs)/sizeof(kISAs[0]); - for (size_t i = 0; i < kISACount; i++) { - EXPECT_EQ(kISAs[i] == nullptr ? false : strcmp(kISAs[i], kRuntimeISA) != 0, - NeedsNativeBridge(kISAs[i])); + const size_t kISACount = sizeof(kISAs) / sizeof(kISAs[0]); + for (size_t i = 0; i < kISACount; i++) { + EXPECT_EQ(kISAs[i] == nullptr ? false : strcmp(kISAs[i], ABI_STRING) != 0, + NeedsNativeBridge(kISAs[i])); } } |
