From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11612 Path: news.gmane.org!.POSTED!not-for-mail From: Andrew Salmon Newsgroups: gmane.linux.lib.musl.general Subject: wmemcpy: call memcpy Date: Sun, 25 Jun 2017 13:44:10 -0400 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114a2df4c732f70552cc61fd" X-Trace: blaine.gmane.org 1498412668 20748 195.159.176.226 (25 Jun 2017 17:44:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 25 Jun 2017 17:44:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11625-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jun 25 19:44:24 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dPBa9-00054Q-CX for gllmg-musl@m.gmane.org; Sun, 25 Jun 2017 19:44:21 +0200 Original-Received: (qmail 1902 invoked by uid 550); 25 Jun 2017 17:44:24 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 1856 invoked from network); 25 Jun 2017 17:44:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yale.edu; s=googleprd; h=mime-version:from:date:message-id:subject:to; bh=GSOvaq6EZf6P8AtMzxFFPTc/anx0JDs5p1gWC40P9HE=; b=t/yFUu64yJGOyPo9rKv8rwFSFV8UWvb2oaW9tfyC1ZrlCzQNe3JHiddvnjfKPxnYb9 MCIZLIBuNNj8ECEQq39HESMzvx4YMcoOE1c3t1kdyBFgQt35NyDzM1t5yreIzM6cb8ry ohuSs/zpSNNGp7uHlC0EO5OE1M7lvwNkGXsT0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=GSOvaq6EZf6P8AtMzxFFPTc/anx0JDs5p1gWC40P9HE=; b=OdIvXVthuw8mcAMF0jwm8zc752BFwmHXDe8KYtuTjZmJntuilt2JX79nyCD0YRNPiy 3FjToWX3sKf1zdLKk+TvmrTmctI5RXFXbCZPqr0FgIQilmFRVieYQEzyh1oFMRCbF8L+ /vZlUZy4NYMYD1saw2hGWL/vlbysxoYm2itDh/wL8iZmsUuAD+w9lz+kqwVd0ovoDTmP 0ksY3TPJbZRcb2zlIG+cReWr7NmeKydVgdoIvjLl22i8bLQJnKMi1LdyNCaA6XuYccEp j3McIcUt+zHwN8FJWniBLOi6SrjFJhsvZOphujHBGLP0zgLbv6bRgEdZX17LpoWEYadv Xg5Q== X-Gm-Message-State: AKS2vOyj6hlBQevH7gO3+uJJ9eQ7ZxkBVNqWMXLX8p6XYVdpUeo9q1+8 uJ3c6Qca+384fPSrOIvPnSCLcipQEPeNpoI= X-Received: by 10.99.246.69 with SMTP id u5mr4752091pgj.173.1498412650752; Sun, 25 Jun 2017 10:44:10 -0700 (PDT) Xref: news.gmane.org gmane.linux.lib.musl.general:11612 Archived-At: --001a114a2df4c732f70552cc61fd Content-Type: text/plain; charset="UTF-8" Currently, wmemcpy is implemented as a loop, which the compiler aggressively optimizes. From a binary perspective it's probably cleaner to implement it as a call to memcpy. diff --git a/src/string/wmemcpy.c b/src/string/wmemcpy.c index 52e6e6e..272f37a 100644 --- a/src/string/wmemcpy.c +++ b/src/string/wmemcpy.c @@ -1,8 +1,7 @@ +#include #include wchar_t *wmemcpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n) { - wchar_t *a = d; - while (n--) *d++ = *s++; - return a; + return memcpy(d, s, n * sizeof(wchar_t)); } --001a114a2df4c732f70552cc61fd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Currently, wmemcpy is implemented as a loop, which the com= piler aggressively optimizes.=C2=A0 From a binary perspective it's prob= ably cleaner to implement it as a call to memcpy.

d= iff --git a/src/string/wmemcpy.c b/src/string/wmemcpy.c
index 52e= 6e6e..272f37a 100644
--- a/src/string/wmemcpy.c
+++ b/s= rc/string/wmemcpy.c
@@ -1,8 +1,7 @@
+#include <strin= g.h>
=C2=A0#include <wchar.h>
=C2=A0
=C2=A0wchar_t *wmemcpy(wchar_t *restrict d, const wchar_t *restrict s, siz= e_t n)
=C2=A0{
- wchar_t *a =3D d;
- while (n--) *d++ = =3D *s++;
- return a;
+ return memcpy(d, s, n * sizeof(wchar_t));=
=C2=A0}
--001a114a2df4c732f70552cc61fd--