Fix make-array transforms.
[sbcl.git] / tools-for-build / determine-endianness.c
1 /*
2  * Test for the endianness of the target platform (needed for MIPS
3  * support, at the very least, as systems with either endianness exist
4  * in the wild).
5  */
6
7 /*
8  * This software is part of the SBCL system. See the README file for
9  * more information.
10  *
11  * While most of SBCL is derived from the CMU CL system, many
12  * utilities for the build process (like this one) were written from
13  * scratch after the fork from CMU CL.
14  *
15  * This software is in the public domain and is provided with
16  * absolutely no warranty. See the COPYING and CREDITS files for
17  * more information.
18  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22
23 int main (int argc, char *argv[]) {
24     int foo = 0x20212223;
25     char *bar = (char *) &foo;
26     switch(*bar) {
27     case ' ':
28         printf(" :big-endian");
29         break;
30     case '#':
31         printf(" :little-endian");
32         break;
33     default:
34         /* FIXME: How do we do sane error processing in Unix?  This
35            program will be called from a script, in a manner somewhat
36            like:
37
38                tools-for-build/determine-endianness >> $ltf
39
40            but what if we have a too-smart C compiler that actually
41            gets us down to this branch?  I suppose that if we have a C
42            compiler that is that smart, we're doomed to miscompile the
43            runtime anyway, so we won't get here.  Still, it might be
44            good to have "set -e" in the various scripts so that we can
45            exit with an error here and have it be caught by the build
46            tools.  -- CSR, 2002-11-24
47         */
48         exit(1);
49     }
50     exit(0);
51 }