Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug #777
Browse files Browse the repository at this point in the history
Implemented SDL_GetPlatform()
  • Loading branch information
slouken committed Sep 26, 2009
1 parent ccb47ce commit 6f179a4
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 114 deletions.
25 changes: 25 additions & 0 deletions include/SDL_platform.h
Expand Up @@ -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: */
56 changes: 56 additions & 0 deletions src/SDL.c
Expand Up @@ -277,6 +277,62 @@ SDL_GetRevision(void)
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))
Expand Down
62 changes: 1 addition & 61 deletions test/automated/platform/platform.c
Expand Up @@ -131,66 +131,6 @@ static void plat_testEndian (void)
}


/**
* @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.
*/
Expand All @@ -207,7 +147,7 @@ int test_platform (void)
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"
Expand Down
2 changes: 1 addition & 1 deletion test/automated/testsdl.c
Expand Up @@ -172,7 +172,7 @@ int main( int argc, char *argv[] )
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
Expand Down
53 changes: 1 addition & 52 deletions test/testplatform.c
Expand Up @@ -157,58 +157,7 @@ main(int argc, char *argv[])
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);
Expand Down

0 comments on commit 6f179a4

Please sign in to comment.