summaryrefslogtreecommitdiff
path: root/sys/lib/libkern
diff options
context:
space:
mode:
authorscw <scw@NetBSD.org>2003-04-07 21:04:19 +0000
committerscw <scw@NetBSD.org>2003-04-07 21:04:19 +0000
commitbfc4be13a676aec7e90cfde1151be73fbdccd5a9 (patch)
tree51c2ac325756da13d287f07c39c77d22ca35e8b9 /sys/lib/libkern
parente77f46b3973b033efc784c7c1ec727b995864cf4 (diff)
When MEMCOPY is defined, don't bother checking if a backwards-copy is
required. That's what memmove() is for. This should fix port-powerpc/16889. The backwards copyin can confuse uiomove/genfs_getpages, resulting in corruption of files written over NFS.
Diffstat (limited to 'sys/lib/libkern')
-rw-r--r--sys/lib/libkern/bcopy.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/lib/libkern/bcopy.c b/sys/lib/libkern/bcopy.c
index 11497866c73..5c01fe5c160 100644
--- a/sys/lib/libkern/bcopy.c
+++ b/sys/lib/libkern/bcopy.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bcopy.c,v 1.3 1998/03/27 01:30:00 cgd Exp $ */
+/* $NetBSD: bcopy.c,v 1.4 2003/04/07 21:04:19 scw Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: bcopy.c,v 1.3 1998/03/27 01:30:00 cgd Exp $");
+__RCSID("$NetBSD: bcopy.c,v 1.4 2003/04/07 21:04:19 scw Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -94,7 +94,9 @@ bcopy(src0, dst0, length)
#define TLOOP(s) if (t) TLOOP1(s)
#define TLOOP1(s) do { s; } while (--t)
+#ifndef MEMCOPY
if ((unsigned long)dst < (unsigned long)src) {
+#endif
/*
* Copy forward.
*/
@@ -118,6 +120,7 @@ bcopy(src0, dst0, length)
TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
t = length & wmask;
TLOOP(*dst++ = *src++);
+#ifndef MEMCOPY
} else {
/*
* Copy backwards. Otherwise essentially the same.
@@ -140,6 +143,8 @@ bcopy(src0, dst0, length)
t = length & wmask;
TLOOP(*--dst = *--src);
}
+#endif /* MEMCOPY */
+
done:
#if defined(MEMCOPY) || defined(MEMMOVE)
return (dst0);