From nobody Wed Jan 24 19:44:49 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TKvYZ41gzz58bdl; Wed, 24 Jan 2024 19:44:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TKvYZ0f0cz464d; Wed, 24 Jan 2024 19:44:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706125490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8jGFXvv9pE8zCZLoiFvAa3sJ2Y27DKSB/zryselIQn4=; b=qSk9iw1D1nystFw/We2iccgofBx4NEen42RKHNMOW79Q7RSPj0zrwSqqfsoK0QYgVKa67Z xq6gSWdyFovAAzDujR93SKIKYopSnlB5E6dnFchM1DC8mLxtJ9djqRZBIoR7PZ8B0qTWJ3 TL2dZFdvRbi9HM++DPNuaZ4GBw5K2vdlBO5LMRzIs2LY+rCG7OA5j+0RPrtIXsioMhmPtP kZ19A5vdLojvz+2nCBVbLYjZViRhNx8K7bollCpmvXMANeH9JcXmxNMSWZcspbubdmq8oH RuctGtlXNNjBv3Os0EJhYiZMxIFFPr2bAmDN4AgKzUSKuKBgyUwGvwxfzBoyRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706125490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8jGFXvv9pE8zCZLoiFvAa3sJ2Y27DKSB/zryselIQn4=; b=OxL80C7efobQcJuvn2Aig9K28Cbk7uSFeMG0JONB6YPxdso2dgNDFTscUyl4Fh3iKmq5mV wtImOmoJktSSlHrLOf4na3IU7oq3PMW2ODaV3rQU1FObAIkyQnXrwS0RtVYIpH9LrBFMpE /Be59178mM3bnCkcJ7XIXtlbbFLG9VLeB9Qezdh/42myO5RjFjQV5dLjix7JQjYD1MRJl4 /sivioNo0cInGbM+RNd3XdV1txZfABgE26pLNz3+6gH5m9HnXplKXSDWveTR72FoF71FyV Vc1WE3O0nT+CNrfyYu+ZmsYtc/nKaZ8/qGRXBdNNnrJ3981CLBplwfznnvngQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706125490; a=rsa-sha256; cv=none; b=r4TCjRWCmn7pgnWS9o9lYB746tbvH0Fr398u6vUd61a2rPxMOfwRLBUmWXg3ezfdp909Km rA+Zeqie73ht8GOnVxr6/qZF8PRIIeLy8JYA3TFP95qUdey4ueh2VGFRxZi5f6UOkD41sk kYgnfBDcX3hKS5NYZvVB6WHiQVW9n6Xmyu+lj01wDQV2TPmgXKGfQP4yl/M/fQFpTpqhZO iQlD3hxovY1UUotjJ7wP6uZVzfFoQqE76K8lZdlJXD1wxYRp4+pZRDhcDwm3q3MhthUXsv rv7HPPHe+ZrMEN4YAYeePvDN7iXy+D89Z1QxinN0ZCn86OdeVhA/WTd0f1vtEQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TKvYY6rV9zRmw; Wed, 24 Jan 2024 19:44:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40OJinsX005692; Wed, 24 Jan 2024 19:44:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40OJinZn005689; Wed, 24 Jan 2024 19:44:49 GMT (envelope-from git) Date: Wed, 24 Jan 2024 19:44:49 GMT Message-Id: <202401241944.40OJinZn005689@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Clausecker Subject: git: 3045c0f198a1 - stable/14 - lib/libc/amd64/string: implement strlcat() through strlcpy() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fuz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 3045c0f198a1113a02f44f77b161fcf79380ae63 Auto-Submitted: auto-generated The branch stable/14 has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=3045c0f198a1113a02f44f77b161fcf79380ae63 commit 3045c0f198a1113a02f44f77b161fcf79380ae63 Author: Robert Clausecker AuthorDate: 2023-11-29 02:32:28 +0000 Commit: Robert Clausecker CommitDate: 2024-01-24 19:39:29 +0000 lib/libc/amd64/string: implement strlcat() through strlcpy() This should pick up our optimised memchr(), strlen(), and strlcpy() when strlcat() is called. Tested by: developers@, exp-run Approved by: mjg MFC after: 1 month MFC to: stable/14 PR: 275785 Differential Revision: https://reviews.freebsd.org/D42863 (cherry picked from commit 2b7b03b7ae179db465c1ef19a5007f729874916a) --- lib/libc/amd64/string/Makefile.inc | 1 + lib/libc/amd64/string/strlcat.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/libc/amd64/string/Makefile.inc b/lib/libc/amd64/string/Makefile.inc index 03bca498e116..2b1e276cb3da 100644 --- a/lib/libc/amd64/string/Makefile.inc +++ b/lib/libc/amd64/string/Makefile.inc @@ -13,6 +13,7 @@ MDSRCS+= \ strcmp.S \ strcpy.c \ strcspn.S \ + strlcat.c \ strlcpy.S \ strlen.S \ strncmp.S \ diff --git a/lib/libc/amd64/string/strlcat.c b/lib/libc/amd64/string/strlcat.c new file mode 100644 index 000000000000..0c1e1c5d05f7 --- /dev/null +++ b/lib/libc/amd64/string/strlcat.c @@ -0,0 +1,25 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Robert Clausecker + */ + +#include + +#include + +void *__memchr(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(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)); +}