Added an endian detection and byte swapping test program
authorSam Lantinga <slouken@libsdl.org>
Mon, 23 Feb 2004 08:03:14 +0000
changeset 850c203b4a42701
parent 849 bab227101de4
child 851 2687d28166d2
Added an endian detection and byte swapping test program
test/Makefile.am
test/testendian.c
test/testver.c
     1.1 --- a/test/Makefile.am	Mon Feb 23 06:09:21 2004 +0000
     1.2 +++ b/test/Makefile.am	Mon Feb 23 08:03:14 2004 +0000
     1.3 @@ -1,7 +1,8 @@
     1.4  AUTOMAKE_OPTIONS = no-dependencies
     1.5  
     1.6  noinst_PROGRAMS = \
     1.7 -	testver testtypes testcpuinfo testhread testlock testerror testsem testtimer \
     1.8 +	testver testtypes testendian testcpuinfo \
     1.9 +	testhread testlock testerror testsem testtimer \
    1.10  	loopwave testcdrom testkeys testvidinfo checkkeys testwin graywin \
    1.11  	testsprite testbitmap testalpha testgamma testpalette testwm \
    1.12  	threadwin testoverlay testoverlay2 testgl testdyngl testjoystick
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/testendian.c	Mon Feb 23 08:03:14 2004 +0000
     2.3 @@ -0,0 +1,25 @@
     2.4 +
     2.5 +/* Test program to check SDL's CPU endian detection and byte swapping routines */
     2.6 +
     2.7 +#include <stdio.h>
     2.8 +
     2.9 +#include "SDL.h"
    2.10 +#include "SDL_endian.h"
    2.11 +
    2.12 +int main(int argc, char *argv[])
    2.13 +{
    2.14 +	Uint16 value16 = 0xCDAB;
    2.15 +	Uint32 value32 = 0xEFBEADDE;
    2.16 +#if defined(__GNUC__) && defined(SDL_HAS_64BIT_TYPE)
    2.17 +	Uint64 value64 = 0xEFBEADDECDAB3412LL;
    2.18 +#endif
    2.19 +
    2.20 +	printf("This is a %s endian machine.\n",
    2.21 +		(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
    2.22 +	printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16));
    2.23 +	printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32));
    2.24 +#if defined(__GNUC__) && defined(SDL_HAS_64BIT_TYPE)
    2.25 +	printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, SDL_Swap64(value64));
    2.26 +#endif
    2.27 +	return(0);
    2.28 +}
     3.1 --- a/test/testver.c	Mon Feb 23 06:09:21 2004 +0000
     3.2 +++ b/test/testver.c	Mon Feb 23 08:03:14 2004 +0000
     3.3 @@ -6,7 +6,6 @@
     3.4  #include <stdio.h>
     3.5  
     3.6  #include "SDL.h"
     3.7 -#include "SDL_byteorder.h"
     3.8  
     3.9  int main(int argc, char *argv[])
    3.10  {
    3.11 @@ -32,8 +31,6 @@
    3.12  			SDL_Linked_Version()->major,
    3.13  			SDL_Linked_Version()->minor,
    3.14  			SDL_Linked_Version()->patch);
    3.15 -	printf("This is a %s endian machine.\n",
    3.16 -		(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
    3.17  	SDL_Quit();
    3.18  	return(0);
    3.19  }