Skip to content

Latest commit

 

History

History
73 lines (67 loc) · 1.39 KB

testendian.c

File metadata and controls

73 lines (67 loc) · 1.39 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* Test program to check SDL's CPU endian detection and byte swapping routines */
#include <stdio.h>
#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
Feb 21, 2006
Feb 21, 2006
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
printf("This system is running %s\n",
#if __AIX__
"AIX"
#elif __AMIGA__
"AmigaOS"
#elif __BEOS__
"BeOS"
#elif __BSDI__
"BSDI"
#elif __DREAMCAST__
"Dreamcast"
#elif __FREEBSD__
"FreeBSD"
#elif __HPUX__
"HP-UX"
#elif __IRIX__
"Irix"
#elif __LINUX__
"Linux"
#elif __MACOS__
"MacOS Classic"
#elif __MACOSX__
"MacOS 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
#else
"an unknown operating system!"
#endif
);
65
66
67
68
69
70
71
72
73
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);
}