1 ?RCS: $Id: charorder.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: charorder.U,v $
12 ?RCS: Revision 3.0.1.1 1994/10/29 16:07:08 ram
13 ?RCS: patch36: added ?F: line for metalint file checking
15 ?RCS: Revision 3.0 1993/08/18 12:05:33 ram
16 ?RCS: Baseline for dist 3.0 netwide release.
18 ?MAKE:chorder_int chorder_short chorder_long: Myread cat +cc +ccflags rm
19 ?MAKE: -pick add $@ %<
20 ?S:chorder_short (d_cos d_bos):
21 ?S: Holds the value describing the byte ordering of characters in a short.
22 ?S: On a Big-Endian machine, that would be "c0c1".
24 ?S:chorder_int (charoder):
25 ?S: Holds the value describing the byte ordering of characters in an int.
26 ?S: For instance, on a Big-Endian machine, this would be: "c0c1c2c3".
28 ?S:chorder_long (d_col d_bol):
29 ?S: Holds the value describing the byte ordering of characters in a long.
30 ?S: On a 64 bits Big-Endian machine, that would yield: "c0c1c2c3c4c5c6c7".
33 ?C: Holds the byte ordering of characters in a short. It's a string
34 ?C: value like "c0c1" on a Big-Endian machine.
37 ?C: Holds the byte ordering of characters in an int. It's a string
38 ?C: value like "c0c1c2c3" on a Big-Endian machine.
41 ?C: Holds the byte ordering of characters in a long. It's a string
42 ?C: value like "c0c1c2c3c4c5c6c7" on a 64 bits Big-Endian machine.
44 ?H:#define CHAR_ORDER_SHORT "$chorder_short" /* byte order in a short */
45 ?H:#define CHAR_ORDER_INT "$chorder_int" /* byte order in an int */
46 ?H:#define CHAR_ORDER_LONG "$chorder_long" /* byte order in a long */
49 : check for character ordering
51 echo "Checking out byte order..." >&4
52 $cat >byteorder.c <<'EOCP'
64 char u_c[sizeof(long)];
69 /* HMS: ASSERT: sizeof(long) < 10. */
70 for(i = 0; i < sizeof(long); ++i) {
78 /* HMS: ASSERT: sizeof(short) < 10. */
79 for(i = 0; i < sizeof(short); ++i) {
87 /* RAM: ASSERT: sizeof(int) < 10. */
88 for(i = 0; i < sizeof(int); ++i) {
98 for(i = 0; i < max; i++) {
99 printf("%x", u.u_c[i] & 0x00FF);
105 if $cc $ccflags -o byteorder byteorder.c >/dev/null 2>&1 ; then
108 chorder_short=`./byteorder s`
111 chorder_int=`./byteorder i`
114 chorder_long=`./byteorder l`
118 (I can't seem to get my test program to work. Guessing 32 bits big-endian.)
121 chorder_int="c0c1c2c3"
122 chorder_long="c0c1c2c3"
126 rp='What is the order of characters in a short?'
132 rp='What is the order of characters in an int?'
138 rp='What is the order of characters in a long?'
142 $rm -f byteorder* core