Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 16kb page size on Android #19658

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ if(NOT MSVC)
# This one is very useful but has many false positives.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-missing-braces")
endif()

if(ANDROID)
Expand Down Expand Up @@ -2718,6 +2718,11 @@ set(WindowsFiles
Windows/stdafx.h
)

if(ANDROID AND ARM64)
# Support 16kb page size on Android
target_link_options(${CoreLibName} PRIVATE "-Wl,-z,max-page-size=16384")
endif()

list(APPEND LinkCommon ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT})

if(WIN32)
Expand Down Expand Up @@ -2900,6 +2905,9 @@ if(TargetBin)
else()
add_executable(${TargetBin} ${NativeAppSource})
endif()
if(ANDROID AND ARM64)
target_link_options(${TargetBin} PRIVATE "-Wl,-z,max-page-size=16384")
endif()
target_link_libraries(${TargetBin} ${LinkCommon} Common)
endif()

Expand Down
2 changes: 1 addition & 1 deletion Common/Log/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void LogManager::LogLine(LogLevel level, Log type, const char *file, int line, c
const char *hostThreadName = GetCurrentThreadName();
if ((hostThreadName && strcmp(hostThreadName, "EmuThread") != 0) || !hleCurrentThreadName) {
// Use the host thread name.
threadName = hostThreadName;
threadName = hostThreadName ? hostThreadName : "unknown";
} else {
// Use the PSP HLE thread name.
threadName = hleCurrentThreadName;
Expand Down
7 changes: 6 additions & 1 deletion Common/MemoryUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,12 @@ int GetMemoryProtectPageSize() {
if (sys_info.dwPageSize == 0)
GetSystemInfo(&sys_info);
return sys_info.dwPageSize;
#else
static int pageSize = 0;
if (!pageSize) {
pageSize = sysconf(_SC_PAGE_SIZE);
}
return pageSize;
#endif
return MEM_PAGE_SIZE;
}
#endif // !PPSSPP_PLATFORM(SWITCH)
6 changes: 3 additions & 3 deletions Common/Thread/ThreadUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void SetCurrentThreadNameThroughException(const char *threadName);

const char *GetCurrentThreadName() {
#ifdef TLS_SUPPORTED
return curThreadName;
return "N/A"; //curThreadName;
#else
return "";
#endif
Expand All @@ -140,7 +140,7 @@ void SetCurrentThreadName(const char *threadName) {
ConvertUTF8ToWString(buffer, ARRAY_SIZE(buffer), threadName);
SetThreadDescription(GetCurrentThread(), buffer);
#elif PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(LINUX)
pthread_setname_np(pthread_self(), threadName);
// pthread_setname_np(pthread_self(), threadName);
#elif defined(__APPLE__)
pthread_setname_np(threadName);
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
Expand All @@ -151,7 +151,7 @@ void SetCurrentThreadName(const char *threadName) {

// Set the locally known threadname using a thread local variable.
#ifdef TLS_SUPPORTED
curThreadName = threadName;
// curThreadName = threadName;
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions Core/Dialog/PSPOskDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static const uint8_t kor_lconsCom[33] = { 18,0,2,21,3,4,26,3,5,0,7,8,15,7,9,16,7
// Korean (Hangul) last consonant Separation key
static const uint8_t kor_lconsSpr[33] = { 2,1,9,4,4,12,5,4,18,8,8,0,9,8,6,10,8,7,11,8,9,12,8,16,13,8,17,14,8,18,17,17,9 };

static const char * const OskKeyboardNames[] =
static const std::string_view OskKeyboardNames[] =
{
"en_US",
"ja_JP",
Expand Down Expand Up @@ -940,11 +940,11 @@ int PSPOskDialog::Update(int animSpeed) {
}

// Now, let's grab the name.
const char *countryCode = OskKeyboardNames[lang];
const char *language = languageMapping[countryCode].first.c_str();
std::string_view countryCode = OskKeyboardNames[lang];
const char *language = languageMapping[std::string(countryCode)].first.c_str();

// It seems like this is a "fake" country code for extra keyboard purposes.
if (!strcmp(countryCode, "English Full-width"))
if (countryCode == "English Full-width")
language = "English Full-width";

return language;
Expand Down
12 changes: 6 additions & 6 deletions UI/ImDebugger/ImDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,12 @@ static void DrawKernelObjects(ImConfig &cfg) {
}

static const char *MemCheckConditionToString(MemCheckCondition cond) {
switch (cond) {
case MEMCHECK_READ: return "Read";
case MEMCHECK_WRITE: return "Write";
case MEMCHECK_READWRITE: return "Read/Write";
case MEMCHECK_WRITE | MEMCHECK_WRITE_ONCHANGE: return "Write Change";
case MEMCHECK_READWRITE | MEMCHECK_WRITE_ONCHANGE: return "Read/Write Change";
switch ((int)cond) {
case (int)MEMCHECK_READ: return "Read";
case (int)MEMCHECK_WRITE: return "Write";
case (int)MEMCHECK_READWRITE: return "Read/Write";
case (int)(MEMCHECK_WRITE | MEMCHECK_WRITE_ONCHANGE): return "Write Change";
case (int)(MEMCHECK_READWRITE | MEMCHECK_WRITE_ONCHANGE): return "Read/Write Change";
default:
return "(bad!)";
}
Expand Down
12 changes: 9 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ android {
}

compileSdk 35
ndkVersion "21.4.7075529"
ndkVersion "27.2.12479018"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
// languageVersion = JavaLanguageVersion.of(17)
}
}
defaultConfig {
Expand Down Expand Up @@ -146,6 +147,7 @@ android {
'-DANDROID_PLATFORM=android-16',
'-DANDROID_TOOLCHAIN=clang',
'-DANDROID_CPP_FEATURES=',
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON',
'-DANDROID_STL=c++_static'
}
}
Expand All @@ -165,6 +167,7 @@ android {
'-DANDROID_CPP_FEATURES=',
'-DANDROID_STL=c++_static',
'-DANDROID_ARM_NEON=TRUE',
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON',
'-DGOLD=TRUE'
}
}
Expand All @@ -184,6 +187,7 @@ android {
'-DANDROID_TOOLCHAIN=clang',
'-DANDROID_CPP_FEATURES=',
'-DANDROID_STL=c++_static',
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON',
'-DANDROID_LEGACY=TRUE'
}
}
Expand All @@ -204,8 +208,10 @@ android {
'-DANDROID_CPP_FEATURES=',
'-DANDROID_STL=c++_static',
'-DANDROID_ARM_NEON=TRUE',
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON',
'-DOPENXR=TRUE',
'-DANDROID_LEGACY=TRUE'
'-DANDROID_LEGACY=TRUE',
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON'
}
}
ndk {
Expand Down
1 change: 1 addition & 0 deletions android/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ APP_STL := c++_static
APP_PLATFORM := android-9
APP_ABI := arm64-v8a armeabi-v7a x86_64
APP_GNUSTL_CPP_FEATURES := exceptions
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
NDK_TOOLCHAIN_VERSION := clang
2 changes: 2 additions & 0 deletions android/jni/Locals.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ffmpeg/android/arm64/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ext/libadrenotools/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ext/libadrenotools/lib/linkernsbypass

LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
endif
2 changes: 1 addition & 1 deletion android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
(JNIEnv * env, jclass, jstring jmodel, jint jdeviceType, jstring jlangRegion, jstring japkpath,
jstring jdataDir, jstring jexternalStorageDir, jstring jexternalFilesDir, jstring jNativeLibDir, jstring jadditionalStorageDirs, jstring jcacheDir, jstring jshortcutParam,
jint jAndroidVersion, jstring jboard) {
SetCurrentThreadName("androidInit");
// SetCurrentThreadName("androidInit");

// Makes sure we get early permission grants.
ProcessFrameCommands(env);
Expand Down
Loading