diff options
-rw-r--r-- | sys/arch/amd64/stand/boot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/cdboot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/Makefile.common | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/pxeboot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/hppa/stand/boot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/cdboot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/pxeboot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/loongson/stand/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/luna88k/stand/boot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/macppc/stand/boot.mac/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/macppc/stand/ofwboot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/octeon/stand/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/sgi/stand/boot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/sgi/stand/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/lib/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/lib/libsa/memcpy.c | 12 | ||||
-rw-r--r-- | sys/lib/libsa/memmove.c | 55 | ||||
-rw-r--r-- | sys/lib/libsa/stand.h | 5 |
20 files changed, 95 insertions, 45 deletions
diff --git a/sys/arch/amd64/stand/boot/Makefile b/sys/arch/amd64/stand/boot/Makefile index ce68b7efaca..c75a1956efe 100644 --- a/sys/arch/amd64/stand/boot/Makefile +++ b/sys/arch/amd64/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.39 2017/10/17 19:31:56 naddy Exp $ +# $OpenBSD: Makefile,v 1.40 2019/04/20 22:59:03 deraadt Exp $ COPTS?= MAN?= boot.8 @@ -32,7 +32,7 @@ SRCS+= softraid_amd64.c .endif .PATH: ${S}/lib/libsa -SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memset.c printf.c \ +SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ diff --git a/sys/arch/amd64/stand/cdboot/Makefile b/sys/arch/amd64/stand/cdboot/Makefile index 401b9dcf1f7..ff43909149e 100644 --- a/sys/arch/amd64/stand/cdboot/Makefile +++ b/sys/arch/amd64/stand/cdboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.34 2017/10/17 19:31:56 naddy Exp $ +# $OpenBSD: Makefile,v 1.35 2019/04/20 22:59:03 deraadt Exp $ MAN= cdboot.8 @@ -26,7 +26,7 @@ SRCS+= cmd.c vars.c bootarg.c .PATH: ${S}/lib/libsa SRCS+= alloc.c exit.c getchar.c putchar.c strcmp.c strlen.c \ - strncmp.c memcmp.c memcpy.c memset.c printf.c snprintf.c \ + strncmp.c memcmp.c memcpy.c memmove.c memset.c printf.c snprintf.c \ strerror.c strncpy.c strtol.c strtoll.c ctime.c strlcpy.c SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c lseek.c \ open.c read.c stat.c cread.c readdir.c cons.c loadfile.c \ diff --git a/sys/arch/amd64/stand/efiboot/Makefile.common b/sys/arch/amd64/stand/efiboot/Makefile.common index e13d67ae98d..c9069d67290 100644 --- a/sys/arch/amd64/stand/efiboot/Makefile.common +++ b/sys/arch/amd64/stand/efiboot/Makefile.common @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.common,v 1.13 2018/10/13 19:56:56 kettenis Exp $ +# $OpenBSD: Makefile.common,v 1.14 2019/04/20 22:59:03 deraadt Exp $ S= ${.CURDIR}/../../../../.. SADIR= ${.CURDIR}/../.. @@ -31,7 +31,7 @@ SRCS+= conf.c SRCS+= boot.c bootarg.c cmd.c vars.c .PATH: ${S}/lib/libsa -SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memset.c printf.c \ +SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ diff --git a/sys/arch/amd64/stand/pxeboot/Makefile b/sys/arch/amd64/stand/pxeboot/Makefile index eff32c5de2d..9b76c21d153 100644 --- a/sys/arch/amd64/stand/pxeboot/Makefile +++ b/sys/arch/amd64/stand/pxeboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.32 2017/10/17 19:31:56 naddy Exp $ +# $OpenBSD: Makefile,v 1.33 2019/04/20 22:59:03 deraadt Exp $ MAN= pxeboot.8 @@ -28,7 +28,7 @@ SRCS+= boot.c cmd.c vars.c bootarg.c .PATH: ${S}/lib/libsa SRCS+= alloc.c exit.c getchar.c getfile.c getln.c globals.c putchar.c \ - strcmp.c strlen.c strncmp.c memcmp.c memcpy.c memset.c printf.c \ + strcmp.c strlen.c strncmp.c memcmp.c memcpy.c memmove.c memset.c printf.c \ snprintf.c strerror.c strncpy.c strtol.c strtoll.c ctime.c strlcpy.c \ strlcat.c SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \ diff --git a/sys/arch/hppa/stand/boot/Makefile b/sys/arch/hppa/stand/boot/Makefile index 77ef969498c..8ec336d47cd 100644 --- a/sys/arch/hppa/stand/boot/Makefile +++ b/sys/arch/hppa/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.27 2016/11/27 01:36:30 deraadt Exp $ +# $OpenBSD: Makefile,v 1.28 2019/04/20 22:59:03 deraadt Exp $ MAN= boot.8 MANSUBDIR=hppa @@ -13,7 +13,7 @@ SRCS= srt0.S exec.c conf.c SRCS+= bootarg.c boot.c vars.c cmd.c .PATH: ${S}/lib/libkern/arch/hppa ${S}/lib/libkern -SRCS+= milli.S ashldi3.c ashrdi3.c memcmp.c memcpy.c memset.c \ +SRCS+= milli.S ashldi3.c ashrdi3.c memcmp.c memcpy.c memmove.c memset.c \ moddi3.c muldi3.c qdivrem.c strcmp.c strlcpy.c strlen.c \ strncmp.c strncpy.c divdi3.c diff --git a/sys/arch/i386/stand/boot/Makefile b/sys/arch/i386/stand/boot/Makefile index 6874e1723f8..f087b3ee62e 100644 --- a/sys/arch/i386/stand/boot/Makefile +++ b/sys/arch/i386/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.67 2017/10/17 19:31:56 naddy Exp $ +# $OpenBSD: Makefile,v 1.68 2019/04/20 22:59:03 deraadt Exp $ COPTS?= MAN?= boot.8 @@ -36,7 +36,7 @@ SRCS+= softraid_i386.c .endif .PATH: ${S}/lib/libsa -SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memset.c printf.c \ +SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ diff --git a/sys/arch/i386/stand/cdboot/Makefile b/sys/arch/i386/stand/cdboot/Makefile index 0c4dc2e159f..fe157e400bd 100644 --- a/sys/arch/i386/stand/cdboot/Makefile +++ b/sys/arch/i386/stand/cdboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.31 2017/10/17 19:31:56 naddy Exp $ +# $OpenBSD: Makefile,v 1.32 2019/04/20 22:59:03 deraadt Exp $ MAN= cdboot.8 @@ -27,7 +27,7 @@ SRCS+= softraid_i386.c SRCS+= bootarg.c cmd.c vars.c .PATH: ${S}/lib/libsa -SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memset.c printf.c \ +SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ diff --git a/sys/arch/i386/stand/pxeboot/Makefile b/sys/arch/i386/stand/pxeboot/Makefile index daa976064c7..5c678a92da7 100644 --- a/sys/arch/i386/stand/pxeboot/Makefile +++ b/sys/arch/i386/stand/pxeboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.28 2017/10/17 19:31:56 naddy Exp $ +# $OpenBSD: Makefile,v 1.29 2019/04/20 22:59:03 deraadt Exp $ MAN= pxeboot.8 @@ -28,7 +28,7 @@ SRCS+= softraid_i386.c SRCS+= boot.c cmd.c vars.c bootarg.c .PATH: ${S}/lib/libsa -SRCS+= alloc.c ctime.c exit.c getchar.c globals.c memcmp.c memcpy.c memset.c \ +SRCS+= alloc.c ctime.c exit.c getchar.c globals.c memcmp.c memmove.c memcpy.c memset.c \ printf.c putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c \ strncpy.c strtol.c strtoll.c SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ diff --git a/sys/arch/loongson/stand/libsa/Makefile b/sys/arch/loongson/stand/libsa/Makefile index 08fa3c27a38..b4820f3d8cf 100644 --- a/sys/arch/loongson/stand/libsa/Makefile +++ b/sys/arch/loongson/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.8 2016/11/06 16:42:00 tb Exp $ +# $OpenBSD: Makefile,v 1.9 2019/04/20 22:59:03 deraadt Exp $ .include "${.CURDIR}/../Makefile.inc" @@ -17,7 +17,7 @@ CFLAGS+= ${CEXTRAFLAGS} ${SAABI} -nostdinc -mno-abicalls -D_NO_ABICALLS \ # stand routines SRCS= alloc.c cons.c ctime.c exit.c getchar.c getfile.c getln.c globals.c \ - memcmp.c memcpy.c memset.c printf.c putchar.c \ + memcmp.c memcpy.c memmove.c memset.c printf.c putchar.c \ snprintf.c strchr.c strcmp.c strerror.c strncmp.c strncpy.c strtol.c # io routines diff --git a/sys/arch/luna88k/stand/boot/Makefile b/sys/arch/luna88k/stand/boot/Makefile index db52b8c6470..45ef7edd6bb 100644 --- a/sys/arch/luna88k/stand/boot/Makefile +++ b/sys/arch/luna88k/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.9 2016/12/03 03:34:33 aoyama Exp $ +# $OpenBSD: Makefile,v 1.10 2019/04/20 22:59:03 deraadt Exp $ # $NetBSD: Makefile,v 1.9 2013/01/22 15:48:40 tsutsui Exp $ # @(#)Makefile 8.2 (Berkeley) 8/15/93 @@ -43,7 +43,7 @@ PROG= boot ### find out what to use for libkern .PATH: ${S}/lib/libkern -SRCS+= memcpy.c strlcat.c strlcpy.c strlen.c +SRCS+= memcpy.c memmove.c strlcat.c strlcpy.c strlen.c SRCS+= muldi3.c negdi2.c ashldi3.c ashrdi3.c ### find out what to use for libsa diff --git a/sys/arch/macppc/stand/boot.mac/Makefile b/sys/arch/macppc/stand/boot.mac/Makefile index 77367c7e347..d48bc32e675 100644 --- a/sys/arch/macppc/stand/boot.mac/Makefile +++ b/sys/arch/macppc/stand/boot.mac/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.14 2016/07/30 03:25:49 guenther Exp $ +# $OpenBSD: Makefile,v 1.15 2019/04/20 22:59:03 deraadt Exp $ # $NetBSD: Makefile,v 1.1 1996/09/30 16:35:05 ws Exp $ S= ${.CURDIR}/../../../.. @@ -25,7 +25,7 @@ LDFLAGS+= -T ${.CURDIR}/elf32_powerpc_merge.x -Bstatic SRCS+= getchar.c .PATH: ${S}/lib/libkern/arch/powerpc ${S}/lib/libkern -SRCS+= strlcpy.c memcpy.c strlen.c strrchr.c strlcat.c ashrdi3.c +SRCS+= strlcpy.c memcpy.c memmove.c strlen.c strrchr.c strlcat.c ashrdi3.c SRCS+= moddi3.c CPPFLAGS+= -I. -I${.CURDIR}/../../.. -I${.CURDIR}/../../../.. diff --git a/sys/arch/macppc/stand/ofwboot/Makefile b/sys/arch/macppc/stand/ofwboot/Makefile index 176e32f7aa6..8887ed64b0a 100644 --- a/sys/arch/macppc/stand/ofwboot/Makefile +++ b/sys/arch/macppc/stand/ofwboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.15 2016/07/30 03:25:49 guenther Exp $ +# $OpenBSD: Makefile,v 1.16 2019/04/20 22:59:04 deraadt Exp $ # $NetBSD: Makefile,v 1.2 1997/04/17 07:46:24 thorpej Exp $ S= ${.CURDIR}/../../../.. @@ -24,7 +24,7 @@ BINDIR= /usr/mdec .PATH: ${S}/lib/libsa .PATH: ${S}/lib/libkern/arch/powerpc ${S}/lib/libkern -SRCS+= getchar.c strlcpy.c memcpy.c strlen.c strrchr.c \ +SRCS+= getchar.c strlcpy.c memcpy.c memmove.c strlen.c strrchr.c \ strlcat.c ashrdi3.c SRCS+= moddi3.c diff --git a/sys/arch/octeon/stand/libsa/Makefile b/sys/arch/octeon/stand/libsa/Makefile index 0432e12354f..d986197249e 100644 --- a/sys/arch/octeon/stand/libsa/Makefile +++ b/sys/arch/octeon/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.6 2016/11/06 16:42:00 tb Exp $ +# $OpenBSD: Makefile,v 1.7 2019/04/20 22:59:04 deraadt Exp $ .include "${.CURDIR}/../Makefile.inc" @@ -17,7 +17,7 @@ CFLAGS+= ${CEXTRAFLAGS} ${SAABI} -nostdinc -mno-abicalls -D_NO_ABICALLS \ # stand routines SRCS= alloc.c cons.c ctime.c exit.c getchar.c getfile.c getln.c globals.c \ - memcmp.c memcpy.c memset.c printf.c putchar.c \ + memcmp.c memcpy.c memmove.c memset.c printf.c putchar.c \ snprintf.c strchr.c strcmp.c strerror.c strncmp.c strncpy.c strtol.c # io routines diff --git a/sys/arch/sgi/stand/boot/Makefile b/sys/arch/sgi/stand/boot/Makefile index 1321201827e..f5e73dba1cb 100644 --- a/sys/arch/sgi/stand/boot/Makefile +++ b/sys/arch/sgi/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.18 2016/11/06 16:04:20 tb Exp $ +# $OpenBSD: Makefile,v 1.19 2019/04/20 22:59:04 deraadt Exp $ NOMAN= noman @@ -19,7 +19,7 @@ SRCS= start.S arcbios.c boot.c conf.c diskio.c filesystem.c \ SRCS+= loadfile.c .PATH: ${S}/lib/libkern/arch/mips64 ${S}/lib/libkern -SRCS+= memcpy.c strchr.c strcmp.S strlcat.c strlcpy.c strlen.c \ +SRCS+= memcpy.c memmove.c strchr.c strcmp.S strlcat.c strlcpy.c strlen.c \ strncmp.c strrchr.c CLEANFILES+= machine mips64 diff --git a/sys/arch/sgi/stand/libsa/Makefile b/sys/arch/sgi/stand/libsa/Makefile index 0b0996611d6..30f52c4f1ce 100644 --- a/sys/arch/sgi/stand/libsa/Makefile +++ b/sys/arch/sgi/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.10 2016/11/06 16:04:20 tb Exp $ +# $OpenBSD: Makefile,v 1.11 2019/04/20 22:59:04 deraadt Exp $ LIB= sa @@ -18,7 +18,7 @@ CPPFLAGS+= ${LIBSA_CPPFLAGS} # stand routines SRCS= alloc.c exit.c getfile.c getln.c globals.c \ - memcmp.c memcpy.c memset.c printf.c snprintf.c strerror.c strncpy.c + memcmp.c memcpy.c memmove.c memset.c printf.c snprintf.c strerror.c strncpy.c # io routines SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c ioctl.c lseek.c \ diff --git a/sys/arch/sparc64/stand/libsa/Makefile b/sys/arch/sparc64/stand/libsa/Makefile index 9c7d4a3cf83..f8eda95fa46 100644 --- a/sys/arch/sparc64/stand/libsa/Makefile +++ b/sys/arch/sparc64/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2016/11/06 16:04:20 tb Exp $ +# $OpenBSD: Makefile,v 1.13 2019/04/20 22:59:04 deraadt Exp $ LIB= sa @@ -17,7 +17,7 @@ CPPFLAGS+= -D__INTERNAL_LIBSA_CREAD # stand routines SRCS= alloc.c exit.c getfile.c getln.c globals.c \ - memcmp.c memcpy.c memset.c printf.c snprintf.c strerror.c strncpy.c + memcmp.c memcpy.c memmove.c memset.c printf.c snprintf.c strerror.c strncpy.c # io routines SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c ioctl.c lseek.c \ diff --git a/sys/lib/libsa/Makefile b/sys/lib/libsa/Makefile index 5e722d49328..a4b9fdcf26b 100644 --- a/sys/lib/libsa/Makefile +++ b/sys/lib/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.28 2015/11/16 19:33:52 miod Exp $ +# $OpenBSD: Makefile,v 1.29 2019/04/20 22:59:04 deraadt Exp $ # $NetBSD: Makefile,v 1.13 1996/10/02 16:19:51 ws Exp $ LIB= sa @@ -24,7 +24,7 @@ CPPFLAGS+= -D__INTERNAL_LIBSA_CREAD .endif # stand routines -SRCS+= alloc.c memcpy.c exit.c getfile.c getchar.c getln.c globals.c \ +SRCS+= alloc.c memcpy.c memmove.c exit.c getfile.c getchar.c getln.c globals.c \ printf.c putchar.c snprintf.c strerror.c strcmp.c memset.c memcmp.c \ strncpy.c strncmp.c strchr.c diff --git a/sys/lib/libsa/memcpy.c b/sys/lib/libsa/memcpy.c index 15425355490..65e95d66cef 100644 --- a/sys/lib/libsa/memcpy.c +++ b/sys/lib/libsa/memcpy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memcpy.c,v 1.5 2003/08/08 03:36:07 deraadt Exp $ */ +/* $OpenBSD: memcpy.c,v 1.6 2019/04/20 22:59:04 deraadt Exp $ */ /* $NetBSD: bcopy.c,v 1.5 1995/04/22 13:46:50 cgd Exp $ */ /*- @@ -44,13 +44,7 @@ memcpy(void *s1, const void *s2, size_t n) const char *f = s2; char *t = s1; - if (f < t) { - f += n; - t += n; - while (n-- > 0) - *--t = *--f; - } else - while (n-- > 0) - *t++ = *f++; + while (n-- > 0) + *t++ = *f++; return s1; } diff --git a/sys/lib/libsa/memmove.c b/sys/lib/libsa/memmove.c new file mode 100644 index 00000000000..6c1d6273895 --- /dev/null +++ b/sys/lib/libsa/memmove.c @@ -0,0 +1,55 @@ +/* $OpenBSD: memmove.c,v 1.1 2019/04/20 22:59:04 deraadt Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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/types.h> +#include <sys/systm.h> + +#undef memmove + +/* + * This is designed to be small, not fast. + */ +void * +memmove(void *s1, const void *s2, size_t n) +{ + const char *f = s2; + char *t = s1; + + if (f < t) { + f += n; + t += n; + while (n-- > 0) + *--t = *--f; + } else + while (n-- > 0) + *t++ = *f++; + return s1; +} diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h index f8147ecad8f..5e78f153770 100644 --- a/sys/lib/libsa/stand.h +++ b/sys/lib/libsa/stand.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stand.h,v 1.65 2017/10/08 00:57:19 guenther Exp $ */ +/* $OpenBSD: stand.h,v 1.66 2019/04/20 22:59:04 deraadt Exp $ */ /* $NetBSD: stand.h,v 1.18 1996/11/30 04:35:51 gwr Exp $ */ /*- @@ -143,9 +143,10 @@ __dead void panic(const char *, ...) __attribute__((noreturn)); __dead void _rtt(void) __attribute__((noreturn)); #define bzero(s,n) ((void)memset((s),0,(n))) #define bcmp(s1,s2,n) (memcmp((s2),(s1),(n))) -#define bcopy(s1,s2,n) ((void)memcpy((s2),(s1),(n))) +#define bcopy(s1,s2,n) ((void)memmove((s2),(s1),(n))) void explicit_bzero(void *, size_t); void *memcpy(void *, const void *, size_t); +void *memmove(void *, const void *, size_t); int memcmp(const void *, const void *, size_t); char *strncpy(char *, const char *, size_t); int strncmp(const char *, const char *, size_t); |