Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / util / byteorder.c
blobd46408a09ea498902c8be097d25eb96ed8e37c59
1 /* $NetBSD$ */
3 /*
4 * This works on:
5 * Crays
6 * Conven
7 * sparc's
8 * Dec mip machines
9 * Dec alpha machines
10 * RS6000
11 * SGI's
14 #include <stdio.h>
16 int
17 main(
18 int argc,
19 char *argv[]
22 int i;
23 int big;
24 union {
25 unsigned long l;
26 char c[sizeof(long)];
27 } u;
29 #if defined(LONG8)
30 u.l = (((long)0x08070605) << 32) | (long)0x04030201;
31 #else
32 u.l = 0x04030201;
33 #endif
34 if (sizeof(long) > 4) {
35 if (u.c[0] == 0x08) big = 1;
36 else big = 0;
37 } else {
38 if (u.c[0] == 0x04) big = 1;
39 else big = 0;
41 for (i=0; i< sizeof(long); i++) {
42 if (big == 1 && (u.c[i] == (sizeof(long) - i))) {
43 continue;
44 } else if (big == 0 && (u.c[i] == (i+1))) {
45 continue;
46 } else {
47 big = -1;
48 break;
52 if (big == 1) {
53 printf("XNTP_BIG_ENDIAN\n");
54 } else if (big == 0) {
55 printf("XNTP_LITTLE_ENDIAN\n");
57 exit(0);