1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2023 Robert Clausecker
5 */
6
7 #include <sys/cdefs.h>
8
9 #include <string.h>
10
11 void *__memchr_aarch64(const void *, int, size_t);
12 size_t __strlcpy(char *restrict, const char *restrict, size_t);
13
14 size_t
strlcat(char * restrict dst,const char * restrict src,size_t dstsize)15 strlcat(char *restrict dst, const char *restrict src, size_t dstsize)
16 {
17 char *loc = __memchr_aarch64(dst, '\0', dstsize);
18
19 if (loc != NULL) {
20 size_t dstlen = (size_t)(loc - dst);
21
22 return (dstlen + __strlcpy(loc, src, dstsize - dstlen));
23 } else
24 return (dstsize + strlen(src));
25 }
26