tron@2186: /* $Id$ */ tron@2186: truelight@157: #include truelight@157: truelight@157: // This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN truelight@157: // it does that by putting a 1 and a 0 in an array, and read it out as one truelight@200: // number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN truelight@157: // truelight@157: // After that it outputs the contents of an include files (endian.h) truelight@157: // that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes truelight@157: // care of the real writing to the file. truelight@157: TrueLight@1692: int main (int argc, char *argv[]) { truelight@157: unsigned char EndianTest[2] = { 1, 0 }; TrueLight@1692: int force_BE = 0, force_LE = 0; TrueLight@1692: TrueLight@1692: if (argc > 1 && strcmp(argv[1], "BE") == 0) TrueLight@1692: force_BE = 1; TrueLight@1692: if (argc > 1 && strcmp(argv[1], "LE") == 0) TrueLight@1692: force_LE = 1; TrueLight@1692: truelight@157: printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n"); TrueLight@1692: TrueLight@1692: if ( (*(short *) EndianTest == 1 && force_BE != 1) || force_LE == 1) truelight@157: printf("#define TTD_LITTLE_ENDIAN\n"); truelight@157: else truelight@157: printf("#define TTD_BIG_ENDIAN\n"); truelight@157: truelight@157: printf("#endif\n"); truelight@157: truelight@157: return 0; truelight@157: }