Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/include Pull up revision 1.17 (requested by scw):



details:   https://anonhg.NetBSD.org/src/rev/cea65a8fb50a
branches:  netbsd-1-4
changeset: 469495:cea65a8fb50a
user:      he <he%NetBSD.org@localhost>
date:      Sun Sep 26 13:29:50 1999 +0000

description:
Pull up revision 1.17 (requested by scw):
  Fix P_{16,32}_SWAP() macros to avoid unaligned 16 and 32 bit
  memory accesses.  This fixes a problem seen on arm32 when trying
  to use the db(3) functions to access a BIG_ENDIAN btree.

diffstat:

 include/db.h |  24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diffs (45 lines):

diff -r 53adc83de6c2 -r cea65a8fb50a include/db.h
--- a/include/db.h      Sun Sep 26 05:33:31 1999 +0000
+++ b/include/db.h      Sun Sep 26 13:29:50 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db.h,v 1.16 1998/12/09 12:42:27 christos Exp $ */
+/*     $NetBSD: db.h,v 1.16.2.1 1999/09/26 13:29:50 he Exp $   */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -186,11 +186,15 @@
        ((char *)(void *)&a)[3] = ((char *)(void *)&_tmp)[0];           \
 }
 #define        P_32_SWAP(a) {                                                  \
-       u_int32_t _tmp = *(u_int32_t *)(void *)a;                       \
-       ((char *)(void *)a)[0] = ((char *)(void *)&_tmp)[3];            \
-       ((char *)(void *)a)[1] = ((char *)(void *)&_tmp)[2];            \
-       ((char *)(void *)a)[2] = ((char *)(void *)&_tmp)[1];            \
-       ((char *)(void *)a)[3] = ((char *)(void *)&_tmp)[0];            \
+       char  _tmp[4];                                                  \
+       _tmp[0] = ((char *)(void *)a)[0];                               \
+       _tmp[1] = ((char *)(void *)a)[1];                               \
+       _tmp[2] = ((char *)(void *)a)[2];                               \
+       _tmp[3] = ((char *)(void *)a)[3];                               \
+       ((char *)(void *)a)[0] = _tmp[3];                               \
+       ((char *)(void *)a)[1] = _tmp[2];                               \
+       ((char *)(void *)a)[2] = _tmp[1];                               \
+       ((char *)(void *)a)[3] = _tmp[0];                               \
 }
 #define        P_32_COPY(a, b) {                                               \
        ((char *)(void *)&(b))[0] = ((char *)(void *)&(a))[3];          \
@@ -211,9 +215,11 @@
        ((char *)(void *)&a)[1] = ((char *)(void *)&_tmp)[0];           \
 }
 #define        P_16_SWAP(a) {                                                  \
-       u_int16_t _tmp = *(u_int16_t *)(void *)a;                       \
-       ((char *)(void *)a)[0] = ((char *)(void *)&_tmp)[1];            \
-       ((char *)(void *)a)[1] = ((char *)(void *)&_tmp)[0];            \
+       char  _tmp[2];                                                  \
+       _tmp[0] = ((char *)(void *)a)[0];                               \
+       _tmp[1] = ((char *)(void *)a)[1];                               \
+       ((char *)(void *)a)[0] = _tmp[1];                               \
+       ((char *)(void *)a)[1] = _tmp[0];                               \
 }
 #define        P_16_COPY(a, b) {                                               \
        ((char *)(void *)&(b))[0] = ((char *)(void *)&(a))[1];          \



Home | Main Index | Thread Index | Old Index