From 5a2feeada70f84f2e783a2e80678a49a78605d71 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Tue, 8 May 2007 21:10:19 +0000 Subject: [PATCH] =?UTF-8?q?2007-05-08=09Ralf=20Cors=C3=A9pius=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * libnetworking/machine/endian.h: Convert htons, htonl, ntohs, ntohl to inline functions, using uint[16,32]_t. --- cpukit/ChangeLog | 2 ++ cpukit/libnetworking/machine/endian.h | 46 ++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index b98e298553..e56765308d 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,5 +1,7 @@ 2007-05-08 Ralf Corsépius + * libnetworking/machine/endian.h: Convert htons, htonl, ntohs, ntohl + to inline functions, using uint[16,32]_t. * libnetworking/netdb.h: Change netent->n_net to uint32_t to comply with SUSv3. * telnetd/icmds.c: Add HAVE_CONFIG_H magic. 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)