summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-02-28 16:21:25 +0000
committered <ed@FreeBSD.org>2009-02-28 16:21:25 +0000
commit322413c46c002718cc357647800a58347e6a7535 (patch)
treed48f20a6281397e8e474df818dbfe4b4795b419e
parent1c22aa10afa2d0933dda4f1fd7bbae1cc4429bf6 (diff)
downloadFreeBSD-src-322413c46c002718cc357647800a58347e6a7535.zip
FreeBSD-src-322413c46c002718cc357647800a58347e6a7535.tar.gz
Add memmove() to the kernel, making the kernel compile with Clang.
When copying big structures, LLVM generates calls to memmove(), because it may not be able to figure out whether structures overlap. This caused linker errors to occur. memmove() is now implemented using bcopy(). Ideally it would be the other way around, but that can be solved in the future. On ARM we don't do add anything, because it already has memmove(). Discussed on: arch@ Reviewed by: rdivacky
-rw-r--r--sys/cddl/compat/opensolaris/sys/sysmacros.h4
-rw-r--r--sys/conf/files.amd641
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/conf/files.ia641
-rw-r--r--sys/conf/files.mips1
-rw-r--r--sys/conf/files.pc981
-rw-r--r--sys/conf/files.powerpc1
-rw-r--r--sys/conf/files.sparc641
-rw-r--r--sys/conf/files.sun4v1
-rw-r--r--sys/gnu/fs/xfs/FreeBSD/xfs_compat.h4
-rw-r--r--sys/libkern/memmove.c38
-rw-r--r--sys/net80211/ieee80211_freebsd.h2
-rw-r--r--sys/netgraph/atm/uni/ng_uni_cust.h2
-rw-r--r--sys/netgraph/ng_l2tp.c3
-rw-r--r--sys/powerpc/booke/pmap.c1
-rw-r--r--sys/sys/systm.h1
-rw-r--r--sys/xdr/xdr_mem.c2
17 files changed, 47 insertions, 18 deletions
diff --git a/sys/cddl/compat/opensolaris/sys/sysmacros.h b/sys/cddl/compat/opensolaris/sys/sysmacros.h
index 7f4885b..3c1e9b1 100644
--- a/sys/cddl/compat/opensolaris/sys/sysmacros.h
+++ b/sys/cddl/compat/opensolaris/sys/sysmacros.h
@@ -97,10 +97,6 @@ extern "C" {
#define P2SAMEHIGHBIT_TYPED(x, y, type) \
(((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
-#ifdef _KERNEL
-#define memmove(dst, src, size) bcopy((src), (dst), (size))
-#endif
-
/*
* Find highest one bit set.
* Returns bit number + 1 of highest bit that is set, otherwise returns 0.
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 14312d5..97f5ee5 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -271,4 +271,5 @@ i386/cpufreq/powernow.c optional cpufreq
i386/cpufreq/est.c optional cpufreq
i386/cpufreq/p4tcc.c optional cpufreq
#
+libkern/memmove.c standard
libkern/memset.c standard
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index cb9e0dc..069e3b9 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -366,6 +366,7 @@ kern/imgact_gzip.c optional gzip
libkern/divdi3.c standard
libkern/ffsl.c standard
libkern/flsl.c standard
+libkern/memmove.c standard
libkern/memset.c standard
libkern/moddi3.c standard
libkern/qdivrem.c standard
diff --git a/sys/conf/files.ia64 b/sys/conf/files.ia64
index 200435b..62e36a5 100644
--- a/sys/conf/files.ia64
+++ b/sys/conf/files.ia64
@@ -130,4 +130,5 @@ libkern/ia64/__umoddi3.S standard
libkern/ia64/__umodsi3.S standard
libkern/ia64/bswap16.S standard
libkern/ia64/bswap32.S standard
+libkern/memmove.c standard
libkern/memset.c standard
diff --git a/sys/conf/files.mips b/sys/conf/files.mips
index 7fa0172..1e233d7 100644
--- a/sys/conf/files.mips
+++ b/sys/conf/files.mips
@@ -82,6 +82,7 @@ libkern/ffsl.c standard
libkern/fls.c standard
libkern/flsl.c standard
libkern/lshrdi3.c standard
+libkern/memmove.c standard
libkern/moddi3.c standard
libkern/qdivrem.c standard
libkern/udivdi3.c standard
diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98
index 2d4bcb8..f8c6f0a 100644
--- a/sys/conf/files.pc98
+++ b/sys/conf/files.pc98
@@ -224,6 +224,7 @@ kern/imgact_gzip.c optional gzip
libkern/divdi3.c standard
libkern/ffsl.c standard
libkern/flsl.c standard
+libkern/memmove.c standard
libkern/memset.c standard
libkern/moddi3.c standard
libkern/qdivrem.c standard
diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc
index 1ecba9e..4c40219 100644
--- a/sys/conf/files.powerpc
+++ b/sys/conf/files.powerpc
@@ -63,6 +63,7 @@ libkern/ffsl.c standard
libkern/fls.c standard
libkern/flsl.c standard
libkern/lshrdi3.c standard
+libkern/memmove.c standard
libkern/memset.c standard
libkern/moddi3.c standard
libkern/qdivrem.c standard
diff --git a/sys/conf/files.sparc64 b/sys/conf/files.sparc64
index 7687f9f..53077bb 100644
--- a/sys/conf/files.sparc64
+++ b/sys/conf/files.sparc64
@@ -65,6 +65,7 @@ libkern/ffs.c standard
libkern/ffsl.c standard
libkern/fls.c standard
libkern/flsl.c standard
+libkern/memmove.c standard
sparc64/central/central.c optional central
sparc64/ebus/ebus.c optional ebus
sparc64/fhc/clkbrd.c optional fhc
diff --git a/sys/conf/files.sun4v b/sys/conf/files.sun4v
index 384c13a..d83b0a2 100644
--- a/sys/conf/files.sun4v
+++ b/sys/conf/files.sun4v
@@ -34,6 +34,7 @@ libkern/ffs.c standard
libkern/ffsl.c standard
libkern/fls.c standard
libkern/flsl.c standard
+libkern/memmove.c standard
sparc64/sparc64/autoconf.c standard
sun4v/sun4v/bus_machdep.c standard
sun4v/sun4v/clock.c standard
diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h b/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h
index a98a7ee..7229f27 100644
--- a/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h
+++ b/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h
@@ -129,10 +129,6 @@ typedef dev_t os_dev_t;
#define copy_from_user(dst, src, len) copyin((src), (dst), (len))
#endif
-#ifndef memmove
-#define memmove(dst, src, len) bcopy((src), (dst), (len))
-#endif
-
#ifndef barrier
#define barrier() __asm__ __volatile__("": : :"memory")
#endif
diff --git a/sys/libkern/memmove.c b/sys/libkern/memmove.c
new file mode 100644
index 0000000..9cb26a2
--- /dev/null
+++ b/sys/libkern/memmove.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2009 Roman Divacky <rdivacky@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+*/
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/libkern.h>
+
+void *
+memmove(void *dest, const void *src, size_t n)
+{
+
+ bcopy(src, dest, n);
+ return (dest);
+}
diff --git a/sys/net80211/ieee80211_freebsd.h b/sys/net80211/ieee80211_freebsd.h
index 065d45c..519e37d 100644
--- a/sys/net80211/ieee80211_freebsd.h
+++ b/sys/net80211/ieee80211_freebsd.h
@@ -207,8 +207,6 @@ void ieee80211_vap_destroy(struct ieee80211vap *);
#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
#define time_before_eq(a,b) time_after_eq(b,a)
-#define memmove(dst, src, n) ovbcopy(src, dst, n)
-
struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
/* tx path usage */
diff --git a/sys/netgraph/atm/uni/ng_uni_cust.h b/sys/netgraph/atm/uni/ng_uni_cust.h
index cf9d354..4336e57 100644
--- a/sys/netgraph/atm/uni/ng_uni_cust.h
+++ b/sys/netgraph/atm/uni/ng_uni_cust.h
@@ -146,5 +146,3 @@ size_t unimem_sizes[UNIMEM_TYPES] = { \
[UNIMEM_CALL] = sizeof(struct call), \
[UNIMEM_PARTY] = sizeof(struct party) \
};
-
-#define memmove(T, F, L) bcopy((F), (T), (L))
diff --git a/sys/netgraph/ng_l2tp.c b/sys/netgraph/ng_l2tp.c
index 46dcba9..a5bb628 100644
--- a/sys/netgraph/ng_l2tp.c
+++ b/sys/netgraph/ng_l2tp.c
@@ -342,9 +342,6 @@ NETGRAPH_INIT(l2tp, &ng_l2tp_typestruct);
#define L2TP_SEQ_CHECK(x) do { } while (0)
#endif
-/* memmove macro */
-#define memmove(d, s, l) bcopy(s, d, l)
-
/* Whether to use m_copypacket() or m_dup() */
#define L2TP_COPY_MBUF m_copypacket
diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c
index 72964f7..136279d 100644
--- a/sys/powerpc/booke/pmap.c
+++ b/sys/powerpc/booke/pmap.c
@@ -100,7 +100,6 @@ __FBSDID("$FreeBSD$");
#endif
#define TODO panic("%s: not implemented", __func__);
-#define memmove(d, s, l) bcopy(s, d, l)
#include "opt_sched.h"
#ifndef SCHED_4BSD
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index eb60a34..5dba512 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -186,6 +186,7 @@ void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2);
void bzero(void *buf, size_t len) __nonnull(1);
void *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2);
+void *memmove(void *dest, const void *src, size_t n) __nonnull(1) __nonnull(2);
int copystr(const void * __restrict kfaddr, void * __restrict kdaddr,
size_t len, size_t * __restrict lencopied)
diff --git a/sys/xdr/xdr_mem.c b/sys/xdr/xdr_mem.c
index 121d5d8..2dd5b73 100644
--- a/sys/xdr/xdr_mem.c
+++ b/sys/xdr/xdr_mem.c
@@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$");
#include <rpc/types.h>
#include <rpc/xdr.h>
-#define memmove(dst, src, len) bcopy(src, dst, len)
-
static void xdrmem_destroy(XDR *);
static bool_t xdrmem_getlong_aligned(XDR *, long *);
static bool_t xdrmem_putlong_aligned(XDR *, const long *);
OpenPOWER on IntegriCloud