# HG changeset patch # User Sam Lantinga # Date 1253961134 0 # Node ID 63d4517fc4ac8eb4cb0fbe6841b996b22620e72e # Parent f085091f74cda00d1d4b79508f40b5eaadf15597 Fixed bug #777 Implemented SDL_GetPlatform() diff -r f085091f74cd -r 63d4517fc4ac include/SDL_platform.h --- a/include/SDL_platform.h Sat Sep 26 10:22:35 2009 +0000 +++ b/include/SDL_platform.h Sat Sep 26 10:32:14 2009 +0000 @@ -123,4 +123,29 @@ #define __NINTENDODS__ 1 #endif + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/** + * \fn const char *SDL_GetPlatform(void) + * \brief Gets the name of the platform. + */ +extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + #endif /* _SDL_platform_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -r f085091f74cd -r 63d4517fc4ac src/SDL.c --- a/src/SDL.c Sat Sep 26 10:22:35 2009 +0000 +++ b/src/SDL.c Sat Sep 26 10:32:14 2009 +0000 @@ -277,6 +277,62 @@ return SDL_REVISION; } +/* Get the name of the platform */ +const char * +SDL_GetPlatform() +{ +#if __AIX__ + return "AIX"; +#elif __HAIKU__ +/* Haiku must appear here before BeOS, since it also defines __BEOS__ */ + return "Haiku"; +#elif __BEOS__ + return "BeOS"; +#elif __BSDI__ + return "BSDI"; +#elif __DREAMCAST__ + return "Dreamcast"; +#elif __FREEBSD__ + return "FreeBSD"; +#elif __HPUX__ + return "HP-UX"; +#elif __IRIX__ + return "Irix"; +#elif __LINUX__ + return "Linux"; +#elif __MINT__ + return "Atari MiNT"; +#elif __MACOS__ + return "MacOS Classic"; +#elif __MACOSX__ + return "Mac OS X"; +#elif __NETBSD__ + return "NetBSD"; +#elif __OPENBSD__ + return "OpenBSD"; +#elif __OS2__ + return "OS/2"; +#elif __OSF__ + return "OSF/1"; +#elif __QNXNTO__ + return "QNX Neutrino"; +#elif __RISCOS__ + return "RISC OS"; +#elif __SOLARIS__ + return "Solaris"; +#elif __WIN32__ +#ifdef _WIN32_WCE + return "Windows CE"; +#else + return "Windows"; +#endif +#elif __IPHONEOS__ + return "iPhone OS"; +#else + return "Unknown (see SDL_platform.h)"; +#endif +} + #if defined(__WIN32__) #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL)) diff -r f085091f74cd -r 63d4517fc4ac test/automated/platform/platform.c --- a/test/automated/platform/platform.c Sat Sep 26 10:22:35 2009 +0000 +++ b/test/automated/platform/platform.c Sat Sep 26 10:32:14 2009 +0000 @@ -132,66 +132,6 @@ /** - * @brief Gets the name of the platform. - */ -const char *platform_getPlatform (void) -{ - return -#if __AIX__ - "AIX" -#elif __HAIKU__ -/* Haiku must appear here before BeOS, since it also defines __BEOS__ */ - "Haiku" -#elif __BEOS__ - "BeOS" -#elif __BSDI__ - "BSDI" -#elif __DREAMCAST__ - "Dreamcast" -#elif __FREEBSD__ - "FreeBSD" -#elif __HPUX__ - "HP-UX" -#elif __IRIX__ - "Irix" -#elif __LINUX__ - "Linux" -#elif __MINT__ - "Atari MiNT" -#elif __MACOS__ - "MacOS Classic" -#elif __MACOSX__ - "Mac OS X" -#elif __NETBSD__ - "NetBSD" -#elif __OPENBSD__ - "OpenBSD" -#elif __OS2__ - "OS/2" -#elif __OSF__ - "OSF/1" -#elif __QNXNTO__ - "QNX Neutrino" -#elif __RISCOS__ - "RISC OS" -#elif __SOLARIS__ - "Solaris" -#elif __WIN32__ -#ifdef _WIN32_WCE - "Windows CE" -#else - "Windows" -#endif -#elif __IPHONEOS__ - "iPhone OS" -#else - "an unknown operating system! (see SDL_platform.h)" -#endif - ; -} - - -/** * @brief Platform test entrypoint. */ #ifdef TEST_STANDALONE @@ -207,7 +147,7 @@ SDL_ATinit( "Platform" ); /* Debug information. */ - SDL_ATprintVerbose( 1, "%s System detected\n", platform_getPlatform() ); + SDL_ATprintVerbose( 1, "%s System detected\n", SDL_GetPlatform() ); SDL_ATprintVerbose( 1, "System is %s endian\n", #ifdef SDL_LIL_ENDIAN "little" diff -r f085091f74cd -r 63d4517fc4ac test/automated/testsdl.c --- a/test/automated/testsdl.c Sat Sep 26 10:22:35 2009 +0000 +++ b/test/automated/testsdl.c Sat Sep 26 10:32:14 2009 +0000 @@ -172,7 +172,7 @@ SDL_ATprintErr( "Tests run with SDL %d.%d.%d revision %d\n", ver.major, ver.minor, ver.patch, rev ); SDL_ATprintErr( "System is running %s and is %s endian\n", - platform_getPlatform(), + SDL_GetPlatform(), #ifdef SDL_LIL_ENDIAN "little" #else diff -r f085091f74cd -r 63d4517fc4ac test/testplatform.c --- a/test/testplatform.c Sat Sep 26 10:22:35 2009 +0000 +++ b/test/testplatform.c Sat Sep 26 10:32:14 2009 +0000 @@ -157,58 +157,7 @@ verbose = SDL_FALSE; } if (verbose) { - printf("This system is running %s\n", -#if __AIX__ - "AIX" -#elif __HAIKU__ -/* Haiku must appear here before BeOS, since it also defines __BEOS__ */ - "Haiku" -#elif __BEOS__ - "BeOS" -#elif __BSDI__ - "BSDI" -#elif __DREAMCAST__ - "Dreamcast" -#elif __FREEBSD__ - "FreeBSD" -#elif __HPUX__ - "HP-UX" -#elif __IRIX__ - "Irix" -#elif __LINUX__ - "Linux" -#elif __MINT__ - "Atari MiNT" -#elif __MACOS__ - "MacOS Classic" -#elif __MACOSX__ - "Mac OS X" -#elif __NETBSD__ - "NetBSD" -#elif __OPENBSD__ - "OpenBSD" -#elif __OS2__ - "OS/2" -#elif __OSF__ - "OSF/1" -#elif __QNXNTO__ - "QNX Neutrino" -#elif __RISCOS__ - "RISC OS" -#elif __SOLARIS__ - "Solaris" -#elif __WIN32__ -#ifdef _WIN32_WCE - "Windows CE" -#else - "Windows" -#endif -#elif __IPHONEOS__ - "iPhone OS" -#else - "an unknown operating system! (see SDL_platform.h)" -#endif - ); + printf("This system is running %s\n", SDL_GetPlatform()); } status += TestTypes(verbose);