diff --git a/include/string.h b/include/string.h index 774cf5fe9756..afa90c3f2536 100644 --- a/include/string.h +++ b/include/string.h @@ -1,164 +1,167 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 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. * * @(#)string.h 8.1 (Berkeley) 6/2/93 * $FreeBSD$ */ #ifndef _STRING_H_ #define _STRING_H_ #include #include #include /* * Prototype functions which were historically defined in , but * are required by POSIX to be prototyped in . */ #if __BSD_VISIBLE #include #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif __BEGIN_DECLS #if __XSI_VISIBLE >= 600 void *memccpy(void * __restrict, const void * __restrict, int, size_t); #endif void *memchr(const void *, int, size_t) __pure; #if __BSD_VISIBLE void *memrchr(const void *, int, size_t) __pure; #endif int memcmp(const void *, const void *, size_t) __pure; void *memcpy(void * __restrict, const void * __restrict, size_t); #if __BSD_VISIBLE void *memmem(const void *, size_t, const void *, size_t) __pure; #endif void *memmove(void *, const void *, size_t); +#if __BSD_VISIBLE +void *mempcpy(void * __restrict, const void * __restrict, size_t); +#endif void *memset(void *, int, size_t); #if __POSIX_VISIBLE >= 200809 char *stpcpy(char * __restrict, const char * __restrict); char *stpncpy(char * __restrict, const char * __restrict, size_t); #endif #if __BSD_VISIBLE char *strcasestr(const char *, const char *) __pure; #endif char *strcat(char * __restrict, const char * __restrict); char *strchr(const char *, int) __pure; #if __BSD_VISIBLE char *strchrnul(const char*, int) __pure; #endif int strcmp(const char *, const char *) __pure; int strcoll(const char *, const char *); char *strcpy(char * __restrict, const char * __restrict); size_t strcspn(const char *, const char *) __pure; #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE char *strdup(const char *) __malloc_like; #endif char *strerror(int); #if __POSIX_VISIBLE >= 200112 int strerror_r(int, char *, size_t); #endif #if __BSD_VISIBLE size_t strlcat(char * __restrict, const char * __restrict, size_t); size_t strlcpy(char * __restrict, const char * __restrict, size_t); #endif size_t strlen(const char *) __pure; #if __BSD_VISIBLE void strmode(int, char *); #endif char *strncat(char * __restrict, const char * __restrict, size_t); int strncmp(const char *, const char *, size_t) __pure; char *strncpy(char * __restrict, const char * __restrict, size_t); #if __POSIX_VISIBLE >= 200809 char *strndup(const char *, size_t) __malloc_like; size_t strnlen(const char *, size_t) __pure; #endif #if __BSD_VISIBLE char *strnstr(const char *, const char *, size_t) __pure; #endif char *strpbrk(const char *, const char *) __pure; char *strrchr(const char *, int) __pure; #if __BSD_VISIBLE char *strsep(char **, const char *); #endif #if __POSIX_VISIBLE >= 200809 char *strsignal(int); #endif size_t strspn(const char *, const char *) __pure; char *strstr(const char *, const char *) __pure; char *strtok(char * __restrict, const char * __restrict); #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500 char *strtok_r(char *, const char *, char **); #endif size_t strxfrm(char * __restrict, const char * __restrict, size_t); #if __BSD_VISIBLE #ifndef _SWAB_DECLARED #define _SWAB_DECLARED #ifndef _SSIZE_T_DECLARED typedef __ssize_t ssize_t; #define _SSIZE_T_DECLARED #endif /* _SIZE_T_DECLARED */ void swab(const void * __restrict, void * __restrict, ssize_t); #endif /* _SWAB_DECLARED */ int timingsafe_bcmp(const void *, const void *, size_t); int timingsafe_memcmp(const void *, const void *, size_t); #endif /* __BSD_VISIBLE */ #if __POSIX_VISIBLE >= 200112 || defined(_XLOCALE_H_) #include #endif #if __EXT1_VISIBLE #ifndef _RSIZE_T_DEFINED #define _RSIZE_T_DEFINED typedef size_t rsize_t; #endif #ifndef _ERRNO_T_DEFINED #define _ERRNO_T_DEFINED typedef int errno_t; #endif /* ISO/IEC 9899:2011 K.3.7.4.1.1 */ errno_t memset_s(void *, rsize_t, int, rsize_t); #endif /* __EXT1_VISIBLE */ __END_DECLS #endif /* _STRING_H_ */ diff --git a/include/wchar.h b/include/wchar.h index 1c9d232d47e3..78f2f010048f 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -1,241 +1,244 @@ /*- * SPDX-License-Identifier: (BSD-2-Clause AND BSD-2-Clause-NetBSD) * * Copyright (c)1999 Citrus Project, * 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. * * $FreeBSD$ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Julian Coleman. * * 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. * * $NetBSD: wchar.h,v 1.8 2000/12/22 05:31:42 itojun Exp $ */ #ifndef _WCHAR_H_ #define _WCHAR_H_ #include #include #include #include #include <_ctype.h> #ifndef _MBSTATE_T_DECLARED typedef __mbstate_t mbstate_t; #define _MBSTATE_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE #ifndef _VA_LIST_DECLARED typedef __va_list va_list; #define _VA_LIST_DECLARED #endif #endif #ifndef __cplusplus #ifndef _WCHAR_T_DECLARED typedef ___wchar_t wchar_t; #define _WCHAR_T_DECLARED #endif #endif #ifndef _WINT_T_DECLARED typedef __wint_t wint_t; #define _WINT_T_DECLARED #endif #define WCHAR_MIN __WCHAR_MIN #define WCHAR_MAX __WCHAR_MAX #ifndef WEOF #define WEOF ((wint_t)-1) #endif #ifndef _STDFILE_DECLARED #define _STDFILE_DECLARED typedef struct __sFILE FILE; #endif struct tm; __BEGIN_DECLS wint_t btowc(int); wint_t fgetwc(FILE *); wchar_t * fgetws(wchar_t * __restrict, int, FILE * __restrict); wint_t fputwc(wchar_t, FILE *); int fputws(const wchar_t * __restrict, FILE * __restrict); int fwide(FILE *, int); int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...); int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...); wint_t getwc(FILE *); wint_t getwchar(void); size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict); size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t, mbstate_t * __restrict); int mbsinit(const mbstate_t *); size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, mbstate_t * __restrict); wint_t putwc(wchar_t, FILE *); wint_t putwchar(wchar_t); int swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict, ...); int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...); wint_t ungetwc(wint_t, FILE *); int vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list); int vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict, __va_list); int vwprintf(const wchar_t * __restrict, __va_list); size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict); wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict); wchar_t *wcschr(const wchar_t *, wchar_t) __pure; int wcscmp(const wchar_t *, const wchar_t *) __pure; int wcscoll(const wchar_t *, const wchar_t *); wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict); size_t wcscspn(const wchar_t *, const wchar_t *) __pure; size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict, const struct tm * __restrict); size_t wcslen(const wchar_t *) __pure; wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict, size_t); int wcsncmp(const wchar_t *, const wchar_t *, size_t) __pure; wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, size_t); wchar_t *wcspbrk(const wchar_t *, const wchar_t *) __pure; wchar_t *wcsrchr(const wchar_t *, wchar_t) __pure; size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t, mbstate_t * __restrict); size_t wcsspn(const wchar_t *, const wchar_t *) __pure; wchar_t *wcsstr(const wchar_t * __restrict, const wchar_t * __restrict) __pure; size_t wcsxfrm(wchar_t * __restrict, const wchar_t * __restrict, size_t); int wctob(wint_t); double wcstod(const wchar_t * __restrict, wchar_t ** __restrict); wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict, wchar_t ** __restrict); long wcstol(const wchar_t * __restrict, wchar_t ** __restrict, int); unsigned long wcstoul(const wchar_t * __restrict, wchar_t ** __restrict, int); wchar_t *wmemchr(const wchar_t *, wchar_t, size_t) __pure; int wmemcmp(const wchar_t *, const wchar_t *, size_t) __pure; wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); +#if __BSD_VISIBLE +wchar_t *wmempcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); +#endif wchar_t *wmemset(wchar_t *, wchar_t, size_t); int wprintf(const wchar_t * __restrict, ...); int wscanf(const wchar_t * __restrict, ...); #ifndef _STDSTREAM_DECLARED extern FILE *__stdinp; extern FILE *__stdoutp; extern FILE *__stderrp; #define _STDSTREAM_DECLARED #endif #define getwc(fp) fgetwc(fp) #define getwchar() fgetwc(__stdinp) #define putwc(wc, fp) fputwc(wc, fp) #define putwchar(wc) fputwc(wc, __stdoutp) #if __ISO_C_VISIBLE >= 1999 int vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list); int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict, __va_list); int vwscanf(const wchar_t * __restrict, __va_list); float wcstof(const wchar_t * __restrict, wchar_t ** __restrict); long double wcstold(const wchar_t * __restrict, wchar_t ** __restrict); #ifdef __LONG_LONG_SUPPORTED /* LONGLONG */ long long wcstoll(const wchar_t * __restrict, wchar_t ** __restrict, int); /* LONGLONG */ unsigned long long wcstoull(const wchar_t * __restrict, wchar_t ** __restrict, int); #endif #endif /* __ISO_C_VISIBLE >= 1999 */ #if __XSI_VISIBLE int wcswidth(const wchar_t *, size_t); int wcwidth(wchar_t); #define wcwidth(_c) __wcwidth(_c) #endif #if __POSIX_VISIBLE >= 200809 size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, size_t, mbstate_t * __restrict); FILE *open_wmemstream(wchar_t **, size_t *); wchar_t *wcpcpy(wchar_t * __restrict, const wchar_t * __restrict); wchar_t *wcpncpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); wchar_t *wcsdup(const wchar_t *) __malloc_like; int wcscasecmp(const wchar_t *, const wchar_t *); int wcsncasecmp(const wchar_t *, const wchar_t *, size_t n); size_t wcsnlen(const wchar_t *, size_t) __pure; size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t, size_t, mbstate_t * __restrict); #endif #if __BSD_VISIBLE wchar_t *fgetwln(FILE * __restrict, size_t * __restrict); size_t wcslcat(wchar_t *, const wchar_t *, size_t); size_t wcslcpy(wchar_t *, const wchar_t *, size_t); #endif #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) #include #endif __END_DECLS #endif /* !_WCHAR_H_ */ diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc index 6e6a3f42f723..6945155812af 100644 --- a/lib/libc/string/Makefile.inc +++ b/lib/libc/string/Makefile.inc @@ -1,104 +1,106 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 # $FreeBSD$ .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/string ${LIBC_SRCTOP}/string .PATH: ${SRCTOP}/sys/libkern CFLAGS+= -I${LIBC_SRCTOP}/locale # machine-independent string sources MISRCS+=bcmp.c bcopy.c bzero.c explicit_bzero.c \ ffs.c ffsl.c ffsll.c fls.c flsl.c flsll.c \ memccpy.c memchr.c memrchr.c memcmp.c \ - memcpy.c memmem.c memmove.c memset.c memset_s.c \ + memcpy.c memmem.c memmove.c mempcpy.c memset.c memset_s.c \ stpcpy.c stpncpy.c strcasecmp.c \ strcat.c strcasestr.c strchr.c strchrnul.c strcmp.c strcoll.c strcpy.c\ strcspn.c strdup.c strerror.c strlcat.c strlcpy.c strlen.c strmode.c \ strncat.c strncmp.c strncpy.c strndup.c strnlen.c strnstr.c \ strpbrk.c strrchr.c strsep.c strsignal.c strspn.c strstr.c strtok.c \ strxfrm.c swab.c \ timingsafe_bcmp.c \ timingsafe_memcmp.c \ wcpcpy.c wcpncpy.c wcscasecmp.c wcscat.c \ wcschr.c wcscmp.c wcscoll.c wcscpy.c wcscspn.c wcsdup.c \ wcslcat.c wcslcpy.c wcslen.c wcsncasecmp.c wcsncat.c wcsncmp.c \ wcsncpy.c wcsnlen.c wcspbrk.c \ wcsrchr.c wcsspn.c wcsstr.c wcstok.c wcswidth.c wcsxfrm.c wmemchr.c \ wmemcmp.c \ - wmemcpy.c wmemmove.c wmemset.c + wmemcpy.c wmemmove.c wmempcpy.c wmemset.c SYM_MAPS+= ${LIBC_SRCTOP}/string/Symbol.map # machine-dependent string sources .sinclude "${LIBC_SRCTOP}/${LIBC_ARCH}/string/Makefile.inc" MAN+= bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \ memcmp.3 memcpy.3 memmem.3 memmove.3 memset.3 strcasecmp.3 strcat.3 \ strchr.3 strcmp.3 strcoll.3 strcpy.3 strdup.3 strerror.3 \ string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strsep.3 \ strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 \ timingsafe_bcmp.3 \ wcscoll.3 wcstok.3 \ wcswidth.3 wcsxfrm.3 wmemchr.3 MLINKS+=bzero.3 explicit_bzero.3 MLINKS+=ffs.3 ffsl.3 \ ffs.3 ffsll.3 \ ffs.3 fls.3 \ ffs.3 flsl.3 \ ffs.3 flsll.3 MLINKS+=index.3 rindex.3 MLINKS+=memchr.3 memrchr.3 +MLINKS+=memcpy.3 mempcpy.3 MLINKS+=memset.3 memset_s.3 MLINKS+=strcasecmp.3 strncasecmp.3 \ strcasecmp.3 strcasecmp_l.3 \ strcasecmp.3 strncasecmp_l.3 MLINKS+=strcat.3 strncat.3 MLINKS+=strchr.3 strrchr.3 \ strchr.3 strchrnul.3 MLINKS+=strcmp.3 strncmp.3 MLINKS+=strcoll.3 strcoll_l.3 MLINKS+=strcpy.3 stpcpy.3 \ strcpy.3 stpncpy.3 \ strcpy.3 strncpy.3 MLINKS+=strdup.3 strndup.3 MLINKS+=strerror.3 perror.3 \ strerror.3 strerror_l.3 \ strerror.3 strerror_r.3 \ strerror.3 sys_errlist.3 \ strerror.3 sys_nerr.3 MLINKS+=strlcpy.3 strlcat.3 MLINKS+=strlen.3 strnlen.3 MLINKS+=strspn.3 strcspn.3 MLINKS+=strstr.3 strcasestr.3 \ strstr.3 strnstr.3 \ strstr.3 strcasestr_l.3 MLINKS+=strtok.3 strtok_r.3 MLINKS+=strxfrm.3 strxfrm_l.3 MLINKS+=timingsafe_bcmp.3 timingsafe_memcmp.3 MLINKS+=wmemchr.3 wcpcpy.3 \ wmemchr.3 wcpncpy.3 \ wmemchr.3 wcscasecmp.3 \ wmemchr.3 wcscat.3 \ wmemchr.3 wcschr.3 \ wmemchr.3 wcscmp.3 \ wmemchr.3 wcscpy.3 \ wmemchr.3 wcscspn.3 \ wmemchr.3 wcsdup.3 \ wmemchr.3 wcslcat.3 \ wmemchr.3 wcslcpy.3 \ wmemchr.3 wcslen.3 \ wmemchr.3 wcsncasecmp.3 \ wmemchr.3 wcsncat.3 \ wmemchr.3 wcsncmp.3 \ wmemchr.3 wcsncpy.3 \ wmemchr.3 wcsnlen.3 \ wmemchr.3 wcspbrk.3 \ wmemchr.3 wcsrchr.3 \ wmemchr.3 wcsspn.3 \ wmemchr.3 wcsstr.3 \ wmemchr.3 wmemcmp.3 \ wmemchr.3 wmemcpy.3 \ wmemchr.3 wmemmove.3 \ + wmemchr.3 wmempcpy.3 \ wmemchr.3 wmemset.3 diff --git a/lib/libc/string/Symbol.map b/lib/libc/string/Symbol.map index 450b745c7e0a..ec45d7fd7ddb 100644 --- a/lib/libc/string/Symbol.map +++ b/lib/libc/string/Symbol.map @@ -1,119 +1,124 @@ /* * $FreeBSD$ */ FBSD_1.0 { bcmp; bcopy; memcpy; memmove; ffs; ffsl; fls; flsl; index; strchr; memccpy; memchr; memcmp; memmem; bzero; memset; strrchr; rindex; stpcpy; strcasecmp; strncasecmp; strcasestr; strcat; strcmp; strcoll; strcpy; strcspn; strdup; strerror_r; strerror; strlcat; strlcpy; strlen; strmode; strncat; strncmp; strncpy; strnstr; strpbrk; strsep; strsignal; strspn; strstr; strtok_r; strtok; strxfrm; swab; wcscat; wcschr; wcscmp; wcscoll; wcscpy; wcscspn; wcsdup; wcslcat; wcslcpy; wcslen; wcsncat; wcsncmp; wcsncpy; wcspbrk; wcsrchr; wcsspn; wcsstr; wcstok; wcswidth; wcsxfrm; wmemchr; wmemcmp; wmemcpy; wmemmove; wmemset; }; FBSD_1.1 { ffsll; flsll; memrchr; stpncpy; strndup; strnlen; wcpcpy; wcpncpy; wcscasecmp; wcsncasecmp; wcsnlen; }; FBSD_1.3 { strcasecmp_l; strcasestr_l; strchrnul; strncasecmp_l; wcswidth_l; wcwidth_l; }; FBSD_1.4 { explicit_bzero; }; FBSD_1.5 { memset_s; timingsafe_bcmp; timingsafe_memcmp; }; FBSD_1.6 { strerror_l; }; +FBSD_1.7 { + mempcpy; + wmempcpy; +}; + FBSDprivate_1.0 { __strtok_r; }; diff --git a/lib/libc/string/memcpy.3 b/lib/libc/string/memcpy.3 index febc0fa34dd9..c65e4145264a 100644 --- a/lib/libc/string/memcpy.3 +++ b/lib/libc/string/memcpy.3 @@ -1,93 +1,104 @@ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" 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. .\" .\" @(#)memcpy.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd July 14, 2021 .Dt MEMCPY 3 .Os .Sh NAME .Nm memcpy .Nd copy byte string .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In string.h .Ft void * .Fn memcpy "void *dst" "const void *src" "size_t len" +.Ft void * +.Fn mempcpy "void *dst" "const void *src" "size_t len" .Sh DESCRIPTION The .Fn memcpy -function -copies +and +.Fn mempcpy +functions +copy .Fa len bytes from string .Fa src to string .Fa dst . If .Fa src and .Fa dst overlap, the results are not defined. .Sh RETURN VALUES The .Fn memcpy function returns the original value of .Fa dst . +.Pp +The +.Fn mempcpy +function returns a pointer to the byte after the last written byte. .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 function conforms to .St -isoC . .Sh BUGS In this implementation .Fn memcpy -is implemented using +and +.Fn mempcpy +are implemented using .Xr bcopy 3 , and therefore the strings may overlap. On other systems, copying overlapping strings may produce surprises. Programs intended to be portable should use .Xr memmove 3 when .Fa src and .Fa dst may overlap. diff --git a/lib/libc/string/mempcpy.c b/lib/libc/string/mempcpy.c new file mode 100644 index 000000000000..12c0d791e9d3 --- /dev/null +++ b/lib/libc/string/mempcpy.c @@ -0,0 +1,41 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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 +__FBSDID("$FreeBSD$"); + +#include + +void * +mempcpy(void *__restrict dst, const void *__restrict src, size_t len) +{ + return ((char *)memcpy(dst, src, len) + len); +} diff --git a/lib/libc/string/wmemchr.3 b/lib/libc/string/wmemchr.3 index 37ba05031ca9..8a926eef456a 100644 --- a/lib/libc/string/wmemchr.3 +++ b/lib/libc/string/wmemchr.3 @@ -1,174 +1,178 @@ .\" $NetBSD: wmemchr.3,v 1.4 2001/01/02 11:26:23 itojun Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" 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. .\" .\" from: @(#)strcpy.3 8.1 (Berkeley) 6/4/93 .\" .\" $FreeBSD$ .\" -.Dd March 4, 2009 +.Dd July 14, 2021 .Dt WMEMCHR 3 .Os .Sh NAME .Nm wmemchr , .Nm wmemcmp , .Nm wmemcpy , .Nm wmemmove , +.Nm wmempcpy , .Nm wmemset , .Nm wcpcpy , .Nm wcpncpy , .Nm wcscasecmp , .Nm wcscat , .Nm wcschr , .Nm wcscmp , .Nm wcscpy , .Nm wcscspn , .Nm wcsdup , .Nm wcslcat , .Nm wcslcpy , .Nm wcslen , .Nm wcsncasecmp , .Nm wcsncat , .Nm wcsncmp , .Nm wcsncpy , .Nm wcsnlen , .Nm wcspbrk , .Nm wcsrchr , .Nm wcsspn , .Nm wcsstr .Nd wide character string manipulation operations .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In wchar.h .Ft wchar_t * .Fn wmemchr "const wchar_t *s" "wchar_t c" "size_t n" .Ft int .Fn wmemcmp "const wchar_t *s1" "const wchar_t *s2" "size_t n" .Ft wchar_t * .Fn wmemcpy "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" .Ft wchar_t * .Fn wmemmove "wchar_t *s1" "const wchar_t *s2" "size_t n" .Ft wchar_t * +.Fn wmempcpy "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" +.Ft wchar_t * .Fn wmemset "wchar_t *s" "wchar_t c" "size_t n" .Ft wchar_t * .Fn wcpcpy "wchar_t *s1" "wchar_t *s2" .Ft wchar_t * .Fn wcpncpy "wchar_t *s1" "wchar_t *s2" "size_t n" .Ft int .Fn wcscasecmp "const wchar_t *s1" "const wchar_t *s2" .Ft wchar_t * .Fn wcscat "wchar_t * restrict s1" "const wchar_t * restrict s2" .Ft wchar_t * .Fn wcschr "const wchar_t *s" "wchar_t c" .Ft int .Fn wcscmp "const wchar_t *s1" "const wchar_t *s2" .Ft wchar_t * .Fn wcscpy "wchar_t * restrict s1" "const wchar_t * restrict s2" .Ft size_t .Fn wcscspn "const wchar_t *s1" "const wchar_t *s2" .Ft wchar_t * .Fn wcsdup "const wchar_t *s" .Ft size_t .Fn wcslcat "wchar_t *s1" "const wchar_t *s2" "size_t n" .Ft size_t .Fn wcslcpy "wchar_t *s1" "const wchar_t *s2" "size_t n" .Ft size_t .Fn wcslen "const wchar_t *s" .Ft int .Fn wcsncasecmp "const wchar_t *s1" "const wchar_t *s2" "size_t n" .Ft wchar_t * .Fn wcsncat "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" .Ft int .Fn wcsncmp "const wchar_t *s1" "const wchar_t * s2" "size_t n" .Ft wchar_t * .Fn wcsncpy "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" .Ft size_t .Fn wcsnlen "const wchar_t *s" "size_t maxlen" .Ft wchar_t * .Fn wcspbrk "const wchar_t *s1" "const wchar_t *s2" .Ft wchar_t * .Fn wcsrchr "const wchar_t *s" "wchar_t c" .Ft size_t .Fn wcsspn "const wchar_t *s1" "const wchar_t *s2" .Ft wchar_t * .Fn wcsstr "const wchar_t * restrict s1" "const wchar_t * restrict s2" .Sh DESCRIPTION The functions implement string manipulation operations over wide character strings. For a detailed description, refer to documents for the respective single-byte counterpart, such as .Xr memchr 3 . .Sh SEE ALSO .Xr memchr 3 , .Xr memcmp 3 , .Xr memcpy 3 , .Xr memmove 3 , .Xr memset 3 , .Xr stpcpy 3 , .Xr stpncpy 3 , .Xr strcasecmp 3 , .Xr strcat 3 , .Xr strchr 3 , .Xr strcmp 3 , .Xr strcpy 3 , .Xr strcspn 3 , .Xr strdup 3 , .Xr strlcat 3 , .Xr strlcpy 3 , .Xr strlen 3 , .Xr strncat 3 , .Xr strncmp 3 , .Xr strncpy 3 , .Xr strnlen 3 , .Xr strpbrk 3 , .Xr strrchr 3 , .Xr strspn 3 , .Xr strstr 3 .Sh STANDARDS These functions conform to .St -isoC-99 , with the exception of .Fn wcpcpy , .Fn wcpncpy , .Fn wcscasecmp , .Fn wcsdup , .Fn wcsncasecmp , and .Fn wcsnlen , which conform to .St -p1003.1-2008 ; and -.Fn wcslcat -and +.Fn wcslcat , .Fn wcslcpy , +and +.Fn wmempcpy , which are extensions. diff --git a/lib/libc/string/wmempcpy.c b/lib/libc/string/wmempcpy.c new file mode 100644 index 000000000000..208d62a26849 --- /dev/null +++ b/lib/libc/string/wmempcpy.c @@ -0,0 +1,42 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include + +wchar_t * +wmempcpy(wchar_t *__restrict dst, const wchar_t *__restrict src, size_t len) +{ + return (wmemcpy(dst, src, len) + len); +}