comparison test/testplatform.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
9 * Watcom C flags these as Warning 201: "Unreachable code" if you just 9 * Watcom C flags these as Warning 201: "Unreachable code" if you just
10 * compare them directly, so we push it through a function to keep the 10 * compare them directly, so we push it through a function to keep the
11 * compiler quiet. --ryan. 11 * compiler quiet. --ryan.
12 */ 12 */
13 static int 13 static int
14 badsize (size_t sizeoftype, size_t hardcodetype) 14 badsize(size_t sizeoftype, size_t hardcodetype)
15 { 15 {
16 return sizeoftype != hardcodetype; 16 return sizeoftype != hardcodetype;
17 } 17 }
18 18
19 int 19 int
20 TestTypes (SDL_bool verbose) 20 TestTypes(SDL_bool verbose)
21 { 21 {
22 int error = 0; 22 int error = 0;
23 23
24 if (badsize (sizeof (Uint8), 1)) { 24 if (badsize(sizeof(Uint8), 1)) {
25 if (verbose) 25 if (verbose)
26 printf ("sizeof(Uint8) != 1, instead = %ul\n", sizeof (Uint8)); 26 printf("sizeof(Uint8) != 1, instead = %ul\n", sizeof(Uint8));
27 ++error; 27 ++error;
28 } 28 }
29 if (badsize (sizeof (Uint16), 2)) { 29 if (badsize(sizeof(Uint16), 2)) {
30 if (verbose) 30 if (verbose)
31 printf ("sizeof(Uint16) != 2, instead = %ul\n", sizeof (Uint16)); 31 printf("sizeof(Uint16) != 2, instead = %ul\n", sizeof(Uint16));
32 ++error; 32 ++error;
33 } 33 }
34 if (badsize (sizeof (Uint32), 4)) { 34 if (badsize(sizeof(Uint32), 4)) {
35 if (verbose) 35 if (verbose)
36 printf ("sizeof(Uint32) != 4, instead = %ul\n", sizeof (Uint32)); 36 printf("sizeof(Uint32) != 4, instead = %ul\n", sizeof(Uint32));
37 ++error; 37 ++error;
38 } 38 }
39 #ifdef SDL_HAS_64BIT_TYPE 39 #ifdef SDL_HAS_64BIT_TYPE
40 if (badsize (sizeof (Uint64), 8)) { 40 if (badsize(sizeof(Uint64), 8)) {
41 if (verbose) 41 if (verbose)
42 printf ("sizeof(Uint64) != 8, instead = %ul\n", sizeof (Uint64)); 42 printf("sizeof(Uint64) != 8, instead = %ul\n", sizeof(Uint64));
43 ++error; 43 ++error;
44 } 44 }
45 #else 45 #else
46 if (verbose) { 46 if (verbose) {
47 printf ("WARNING: No 64-bit datatype on this platform\n"); 47 printf("WARNING: No 64-bit datatype on this platform\n");
48 } 48 }
49 #endif 49 #endif
50 if (verbose && !error) 50 if (verbose && !error)
51 printf ("All data types are the expected size.\n"); 51 printf("All data types are the expected size.\n");
52 52
53 return (error ? 1 : 0); 53 return (error ? 1 : 0);
54 } 54 }
55 55
56 int 56 int
57 TestEndian (SDL_bool verbose) 57 TestEndian(SDL_bool verbose)
58 { 58 {
59 int error = 0; 59 int error = 0;
60 Uint16 value = 0x1234; 60 Uint16 value = 0x1234;
61 int real_byteorder; 61 int real_byteorder;
62 Uint16 value16 = 0xCDAB; 62 Uint16 value16 = 0xCDAB;
72 swapped64 <<= 32; 72 swapped64 <<= 32;
73 swapped64 |= 0xDEADBEEF; 73 swapped64 |= 0xDEADBEEF;
74 #endif 74 #endif
75 75
76 if (verbose) { 76 if (verbose) {
77 printf ("Detected a %s endian machine.\n", 77 printf("Detected a %s endian machine.\n",
78 (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); 78 (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
79 } 79 }
80 if ((*((char *) &value) >> 4) == 0x1) { 80 if ((*((char *) &value) >> 4) == 0x1) {
81 real_byteorder = SDL_BIG_ENDIAN; 81 real_byteorder = SDL_BIG_ENDIAN;
82 } else { 82 } else {
83 real_byteorder = SDL_LIL_ENDIAN; 83 real_byteorder = SDL_LIL_ENDIAN;
84 } 84 }
85 if (real_byteorder != SDL_BYTEORDER) { 85 if (real_byteorder != SDL_BYTEORDER) {
86 if (verbose) { 86 if (verbose) {
87 printf ("Actually a %s endian machine!\n", 87 printf("Actually a %s endian machine!\n",
88 (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); 88 (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
89 } 89 }
90 ++error; 90 ++error;
91 } 91 }
92 if (verbose) { 92 if (verbose) {
93 printf ("Value 16 = 0x%X, swapped = 0x%X\n", value16, 93 printf("Value 16 = 0x%X, swapped = 0x%X\n", value16,
94 SDL_Swap16 (value16)); 94 SDL_Swap16(value16));
95 } 95 }
96 if (SDL_Swap16 (value16) != swapped16) { 96 if (SDL_Swap16(value16) != swapped16) {
97 if (verbose) { 97 if (verbose) {
98 printf ("16 bit value swapped incorrectly!\n"); 98 printf("16 bit value swapped incorrectly!\n");
99 } 99 }
100 ++error; 100 ++error;
101 } 101 }
102 if (verbose) { 102 if (verbose) {
103 printf ("Value 32 = 0x%X, swapped = 0x%X\n", value32, 103 printf("Value 32 = 0x%X, swapped = 0x%X\n", value32,
104 SDL_Swap32 (value32)); 104 SDL_Swap32(value32));
105 } 105 }
106 if (SDL_Swap32 (value32) != swapped32) { 106 if (SDL_Swap32(value32) != swapped32) {
107 if (verbose) { 107 if (verbose) {
108 printf ("32 bit value swapped incorrectly!\n"); 108 printf("32 bit value swapped incorrectly!\n");
109 } 109 }
110 ++error; 110 ++error;
111 } 111 }
112 #ifdef SDL_HAS_64BIT_TYPE 112 #ifdef SDL_HAS_64BIT_TYPE
113 if (verbose) { 113 if (verbose) {
114 #ifdef _MSC_VER 114 #ifdef _MSC_VER
115 printf ("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, 115 printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
116 SDL_Swap64 (value64)); 116 SDL_Swap64(value64));
117 #else 117 #else
118 printf ("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, 118 printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64,
119 SDL_Swap64 (value64)); 119 SDL_Swap64(value64));
120 #endif 120 #endif
121 } 121 }
122 if (SDL_Swap64 (value64) != swapped64) { 122 if (SDL_Swap64(value64) != swapped64) {
123 if (verbose) { 123 if (verbose) {
124 printf ("64 bit value swapped incorrectly!\n"); 124 printf("64 bit value swapped incorrectly!\n");
125 } 125 }
126 ++error; 126 ++error;
127 } 127 }
128 #endif 128 #endif
129 return (error ? 1 : 0); 129 return (error ? 1 : 0);
130 } 130 }
131 131
132 132
133 int 133 int
134 TestCPUInfo (SDL_bool verbose) 134 TestCPUInfo(SDL_bool verbose)
135 { 135 {
136 if (verbose) { 136 if (verbose) {
137 printf ("RDTSC %s\n", SDL_HasRDTSC ()? "detected" : "not detected"); 137 printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
138 printf ("MMX %s\n", SDL_HasMMX ()? "detected" : "not detected"); 138 printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
139 printf ("MMX Ext %s\n", 139 printf("MMX Ext %s\n", SDL_HasMMXExt()? "detected" : "not detected");
140 SDL_HasMMXExt ()? "detected" : "not detected"); 140 printf("3DNow %s\n", SDL_Has3DNow()? "detected" : "not detected");
141 printf ("3DNow %s\n", SDL_Has3DNow ()? "detected" : "not detected"); 141 printf("3DNow Ext %s\n",
142 printf ("3DNow Ext %s\n", 142 SDL_Has3DNowExt()? "detected" : "not detected");
143 SDL_Has3DNowExt ()? "detected" : "not detected"); 143 printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
144 printf ("SSE %s\n", SDL_HasSSE ()? "detected" : "not detected"); 144 printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
145 printf ("SSE2 %s\n", SDL_HasSSE2 ()? "detected" : "not detected"); 145 printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
146 printf ("AltiVec %s\n",
147 SDL_HasAltiVec ()? "detected" : "not detected");
148 } 146 }
149 return (0); 147 return (0);
150 } 148 }
151 149
152 int 150 int
153 main (int argc, char *argv[]) 151 main(int argc, char *argv[])
154 { 152 {
155 SDL_bool verbose = SDL_TRUE; 153 SDL_bool verbose = SDL_TRUE;
156 int status = 0; 154 int status = 0;
157 155
158 if (argv[1] && (SDL_strcmp (argv[1], "-q") == 0)) { 156 if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) {
159 verbose = SDL_FALSE; 157 verbose = SDL_FALSE;
160 } 158 }
161 if (verbose) { 159 if (verbose) {
162 printf ("This system is running %s\n", 160 printf("This system is running %s\n",
163 #if __AIX__ 161 #if __AIX__
164 "AIX" 162 "AIX"
165 #elif __AMIGA__ 163 #elif __AMIGA__
166 "AmigaOS" 164 "AmigaOS"
167 #elif __BEOS__ 165 #elif __BEOS__
168 "BeOS" 166 "BeOS"
169 #elif __BSDI__ 167 #elif __BSDI__
170 "BSDI" 168 "BSDI"
171 #elif __DREAMCAST__ 169 #elif __DREAMCAST__
172 "Dreamcast" 170 "Dreamcast"
173 #elif __FREEBSD__ 171 #elif __FREEBSD__
174 "FreeBSD" 172 "FreeBSD"
175 #elif __HPUX__ 173 #elif __HPUX__
176 "HP-UX" 174 "HP-UX"
177 #elif __IRIX__ 175 #elif __IRIX__
178 "Irix" 176 "Irix"
179 #elif __LINUX__ 177 #elif __LINUX__
180 "Linux" 178 "Linux"
181 #elif __MINT__ 179 #elif __MINT__
182 "Atari MiNT" 180 "Atari MiNT"
183 #elif __MACOS__ 181 #elif __MACOS__
184 "MacOS Classic" 182 "MacOS Classic"
185 #elif __MACOSX__ 183 #elif __MACOSX__
186 "Mac OS X" 184 "Mac OS X"
187 #elif __NETBSD__ 185 #elif __NETBSD__
188 "NetBSD" 186 "NetBSD"
189 #elif __OPENBSD__ 187 #elif __OPENBSD__
190 "OpenBSD" 188 "OpenBSD"
191 #elif __OS2__ 189 #elif __OS2__
192 "OS/2" 190 "OS/2"
193 #elif __OSF__ 191 #elif __OSF__
194 "OSF/1" 192 "OSF/1"
195 #elif __QNXNTO__ 193 #elif __QNXNTO__
196 "QNX Neutrino" 194 "QNX Neutrino"
197 #elif __RISCOS__ 195 #elif __RISCOS__
198 "RISC OS" 196 "RISC OS"
199 #elif __SOLARIS__ 197 #elif __SOLARIS__
200 "Solaris" 198 "Solaris"
201 #elif __WIN32__ 199 #elif __WIN32__
202 #ifdef _WIN32_WCE 200 #ifdef _WIN32_WCE
203 "Windows CE" 201 "Windows CE"
204 #else 202 #else
205 "Windows" 203 "Windows"
206 #endif 204 #endif
207 #else 205 #else
208 "an unknown operating system! (see SDL_platform.h)" 206 "an unknown operating system! (see SDL_platform.h)"
209 #endif 207 #endif
210 ); 208 );
211 } 209 }
212 210
213 status += TestTypes (verbose); 211 status += TestTypes(verbose);
214 status += TestEndian (verbose); 212 status += TestEndian(verbose);
215 status += TestCPUInfo (verbose); 213 status += TestCPUInfo(verbose);
216 return status; 214 return status;
217 } 215 }