4.104.114.84.95
Last change
on this file since 3f098aed was
3f098aed,
checked in by Joel Sherrill <joel.sherrill@…>, on 08/20/98 at 14:37:17
|
FreeBSD stack compiles for the first time (except libc/strsep.c).
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | #ifndef _MACHINE_ENDIAN_H_ |
---|
2 | #define _MACHINE_ENDIAN_H_ |
---|
3 | |
---|
4 | #include <rtems/score/cpu.h> |
---|
5 | |
---|
6 | /* |
---|
7 | * BSD-style endian declaration |
---|
8 | */ |
---|
9 | #define BIG_ENDIAN 4321 |
---|
10 | #define LITTLE_ENDIAN 1234 |
---|
11 | |
---|
12 | #if CPU_BIG_ENDIAN |
---|
13 | # define BYTE_ORDER BIG_ENDIAN |
---|
14 | #elif CPU_LITTLE_ENDIAN |
---|
15 | # define BYTE_ORDER LITTLE_ENDIAN |
---|
16 | #else |
---|
17 | # error "Can't decide which end is which!" |
---|
18 | #endif |
---|
19 | |
---|
20 | #if ( CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES == FALSE ) |
---|
21 | |
---|
22 | #if ( CPU_BIG_ENDIAN == TRUE ) |
---|
23 | |
---|
24 | /* |
---|
25 | * Very simply on big endian CPUs |
---|
26 | */ |
---|
27 | |
---|
28 | #define ntohl(_x) (_x) |
---|
29 | #define ntohs(_x) (_x) |
---|
30 | #define htonl(_x) (_x) |
---|
31 | #define htons(_x) (_x) |
---|
32 | |
---|
33 | #define NTOHS(x) |
---|
34 | #define HTONS(x) |
---|
35 | #define NTOHL(x) |
---|
36 | #define HTONL(x) |
---|
37 | |
---|
38 | #elif ( CPU_LITTLE_ENDIAN == TRUE ) |
---|
39 | |
---|
40 | /* |
---|
41 | * A little more complicated on little endian CPUs |
---|
42 | */ |
---|
43 | |
---|
44 | #define ntohl(_x) ((long) CPU_swap_u32((unsigned32)_x)) |
---|
45 | #define ntohs(_x) ((short) CPU_swap_u16((unsigned16)_x)) |
---|
46 | #define htonl(_x) ((long) CPU_swap_u32((unsigned32)_x)) |
---|
47 | #define htons(_x) ((short) CPU_swap_u16((unsigned16)_x)) |
---|
48 | |
---|
49 | #define NTOHS(x) (x) = ntohs(x) |
---|
50 | #define HTONS(x) (x) = htons(x) |
---|
51 | #define NTOHL(x) (x) = ntohl(x) |
---|
52 | #define HTONL(x) (x) = htonl(x) |
---|
53 | |
---|
54 | #else |
---|
55 | #error "Unknown endian-ness for this cpu" |
---|
56 | #endif |
---|
57 | |
---|
58 | #endif /* CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES */ |
---|
59 | |
---|
60 | #endif /* _MACHINE_ENDIAN_H_ */ |
---|
Note: See
TracBrowser
for help on using the repository browser.