author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 200 | 03b8104d1479 |
child 1692 | 0b52df38cabc |
permissions | -rw-r--r-- |
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
1 |
#include <stdio.h> |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
2 |
|
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
3 |
// This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
4 |
// it does that by putting a 1 and a 0 in an array, and read it out as one |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
157
diff
changeset
|
5 |
// number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN |
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
6 |
// |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
7 |
// After that it outputs the contents of an include files (endian.h) |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
8 |
// that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
9 |
// care of the real writing to the file. |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
10 |
|
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
11 |
int main () { |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
12 |
unsigned char EndianTest[2] = { 1, 0 }; |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
13 |
printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n"); |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
14 |
if( *(short *) EndianTest == 1 ) |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
15 |
printf("#define TTD_LITTLE_ENDIAN\n"); |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
16 |
else |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
17 |
printf("#define TTD_BIG_ENDIAN\n"); |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
18 |
|
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
19 |
printf("#endif\n"); |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
20 |
|
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
21 |
return 0; |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
diff
changeset
|
22 |
} |