annotate test/testendian.c @ 1416:a4c05c115bb7

Fixed script on mingw
author Sam Lantinga <slouken@libsdl.org>
date Wed, 22 Feb 2006 04:44:33 +0000
parents 983df4f9c1c6
children
rev   line source
850
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 /* Test program to check SDL's CPU endian detection and byte swapping routines */
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 #include <stdio.h>
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 #include "SDL.h"
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 #include "SDL_endian.h"
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 int main(int argc, char *argv[])
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 {
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 Uint16 value16 = 0xCDAB;
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 Uint32 value32 = 0xEFBEADDE;
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 #if defined(__GNUC__) && defined(SDL_HAS_64BIT_TYPE)
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 Uint64 value64 = 0xEFBEADDECDAB3412LL;
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 #endif
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16
1405
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
17 printf("This system is running %s\n",
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
18 #if __AIX__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
19 "AIX"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
20 #elif __AMIGA__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
21 "AmigaOS"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
22 #elif __BEOS__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
23 "BeOS"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
24 #elif __BSDI__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
25 "BSDI"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
26 #elif __DREAMCAST__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
27 "Dreamcast"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
28 #elif __FREEBSD__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
29 "FreeBSD"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
30 #elif __HPUX__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
31 "HP-UX"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
32 #elif __IRIX__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
33 "Irix"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
34 #elif __LINUX__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
35 "Linux"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
36 #elif __MACOS__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
37 "MacOS Classic"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
38 #elif __MACOSX__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
39 "MacOS X"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
40 #elif __NETBSD__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
41 "NetBSD"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
42 #elif __OPENBSD__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
43 "OpenBSD"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
44 #elif __OS2__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
45 "OS/2"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
46 #elif __OSF__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
47 "OSF/1"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
48 #elif __QNXNTO__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
49 "QNX Neutrino"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
50 #elif __RISCOS__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
51 "RISC OS"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
52 #elif __SOLARIS__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
53 "Solaris"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
54 #elif __WIN32__
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
55 #ifdef _WIN32_WCE
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
56 "Windows CE"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
57 #else
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
58 "Windows"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
59 #endif
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
60 #else
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
61 "an unknown operating system!"
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
62 #endif
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
63 );
983df4f9c1c6 Added a test case
Sam Lantinga <slouken@libsdl.org>
parents: 850
diff changeset
64
850
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 printf("This is a %s endian machine.\n",
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16));
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32));
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 #if defined(__GNUC__) && defined(SDL_HAS_64BIT_TYPE)
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, SDL_Swap64(value64));
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 #endif
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 return(0);
c203b4a42701 Added an endian detection and byte swapping test program
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 }