Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/include * Rename "word" -> 16, and "long" -> 32...
details: https://anonhg.NetBSD.org/src/rev/39dbe5424d2d
branches: trunk
changeset: 535303:39dbe5424d2d
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Aug 14 15:08:57 2002 +0000
description:
* 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).
diffstat:
sys/arch/arm/include/bswap.h | 6 +++---
sys/arch/arm/include/byte_swap.h | 35 ++++++++++++++++-------------------
sys/arch/arm/include/endian_machdep.h | 10 +++++-----
3 files changed, 24 insertions(+), 27 deletions(-)
diffs (121 lines):
diff -r baa0c440cc30 -r 39dbe5424d2d sys/arch/arm/include/bswap.h
--- a/sys/arch/arm/include/bswap.h Wed Aug 14 14:45:37 2002 +0000
+++ b/sys/arch/arm/include/bswap.h Wed Aug 14 15:08:57 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bswap.h,v 1.2 2002/08/13 22:41:36 thorpej Exp $ */
+/* $NetBSD: bswap.h,v 1.3 2002/08/14 15:08:57 thorpej Exp $ */
#ifndef _MACHINE_BSWAP_H_
#define _MACHINE_BSWAP_H_
@@ -9,8 +9,8 @@
#ifdef __GNUC__
#include <arm/byte_swap.h>
-#define bswap16(x) __byte_swap_word(x)
-#define bswap32(x) __byte_swap_long(x)
+#define bswap16(x) __byte_swap_16(x)
+#define bswap32(x) __byte_swap_32(x)
#endif /* __GNUC__ */
diff -r baa0c440cc30 -r 39dbe5424d2d sys/arch/arm/include/byte_swap.h
--- a/sys/arch/arm/include/byte_swap.h Wed Aug 14 14:45:37 2002 +0000
+++ b/sys/arch/arm/include/byte_swap.h Wed Aug 14 15:08:57 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: byte_swap.h,v 1.1 2002/08/13 22:41:36 thorpej Exp $ */
+/* $NetBSD: byte_swap.h,v 1.2 2002/08/14 15:08:58 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc.
@@ -42,23 +42,20 @@
#include <sys/types.h>
static __inline u_int32_t
-__byte_swap_long_variable(u_int32_t v)
+__byte_swap_32_variable(u_int32_t v)
{
- int tmp;
+ u_int32_t t1;
- __asm __volatile(
- "eor %1, %2, %2, ror #16\n"
- "bic %1, %1, #0x00ff0000\n"
- "mov %0, %2, ror #8\n"
- "eor %0, %0, %1, lsr #8"
- : "=r" (v), "=&r" (tmp)
- : "0" (v));
+ t1 = v ^ ((v << 16) | (v >> 16));
+ t1 &= 0xff00ffff;
+ v = (v >> 8) | (v << 24);
+ v ^= (t1 >> 8);
return (v);
}
static __inline u_int16_t
-__byte_swap_word_variable(u_int16_t v)
+__byte_swap_16_variable(u_int16_t v)
{
__asm __volatile(
@@ -73,28 +70,28 @@
#ifdef __OPTIMIZE__
-#define __byte_swap_long_constant(x) \
+#define __byte_swap_32_constant(x) \
((((x) & 0xff000000) >> 24) | \
(((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | \
(((x) & 0x000000ff) << 24))
-#define __byte_swap_word_constant(x) \
+#define __byte_swap_16_constant(x) \
((((x) & 0xff00) >> 8) | \
(((x) & 0x00ff) << 8))
-#define __byte_swap_long(x) \
+#define __byte_swap_32(x) \
(__builtin_constant_p((x)) ? \
- __byte_swap_long_constant(x) : __byte_swap_long_variable(x))
+ __byte_swap_32_constant(x) : __byte_swap_32_variable(x))
-#define __byte_swap_word(x) \
+#define __byte_swap_16(x) \
(__builtin_constant_p((x)) ? \
- __byte_swap_word_constant(x) : __byte_swap_word_variable(x))
+ __byte_swap_16_constant(x) : __byte_swap_16_variable(x))
#else
-#define __byte_swap_long(x) __byte_swap_long_variable(x)
-#define __byte_swap_word(x) __byte_swap_word_variable(x)
+#define __byte_swap_32(x) __byte_swap_32_variable(x)
+#define __byte_swap_16(x) __byte_swap_16_variable(x)
#endif /* __OPTIMIZE__ */
diff -r baa0c440cc30 -r 39dbe5424d2d sys/arch/arm/include/endian_machdep.h
--- a/sys/arch/arm/include/endian_machdep.h Wed Aug 14 14:45:37 2002 +0000
+++ b/sys/arch/arm/include/endian_machdep.h Wed Aug 14 15:08:57 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: endian_machdep.h,v 1.4 2002/08/13 22:41:36 thorpej Exp $ */
+/* $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__
@@ -12,10 +12,10 @@
#include <arm/byte_swap.h>
#if _BYTE_ORDER == _LITTLE_ENDIAN
-#define ntohl(x) ((in_addr_t)__byte_swap_long((in_addr_t)(x)))
-#define ntohs(x) ((in_port_t)__byte_swap_word((in_port_t)(x)))
-#define htonl(x) ((in_addr_t)__byte_swap_long((in_addr_t)(x)))
-#define htons(x) ((in_port_t)__byte_swap_word((in_port_t)(x)))
+#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
Home |
Main Index |
Thread Index |
Old Index