Mercurial > sdl-ios-xcode
annotate test/testplatform.c @ 4932:0d1bb1ce9d15
Removed carriage returns
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 29 Dec 2010 15:23:54 -0800 |
parents | 8e5186a99af4 |
children | 87f452305db4 |
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" |
3663
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
7 #include "SDL_assert.h" |
1421
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 /* |
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 * 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
|
11 * 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
|
12 * compiler quiet. --ryan. |
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
14 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
15 badsize(size_t sizeoftype, size_t hardcodetype) |
1421
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 return sizeoftype != hardcodetype; |
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 } |
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
20 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
21 TestTypes(SDL_bool verbose) |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
23 int error = 0; |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
25 if (badsize(sizeof(Uint8), 1)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
26 if (verbose) |
3687
8e5186a99af4
Fixed compile warning on 64-bit Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
3684
diff
changeset
|
27 printf("sizeof(Uint8) != 1, instead = %u\n", |
8e5186a99af4
Fixed compile warning on 64-bit Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
3684
diff
changeset
|
28 (unsigned int)sizeof(Uint8)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
29 ++error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
30 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
31 if (badsize(sizeof(Uint16), 2)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
32 if (verbose) |
3687
8e5186a99af4
Fixed compile warning on 64-bit Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
3684
diff
changeset
|
33 printf("sizeof(Uint16) != 2, instead = %u\n", |
8e5186a99af4
Fixed compile warning on 64-bit Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
3684
diff
changeset
|
34 (unsigned int)sizeof(Uint16)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
35 ++error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
36 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
37 if (badsize(sizeof(Uint32), 4)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
38 if (verbose) |
3687
8e5186a99af4
Fixed compile warning on 64-bit Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
3684
diff
changeset
|
39 printf("sizeof(Uint32) != 4, instead = %u\n", |
8e5186a99af4
Fixed compile warning on 64-bit Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
3684
diff
changeset
|
40 (unsigned int)sizeof(Uint32)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
41 ++error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
42 } |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 #ifdef SDL_HAS_64BIT_TYPE |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
44 if (badsize(sizeof(Uint64), 8)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
45 if (verbose) |
3687
8e5186a99af4
Fixed compile warning on 64-bit Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
3684
diff
changeset
|
46 printf("sizeof(Uint64) != 8, instead = %u\n", |
8e5186a99af4
Fixed compile warning on 64-bit Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
3684
diff
changeset
|
47 (unsigned int)sizeof(Uint64)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
48 ++error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
49 } |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
51 if (verbose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
52 printf("WARNING: No 64-bit datatype on this platform\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
53 } |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
55 if (verbose && !error) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
56 printf("All data types are the expected size.\n"); |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
58 return (error ? 1 : 0); |
1421
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 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
61 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
62 TestEndian(SDL_bool verbose) |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
64 int error = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
65 Uint16 value = 0x1234; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
66 int real_byteorder; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
67 Uint16 value16 = 0xCDAB; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
68 Uint16 swapped16 = 0xABCD; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
69 Uint32 value32 = 0xEFBEADDE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
70 Uint32 swapped32 = 0xDEADBEEF; |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 #ifdef SDL_HAS_64BIT_TYPE |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
72 Uint64 value64, swapped64; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
73 value64 = 0xEFBEADDE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
74 value64 <<= 32; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
75 value64 |= 0xCDAB3412; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
76 swapped64 = 0x1234ABCD; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
77 swapped64 <<= 32; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
78 swapped64 |= 0xDEADBEEF; |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 #endif |
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
81 if (verbose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
82 printf("Detected a %s endian machine.\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
83 (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
84 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
85 if ((*((char *) &value) >> 4) == 0x1) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
86 real_byteorder = SDL_BIG_ENDIAN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
87 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
88 real_byteorder = SDL_LIL_ENDIAN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
89 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
90 if (real_byteorder != SDL_BYTEORDER) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
91 if (verbose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
92 printf("Actually a %s endian machine!\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
93 (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
94 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
95 ++error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
96 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
97 if (verbose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
98 printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
99 SDL_Swap16(value16)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
100 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
101 if (SDL_Swap16(value16) != swapped16) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
102 if (verbose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
103 printf("16 bit value swapped incorrectly!\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
104 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
105 ++error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
106 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
107 if (verbose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
108 printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
109 SDL_Swap32(value32)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
110 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
111 if (SDL_Swap32(value32) != swapped32) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
112 if (verbose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
113 printf("32 bit value swapped incorrectly!\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
114 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
115 ++error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
116 } |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 #ifdef SDL_HAS_64BIT_TYPE |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
118 if (verbose) { |
1615
d5298e8f22b3
Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
1424
diff
changeset
|
119 #ifdef _MSC_VER |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
120 printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
121 SDL_Swap64(value64)); |
1615
d5298e8f22b3
Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
1424
diff
changeset
|
122 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
123 printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
124 SDL_Swap64(value64)); |
1615
d5298e8f22b3
Ugh, more 64-bit cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
1424
diff
changeset
|
125 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
126 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
127 if (SDL_Swap64(value64) != swapped64) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
128 if (verbose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
129 printf("64 bit value swapped incorrectly!\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
130 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
131 ++error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
132 } |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
134 return (error ? 1 : 0); |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 } |
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 |
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
138 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
139 TestCPUInfo(SDL_bool verbose) |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
141 if (verbose) { |
3579
3427271a2d75
Added SDL_GetCPUCount() to see how many cores are available.
Sam Lantinga <slouken@libsdl.org>
parents:
3319
diff
changeset
|
142 printf("CPU count: %d\n", SDL_GetCPUCount()); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
143 printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
144 printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
145 printf("MMX Ext %s\n", SDL_HasMMXExt()? "detected" : "not detected"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
146 printf("3DNow %s\n", SDL_Has3DNow()? "detected" : "not detected"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
147 printf("3DNow Ext %s\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
148 SDL_Has3DNowExt()? "detected" : "not detected"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
149 printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
150 printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
151 printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
152 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
153 return (0); |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 } |
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
156 int |
3663
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
157 TestAssertions(SDL_bool verbose) |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
158 { |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
159 SDL_assert(1); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
160 SDL_assert_release(1); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
161 SDL_assert_paranoid(1); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
162 SDL_assert(0 || 1); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
163 SDL_assert_release(0 || 1); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
164 SDL_assert_paranoid(0 || 1); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
165 |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
166 #if 0 /* enable this to test assertion failures. */ |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
167 SDL_assert_release(1 == 2); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
168 SDL_assert_release(5 < 4); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
169 SDL_assert_release(0 && "This is a test"); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
170 #endif |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
171 SDL_assert_release(0 && "This is a test"); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
172 |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
173 return (0); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
174 } |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
175 |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
176 int |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
177 main(int argc, char *argv[]) |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
179 SDL_bool verbose = SDL_TRUE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
180 int status = 0; |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
182 if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
183 verbose = SDL_FALSE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
184 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
185 if (verbose) { |
3319 | 186 printf("This system is running %s\n", SDL_GetPlatform()); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
187 } |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
189 status += TestTypes(verbose); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
190 status += TestEndian(verbose); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
191 status += TestCPUInfo(verbose); |
3663
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
192 status += TestAssertions(verbose); |
bc50cd16bb07
Moved the assertion tests to testplatform
Sam Lantinga <slouken@libsdl.org>
parents:
3579
diff
changeset
|
193 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1621
diff
changeset
|
194 return status; |
1421
638da75f9ab8
testplatform replaces testtypes, testendian, and testcpuinfo
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 } |