1 ?RCS: $Id: byteorder.U 1 2006-08-24 12:32:52Z rmanfredi $
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
11 ?RCS: $Log: byteorder.U,v $
12 ?RCS: Revision 3.0.1.2 1997/02/28 15:24:55 ram
13 ?RCS: patch61: no longer ask the user if the test runs ok
15 ?RCS: Revision 3.0.1.1 1994/10/29 16:02:58 ram
16 ?RCS: patch36: added ?F: line for metalint file checking
18 ?RCS: Revision 3.0 1993/08/18 12:05:28 ram
19 ?RCS: Baseline for dist 3.0 netwide release.
21 ?MAKE:byteorder: cat Myread Oldconfig Loc +cc +ccflags rm
22 ?MAKE: -pick add $@ %<
24 ?S: This variable holds the byte order. In the following, larger digits
25 ?S: indicate more significance. The variable byteorder is either 4321
26 ?S: on a big-endian machine, or 1234 on a little-endian, or 87654321
27 ?S: on a Cray ... or 3412 with weird order !
30 ?C: This symbol hold the hexadecimal constant defined in byteorder,
31 ?C: i.e. 0x1234 or 0x4321, etc...
33 ?H:#define BYTEORDER 0x$byteorder /* large digits for MSB */
37 : check for ordering of bytes in a long
42 In the following, larger digits indicate more significance. A big-endian
43 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
44 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
45 machines may have weird orders like 3412. A Cray will report 87654321. If
46 the test program works the default is probably right.
47 I'm now running the test program...
60 u.l = (0x08070605L << 32) | 0x04030201L;
63 for (i = 0; i < sizeof(long); i++)
64 printf("%c", u.c[i]+'0');
70 if $cc $ccflags -o try try.c >/dev/null 2>&1 && ./try > /dev/null; then
73 [1-4][1-4][1-4][1-4]|12345678|87654321)
74 echo "(The test program ran ok.)"
75 echo "byteorder=$dflt"
78 ????|????????) echo "(The test program ran ok.)" ;;
79 *) echo "(The test program didn't run right for some reason.)" ;;
84 (I can't seem to compile the test program. Guessing big-endian...)
89 rp="What is the order of bytes in a long?"