Add basic support for compiling on RISC OS
authorCameron Cawley <ccawley2011@gmail.com>
Thu, 13 Feb 2020 20:50:47 +0000
changeset 135262b708d63875d
parent 13525 df0f883cc273
child 13527 604325956b9a
Add basic support for compiling on RISC OS
CMakeLists.txt
configure
configure.ac
src/atomic/SDL_spinlock.c
src/dynapi/SDL_dynapi.h
src/thread/pthread/SDL_systhread.c
test/configure
test/configure.ac
     1.1 --- a/CMakeLists.txt	Thu Feb 13 22:58:04 2020 +0000
     1.2 +++ b/CMakeLists.txt	Thu Feb 13 20:50:47 2020 +0000
     1.3 @@ -129,7 +129,7 @@
     1.4  endif()
     1.5  
     1.6  # Don't mistake osx for unix
     1.7 -if(UNIX AND NOT APPLE)
     1.8 +if(UNIX AND NOT APPLE AND NOT RISCOS)
     1.9    set(UNIX_SYS ON)
    1.10  else()
    1.11    set(UNIX_SYS OFF)
    1.12 @@ -341,7 +341,7 @@
    1.13  set_option(PTHREADS            "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
    1.14  dep_option(PTHREADS_SEM        "Use pthread semaphores" ON "PTHREADS" OFF)
    1.15  set_option(SDL_DLOPEN          "Use dlopen for shared object loading" ${SDL_DLOPEN_ENABLED_BY_DEFAULT})
    1.16 -set_option(OSS                 "Support the OSS audio API" ${UNIX_SYS})
    1.17 +dep_option(OSS                 "Support the OSS audio API" ON "UNIX_SYS OR RISCOS" OFF)
    1.18  set_option(ALSA                "Support the ALSA audio API" ${UNIX_SYS})
    1.19  dep_option(ALSA_SHARED         "Dynamically load ALSA audio support" ON "ALSA" OFF)
    1.20  set_option(JACK                "Support the JACK audio API" ${UNIX_SYS})
    1.21 @@ -1091,7 +1091,7 @@
    1.22      endif()
    1.23    endif()
    1.24  
    1.25 -elseif(UNIX AND NOT APPLE AND NOT ANDROID)
    1.26 +elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS)
    1.27    if(SDL_AUDIO)
    1.28      if(SYSV5 OR SOLARIS OR HPUX)
    1.29          set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
    1.30 @@ -1814,6 +1814,24 @@
    1.31    endif()
    1.32  
    1.33    CheckPTHREAD()
    1.34 +
    1.35 +elseif(RISCOS)
    1.36 +  if(SDL_TIMERS)
    1.37 +    set(SDL_TIMER_UNIX 1)
    1.38 +    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
    1.39 +    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
    1.40 +    set(HAVE_SDL_TIMERS TRUE)
    1.41 +
    1.42 +    if(CLOCK_GETTIME)
    1.43 +      set(HAVE_CLOCK_GETTIME 1)
    1.44 +    endif()
    1.45 +  endif()
    1.46 +
    1.47 +  CheckPTHREAD()
    1.48 +
    1.49 +  if(SDL_AUDIO)
    1.50 +    CheckOSS()
    1.51 +  endif()
    1.52  endif()
    1.53  
    1.54  if(VIDEO_VULKAN)
     2.1 --- a/configure	Thu Feb 13 22:58:04 2020 +0000
     2.2 +++ b/configure	Thu Feb 13 20:50:47 2020 +0000
     2.3 @@ -25371,6 +25371,27 @@
     2.4              have_timers=yes
     2.5          fi
     2.6          ;;
     2.7 +    *-*-riscos*)
     2.8 +        ARCH=riscos
     2.9 +        CheckVisibilityHidden
    2.10 +        CheckDeclarationAfterStatement
    2.11 +        CheckDummyVideo
    2.12 +        CheckDiskAudio
    2.13 +        CheckDummyAudio
    2.14 +        CheckDLOPEN
    2.15 +        CheckOSS
    2.16 +        CheckPTHREAD
    2.17 +        CheckClockGettime
    2.18 +
    2.19 +        # Set up files for the timer library
    2.20 +        if test x$enable_timers = xyes; then
    2.21 +
    2.22 +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
    2.23 +
    2.24 +            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
    2.25 +            have_timers=yes
    2.26 +        fi
    2.27 +        ;;
    2.28      *)
    2.29          as_fn_error $? "
    2.30  *** Unsupported host:  Please add to configure.ac
     3.1 --- a/configure.ac	Thu Feb 13 22:58:04 2020 +0000
     3.2 +++ b/configure.ac	Thu Feb 13 20:50:47 2020 +0000
     3.3 @@ -4063,6 +4063,25 @@
     3.4              have_timers=yes
     3.5          fi
     3.6          ;;
     3.7 +    *-*-riscos*)
     3.8 +        ARCH=riscos
     3.9 +        CheckVisibilityHidden
    3.10 +        CheckDeclarationAfterStatement
    3.11 +        CheckDummyVideo
    3.12 +        CheckDiskAudio
    3.13 +        CheckDummyAudio
    3.14 +        CheckDLOPEN
    3.15 +        CheckOSS
    3.16 +        CheckPTHREAD
    3.17 +        CheckClockGettime
    3.18 +
    3.19 +        # Set up files for the timer library
    3.20 +        if test x$enable_timers = xyes; then
    3.21 +            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
    3.22 +            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
    3.23 +            have_timers=yes
    3.24 +        fi
    3.25 +        ;;
    3.26      *)
    3.27          AC_MSG_ERROR([
    3.28  *** Unsupported host:  Please add to configure.ac
     4.1 --- a/src/atomic/SDL_spinlock.c	Thu Feb 13 22:58:04 2020 +0000
     4.2 +++ b/src/atomic/SDL_spinlock.c	Thu Feb 13 20:50:47 2020 +0000
     4.3 @@ -32,6 +32,10 @@
     4.4  #include <atomic.h>
     4.5  #endif
     4.6  
     4.7 +#if !defined(HAVE_GCC_ATOMICS) && defined(__RISCOS__)
     4.8 +#include <unixlib/local.h>
     4.9 +#endif
    4.10 +
    4.11  #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
    4.12  #include <xmmintrin.h>
    4.13  #endif
    4.14 @@ -84,6 +88,16 @@
    4.15           defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__) || \
    4.16           defined(__ARM_ARCH_5TEJ__))
    4.17      int result;
    4.18 +
    4.19 +#if defined(__RISCOS__)
    4.20 +    if (__cpucap_have_rex()) {
    4.21 +        __asm__ __volatile__ (
    4.22 +            "ldrex %0, [%2]\nteq   %0, #0\nstrexeq %0, %1, [%2]"
    4.23 +            : "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
    4.24 +        return (result == 0);
    4.25 +    }
    4.26 +#endif
    4.27 +
    4.28      __asm__ __volatile__ (
    4.29          "swp %0, %1, [%2]\n"
    4.30          : "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory");
     5.1 --- a/src/dynapi/SDL_dynapi.h	Thu Feb 13 22:58:04 2020 +0000
     5.2 +++ b/src/dynapi/SDL_dynapi.h	Thu Feb 13 20:50:47 2020 +0000
     5.3 @@ -53,6 +53,8 @@
     5.4  #define SDL_DYNAMIC_API 0
     5.5  #elif defined(__PSP__) && __PSP__
     5.6  #define SDL_DYNAMIC_API 0
     5.7 +#elif defined(__riscos__) && __riscos__ /* probably not useful on RISC OS, since dlopen() can't be used when using static linking. */
     5.8 +#define SDL_DYNAMIC_API 0
     5.9  #elif defined(__clang_analyzer__)
    5.10  #define SDL_DYNAMIC_API 0  /* Turn off for static analysis, so reports are more clear. */
    5.11  #endif
     6.1 --- a/src/thread/pthread/SDL_systhread.c	Thu Feb 13 22:58:04 2020 +0000
     6.2 +++ b/src/thread/pthread/SDL_systhread.c	Thu Feb 13 20:50:47 2020 +0000
     6.3 @@ -188,7 +188,7 @@
     6.4  int
     6.5  SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
     6.6  {
     6.7 -#if __NACL__ 
     6.8 +#if __NACL__ || __RISCOS__
     6.9      /* FIXME: Setting thread priority does not seem to be supported in NACL */
    6.10      return 0;
    6.11  #elif __LINUX__
     7.1 --- a/test/configure	Thu Feb 13 22:58:04 2020 +0000
     7.2 +++ b/test/configure	Thu Feb 13 20:50:47 2020 +0000
     7.3 @@ -2988,6 +2988,11 @@
     7.4          MATHLIB=""
     7.5          SYS_GL_LIBS=""
     7.6          ;;
     7.7 +    *-*-riscos* )
     7.8 +        EXE=",e1f"
     7.9 +        MATHLIB=""
    7.10 +        SYS_GL_LIBS=""
    7.11 +        ;;
    7.12      *)
    7.13                  ISUNIX="true"
    7.14          EXE=""
     8.1 --- a/test/configure.ac	Thu Feb 13 22:58:04 2020 +0000
     8.2 +++ b/test/configure.ac	Thu Feb 13 20:50:47 2020 +0000
     8.3 @@ -71,6 +71,11 @@
     8.4          MATHLIB=""
     8.5          SYS_GL_LIBS=""
     8.6          ;;
     8.7 +    *-*-riscos* )
     8.8 +        EXE=",e1f"
     8.9 +        MATHLIB=""
    8.10 +        SYS_GL_LIBS=""
    8.11 +        ;;
    8.12      *)
    8.13          dnl Oh well, call it Unix...
    8.14          ISUNIX="true"