diff options
author | Ralf Corsepius <ralf.corsepius@rtems.org> | 2007-05-08 21:10:19 +0000 |
---|---|---|
committer | Ralf Corsepius <ralf.corsepius@rtems.org> | 2007-05-08 21:10:19 +0000 |
commit | 5a2feeada70f84f2e783a2e80678a49a78605d71 (patch) | |
tree | 379ae446ea6ba752c13c87f8abcaf22d3758bd03 /cpukit/libnetworking/machine | |
parent | 2007-05-08 Ralf Corsépius <ralf.corsepius@rtems.org> (diff) | |
download | rtems-5a2feeada70f84f2e783a2e80678a49a78605d71.tar.bz2 |
2007-05-08 Ralf Corsépius <ralf.corsepius@rtems.org>
* libnetworking/machine/endian.h: Convert htons, htonl, ntohs, ntohl
to inline functions, using uint[16,32]_t.
Diffstat (limited to 'cpukit/libnetworking/machine')
-rw-r--r-- | cpukit/libnetworking/machine/endian.h | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/cpukit/libnetworking/machine/endian.h b/cpukit/libnetworking/machine/endian.h index 6faa8f1a71..d76f59c115 100644 --- a/cpukit/libnetworking/machine/endian.h +++ b/cpukit/libnetworking/machine/endian.h @@ -31,10 +31,25 @@ * Very simply on big endian CPUs */ -#define ntohl(_x) (_x) -#define ntohs(_x) (_x) -#define htonl(_x) (_x) -#define htons(_x) (_x) +static inline uint32_t ntohl( uint32_t _x ) +{ + return _x; +} + +static inline uint16_t ntohs( uint16_t _x ) +{ + return _x; +} + +static inline uint32_t htonl( uint32_t _x ) +{ + return _x; +} + +static inline uint16_t htons( uint16_t _x ) +{ + return _x; +} #define NTOHS(x) #define HTONS(x) @@ -47,10 +62,25 @@ * A little more complicated on little endian CPUs */ -#define ntohl(_x) ((long) CPU_swap_u32((uint32_t )_x)) -#define ntohs(_x) ((short) CPU_swap_u16((uint16_t )_x)) -#define htonl(_x) ((long) CPU_swap_u32((uint32_t )_x)) -#define htons(_x) ((short) CPU_swap_u16((uint16_t )_x)) +static inline uint32_t ntohl( uint32_t _x ) +{ + return CPU_swap_u32(_x); +} + +static inline uint16_t ntohs( uint16_t _x ) +{ + return CPU_swap_u16(_x); +} + +static inline uint32_t htonl( uint32_t _x ) +{ + return CPU_swap_u32(_x); +} + +static inline uint16_t htons( uint16_t _x ) +{ + return CPU_swap_u16(_x); +} #define NTOHS(x) (x) = ntohs(x) #define HTONS(x) (x) = htons(x) |