|
17 | 17 | #include <android/bitmap.h> |
18 | 18 | #include <ctime> |
19 | 19 | #include <jni.h> |
| 20 | +#include <unistd.h> |
| 21 | +#include <sys/mman.h> |
| 22 | +#include <android/api-level.h> |
20 | 23 |
|
21 | 24 | using namespace CGE; |
22 | 25 |
|
| 26 | +// Function to check 16KB page size status |
| 27 | +static void cgeCheck16kPageSize() { |
| 28 | + const char* status = "Unknown"; |
| 29 | + const char* details = ""; |
| 30 | + |
| 31 | + // 1. Check compile-time support |
| 32 | +#ifdef ENABLE_16K_PAGE_SIZES |
| 33 | + bool compileTimeSupport = true; |
| 34 | +#else |
| 35 | + bool compileTimeSupport = false; |
| 36 | +#endif |
| 37 | + |
| 38 | + // 2. Check runtime Android version (16KB pages are supported from Android 15, API 35) |
| 39 | + int apiLevel = android_get_device_api_level(); |
| 40 | + bool systemSupport = (apiLevel >= 35); |
| 41 | + |
| 42 | + // 3. Check actual page size being used |
| 43 | + long pageSize = sysconf(_SC_PAGESIZE); |
| 44 | + bool activelyUsing16k = (pageSize == 16384); |
| 45 | + |
| 46 | + // Determine status and details |
| 47 | + if (!compileTimeSupport) { |
| 48 | + status = "DISABLED"; |
| 49 | + details = "16KB page size support not enabled at compile time"; |
| 50 | + } else if (!systemSupport) { |
| 51 | + status = "COMPILE_READY"; |
| 52 | + details = "16KB support compiled in, but Android version < 35 (Android 15)"; |
| 53 | + } else if (activelyUsing16k) { |
| 54 | + status = "ACTIVE"; |
| 55 | + details = "16KB page size is fully active and working"; |
| 56 | + } else { |
| 57 | + status = "SUPPORTED_BUT_INACTIVE"; |
| 58 | + details = "16KB support available but current page size is not 16KB"; |
| 59 | + } |
| 60 | + |
| 61 | + // Log comprehensive status - use CGE_LOG_KEEP for important status info |
| 62 | + CGE_LOG_KEEP("=== CGE 16KB Page Size Status ==="); |
| 63 | + CGE_LOG_KEEP("Status: %s", status); |
| 64 | + CGE_LOG_KEEP("Details: %s", details); |
| 65 | + CGE_LOG_INFO("Compile-time support: %s", compileTimeSupport ? "YES" : "NO"); |
| 66 | + CGE_LOG_INFO("Android API Level: %d (16KB support needs API 35+)", apiLevel); |
| 67 | + CGE_LOG_INFO("Current page size: %ld bytes", pageSize); |
| 68 | + CGE_LOG_INFO("16KB pages active: %s", activelyUsing16k ? "YES" : "NO"); |
| 69 | + CGE_LOG_KEEP("================================"); |
| 70 | +} |
| 71 | + |
23 | 72 | extern "C" |
24 | 73 | { |
25 | 74 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) |
26 | 75 | { |
27 | 76 | cgeGl3StubInit(); |
28 | 77 | cgeGl31StubInit(); |
29 | 78 | CGE_LOG_INFO("JNI_OnLoad called. cgeGl3StubInit called.\n"); |
| 79 | + |
| 80 | + // Check and report 16KB page size status |
| 81 | + cgeCheck16kPageSize(); |
| 82 | + |
30 | 83 | return JNI_VERSION_1_6; |
31 | 84 | } |
32 | 85 |
|
|
0 commit comments