# HG changeset patch # User Sam Lantinga # Date 1077523394 0 # Node ID c203b4a427010d6980cabfe54f331bc58ae8ba75 # Parent bab227101de43cb4c5101a671f6662a0a06879ab Added an endian detection and byte swapping test program diff -r bab227101de4 -r c203b4a42701 test/Makefile.am --- a/test/Makefile.am Mon Feb 23 06:09:21 2004 +0000 +++ b/test/Makefile.am Mon Feb 23 08:03:14 2004 +0000 @@ -1,7 +1,8 @@ AUTOMAKE_OPTIONS = no-dependencies noinst_PROGRAMS = \ - testver testtypes testcpuinfo testhread testlock testerror testsem testtimer \ + testver testtypes testendian testcpuinfo \ + testhread testlock testerror testsem testtimer \ loopwave testcdrom testkeys testvidinfo checkkeys testwin graywin \ testsprite testbitmap testalpha testgamma testpalette testwm \ threadwin testoverlay testoverlay2 testgl testdyngl testjoystick diff -r bab227101de4 -r c203b4a42701 test/testendian.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/testendian.c Mon Feb 23 08:03:14 2004 +0000 @@ -0,0 +1,25 @@ + +/* Test program to check SDL's CPU endian detection and byte swapping routines */ + +#include + +#include "SDL.h" +#include "SDL_endian.h" + +int main(int argc, char *argv[]) +{ + Uint16 value16 = 0xCDAB; + Uint32 value32 = 0xEFBEADDE; +#if defined(__GNUC__) && defined(SDL_HAS_64BIT_TYPE) + Uint64 value64 = 0xEFBEADDECDAB3412LL; +#endif + + printf("This is a %s endian machine.\n", + (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); + printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16)); + printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32)); +#if defined(__GNUC__) && defined(SDL_HAS_64BIT_TYPE) + printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, SDL_Swap64(value64)); +#endif + return(0); +} diff -r bab227101de4 -r c203b4a42701 test/testver.c --- a/test/testver.c Mon Feb 23 06:09:21 2004 +0000 +++ b/test/testver.c Mon Feb 23 08:03:14 2004 +0000 @@ -6,7 +6,6 @@ #include #include "SDL.h" -#include "SDL_byteorder.h" int main(int argc, char *argv[]) { @@ -32,8 +31,6 @@ SDL_Linked_Version()->major, SDL_Linked_Version()->minor, SDL_Linked_Version()->patch); - printf("This is a %s endian machine.\n", - (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); SDL_Quit(); return(0); }