Add companion mempcpy to wmempcpy, bump.

This commit is contained in:
christos 2023-08-01 17:51:24 +00:00
parent 9a87615fa7
commit b515b5959a
6 changed files with 62 additions and 11 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.2440 2023/08/01 06:35:55 mrg Exp $
# $NetBSD: mi,v 1.2441 2023/08/01 17:51:24 christos Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@ -9199,6 +9199,7 @@
./usr/share/man/cat3/memmem.0 comp-c-catman .cat
./usr/share/man/cat3/memmove.0 comp-c-catman .cat
./usr/share/man/cat3/memory.0 comp-c-catman .cat
./usr/share/man/cat3/mempcpy.0 comp-c-catman .cat
./usr/share/man/cat3/memrchr.0 comp-c-catman .cat
./usr/share/man/cat3/memset.0 comp-c-catman .cat
./usr/share/man/cat3/menu_attributes.0 comp-c-catman .cat
@ -17622,6 +17623,7 @@
./usr/share/man/html3/memmem.html comp-c-htmlman html
./usr/share/man/html3/memmove.html comp-c-htmlman html
./usr/share/man/html3/memory.html comp-c-htmlman html
./usr/share/man/html3/mempcpy.html comp-c-htmlman html
./usr/share/man/html3/memrchr.html comp-c-htmlman html
./usr/share/man/html3/memset.html comp-c-htmlman html
./usr/share/man/html3/menu_attributes.html comp-c-htmlman html
@ -26052,6 +26054,7 @@
./usr/share/man/man3/memmem.3 comp-c-man .man
./usr/share/man/man3/memmove.3 comp-c-man .man
./usr/share/man/man3/memory.3 comp-c-man .man
./usr/share/man/man3/mempcpy.3 comp-c-man .man
./usr/share/man/man3/memrchr.3 comp-c-man .man
./usr/share/man/man3/memset.3 comp-c-man .man
./usr/share/man/man3/menu_attributes.3 comp-c-man .man

View File

@ -1,4 +1,4 @@
/* $NetBSD: string.h,v 1.53 2021/08/09 20:49:08 andvar Exp $ */
/* $NetBSD: string.h,v 1.54 2023/08/01 17:51:24 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -106,6 +106,7 @@ char *strsep(char **, const char *);
char *stresep(char **, const char *, int);
char *strnstr(const char *, const char *, size_t);
void *memrchr(const void *, int, size_t);
void *mempcpy(void * __restrict, const void * __restrict, size_t);
void *explicit_memset(void *, int, size_t);
int consttime_memequal(const void *, const void *, size_t);
__END_DECLS

View File

@ -1,4 +1,4 @@
# $NetBSD: shlib_version,v 1.294 2023/07/02 00:52:04 dholland Exp $
# $NetBSD: shlib_version,v 1.295 2023/08/01 17:51:24 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
# things we wish to do on next major version bump:
@ -55,4 +55,4 @@
# - remove tzsetwall(3), upstream has removed it
# - move *rand48* to libcompat
major=12
minor=220
minor=221

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
# $NetBSD: Makefile.inc,v 1.86 2023/07/31 17:38:28 christos Exp $
# $NetBSD: Makefile.inc,v 1.87 2023/08/01 17:51:25 christos Exp $
# string sources
.PATH: ${ARCHDIR}/string ${.CURDIR}/string
@ -21,7 +21,7 @@ SRCS+= strncat.c strncmp.c strncpy.c strpbrk.c strsep.c
SRCS+= strspn.c strstr.c swab.c strnstr.c
SRCS+= explicit_memset.c consttime_memequal.c
SRCS+= memccpy.c memcpy.c memmem.c memmove.c
SRCS+= memccpy.c memcpy.c memmem.c memmove.c mempcpy.c
SRCS+= strchr.c strrchr.c strchrnul.c
SRCS+= popcount32.c popcount64.c
@ -67,6 +67,7 @@ MLINKS+=strstr.3 strcasestr.3
MLINKS+=strstr.3 strnstr.3
MLINKS+=strchr.3 strchrnul.3
MLINKS+=memchr.3 memrchr.3
MLINKS+=memcpy.3 mempcpy.3
MLINKS+=strtok.3 strtok_r.3
MLINKS+=strerror.3 strerror_r.3 strerror.3 perror.3 \
strerror.3 strerror_l.3 \

View File

@ -30,9 +30,9 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)memcpy.3 8.1 (Berkeley) 6/4/93
.\" $NetBSD: memcpy.3,v 1.13 2003/09/08 17:54:33 wiz Exp $
.\" $NetBSD: memcpy.3,v 1.14 2023/08/01 17:51:25 christos Exp $
.\"
.Dd June 4, 1993
.Dd August 1, 2023
.Dt MEMCPY 3
.Os
.Sh NAME
@ -44,11 +44,15 @@
.In string.h
.Ft void *
.Fn memcpy "void * restrict dst" "const void * restrict src" "size_t len"
.Ft void *
.Fn mempcpy "void *restrict dst" "const void * restrict src" "size_t len"
.Sh DESCRIPTION
The
.Fn memcpy
function
copies
and
.Fn mempcpy
functions
copy
.Fa len
bytes from string
.Fa src
@ -63,12 +67,17 @@ The
.Fn memcpy
function
returns the original value of
.Pp
The
.Fn mempcpy
function returns a pointer to the byte after the last written byte.
.Fa dst .
.Sh SEE ALSO
.Xr bcopy 3 ,
.Xr memccpy 3 ,
.Xr memmove 3 ,
.Xr strcpy 3
.Xr wmemcpy 3 ,
.Xr wmempcpy 3
.Sh STANDARDS
The
.Fn memcpy

37
lib/libc/string/mempcpy.c Normal file
View File

@ -0,0 +1,37 @@
/* $NetBSD: mempcpy.c,v 1.1 2023/08/01 17:51:25 christos Exp $ */
/*-
* Copyright (c) 2023 The NetBSD Foundation, Inc.
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
__RCSID("$NetBSD: mempcpy.c,v 1.1 2023/08/01 17:51:25 christos Exp $");
#include <string.h>
void *
mempcpy(void *__restrict dst, const void *__restrict src, size_t len)
{
return (char *)memcpy(dst, src, len) + len;
}