annotate test/testplatform.c @ 4106:12bb6311fd5d SDL-1.2

Hans de Goede fixed bug #495 When running boswars: http://www.boswars.org/ on a machine with intel integrathed graphics it crashes when it tries to play the initial theora splashscreen video: X Error of failed request: BadAlloc (insufficient resources for operation) Major opcode of failed request: 140 (XVideo) Minor opcode of failed request: 19 () Serial number of failed request: 25 Current serial number in output stream: 26 boswars: xcb_xlib.c:41: xcb_xlib_lock: Assertion `!c->xlib.lock' failed. Aborted I recognized this problem from a few years back, when I encountered it while working on the Xv blitter for xmame. The problem is that for some reason creation the Xvport and XvImage succeeds, and failure (lack of resources / hw capability?) is only indicated during the first XvPut[Shm]Image. I've written a patch for SDL using the work around for this I developed for xmame (and which is still used successfully in xmame after many years of usage). I'll admit it isn't very pretty, but after investigating several possibilities this was the best option, any other fixes would need changes to the SDL api and abi.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 29 Dec 2007 02:23:48 +0000
parents 6d2e1961661a
children 7a4c511c980a
rev   line source
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 #include <stdio.h>
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 #include "SDL.h"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 #include "SDL_endian.h"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 #include "SDL_cpuinfo.h"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 /*
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 * Watcom C flags these as Warning 201: "Unreachable code" if you just
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 * compare them directly, so we push it through a function to keep the
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 * compiler quiet. --ryan.
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 */
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 static int badsize(size_t sizeoftype, size_t hardcodetype)
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 return sizeoftype != hardcodetype;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 int TestTypes(SDL_bool verbose)
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 int error = 0;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 if ( badsize(sizeof(Uint8), 1) ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 if ( verbose )
1615
d5298e8f22b3 Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1424
diff changeset
24 printf("sizeof(Uint8) != 1, instead = %ul\n",
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 sizeof(Uint8));
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 ++error;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 if ( badsize(sizeof(Uint16), 2) ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 if ( verbose )
1615
d5298e8f22b3 Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1424
diff changeset
30 printf("sizeof(Uint16) != 2, instead = %ul\n",
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 sizeof(Uint16));
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 ++error;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 if ( badsize(sizeof(Uint32), 4) ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 if ( verbose )
1615
d5298e8f22b3 Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1424
diff changeset
36 printf("sizeof(Uint32) != 4, instead = %ul\n",
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 sizeof(Uint32));
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 ++error;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #ifdef SDL_HAS_64BIT_TYPE
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 if ( badsize(sizeof(Uint64), 8) ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 if ( verbose )
1615
d5298e8f22b3 Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1424
diff changeset
43 printf("sizeof(Uint64) != 8, instead = %ul\n",
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 sizeof(Uint64));
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 ++error;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 #else
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 printf("WARNING: No 64-bit datatype on this platform\n");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 #endif
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 if ( verbose && !error )
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 printf("All data types are the expected size.\n");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 return( error ? 1 : 0 );
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 int TestEndian(SDL_bool verbose)
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 int error = 0;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 Uint16 value = 0x1234;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 int real_byteorder;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 Uint16 value16 = 0xCDAB;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 Uint16 swapped16 = 0xABCD;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 Uint32 value32 = 0xEFBEADDE;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 Uint32 swapped32 = 0xDEADBEEF;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 #ifdef SDL_HAS_64BIT_TYPE
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 Uint64 value64, swapped64;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 value64 = 0xEFBEADDE;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 value64 <<= 32;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 value64 |= 0xCDAB3412;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 swapped64 = 0x1234ABCD;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 swapped64 <<= 32;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 swapped64 |= 0xDEADBEEF;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 #endif
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 printf("Detected a %s endian machine.\n",
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 }
1424
7a610f25c12f Updated MacOS Classic MPW build
Sam Lantinga <slouken@libsdl.org>
parents: 1421
diff changeset
81 if ( (*((char *)&value) >> 4) == 0x1 ) {
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 real_byteorder = SDL_BIG_ENDIAN;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 } else {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 real_byteorder = SDL_LIL_ENDIAN;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 if ( real_byteorder != SDL_BYTEORDER ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 printf("Actually a %s endian machine!\n",
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 ++error;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16));
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 if ( SDL_Swap16(value16) != swapped16 ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 printf("16 bit value swapped incorrectly!\n");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 ++error;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32));
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 if ( SDL_Swap32(value32) != swapped32 ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 printf("32 bit value swapped incorrectly!\n");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 ++error;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 #ifdef SDL_HAS_64BIT_TYPE
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 if ( verbose ) {
1615
d5298e8f22b3 Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1424
diff changeset
113 #ifdef _MSC_VER
d5298e8f22b3 Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1424
diff changeset
114 printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, SDL_Swap64(value64));
d5298e8f22b3 Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1424
diff changeset
115 #else
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, SDL_Swap64(value64));
1615
d5298e8f22b3 Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1424
diff changeset
117 #endif
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 if ( SDL_Swap64(value64) != swapped64 ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 printf("64 bit value swapped incorrectly!\n");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 ++error;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 #endif
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 return( error ? 1 : 0 );
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 int TestCPUInfo(SDL_bool verbose)
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 printf("RDTSC %s\n", SDL_HasRDTSC() ? "detected" : "not detected");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 printf("MMX %s\n", SDL_HasMMX() ? "detected" : "not detected");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 printf("MMX Ext %s\n", SDL_HasMMXExt() ? "detected" : "not detected");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 printf("3DNow %s\n", SDL_Has3DNow() ? "detected" : "not detected");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 printf("3DNow Ext %s\n", SDL_Has3DNowExt() ? "detected" : "not detected");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 printf("SSE %s\n", SDL_HasSSE() ? "detected" : "not detected");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 printf("SSE2 %s\n", SDL_HasSSE2() ? "detected" : "not detected");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 printf("AltiVec %s\n", SDL_HasAltiVec() ? "detected" : "not detected");
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 return(0);
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 int main(int argc, char *argv[])
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 SDL_bool verbose = SDL_TRUE;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 int status = 0;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 if ( argv[1] && (SDL_strcmp(argv[1], "-q") == 0) ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 verbose = SDL_FALSE;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 if ( verbose ) {
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 printf("This system is running %s\n",
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 #if __AIX__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 "AIX"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 #elif __BEOS__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 "BeOS"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 #elif __BSDI__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 "BSDI"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 #elif __DREAMCAST__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 "Dreamcast"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 #elif __FREEBSD__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 "FreeBSD"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 #elif __HPUX__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 "HP-UX"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 #elif __IRIX__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 "Irix"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 #elif __LINUX__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 "Linux"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 #elif __MINT__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 "Atari MiNT"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 #elif __MACOS__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 "MacOS Classic"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 #elif __MACOSX__
1621
f12379c41042 Fixes bug #195:
Sam Lantinga <slouken@libsdl.org>
parents: 1615
diff changeset
176 "Mac OS X"
1421
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 #elif __NETBSD__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 "NetBSD"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 #elif __OPENBSD__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 "OpenBSD"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 #elif __OS2__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 "OS/2"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 #elif __OSF__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 "OSF/1"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 #elif __QNXNTO__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 "QNX Neutrino"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 #elif __RISCOS__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 "RISC OS"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 #elif __SOLARIS__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 "Solaris"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 #elif __WIN32__
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 #ifdef _WIN32_WCE
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 "Windows CE"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 #else
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 "Windows"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 #endif
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 #else
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 "an unknown operating system! (see SDL_platform.h)"
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 #endif
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 );
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 }
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 status += TestTypes(verbose);
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 status += TestEndian(verbose);
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 status += TestCPUInfo(verbose);
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 return status;
638da75f9ab8 testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 }