Annotation of embedaddon/ntp/util/byteorder.c, revision 1.1.1.1
1.1 misho 1: /*
2: * This works on:
3: * Crays
4: * Conven
5: * sparc's
6: * Dec mip machines
7: * Dec alpha machines
8: * RS6000
9: * SGI's
10: */
11:
12: #include <stdio.h>
13:
14: int
15: main(
16: int argc,
17: char *argv[]
18: )
19: {
20: int i;
21: int big;
22: union {
23: unsigned long l;
24: char c[sizeof(long)];
25: } u;
26:
27: #if defined(LONG8)
28: u.l = (((long)0x08070605) << 32) | (long)0x04030201;
29: #else
30: u.l = 0x04030201;
31: #endif
32: if (sizeof(long) > 4) {
33: if (u.c[0] == 0x08) big = 1;
34: else big = 0;
35: } else {
36: if (u.c[0] == 0x04) big = 1;
37: else big = 0;
38: }
39: for (i=0; i< sizeof(long); i++) {
40: if (big == 1 && (u.c[i] == (sizeof(long) - i))) {
41: continue;
42: } else if (big == 0 && (u.c[i] == (i+1))) {
43: continue;
44: } else {
45: big = -1;
46: break;
47: }
48: }
49:
50: if (big == 1) {
51: printf("XNTP_BIG_ENDIAN\n");
52: } else if (big == 0) {
53: printf("XNTP_LITTLE_ENDIAN\n");
54: }
55: exit(0);
56: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>