SDL: Set SDL_MAIN_AVAILABLE for all platforms

From 1c46c8a3dc87b905531b2c584bbb36572f74c3a3 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 30 Nov 2025 10:23:48 -0800
Subject: [PATCH] Set SDL_MAIN_AVAILABLE for all platforms

---
 include/SDL3/SDL_main.h | 17 ++++++++++++-----
 src/main/SDL_runapp.c   | 12 +++++++++---
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/include/SDL3/SDL_main.h b/include/SDL3/SDL_main.h
index 009cd4ef1a13e..81a601df8f0f5 100644
--- a/include/SDL3/SDL_main.h
+++ b/include/SDL3/SDL_main.h
@@ -167,12 +167,10 @@
         */
         #define SDL_MAIN_NEEDED
 
-    #elif defined(SDL_PLATFORM_IOS)
-        /* On iOS SDL provides a main function that creates an application delegate
-           and starts the iOS application run loop.
+    #elif defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS)
+        /* On iOS and tvOS SDL provides a main function that creates an application delegate and starts the application run loop.
 
-           To use it, just #include SDL_main.h in the source file that contains your
-           main() function.
+           To use it, just #include <SDL3/SDL_main.h> in the source file that contains your main() function.
 
            See src/video/uikit/SDL_uikitappdelegate.m for more details.
          */
@@ -230,6 +228,15 @@
         */
         #define SDL_MAIN_AVAILABLE
 
+    #else
+        /*
+          This platform SDL provides a main function that sets up the main
+          thread and calls your main function.
+
+          If you provide this yourself, you may define SDL_MAIN_HANDLED
+        */
+        #define SDL_MAIN_AVAILABLE
+
     #endif
 #endif /* SDL_MAIN_HANDLED */
 
diff --git a/src/main/SDL_runapp.c b/src/main/SDL_runapp.c
index df0750529d6a8..09c6b003c116f 100644
--- a/src/main/SDL_runapp.c
+++ b/src/main/SDL_runapp.c
@@ -21,9 +21,15 @@
 #include "SDL_internal.h"
 #include "SDL_main_callbacks.h"
 
-/* Most platforms that use/need SDL_main have their own SDL_RunApp() implementation.
- * If not, you can special case it here by appending || defined(__YOUR_PLATFORM__) */
-#if ( !defined(SDL_MAIN_NEEDED) && !defined(SDL_MAIN_AVAILABLE) ) || defined(SDL_PLATFORM_ANDROID)
+// Add your platform here if you define a custom SDL_RunApp() implementation
+#if !defined(SDL_PLATFORM_WIN32) && \
+    !defined(SDL_PLATFORM_GDK) && \
+    !defined(SDL_PLATFORM_IOS) && \
+    !defined(SDL_PLATFORM_TVOS) && \
+    !defined(SDL_PLATFORM_EMSCRIPTEN) && \
+    !defined(SDL_PLATFORM_PSP) && \
+    !defined(SDL_PLATFORM_PS2) && \
+    !defined(SDL_PLATFORM_3DS)
 
 int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserved)
 {