From nobody Wed Jan 24 19:44:56 2024 X-Original-To: dev-commits-src-branches@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 4TKvYj1Bgdz58c63; Wed, 24 Jan 2024 19:44:57 +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 4TKvYh71jVz46KD; Wed, 24 Jan 2024 19:44:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706125497; 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=kCGRLS183zoGj5zrjB4XTI0A6ZypdTlZQJG3Q/YkZgE=; b=TgI3l8QX006uEeCcNj9to5y4Y93j2VpmEcpw8FsFs+9IriLwRWKE5aCsCzBI62ATvlXAmN aMsaCktqqgAReZF9bA6HURrfRkr0EU0dRxRK+XM+2NG/A9TaKZqoLMqr1vYrJu33o7Ge/5 jaaPg6tkJoELzz8U9Tt0TlEWDwETIzDeYG37C2UZu2a7GlhrUHY5LNGg0Nm3ADjpP43G30 3S/+3bZIh0EYqo2lgtlxlhUPPjNBgXGQ0mA0OWuOEMWTiIZRlELct9N7LU1D3cTIlS6nCp QCWcLjAMne0rUYPn3z7+0ojU/T+FV5tmqcaX+1dcVfrX6wcYaWyPnlFGix8E1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706125497; 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=kCGRLS183zoGj5zrjB4XTI0A6ZypdTlZQJG3Q/YkZgE=; b=dQaqBCY2xkO5OAXQWuIvDsD4mqFupKr8VgVQotK/Jw3UbXCCukrESLQv4mv4CYbtSxtyG8 3I7yyR0CoVd2cYT2869FHtyagjFUFQb0EwjaFC+BUUVX+dUBtwZCJ5PYOOTgJwOe8XYPiS ux5BNIUwRA10lhLo7bso7Z/1UlWjnm9Y9XzmjobdNqOgideGt0sIIJkSPSJS/GOom4V4ft Id/Qzw+NAeIxPEX/rWoPgxgMbgmRTCIFYiRPTfw/FSVQubdXU+RsexnjWD6nKw6+pub1Mq FdsIuVYDbqpOF7jOkuQrPSFCW8c4M8XQeXIsd4t1tbXiyTBHMna/HMEkLECmQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706125497; a=rsa-sha256; cv=none; b=uHW130bQYFm78wGAJS7g4P4dXI0ucF1lhhK6fIZpOvS2ZoJkQ/r0/iEqhcHS/b0D4Kcu4i /kvPuV91POg8xgBbVMuswKUm01b/sIQl9JW5oPiB3XeBFHFwYVU42E++Z2SRMNxw2aNmFD t6FyhvjP0wspoR9hy7nl1NThklzfWoI89Ly8lRvyuHVzGANGVj2j8q9k+1N4ykWGcbMzuA EVAnyHeG4Qj+1gHNKOe0U5fDW7tUyyr0dwTrVvbUi/7ATalsmt8rCHcVHXOGhofZZVU4c8 Y9S9puu5ssM8bIuxU2D/vAcA4IoF9snLEg5nZghUE0ur9AVfNq3MJqDUME3smA== 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 4TKvYh67KnzRy7; Wed, 24 Jan 2024 19:44:56 +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 40OJiu2S005973; Wed, 24 Jan 2024 19:44:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40OJiuUP005970; Wed, 24 Jan 2024 19:44:56 GMT (envelope-from git) Date: Wed, 24 Jan 2024 19:44:56 GMT Message-Id: <202401241944.40OJiuUP005970@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: ddab9e646122 - stable/14 - lib/libc/amd64/string: implement strncat() by calling strlen(), memccpy() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: ddab9e646122df077570fc0dfb2af1516c098668 Auto-Submitted: auto-generated The branch stable/14 has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=ddab9e646122df077570fc0dfb2af1516c098668 commit ddab9e646122df077570fc0dfb2af1516c098668 Author: Robert Clausecker AuthorDate: 2023-12-04 17:32:49 +0000 Commit: Robert Clausecker CommitDate: 2024-01-24 19:39:30 +0000 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) --- lib/libc/amd64/string/Makefile.inc | 1 + lib/libc/amd64/string/strncat.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/libc/amd64/string/Makefile.inc b/lib/libc/amd64/string/Makefile.inc index b569d2cb8be8..a14e8a768f01 100644 --- a/lib/libc/amd64/string/Makefile.inc +++ b/lib/libc/amd64/string/Makefile.inc @@ -17,6 +17,7 @@ MDSRCS+= \ strlcat.c \ strlcpy.S \ strlen.S \ + strncat.c \ strncmp.S \ strncpy.c \ strnlen.c \ diff --git a/lib/libc/amd64/string/strncat.c b/lib/libc/amd64/string/strncat.c new file mode 100644 index 000000000000..33b278ac5e04 --- /dev/null +++ b/lib/libc/amd64/string/strncat.c @@ -0,0 +1,29 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Robert Clausecker + */ + +#include + +#include + +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); +}