mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: musl@lists.openwall.com
Cc: Alexander Monakov <amonakov@ispras.ru>
Subject: [PATCH] optimize explicit_bzero for size
Date: Thu, 28 Jun 2018 20:57:29 +0300	[thread overview]
Message-ID: <20180628175729.4391-1-amonakov@ispras.ru> (raw)

Avoid saving/restoring the incoming argument by reusing memset return value.
---

I think it's unfortunate that the commit adding explicit_bzero does not say
the rationale for the magic empty asm; LTO being the "obvious" explanation,
of course, IMHO is not a reason to omit the explanation. Does it imply an
intention to support LTO, and if so, would other magic asms elsewhere be
accepted if they help with LTO issues?

Alexander

 src/string/explicit_bzero.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/string/explicit_bzero.c b/src/string/explicit_bzero.c
index 3d270040..f2e12f23 100644
--- a/src/string/explicit_bzero.c
+++ b/src/string/explicit_bzero.c
@@ -3,6 +3,6 @@
 
 void explicit_bzero(void *d, size_t n)
 {
-	memset(d, 0, n);
+	d = memset(d, 0, n);
 	__asm__ __volatile__ ("" : : "r"(d) : "memory");
 }
-- 
2.11.0



             reply	other threads:[~2018-06-28 17:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28 17:57 Alexander Monakov [this message]
2018-06-28 19:35 ` Rich Felker
2018-06-28 19:42   ` David CARLIER
2018-06-28 20:21     ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180628175729.4391-1-amonakov@ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).