Skip to content

Commit

Permalink
android: Replace _ANDROID with standard __ANDROID__ define
Browse files Browse the repository at this point in the history
`__ANDROID__` is automatically defined by the Android NDK, which means
that we no longer need a conditional `--copt`.
  • Loading branch information
fmeum committed Aug 2, 2023
1 parent 0e563f6 commit 91b89f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ build --experimental_java_classpath=bazel
# Android
build --incompatible_enable_android_toolchain_resolution
build --android_platforms=//:android_arm64
build:android_arm --copt=-D_ANDROID
build:android_arm --java_runtime_version=local_jdk

# Windows
Expand Down
12 changes: 6 additions & 6 deletions launcher/jvm_tooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "jvm_tooling.h"

#if defined(_ANDROID)
#if defined(__ANDROID__)
#include <dlfcn.h>
#elif defined(__APPLE__)
#include <mach-o/dyld.h>
Expand Down Expand Up @@ -69,7 +69,7 @@ std::string getExecutablePath() {
#elif defined(_WIN32)
DWORD read_bytes = GetModuleFileNameA(NULL, buf, sizeof(buf));
bool failed = (read_bytes == 0);
#elif defined(_ANDROID)
#elif defined(__ANDROID__)
bool failed = true;
uint32_t read_bytes = 0;
#else // Assume Linux
Expand Down Expand Up @@ -161,7 +161,7 @@ std::vector<std::string> splitEscaped(const std::string &str) {

namespace jazzer {

#if defined(_ANDROID)
#if defined(__ANDROID__)
typedef jint (*JNI_CreateJavaVM_t)(JavaVM **, JNIEnv **, void *);
JNI_CreateJavaVM_t LoadAndroidVMLibs() {
std::cout << "Loading Android libraries" << std::endl;
Expand Down Expand Up @@ -227,7 +227,7 @@ JVM::JVM() {
options.push_back(
JavaVMOption{.optionString = const_cast<char *>(class_path.c_str())});

#if !defined(_ANDROID)
#if !defined(__ANDROID__)
// Set the maximum heap size to a value that is slightly smaller than
// libFuzzer's default rss_limit_mb. This prevents erroneous oom reports.
options.push_back(JavaVMOption{.optionString = (char *)"-Xmx1800m"});
Expand Down Expand Up @@ -278,7 +278,7 @@ JVM::JVM() {
}
}

#if !defined(_ANDROID)
#if !defined(__ANDROID__)
jint jni_version = JNI_VERSION_1_8;
#else
jint jni_version = JNI_VERSION_1_6;
Expand All @@ -289,7 +289,7 @@ JVM::JVM() {
.options = options.data(),
.ignoreUnrecognized = JNI_FALSE};

#if !defined(_ANDROID)
#if !defined(__ANDROID__)
int ret = JNI_CreateJavaVM(&jvm_, (void **)&env_, &jvm_init_args);
#else
JNI_CreateJavaVM_t CreateArtVM = LoadAndroidVMLibs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <cstdlib>

#if defined(_ANDROID)
#if defined(__ANDROID__)
#define __jni_version__ JNI_VERSION_1_6
#else
#define __jni_version__ JNI_VERSION_1_8
Expand Down

0 comments on commit 91b89f2

Please sign in to comment.