mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
lib/libc/amd64/string: implement strncat() by calling strlen(), memccpy()
This picks up the accelerated implementation of memccpy(). Tested by: developers@, exp-run Approved by: mjg MFC after: 1 month MFC to: stable/14 PR: 275785 Differential Revision: https://reviews.freebsd.org/D42902 (cherry picked from commit ea7b13771cc9d45bf1bc6c6edad8d1b7bce12990)
This commit is contained in:
parent
bd051ed3fe
commit
ddab9e6461
2 changed files with 30 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ MDSRCS+= \
|
|||
strlcat.c \
|
||||
strlcpy.S \
|
||||
strlen.S \
|
||||
strncat.c \
|
||||
strncmp.S \
|
||||
strncpy.c \
|
||||
strnlen.c \
|
||||
|
|
|
|||
29
lib/libc/amd64/string/strncat.c
Normal file
29
lib/libc/amd64/string/strncat.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2023 Robert Clausecker
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void *__memccpy(void *restrict, const void *restrict, int, size_t);
|
||||
|
||||
char *
|
||||
strncat(char *dest, const char *src, size_t n)
|
||||
{
|
||||
size_t len;
|
||||
char *endptr;
|
||||
|
||||
len = strlen(dest);
|
||||
endptr = __memccpy(dest + len, src, '\0', n);
|
||||
|
||||
/* avoid an extra branch */
|
||||
if (endptr == NULL)
|
||||
endptr = dest + len + n + 1;
|
||||
|
||||
endptr[-1] = '\0';
|
||||
|
||||
return (dest);
|
||||
}
|
||||
Loading…
Reference in a new issue