From 35497da6a6410491fcb3e0ffb5522f489e4e660d Mon Sep 17 00:00:00 2001 From: Alberto Torres Date: Tue, 21 Jan 2025 13:01:40 +0100 Subject: [PATCH] GLFM: Update ASan no_sanitize attributes to both "address" and "hwaddress". --- libs/glfm/src/glfm_android.c | 196 ++++++++++++++++++----------------- 1 file changed, 99 insertions(+), 97 deletions(-) diff --git a/libs/glfm/src/glfm_android.c b/libs/glfm/src/glfm_android.c index a8866f1..e8be328 100644 --- a/libs/glfm/src/glfm_android.c +++ b/libs/glfm/src/glfm_android.c @@ -3,6 +3,8 @@ // #if defined(__ANDROID__) +#define NO_SANITIZE __attribute__((no_sanitize("address", "hwaddress"))) + #include "glfm.h" #include "glfm_internal.h" @@ -111,18 +113,18 @@ static GLFMPlatformData *platformDataGlobal = NULL; // MARK: - Private function declarations -__attribute__((no_sanitize("hwaddress"))) static void *glfm__mainLoop(void *param); -__attribute__((no_sanitize("hwaddress"))) static int glfm__looperCallback(int pipe, int events, void *userData); -__attribute__((no_sanitize("hwaddress"))) static void glfm__setAllRequestedSensorsEnabled(GLFMDisplay *display, bool enable); -__attribute__((no_sanitize("hwaddress"))) static void glfm__reportOrientationChangeIfNeeded(GLFMDisplay *display); -__attribute__((no_sanitize("hwaddress"))) static void glfm__reportInsetsChangedIfNeeded(GLFMDisplay *display); -__attribute__((no_sanitize("hwaddress"))) static bool glfm__updateSurfaceSizeIfNeeded(GLFMDisplay *display, bool force); +NO_SANITIZE static void *glfm__mainLoop(void *param); +NO_SANITIZE static int glfm__looperCallback(int pipe, int events, void *userData); +NO_SANITIZE static void glfm__setAllRequestedSensorsEnabled(GLFMDisplay *display, bool enable); +NO_SANITIZE static void glfm__reportOrientationChangeIfNeeded(GLFMDisplay *display); +NO_SANITIZE static void glfm__reportInsetsChangedIfNeeded(GLFMDisplay *display); +NO_SANITIZE static bool glfm__updateSurfaceSizeIfNeeded(GLFMDisplay *display, bool force); static float glfm__getRefreshRate(const GLFMDisplay *display); -__attribute__((no_sanitize("hwaddress"))) static void glfm__getDisplayChromeInsets(const GLFMDisplay *display, int *top, int *right, +NO_SANITIZE static void glfm__getDisplayChromeInsets(const GLFMDisplay *display, int *top, int *right, int *bottom, int *left); -__attribute__((no_sanitize("hwaddress"))) static void glfm__resetContentRect(GLFMPlatformData *platformData); -__attribute__((no_sanitize("hwaddress"))) static void glfm__updateKeyboardVisibility(GLFMPlatformData *platformData); -__attribute__((no_sanitize("hwaddress"))) static void glfm__updateUserInterfaceChrome(GLFMPlatformData *platformData); +NO_SANITIZE static void glfm__resetContentRect(GLFMPlatformData *platformData); +NO_SANITIZE static void glfm__updateKeyboardVisibility(GLFMPlatformData *platformData); +NO_SANITIZE static void glfm__updateUserInterfaceChrome(GLFMPlatformData *platformData); // MARK: - JNI code @@ -143,7 +145,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__updateUserInterfaceC } \ } while (0) -__attribute__((no_sanitize("hwaddress"))) static jmethodID glfm__getJavaMethodID(JNIEnv *jni, jobject object, const char *name, const char *sig) { +NO_SANITIZE static jmethodID glfm__getJavaMethodID(JNIEnv *jni, jobject object, const char *name, const char *sig) { if (!object) { return NULL; } @@ -153,7 +155,7 @@ __attribute__((no_sanitize("hwaddress"))) static jmethodID glfm__getJavaMethodID return glfm__wasJavaExceptionThrown(jni) ? NULL : methodID; } -__attribute__((no_sanitize("hwaddress"))) static jfieldID glfm__getJavaFieldID(JNIEnv *jni, jobject object, const char *name, const char *sig) { +NO_SANITIZE static jfieldID glfm__getJavaFieldID(JNIEnv *jni, jobject object, const char *name, const char *sig) { if (!object) { return NULL; } @@ -163,7 +165,7 @@ __attribute__((no_sanitize("hwaddress"))) static jfieldID glfm__getJavaFieldID(J return glfm__wasJavaExceptionThrown(jni) ? NULL : fieldID; } -__attribute__((no_sanitize("hwaddress"))) static jmethodID glfm__getJavaStaticMethodID(JNIEnv *jni, jclass class, const char *name, const char *sig) { +NO_SANITIZE static jmethodID glfm__getJavaStaticMethodID(JNIEnv *jni, jclass class, const char *name, const char *sig) { if (!class) { return NULL; } @@ -171,7 +173,7 @@ __attribute__((no_sanitize("hwaddress"))) static jmethodID glfm__getJavaStaticMe return glfm__wasJavaExceptionThrown(jni) ? NULL : methodID; } -__attribute__((no_sanitize("hwaddress"))) static jfieldID glfm__getJavaStaticFieldID(JNIEnv *jni, jclass class, const char *name, const char *sig) { +NO_SANITIZE static jfieldID glfm__getJavaStaticFieldID(JNIEnv *jni, jclass class, const char *name, const char *sig) { if (!class) { return NULL; } @@ -205,7 +207,7 @@ __attribute__((no_sanitize("hwaddress"))) static jfieldID glfm__getJavaStaticFie // MARK: - EGL -__attribute__((no_sanitize("hwaddress"))) static bool glfm__eglContextInit(GLFMPlatformData *platformData) { +NO_SANITIZE static bool glfm__eglContextInit(GLFMPlatformData *platformData) { // Available in eglext.h in API 18 static const int EGL_CONTEXT_MAJOR_VERSION_KHR = 0x3098; @@ -311,14 +313,14 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__eglContextInit(GLFMP return true; } -__attribute__((no_sanitize("hwaddress"))) static void glfm__eglContextDisable(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__eglContextDisable(GLFMPlatformData *platformData) { if (platformData->eglDisplay != EGL_NO_DISPLAY) { eglMakeCurrent(platformData->eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); } platformData->eglContextCurrent = false; } -__attribute__((no_sanitize("hwaddress"))) static void glfm__eglSurfaceInit(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__eglSurfaceInit(GLFMPlatformData *platformData) { if (platformData->eglSurface == EGL_NO_SURFACE) { platformData->eglSurface = eglCreateWindowSurface(platformData->eglDisplay, platformData->eglConfig, @@ -332,14 +334,14 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__eglSurfaceInit(GLFMP eglSurfaceAttrib(platformData->eglDisplay, platformData->eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); break; case GLFMSwapBehaviorBufferDestroyed: - eglSurfaceAttrib(platformData->eglDisplay, platformData->eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); - } + eglSurfaceAttrib(platformData->eglDisplay, platformData->eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); } } +} #ifndef NDEBUG -__attribute__((no_sanitize("hwaddress"))) static void glfm__eglLogConfig(GLFMPlatformData *platformData, EGLConfig config) { +NO_SANITIZE static void glfm__eglLogConfig(GLFMPlatformData *platformData, EGLConfig config) { GLFM_LOG("Config: %p", config); EGLint value = 0; eglGetConfigAttrib(platformData->eglDisplay, config, EGL_RENDERABLE_TYPE, &value); @@ -366,7 +368,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__eglLogConfig(GLFMPla #endif -__attribute__((no_sanitize("hwaddress"))) static bool glfm__eglInit(GLFMPlatformData *platformData) { +NO_SANITIZE static bool glfm__eglInit(GLFMPlatformData *platformData) { if (platformData->eglDisplay != EGL_NO_DISPLAY) { glfm__eglSurfaceInit(platformData); return glfm__eglContextInit(platformData); @@ -502,7 +504,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__eglInit(GLFMPlatform return glfm__eglContextInit(platformData); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__eglSurfaceDestroy(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__eglSurfaceDestroy(GLFMPlatformData *platformData) { if (platformData->eglSurface != EGL_NO_SURFACE) { eglDestroySurface(platformData->eglDisplay, platformData->eglSurface); platformData->eglSurface = EGL_NO_SURFACE; @@ -510,7 +512,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__eglSurfaceDestroy(GL glfm__eglContextDisable(platformData); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__eglDestroy(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__eglDestroy(GLFMPlatformData *platformData) { if (platformData->eglDisplay != EGL_NO_DISPLAY) { eglMakeCurrent(platformData->eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (platformData->eglContext != EGL_NO_CONTEXT) { @@ -534,7 +536,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__eglDestroy(GLFMPlatf platformData->eglContextCurrent = false; } -__attribute__((no_sanitize("hwaddress"))) static void glfm__eglCheckError(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__eglCheckError(GLFMPlatformData *platformData) { EGLint err = eglGetError(); if (err == EGL_BAD_SURFACE) { glfm__eglSurfaceDestroy(platformData); @@ -558,7 +560,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__eglCheckError(GLFMPl } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__drawFrame(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__drawFrame(GLFMPlatformData *platformData) { if (!platformData->eglContextCurrent) { // Probably a bad config (Happens on Android 2.3 emulator) return; @@ -606,7 +608,7 @@ typedef enum { GLFMActivityCommandOnLowMemory, } GLFMActivityCommand; -__attribute__((no_sanitize("hwaddress"))) static void glfm__sendCommand(ANativeActivity *activity, GLFMActivityCommand command) { +NO_SANITIZE static void glfm__sendCommand(ANativeActivity *activity, GLFMActivityCommand command) { GLFMPlatformData *platformData = activity->instance; if (!platformData) { return; @@ -617,7 +619,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__sendCommand(ANativeA } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnStart(ANativeActivity *activity) { +NO_SANITIZE static void glfm__activityOnStart(ANativeActivity *activity) { GLFMPlatformData *platformData = activity->instance; if (platformData && platformData->display) { glfm__updateUserInterfaceChrome(platformData); @@ -625,42 +627,42 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnStart(ANat glfm__sendCommand(activity, GLFMActivityCommandOnStart); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnPause(ANativeActivity *activity) { +NO_SANITIZE static void glfm__activityOnPause(ANativeActivity *activity) { glfm__sendCommand(activity, GLFMActivityCommandOnPause); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnResume(ANativeActivity *activity) { +NO_SANITIZE static void glfm__activityOnResume(ANativeActivity *activity) { glfm__sendCommand(activity, GLFMActivityCommandOnResume); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnStop(ANativeActivity *activity) { +NO_SANITIZE static void glfm__activityOnStop(ANativeActivity *activity) { glfm__sendCommand(activity, GLFMActivityCommandOnStop); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnWindowFocusChanged(ANativeActivity *activity, int hasFocus) { +NO_SANITIZE static void glfm__activityOnWindowFocusChanged(ANativeActivity *activity, int hasFocus) { glfm__sendCommand(activity, (hasFocus ? GLFMActivityCommandOnWindowFocusGained : GLFMActivityCommandOnWindowFocusLost)); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnConfigurationChanged(ANativeActivity *activity) { +NO_SANITIZE static void glfm__activityOnConfigurationChanged(ANativeActivity *activity) { glfm__sendCommand(activity, GLFMActivityCommandOnConfigurationChanged); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnLowMemory(ANativeActivity *activity) { +NO_SANITIZE static void glfm__activityOnLowMemory(ANativeActivity *activity) { glfm__sendCommand(activity, GLFMActivityCommandOnLowMemory); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnNativeWindowResized(ANativeActivity *activity, ANativeWindow *window) { +NO_SANITIZE static void glfm__activityOnNativeWindowResized(ANativeActivity *activity, ANativeWindow *window) { (void)window; glfm__sendCommand(activity, GLFMActivityCommandOnNativeWindowResized); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnNativeWindowRedrawNeeded(ANativeActivity *activity, ANativeWindow *window) { +NO_SANITIZE static void glfm__activityOnNativeWindowRedrawNeeded(ANativeActivity *activity, ANativeWindow *window) { (void)window; glfm__sendCommand(activity, GLFMActivityCommandOnNativeWindowRedrawNeeded); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnNativeWindowCreated(ANativeActivity *activity, ANativeWindow *window) { +NO_SANITIZE static void glfm__activityOnNativeWindowCreated(ANativeActivity *activity, ANativeWindow *window) { GLFMPlatformData *platformData = activity->instance; pthread_mutex_lock(&platformData->mutex); platformData->pendingWindow = window; @@ -671,12 +673,12 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnNativeWind pthread_mutex_unlock(&platformData->mutex); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnNativeWindowDestroyed(ANativeActivity *activity, ANativeWindow *window) { +NO_SANITIZE static void glfm__activityOnNativeWindowDestroyed(ANativeActivity *activity, ANativeWindow *window) { (void)window; glfm__sendCommand(activity, GLFMActivityCommandOnNativeWindowDestroyed); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnInputQueueCreated(ANativeActivity *activity, AInputQueue *queue) { +NO_SANITIZE static void glfm__activityOnInputQueueCreated(ANativeActivity *activity, AInputQueue *queue) { GLFMPlatformData *platformData = activity->instance; pthread_mutex_lock(&platformData->mutex); platformData->pendingInputQueue = queue; @@ -687,12 +689,12 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnInputQueue pthread_mutex_unlock(&platformData->mutex); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnInputQueueDestroyed(ANativeActivity *activity, AInputQueue *queue) { +NO_SANITIZE static void glfm__activityOnInputQueueDestroyed(ANativeActivity *activity, AInputQueue *queue) { (void)queue; glfm__sendCommand(activity, GLFMActivityCommandOnInputQueueDestroyed); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnContentRectChanged(ANativeActivity *activity, const ARect *rect) { +NO_SANITIZE static void glfm__activityOnContentRectChanged(ANativeActivity *activity, const ARect *rect) { GLFMPlatformData *platformData = activity->instance; int nextContentRectIndex = platformData->contentRectIndex ^ 1; platformData->contentRectArray[nextContentRectIndex] = *rect; @@ -701,7 +703,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnContentRec glfm__sendCommand(activity, GLFMActivityCommandOnContentRectChanged); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnDestroy(ANativeActivity *activity) { +NO_SANITIZE static void glfm__activityOnDestroy(ANativeActivity *activity) { GLFMPlatformData *platformData = activity->instance; pthread_mutex_lock(&platformData->mutex); glfm__sendCommand(activity, GLFMActivityCommandOnDestroy); @@ -720,13 +722,13 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__activityOnDestroy(AN GLFM_LOG_LIFECYCLE("Goodbye"); } -__attribute__((no_sanitize("hwaddress"))) static void *glfm__activityOnSaveInstanceState(ANativeActivity *activity, size_t *outSize) { +NO_SANITIZE static void *glfm__activityOnSaveInstanceState(ANativeActivity *activity, size_t *outSize) { (void)activity; *outSize = 0; return NULL; } -__attribute__((no_sanitize("hwaddress"))) JNIEXPORT void ANativeActivity_onCreate(ANativeActivity *activity, void *savedState, size_t savedStateSize) +NO_SANITIZE JNIEXPORT void ANativeActivity_onCreate(ANativeActivity *activity, void *savedState, size_t savedStateSize) { (void)savedState; (void)savedStateSize; @@ -823,7 +825,7 @@ typedef struct { } GLFMLooperMessage; // Called from the UI thread -__attribute__((no_sanitize("hwaddress"))) static int glfm__looperCallback(int pipe, int events, void *userData) { +NO_SANITIZE static int glfm__looperCallback(int pipe, int events, void *userData) { GLFMPlatformData *platformData = userData; GLFMLooperMessage message; assert(ALooper_forThread() == platformData->uiLooper); @@ -837,7 +839,7 @@ __attribute__((no_sanitize("hwaddress"))) static int glfm__looperCallback(int pi /// Queues a function to execute on the UI thread. /// Returns true if the function was queued, false otherwise. -__attribute__((no_sanitize("hwaddress"))) static bool glfm__runOnUIThread(GLFMPlatformData *platformData, GLFMUIThreadFunc function, +NO_SANITIZE static bool glfm__runOnUIThread(GLFMPlatformData *platformData, GLFMUIThreadFunc function, void *userData) { assert(platformData->looper == ALooper_forThread()); if (platformData->looper != ALooper_forThread() || !function) { @@ -856,7 +858,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__runOnUIThread(GLFMPl // MARK: - App command callback and input callbacks -__attribute__((no_sanitize("hwaddress"))) static void glfm__setAnimating(GLFMPlatformData *platformData, bool animating) { +NO_SANITIZE static void glfm__setAnimating(GLFMPlatformData *platformData, bool animating) { if (platformData->animating != animating) { platformData->animating = animating; platformData->refreshRequested = true; @@ -867,7 +869,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__setAnimating(GLFMPla } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__onAppCmd(GLFMPlatformData *platformData, GLFMActivityCommand command) { +NO_SANITIZE static void glfm__onAppCmd(GLFMPlatformData *platformData, GLFMActivityCommand command) { switch (command) { case GLFMActivityCommandOnNativeWindowCreated: { GLFM_LOG_LIFECYCLE("OnNativeWindowCreated"); @@ -1011,7 +1013,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__onAppCmd(GLFMPlatfor } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__unicodeToUTF8(uint32_t unicode, char utf8[5]) { +NO_SANITIZE static void glfm__unicodeToUTF8(uint32_t unicode, char utf8[5]) { if (unicode < 0x80) { utf8[0] = (char)(unicode & 0x7fu); utf8[1] = 0; @@ -1076,7 +1078,7 @@ static uint32_t glfm__getUnicodeChar(GLFMPlatformData *platformData, jint keyCod * * When this, when the app is in the background, the app will pause in the ALooper_pollAll() call. */ -__attribute__((no_sanitize("hwaddress"))) static bool glfm__handleBackButton(GLFMPlatformData *platformData) { +NO_SANITIZE static bool glfm__handleBackButton(GLFMPlatformData *platformData) { if (!platformData || !platformData->activity) { return false; } @@ -1090,7 +1092,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__handleBackButton(GLF return !glfm__wasJavaExceptionThrown(jni) && handled; } -__attribute__((no_sanitize("hwaddress"))) static bool glfm__onKeyEvent(GLFMPlatformData *platformData, AInputEvent *event) { +NO_SANITIZE static bool glfm__onKeyEvent(GLFMPlatformData *platformData, AInputEvent *event) { if (!platformData || !platformData->display) { return false; } @@ -1303,7 +1305,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__onKeyEvent(GLFMPlatf return handled; } -__attribute__((no_sanitize("hwaddress"))) static bool glfm__onTouchEvent(GLFMPlatformData *platformData, AInputEvent *event) { +NO_SANITIZE static bool glfm__onTouchEvent(GLFMPlatformData *platformData, AInputEvent *event) { if (!platformData || !platformData->display || !platformData->display->touchFunc) { return false; } @@ -1369,7 +1371,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__onTouchEvent(GLFMPla return true; } -__attribute__((no_sanitize("hwaddress"))) static void glfm__onInputEvent(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__onInputEvent(GLFMPlatformData *platformData) { AInputEvent *event = NULL; while (AInputQueue_getEvent(platformData->inputQueue, &event) >= 0) { if (AInputQueue_preDispatchEvent(platformData->inputQueue, event)) { @@ -1386,7 +1388,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__onInputEvent(GLFMPla } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__onSensorEvent(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__onSensorEvent(GLFMPlatformData *platformData) { ASensorEvent event; bool sensorEventReceived[GLFM_NUM_SENSORS] = { 0 }; while (ASensorEventQueue_getEvents(platformData->sensorEventQueue, &event, 1) > 0) { @@ -1542,7 +1544,7 @@ int pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData) { return result; } -__attribute__((no_sanitize("hwaddress"))) static void *glfm__mainLoop(void *param) { +NO_SANITIZE static void *glfm__mainLoop(void *param) { GLFM_LOG_LIFECYCLE("glfm__mainLoop"); // Init platform data @@ -1714,7 +1716,7 @@ __attribute__((no_sanitize("hwaddress"))) static void *glfm__mainLoop(void *para // MARK: - GLFM private functions -__attribute__((no_sanitize("hwaddress"))) static jobject glfm__getDecorView(JNIEnv *jni, GLFMPlatformData *platformData) +NO_SANITIZE static jobject glfm__getDecorView(JNIEnv *jni, GLFMPlatformData *platformData) { if (!platformData || !platformData->activity || (*jni)->ExceptionCheck(jni)) { return NULL; @@ -1728,7 +1730,7 @@ __attribute__((no_sanitize("hwaddress"))) static jobject glfm__getDecorView(JNIE return glfm__wasJavaExceptionThrown(jni) ? NULL : decorView; } -__attribute__((no_sanitize("hwaddress"))) static ARect glfm__getDecorViewRect(GLFMPlatformData *platformData, const ARect *defaultRect) +NO_SANITIZE static ARect glfm__getDecorViewRect(GLFMPlatformData *platformData, const ARect *defaultRect) { JNIEnv *jni = platformData->jniEnv; if ((*jni)->ExceptionCheck(jni)) { @@ -1770,13 +1772,13 @@ __attribute__((no_sanitize("hwaddress"))) static ARect glfm__getDecorViewRect(GL return result; } -__attribute__((no_sanitize("hwaddress"))) static void glfm__updateUserInterfaceChromeCallback(GLFMPlatformData *platformData, void *userData) { +NO_SANITIZE static void glfm__updateUserInterfaceChromeCallback(GLFMPlatformData *platformData, void *userData) { (void)userData; glfm__updateUserInterfaceChrome(platformData); } // Can be called from either native thread or UI thread -__attribute__((no_sanitize("hwaddress"))) static void glfm__updateUserInterfaceChrome(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__updateUserInterfaceChrome(GLFMPlatformData *platformData) { static const unsigned int View_STATUS_BAR_HIDDEN = 0x00000001; static const unsigned int View_SYSTEM_UI_FLAG_LOW_PROFILE = 0x00000001; static const unsigned int View_SYSTEM_UI_FLAG_HIDE_NAVIGATION = 0x00000002; @@ -1890,7 +1892,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__updateUserInterfaceC (*jni)->DeleteLocalRef(jni, decorView); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__resetContentRect(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__resetContentRect(GLFMPlatformData *platformData) { // Reset's NativeActivity's content rect so that onContentRectChanged acts as a // OnGlobalLayoutListener. This is needed to detect changes to getWindowVisibleDisplayFrame() // HACK: This uses undocumented fields. @@ -1912,7 +1914,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__resetContentRect(GLF glfm__clearJavaException(jni); } -__attribute__((no_sanitize("hwaddress"))) static ARect glfm__getWindowVisibleDisplayFrame(GLFMPlatformData *platformData, const ARect *defaultRect) +NO_SANITIZE static ARect glfm__getWindowVisibleDisplayFrame(GLFMPlatformData *platformData, const ARect *defaultRect) { JNIEnv *jni = platformData->jniEnv; if ((*jni)->ExceptionCheck(jni)) { @@ -1968,7 +1970,7 @@ __attribute__((no_sanitize("hwaddress"))) static ARect glfm__getWindowVisibleDis return rect; } -__attribute__((no_sanitize("hwaddress"))) static bool glfm__getSafeInsets(const GLFMDisplay *display, int *top, int *right, +NO_SANITIZE static bool glfm__getSafeInsets(const GLFMDisplay *display, int *top, int *right, int *bottom, int *left) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; const int SDK_INT = platformData->activity->sdkVersion; @@ -2004,7 +2006,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__getSafeInsets(const return true; } -__attribute__((no_sanitize("hwaddress"))) static bool glfm__getSystemWindowInsets(const GLFMDisplay *display, int *top, int *right, +NO_SANITIZE static bool glfm__getSystemWindowInsets(const GLFMDisplay *display, int *top, int *right, int *bottom, int *left) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; const int SDK_INT = platformData->activity->sdkVersion; @@ -2035,7 +2037,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__getSystemWindowInset } // Calls activity.getWindow().getWindowManager().getDefaultDisplay() -__attribute__((no_sanitize("hwaddress"))) static jobject glfm__getWindowDisplay(GLFMPlatformData *platformData) { +NO_SANITIZE static jobject glfm__getWindowDisplay(GLFMPlatformData *platformData) { JNIEnv *jni = platformData->jniEnv; jobject activity = platformData->activity->clazz; jobject window = glfm__callJavaMethod(jni, activity, "getWindow", @@ -2058,7 +2060,7 @@ __attribute__((no_sanitize("hwaddress"))) static jobject glfm__getWindowDisplay( return windowDisplay; } -__attribute__((no_sanitize("hwaddress"))) static float glfm__getRefreshRate(const GLFMDisplay *display) { +NO_SANITIZE static float glfm__getRefreshRate(const GLFMDisplay *display) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; JNIEnv *jni = platformData->jniEnv; float refreshRate = -1; @@ -2073,7 +2075,7 @@ __attribute__((no_sanitize("hwaddress"))) static float glfm__getRefreshRate(cons return refreshRate; } -__attribute__((no_sanitize("hwaddress"))) static bool glfm__updateSurfaceSizeIfNeeded(GLFMDisplay *display, bool force) { +NO_SANITIZE static bool glfm__updateSurfaceSizeIfNeeded(GLFMDisplay *display, bool force) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; int32_t width = 0; int32_t height = 0; @@ -2101,7 +2103,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__updateSurfaceSizeIfN return false; } -__attribute__((no_sanitize("hwaddress"))) static void glfm__getDisplayChromeInsets(const GLFMDisplay *display, int *top, int *right, +NO_SANITIZE static void glfm__getDisplayChromeInsets(const GLFMDisplay *display, int *top, int *right, int *bottom, int *left) { bool success; @@ -2128,7 +2130,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__getDisplayChromeInse } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__reportInsetsChangedIfNeeded(GLFMDisplay *display) { +NO_SANITIZE static void glfm__reportInsetsChangedIfNeeded(GLFMDisplay *display) { if (!display) { return; } @@ -2149,7 +2151,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__reportInsetsChangedI platformData->insets.valid = true; } -__attribute__((no_sanitize("hwaddress"))) static void glfm__reportOrientationChangeIfNeeded(GLFMDisplay *display) { +NO_SANITIZE static void glfm__reportOrientationChangeIfNeeded(GLFMDisplay *display) { if (!display) { return; } @@ -2164,7 +2166,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__reportOrientationCha } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__setOrientation(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__setOrientation(GLFMPlatformData *platformData) { static const int ActivityInfo_SCREEN_ORIENTATION_SENSOR = 0x00000004; static const int ActivityInfo_SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 0x00000006; static const int ActivityInfo_SCREEN_ORIENTATION_SENSOR_PORTRAIT = 0x00000007; @@ -2195,7 +2197,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__setOrientation(GLFMP glfm__clearJavaException(jni); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__displayChromeUpdated(GLFMDisplay *display) { +NO_SANITIZE static void glfm__displayChromeUpdated(GLFMDisplay *display) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; glfm__updateUserInterfaceChrome(platformData); } @@ -2216,7 +2218,7 @@ static const ASensor *glfm__getDeviceSensor(GLFMSensor sensor) { } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__setAllRequestedSensorsEnabled(GLFMDisplay *display, bool enabledGlobally) { +NO_SANITIZE static void glfm__setAllRequestedSensorsEnabled(GLFMDisplay *display, bool enabledGlobally) { if (!display) { return; } @@ -2262,7 +2264,7 @@ __attribute__((no_sanitize("hwaddress"))) static void glfm__setAllRequestedSenso } } -__attribute__((no_sanitize("hwaddress"))) static void glfm__sensorFuncUpdated(GLFMDisplay *display) { +NO_SANITIZE static void glfm__sensorFuncUpdated(GLFMDisplay *display) { if (display) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; glfm__setAllRequestedSensorsEnabled(display, platformData->animating); @@ -2300,7 +2302,7 @@ static jobject glfm__getSystemService(GLFMPlatformData *platformData, const char return service; } -__attribute__((no_sanitize("hwaddress"))) static bool glfm__setKeyboardVisible(GLFMPlatformData *platformData, bool visible) { +NO_SANITIZE static bool glfm__setKeyboardVisible(GLFMPlatformData *platformData, bool visible) { static const int InputMethodManager_SHOW_FORCED = 2; JNIEnv *jni = platformData->jniEnv; @@ -2343,7 +2345,7 @@ __attribute__((no_sanitize("hwaddress"))) static bool glfm__setKeyboardVisible(G return !glfm__wasJavaExceptionThrown(jni); } -__attribute__((no_sanitize("hwaddress"))) static void glfm__updateKeyboardVisibility(GLFMPlatformData *platformData) { +NO_SANITIZE static void glfm__updateKeyboardVisibility(GLFMPlatformData *platformData) { if (platformData->display) { const ARect *contentRect = &platformData->contentRectArray[platformData->contentRectIndex]; ARect windowRect = glfm__getDecorViewRect(platformData, contentRect); @@ -2455,7 +2457,7 @@ void glfmSwapBuffers(GLFMDisplay *display) { } } -__attribute__((no_sanitize("hwaddress"))) void glfmSetSupportedInterfaceOrientation(GLFMDisplay *display, GLFMInterfaceOrientation supportedOrientations) { +NO_SANITIZE void glfmSetSupportedInterfaceOrientation(GLFMDisplay *display, GLFMInterfaceOrientation supportedOrientations) { if (display && display->supportedOrientations != supportedOrientations) { display->supportedOrientations = supportedOrientations; GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; @@ -2463,7 +2465,7 @@ __attribute__((no_sanitize("hwaddress"))) void glfmSetSupportedInterfaceOrientat } } -__attribute__((no_sanitize("hwaddress"))) GLFMInterfaceOrientation glfmGetInterfaceOrientation(const GLFMDisplay *display) { +NO_SANITIZE GLFMInterfaceOrientation glfmGetInterfaceOrientation(const GLFMDisplay *display) { enum { Surface_ROTATION_0 = 0, Surface_ROTATION_90 = 1, @@ -2497,18 +2499,18 @@ __attribute__((no_sanitize("hwaddress"))) GLFMInterfaceOrientation glfmGetInterf } } -__attribute__((no_sanitize("hwaddress"))) void glfmGetDisplaySize(const GLFMDisplay *display, int *width, int *height) { +NO_SANITIZE void glfmGetDisplaySize(const GLFMDisplay *display, int *width, int *height) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; if (width) *width = platformData->width; if (height) *height = platformData->height; } -__attribute__((no_sanitize("hwaddress"))) double glfmGetDisplayScale(const GLFMDisplay *display) { +NO_SANITIZE double glfmGetDisplayScale(const GLFMDisplay *display) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; return platformData->scale; } -__attribute__((no_sanitize("hwaddress"))) void glfmGetDisplayChromeInsets(const GLFMDisplay *display, double *top, double *right, +NO_SANITIZE void glfmGetDisplayChromeInsets(const GLFMDisplay *display, double *top, double *right, double *bottom, double *left) { int intTop, intRight, intBottom, intLeft; glfm__getDisplayChromeInsets(display, &intTop, &intRight, &intBottom, &intLeft); @@ -2518,34 +2520,34 @@ __attribute__((no_sanitize("hwaddress"))) void glfmGetDisplayChromeInsets(const if (left) *left = (double)intLeft; } -__attribute__((no_sanitize("hwaddress"))) GLFMRenderingAPI glfmGetRenderingAPI(const GLFMDisplay *display) { +NO_SANITIZE GLFMRenderingAPI glfmGetRenderingAPI(const GLFMDisplay *display) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; return platformData->renderingAPI; } -__attribute__((no_sanitize("hwaddress"))) bool glfmHasTouch(const GLFMDisplay *display) { +NO_SANITIZE bool glfmHasTouch(const GLFMDisplay *display) { (void)display; // This will need to change, for say, TV apps return true; } -__attribute__((no_sanitize("hwaddress"))) void glfmSetMouseCursor(GLFMDisplay *display, GLFMMouseCursor mouseCursor) { +NO_SANITIZE void glfmSetMouseCursor(GLFMDisplay *display, GLFMMouseCursor mouseCursor) { (void)display; (void)mouseCursor; // Do nothing } -__attribute__((no_sanitize("hwaddress"))) void glfmSetMultitouchEnabled(GLFMDisplay *display, bool multitouchEnabled) { +NO_SANITIZE void glfmSetMultitouchEnabled(GLFMDisplay *display, bool multitouchEnabled) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; platformData->multitouchEnabled = multitouchEnabled; } -__attribute__((no_sanitize("hwaddress"))) bool glfmGetMultitouchEnabled(const GLFMDisplay *display) { +NO_SANITIZE bool glfmGetMultitouchEnabled(const GLFMDisplay *display) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; return platformData->multitouchEnabled; } -__attribute__((no_sanitize("hwaddress"))) GLFMProc glfmGetProcAddress(const char *functionName) { +NO_SANITIZE GLFMProc glfmGetProcAddress(const char *functionName) { GLFMProc function = eglGetProcAddress(functionName); if (!function) { static void *handle = NULL; @@ -2557,29 +2559,29 @@ __attribute__((no_sanitize("hwaddress"))) GLFMProc glfmGetProcAddress(const char return function; } -__attribute__((no_sanitize("hwaddress"))) bool glfmHasVirtualKeyboard(const GLFMDisplay *display) { +NO_SANITIZE bool glfmHasVirtualKeyboard(const GLFMDisplay *display) { (void)display; return true; } -__attribute__((no_sanitize("hwaddress"))) void glfmSetKeyboardVisible(GLFMDisplay *display, bool visible) { +NO_SANITIZE void glfmSetKeyboardVisible(GLFMDisplay *display, bool visible) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; if (glfm__setKeyboardVisible(platformData, visible)) { glfm__updateUserInterfaceChrome(platformData); } } -__attribute__((no_sanitize("hwaddress"))) bool glfmIsKeyboardVisible(const GLFMDisplay *display) { +NO_SANITIZE bool glfmIsKeyboardVisible(const GLFMDisplay *display) { GLFMPlatformData *platformData = (GLFMPlatformData *)display->platformData; return platformData->keyboardVisible; } -__attribute__((no_sanitize("hwaddress"))) bool glfmIsSensorAvailable(const GLFMDisplay *display, GLFMSensor sensor) { +NO_SANITIZE bool glfmIsSensorAvailable(const GLFMDisplay *display, GLFMSensor sensor) { (void)display; return glfm__getDeviceSensor(sensor) != NULL; } -__attribute__((no_sanitize("hwaddress"))) bool glfmIsHapticFeedbackSupported(const GLFMDisplay *display) { +NO_SANITIZE bool glfmIsHapticFeedbackSupported(const GLFMDisplay *display) { /* Vibrator vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); return vibrator ? vibrator.hasVibrator() : false; @@ -2604,7 +2606,7 @@ __attribute__((no_sanitize("hwaddress"))) bool glfmIsHapticFeedbackSupported(con return result; } -__attribute__((no_sanitize("hwaddress"))) void glfmPerformHapticFeedback(GLFMDisplay *display, GLFMHapticFeedbackStyle style) { +NO_SANITIZE void glfmPerformHapticFeedback(GLFMDisplay *display, GLFMHapticFeedbackStyle style) { // decorView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, flags); static const jint HapticFeedbackConstants_CONTEXT_CLICK = 6; // Light, API 23 static const jint HapticFeedbackConstants_VIRTUAL_KEY = 1; // Medium @@ -2658,7 +2660,7 @@ __attribute__((no_sanitize("hwaddress"))) void glfmPerformHapticFeedback(GLFMDis (*jni)->DeleteLocalRef(jni, decorView); } -__attribute__((no_sanitize("hwaddress"))) bool glfmHasClipboardText(const GLFMDisplay *display) { +NO_SANITIZE bool glfmHasClipboardText(const GLFMDisplay *display) { if (!display || !display->platformData) { return false; } @@ -2697,7 +2699,7 @@ __attribute__((no_sanitize("hwaddress"))) bool glfmHasClipboardText(const GLFMDi return hasText; } -__attribute__((no_sanitize("hwaddress"))) void glfmRequestClipboardText(GLFMDisplay *display, GLFMClipboardTextFunc clipboardTextFunc) { +NO_SANITIZE void glfmRequestClipboardText(GLFMDisplay *display, GLFMClipboardTextFunc clipboardTextFunc) { if (!clipboardTextFunc) { return; } @@ -2765,7 +2767,7 @@ __attribute__((no_sanitize("hwaddress"))) void glfmRequestClipboardText(GLFMDisp (*jni)->DeleteLocalRef(jni, javaString); } -__attribute__((no_sanitize("hwaddress"))) bool glfmSetClipboardText(GLFMDisplay *display, const char *string) { +NO_SANITIZE bool glfmSetClipboardText(GLFMDisplay *display, const char *string) { if (!string || !display || !display->platformData) { return false; } @@ -2818,19 +2820,19 @@ __attribute__((no_sanitize("hwaddress"))) bool glfmSetClipboardText(GLFMDisplay // MARK: - Platform-specific functions -__attribute__((no_sanitize("hwaddress"))) bool glfmIsMetalSupported(const GLFMDisplay *display) { +NO_SANITIZE bool glfmIsMetalSupported(const GLFMDisplay *display) { (void)display; return false; } -__attribute__((no_sanitize("hwaddress"))) ANativeActivity *glfmAndroidGetActivity(void) { +NO_SANITIZE ANativeActivity *glfmAndroidGetActivity(void) { if (!platformDataGlobal) { return NULL; } return platformDataGlobal->activity; } -__attribute__((no_sanitize("hwaddress"))) void *glfmGetAndroidActivity(const GLFMDisplay *display) { +NO_SANITIZE void *glfmGetAndroidActivity(const GLFMDisplay *display) { if (!display || !display->platformData) { return NULL; }