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.
This commit is contained in:
Ralf Corsepius
2007-05-08 21:10:19 +00:00
parent 70e624e366
commit 5a2feeada7
2 changed files with 40 additions and 8 deletions

View File

@@ -1,5 +1,7 @@
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.
* libnetworking/netdb.h: Change netent->n_net to uint32_t to comply
with SUSv3.
* telnetd/icmds.c: Add HAVE_CONFIG_H magic.

View File

@@ -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)