Add Genode platform support
M configure.ac +25 -5
@@ 2843,11 2843,7 @@ AS_HELP_STRING([--enable-pthread-sem], [
             pthread_cflags="-D_REENTRANT"
             pthread_lib="-L/usr/lib -lpthread"
             ;;
-        *-*-haiku*)
-            pthread_cflags="-D_REENTRANT"
-            pthread_lib=""
-            ;;
-        *-*-nto*)
+        *-*-genode*|*-*-haiku*|*-*-nto*)
             pthread_cflags="-D_REENTRANT"
             pthread_lib=""
             ;;

          
@@ 4085,6 4081,30 @@ AS_HELP_STRING([--enable-render-d3d], [e
             have_timers=yes
         fi
         ;;
+    *-*-genode*)
+        ARCH=genode
+        CheckDLOPEN
+        CheckDummyAudio
+        CheckDummyVideo
+
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AC_DEFINE(SDL_AUDIO_DRIVER_GENODE, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/audio/genode/*.cc"
+            SUMMARY_audio="${SUMMARY_audio} genode"
+            have_audio=yes
+        fi
+
+        # Set up files for the video library
+        if test x$enable_video = xyes; then
+            AC_DEFINE(SDL_VIDEO_DRIVER_GENODE, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/video/genode/*.cc"
+            SUMMARY_audio="${SUMMARY_video} genode"
+            have_video=yes
+        fi
+
+        SOURCES="$srcdir/src/core/genode/*.cc $srcdir/src/main/genode/*.cc $SOURCES "
+        ;;
     *)
         AC_MSG_ERROR([
 *** Unsupported host:  Please add to configure.ac

          
A => include/SDL_config_genode.h +52 -0
@@ 0,0 1,52 @@ 
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SDL_config_genode_h_
+#define SDL_config_genode_h_
+#define SDL_config_h_
+
+#include "SDL_platform.h"
+
+#define HAVE_STDARG_H   1
+#define HAVE_STDDEF_H   1
+
+/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
+#define SDL_JOYSTICK_DISABLED   1
+
+/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
+#define SDL_HAPTIC_DISABLED 1
+
+/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */
+#define SDL_SENSOR_DISABLED 1
+
+/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
+#define SDL_LOADSO_DISABLED 1
+
+/* Enable the stub thread support (src/thread/generic/\*.c) */
+#define SDL_THREADS_DISABLED    1
+
+/* Enable the stub timer support (src/timer/dummy/\*.c) */
+#define SDL_TIMERS_DISABLED 1
+
+/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
+#define SDL_FILESYSTEM_DUMMY  1
+
+#endif /* SDL_config_genode_h_ */

          
A => src/audio/genode/SDL_Genode_audio.cc +0 -0

A => src/core/genode/SDL_genode.cc +67 -0
@@ 0,0 1,67 @@ 
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifdef __GENODE__
+
+#include "SDL_genode.h"
+
+/* Genode includes */
+#include <gui_session/connection.h>
+#include <base/log.h>
+#include <input_session/connection.h>
+#include <input/event.h>
+#include <input/keycodes.h>
+
+static Genode::Env *_global_env = nullptr;
+
+static Genode::Constructible<Gui::Connection> _global_gui { };
+
+void SDL_Genode_Init(Genode::Env &env)
+{
+	_global_env = &env;
+}
+
+Genode::Env &SDL_Genode_Env(void)
+{
+	if (!_global_env) {
+		Genode::error("sdl_init_genode() not called, aborting");
+		throw Genode::Exception();
+	}
+
+	return *_global_env;
+}
+
+Gui::Connection &SDL_Genode_Gui()
+{
+	if (!_global_gui.constructed())
+		_global_gui.construct(global_env());
+
+	return *_global_gui;
+}
+
+extern "C"
+int SDL_Genode_SystemRAM()
+{
+	return SDL_Genode_Env().pd().ram_quota().value;
+}
+
+
+#endif /* __GENODE__ */

          
A => src/core/genode/SDL_genode.h +36 -0
@@ 0,0 1,36 @@ 
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "../../SDL_internal.h"
+#include "SDL_system.h"
+
+/* Genode includes */
+#include <base/env.h>
+
+/* Genode platform initialization */
+void SDL_Genode_Init(Genode::Env &env);
+
+Genode::Env &SDL_Genode_Env(void);
+
+Gui::Connection &SDL_Genode_Gui();
+
+extern "C"
+int SDL_Genode_SystemRAM();

          
M src/cpuinfo/SDL_cpuinfo.c +9 -0
@@ 95,6 95,10 @@ 
 #include <swis.h>
 #endif
 
+#ifdef __GENODE__
+extern int SDL_Genode_SystemRAM();
+#endif
+
 #define CPU_HAS_RDTSC   (1 << 0)
 #define CPU_HAS_ALTIVEC (1 << 1)
 #define CPU_HAS_MMX     (1 << 2)

          
@@ 923,6 927,11 @@ SDL_GetSystemRAM(void)
             }
         }
 #endif
+#ifdef __GENODE__
+        if (SDL_SystemRAM <= 0) {
+            SDL_SystemRAM = SDL_Genode_SystemRAM();
+        }
+#endif
 #endif
     }
     return SDL_SystemRAM;

          
A => src/main/genode/SDL_Genode.cc +0 -0

A => src/video/genode/SDL_Genode_video.cc +0 -0