mirror of
https://git.freebsd.org/src.git
synced 2026-01-16 23:02:24 +00:00
lib/libc/aarch64/string: add strlcat SIMD implementation
This patch requires D46243 as it depends on strlcpy being labeled __strlcpy. It's a direct copy from the amd64 string functions using memchr and strlcpy to implement strlcat. Tested by: fuz (exprun) Reviewed by: fuz, emaste Sponsored by: Google LLC (GSoC 2024) PR: 281175 Differential Revision: https://reviews.freebsd.org/D46272
This commit is contained in:
parent
3dc5429158
commit
bea89d038a
3 changed files with 31 additions and 1 deletions
|
|
@ -29,7 +29,8 @@ MDSRCS+= \
|
|||
strlcpy.S \
|
||||
strncmp.S \
|
||||
memccpy.S \
|
||||
strncat.c
|
||||
strncat.c \
|
||||
strlcat.c
|
||||
|
||||
#
|
||||
# Add the above functions. Generate an asm file that includes the needed
|
||||
|
|
|
|||
4
lib/libc/aarch64/string/memchr.S
Normal file
4
lib/libc/aarch64/string/memchr.S
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.weak memchr
|
||||
.set memchr, __memchr_aarch64
|
||||
|
||||
#include "aarch64/memchr.S"
|
||||
25
lib/libc/aarch64/string/strlcat.c
Normal file
25
lib/libc/aarch64/string/strlcat.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2023 Robert Clausecker
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void *__memchr_aarch64(const void *, int, size_t);
|
||||
size_t __strlcpy(char *restrict, const char *restrict, size_t);
|
||||
|
||||
size_t
|
||||
strlcat(char *restrict dst, const char *restrict src, size_t dstsize)
|
||||
{
|
||||
char *loc = __memchr_aarch64(dst, '\0', dstsize);
|
||||
|
||||
if (loc != NULL) {
|
||||
size_t dstlen = (size_t)(loc - dst);
|
||||
|
||||
return (dstlen + __strlcpy(loc, src, dstsize - dstlen));
|
||||
} else
|
||||
return (dstsize + strlen(src));
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue