diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-19 10:22:06 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-30 08:11:39 +0200 |
commit | 868cd24dcd149bc2871130d77f398f9202c5e6ff (patch) | |
tree | d2ce551d00af3968bc674c502cf179cd15fcf8f9 /cpukit/include/rtems/endian.h | |
parent | network: Align with Newlib type definitions (diff) | |
download | rtems-868cd24dcd149bc2871130d77f398f9202c5e6ff.tar.bz2 |
score: Use Newlib provided <machine/endian.h>
Diffstat (limited to 'cpukit/include/rtems/endian.h')
-rw-r--r-- | cpukit/include/rtems/endian.h | 85 |
1 files changed, 9 insertions, 76 deletions
diff --git a/cpukit/include/rtems/endian.h b/cpukit/include/rtems/endian.h index e6704779ac..802cc4bb91 100644 --- a/cpukit/include/rtems/endian.h +++ b/cpukit/include/rtems/endian.h @@ -8,90 +8,23 @@ #ifndef _RTEMS_ENDIAN_H #define _RTEMS_ENDIAN_H -#include <rtems/score/cpu.h> +#include <stdint.h> -/* - * BSD-style endian declaration - */ -#define BIG_ENDIAN 4321 -#define LITTLE_ENDIAN 1234 - -#ifndef BYTE_ORDER -#if CPU_BIG_ENDIAN -# define BYTE_ORDER BIG_ENDIAN -#elif CPU_LITTLE_ENDIAN -# define BYTE_ORDER LITTLE_ENDIAN -#else -# error "Can't decide which end is which!" -#endif -#endif - -#if ( CPU_BIG_ENDIAN == TRUE ) - -/* - * Very simply on big endian CPUs - */ - -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; -} +#include <machine/endian.h> -#define NTOHS(x) -#define HTONS(x) -#define NTOHL(x) -#define HTONL(x) - -#elif ( CPU_LITTLE_ENDIAN == TRUE ) - -/* - * A little more complicated on little endian CPUs - */ - -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); -} +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) +#endif #define NTOHS(x) (x) = ntohs(x) #define HTONS(x) (x) = htons(x) #define NTOHL(x) (x) = ntohl(x) #define HTONL(x) (x) = htonl(x) -#else -#error "Unknown endian-ness for this cpu" -#endif - static inline uint16_t rtems_uint16_from_little_endian( const uint8_t *data) { uint16_t value = 0; |