Date: Sat, 28 Feb 2009 16:21:25 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r189170 - in head/sys: cddl/compat/opensolaris/sys conf gnu/fs/xfs/FreeBSD libkern net80211 netgraph netgraph/atm/uni powerpc/booke sys xdr Message-ID: <200902281621.n1SGLPBK014429@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Sat Feb 28 16:21:25 2009 New Revision: 189170 URL: http://svn.freebsd.org/changeset/base/189170 Log: 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 Added: head/sys/libkern/memmove.c (contents, props changed) Modified: head/sys/cddl/compat/opensolaris/sys/sysmacros.h head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/conf/files.ia64 head/sys/conf/files.mips head/sys/conf/files.pc98 head/sys/conf/files.powerpc head/sys/conf/files.sparc64 head/sys/conf/files.sun4v head/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h head/sys/net80211/ieee80211_freebsd.h head/sys/netgraph/atm/uni/ng_uni_cust.h head/sys/netgraph/ng_l2tp.c head/sys/powerpc/booke/pmap.c head/sys/sys/systm.h head/sys/xdr/xdr_mem.c Modified: head/sys/cddl/compat/opensolaris/sys/sysmacros.h ============================================================================== --- head/sys/cddl/compat/opensolaris/sys/sysmacros.h Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/cddl/compat/opensolaris/sys/sysmacros.h Sat Feb 28 16:21:25 2009 (r189170) @@ -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. Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/conf/files.amd64 Sat Feb 28 16:21:25 2009 (r189170) @@ -271,4 +271,5 @@ i386/cpufreq/powernow.c optional cpufre i386/cpufreq/est.c optional cpufreq i386/cpufreq/p4tcc.c optional cpufreq # +libkern/memmove.c standard libkern/memset.c standard Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/conf/files.i386 Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/conf/files.ia64 ============================================================================== --- head/sys/conf/files.ia64 Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/conf/files.ia64 Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/conf/files.mips ============================================================================== --- head/sys/conf/files.mips Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/conf/files.mips Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/conf/files.pc98 ============================================================================== --- head/sys/conf/files.pc98 Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/conf/files.pc98 Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/conf/files.powerpc ============================================================================== --- head/sys/conf/files.powerpc Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/conf/files.powerpc Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/conf/files.sparc64 ============================================================================== --- head/sys/conf/files.sparc64 Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/conf/files.sparc64 Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/conf/files.sun4v ============================================================================== --- head/sys/conf/files.sun4v Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/conf/files.sun4v Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h ============================================================================== --- head/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/gnu/fs/xfs/FreeBSD/xfs_compat.h Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Added: head/sys/libkern/memmove.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/libkern/memmove.c Sat Feb 28 16:21:25 2009 (r189170) @@ -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); +} Modified: head/sys/net80211/ieee80211_freebsd.h ============================================================================== --- head/sys/net80211/ieee80211_freebsd.h Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/net80211/ieee80211_freebsd.h Sat Feb 28 16:21:25 2009 (r189170) @@ -207,8 +207,6 @@ void ieee80211_vap_destroy(struct ieee80 #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 */ Modified: head/sys/netgraph/atm/uni/ng_uni_cust.h ============================================================================== --- head/sys/netgraph/atm/uni/ng_uni_cust.h Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/netgraph/atm/uni/ng_uni_cust.h Sat Feb 28 16:21:25 2009 (r189170) @@ -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)) Modified: head/sys/netgraph/ng_l2tp.c ============================================================================== --- head/sys/netgraph/ng_l2tp.c Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/netgraph/ng_l2tp.c Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/powerpc/booke/pmap.c ============================================================================== --- head/sys/powerpc/booke/pmap.c Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/powerpc/booke/pmap.c Sat Feb 28 16:21:25 2009 (r189170) @@ -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 Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/sys/systm.h Sat Feb 28 16:21:25 2009 (r189170) @@ -186,6 +186,7 @@ void bcopy(const void *from, void *to, s 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) Modified: head/sys/xdr/xdr_mem.c ============================================================================== --- head/sys/xdr/xdr_mem.c Sat Feb 28 16:16:37 2009 (r189169) +++ head/sys/xdr/xdr_mem.c Sat Feb 28 16:21:25 2009 (r189170) @@ -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 *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902281621.n1SGLPBK014429>