Fixed bug #777
authorSam Lantinga <slouken@libsdl.org>
Sat, 26 Sep 2009 10:32:14 +0000
changeset 331963d4517fc4ac
parent 3318 f085091f74cd
child 3320 b225c8a7896e
Fixed bug #777

Implemented SDL_GetPlatform()
include/SDL_platform.h
src/SDL.c
test/automated/platform/platform.c
test/automated/testsdl.c
test/testplatform.c
     1.1 --- a/include/SDL_platform.h	Sat Sep 26 10:22:35 2009 +0000
     1.2 +++ b/include/SDL_platform.h	Sat Sep 26 10:32:14 2009 +0000
     1.3 @@ -123,4 +123,29 @@
     1.4  #define __NINTENDODS__	1
     1.5  #endif
     1.6  
     1.7 +
     1.8 +#include "begin_code.h"
     1.9 +/* Set up for C function definitions, even when using C++ */
    1.10 +#ifdef __cplusplus
    1.11 +/* *INDENT-OFF* */
    1.12 +extern "C" {
    1.13 +/* *INDENT-ON* */
    1.14 +#endif
    1.15 +
    1.16 +/**
    1.17 + * \fn const char *SDL_GetPlatform(void)
    1.18 + * \brief Gets the name of the platform.
    1.19 + */
    1.20 +extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);
    1.21 +
    1.22 +/* Ends C function definitions when using C++ */
    1.23 +#ifdef __cplusplus
    1.24 +/* *INDENT-OFF* */
    1.25 +}
    1.26 +/* *INDENT-ON* */
    1.27 +#endif
    1.28 +#include "close_code.h"
    1.29 +
    1.30  #endif /* _SDL_platform_h */
    1.31 +
    1.32 +/* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/SDL.c	Sat Sep 26 10:22:35 2009 +0000
     2.2 +++ b/src/SDL.c	Sat Sep 26 10:32:14 2009 +0000
     2.3 @@ -277,6 +277,62 @@
     2.4      return SDL_REVISION;
     2.5  }
     2.6  
     2.7 +/* Get the name of the platform */
     2.8 +const char *
     2.9 +SDL_GetPlatform()
    2.10 +{
    2.11 +#if __AIX__
    2.12 +    return "AIX";
    2.13 +#elif __HAIKU__
    2.14 +/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
    2.15 +    return "Haiku";
    2.16 +#elif __BEOS__
    2.17 +    return "BeOS";
    2.18 +#elif __BSDI__
    2.19 +    return "BSDI";
    2.20 +#elif __DREAMCAST__
    2.21 +    return "Dreamcast";
    2.22 +#elif __FREEBSD__
    2.23 +    return "FreeBSD";
    2.24 +#elif __HPUX__
    2.25 +    return "HP-UX";
    2.26 +#elif __IRIX__
    2.27 +    return "Irix";
    2.28 +#elif __LINUX__
    2.29 +    return "Linux";
    2.30 +#elif __MINT__
    2.31 +    return "Atari MiNT";
    2.32 +#elif __MACOS__
    2.33 +    return "MacOS Classic";
    2.34 +#elif __MACOSX__
    2.35 +    return "Mac OS X";
    2.36 +#elif __NETBSD__
    2.37 +    return "NetBSD";
    2.38 +#elif __OPENBSD__
    2.39 +    return "OpenBSD";
    2.40 +#elif __OS2__
    2.41 +    return "OS/2";
    2.42 +#elif __OSF__
    2.43 +    return "OSF/1";
    2.44 +#elif __QNXNTO__
    2.45 +    return "QNX Neutrino";
    2.46 +#elif __RISCOS__
    2.47 +    return "RISC OS";
    2.48 +#elif __SOLARIS__
    2.49 +    return "Solaris";
    2.50 +#elif __WIN32__
    2.51 +#ifdef _WIN32_WCE
    2.52 +    return "Windows CE";
    2.53 +#else
    2.54 +    return "Windows";
    2.55 +#endif
    2.56 +#elif __IPHONEOS__
    2.57 +    return "iPhone OS";
    2.58 +#else
    2.59 +    return "Unknown (see SDL_platform.h)";
    2.60 +#endif
    2.61 +}
    2.62 +
    2.63  #if defined(__WIN32__)
    2.64  
    2.65  #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
     3.1 --- a/test/automated/platform/platform.c	Sat Sep 26 10:22:35 2009 +0000
     3.2 +++ b/test/automated/platform/platform.c	Sat Sep 26 10:32:14 2009 +0000
     3.3 @@ -132,66 +132,6 @@
     3.4  
     3.5  
     3.6  /**
     3.7 - * @brief Gets the name of the platform.
     3.8 - */
     3.9 -const char *platform_getPlatform (void)
    3.10 -{
    3.11 -   return
    3.12 -#if __AIX__   
    3.13 -      "AIX"
    3.14 -#elif __HAIKU__
    3.15 -/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
    3.16 -      "Haiku"
    3.17 -#elif __BEOS__
    3.18 -      "BeOS"
    3.19 -#elif __BSDI__
    3.20 -      "BSDI"
    3.21 -#elif __DREAMCAST__
    3.22 -      "Dreamcast"
    3.23 -#elif __FREEBSD__
    3.24 -      "FreeBSD"
    3.25 -#elif __HPUX__ 
    3.26 -      "HP-UX"
    3.27 -#elif __IRIX__ 
    3.28 -      "Irix"
    3.29 -#elif __LINUX__
    3.30 -      "Linux"
    3.31 -#elif __MINT__
    3.32 -      "Atari MiNT"
    3.33 -#elif __MACOS__
    3.34 -      "MacOS Classic"
    3.35 -#elif __MACOSX__
    3.36 -      "Mac OS X"
    3.37 -#elif __NETBSD__
    3.38 -      "NetBSD"
    3.39 -#elif __OPENBSD__
    3.40 -      "OpenBSD"
    3.41 -#elif __OS2__ 
    3.42 -      "OS/2"
    3.43 -#elif __OSF__ 
    3.44 -      "OSF/1"
    3.45 -#elif __QNXNTO__
    3.46 -      "QNX Neutrino"
    3.47 -#elif __RISCOS__
    3.48 -      "RISC OS"
    3.49 -#elif __SOLARIS__
    3.50 -      "Solaris"
    3.51 -#elif __WIN32__
    3.52 -#ifdef _WIN32_WCE
    3.53 -      "Windows CE"
    3.54 -#else         
    3.55 -      "Windows"
    3.56 -#endif
    3.57 -#elif __IPHONEOS__
    3.58 -      "iPhone OS"
    3.59 -#else         
    3.60 -      "an unknown operating system! (see SDL_platform.h)"
    3.61 -#endif     
    3.62 -      ;
    3.63 -}
    3.64 -
    3.65 -
    3.66 -/**
    3.67   * @brief Platform test entrypoint.
    3.68   */
    3.69  #ifdef TEST_STANDALONE
    3.70 @@ -207,7 +147,7 @@
    3.71     SDL_ATinit( "Platform" );
    3.72  
    3.73     /* Debug information. */
    3.74 -   SDL_ATprintVerbose( 1, "%s System detected\n", platform_getPlatform() );
    3.75 +   SDL_ATprintVerbose( 1, "%s System detected\n", SDL_GetPlatform() );
    3.76     SDL_ATprintVerbose( 1, "System is %s endian\n",
    3.77  #ifdef SDL_LIL_ENDIAN
    3.78           "little"
     4.1 --- a/test/automated/testsdl.c	Sat Sep 26 10:22:35 2009 +0000
     4.2 +++ b/test/automated/testsdl.c	Sat Sep 26 10:32:14 2009 +0000
     4.3 @@ -172,7 +172,7 @@
     4.4        SDL_ATprintErr( "Tests run with SDL %d.%d.%d revision %d\n",
     4.5              ver.major, ver.minor, ver.patch, rev );
     4.6        SDL_ATprintErr( "System is running %s and is %s endian\n",
     4.7 -            platform_getPlatform(),
     4.8 +            SDL_GetPlatform(),
     4.9  #ifdef SDL_LIL_ENDIAN
    4.10              "little"
    4.11  #else
     5.1 --- a/test/testplatform.c	Sat Sep 26 10:22:35 2009 +0000
     5.2 +++ b/test/testplatform.c	Sat Sep 26 10:32:14 2009 +0000
     5.3 @@ -157,58 +157,7 @@
     5.4          verbose = SDL_FALSE;
     5.5      }
     5.6      if (verbose) {
     5.7 -        printf("This system is running %s\n",
     5.8 -#if __AIX__
     5.9 -               "AIX"
    5.10 -#elif __HAIKU__
    5.11 -/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
    5.12 -               "Haiku"
    5.13 -#elif __BEOS__
    5.14 -               "BeOS"
    5.15 -#elif __BSDI__
    5.16 -               "BSDI"
    5.17 -#elif __DREAMCAST__
    5.18 -               "Dreamcast"
    5.19 -#elif __FREEBSD__
    5.20 -               "FreeBSD"
    5.21 -#elif __HPUX__
    5.22 -               "HP-UX"
    5.23 -#elif __IRIX__
    5.24 -               "Irix"
    5.25 -#elif __LINUX__
    5.26 -               "Linux"
    5.27 -#elif __MINT__
    5.28 -               "Atari MiNT"
    5.29 -#elif __MACOS__
    5.30 -               "MacOS Classic"
    5.31 -#elif __MACOSX__
    5.32 -               "Mac OS X"
    5.33 -#elif __NETBSD__
    5.34 -               "NetBSD"
    5.35 -#elif __OPENBSD__
    5.36 -               "OpenBSD"
    5.37 -#elif __OS2__
    5.38 -               "OS/2"
    5.39 -#elif __OSF__
    5.40 -               "OSF/1"
    5.41 -#elif __QNXNTO__
    5.42 -               "QNX Neutrino"
    5.43 -#elif __RISCOS__
    5.44 -               "RISC OS"
    5.45 -#elif __SOLARIS__
    5.46 -               "Solaris"
    5.47 -#elif __WIN32__
    5.48 -#ifdef _WIN32_WCE
    5.49 -               "Windows CE"
    5.50 -#else
    5.51 -               "Windows"
    5.52 -#endif
    5.53 -#elif __IPHONEOS__
    5.54 -               "iPhone OS"
    5.55 -#else
    5.56 -               "an unknown operating system! (see SDL_platform.h)"
    5.57 -#endif
    5.58 -            );
    5.59 +        printf("This system is running %s\n", SDL_GetPlatform());
    5.60      }
    5.61  
    5.62      status += TestTypes(verbose);