NetBSD/sys/arch/arm/include/endian_machdep.h
thorpej 201e41fc31 * Rename "word" -> 16, and "long" -> 32, as suggested by Ben Harris.
* Replace __byte_swap_32_variable() with a C version from Richard
  Earnshaw that generates nearly identical assembly (and it would be
  exactly identical with the addition of another peephole to GCC ARM
  back-end).
2002-08-14 15:08:57 +00:00

22 lines
574 B
C

/* $NetBSD: endian_machdep.h,v 1.5 2002/08/14 15:08:58 thorpej Exp $ */
/* GCC predefines __ARMEB__ when building for big-endian ARM. */
#ifdef __ARMEB__
#define _BYTE_ORDER _BIG_ENDIAN
#else
#define _BYTE_ORDER _LITTLE_ENDIAN
#endif
#ifdef __GNUC__
#include <arm/byte_swap.h>
#if _BYTE_ORDER == _LITTLE_ENDIAN
#define ntohl(x) ((in_addr_t)__byte_swap_32((in_addr_t)(x)))
#define ntohs(x) ((in_port_t)__byte_swap_16((in_port_t)(x)))
#define htonl(x) ((in_addr_t)__byte_swap_32((in_addr_t)(x)))
#define htons(x) ((in_port_t)__byte_swap_16((in_port_t)(x)))
#endif
#endif