[e86079]: tools-for-build / determine-endianness.c Maximize Restore History

Download this file

determine-endianness.c    51 lines (45 with data), 1.6 kB

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