mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [RFC PATCH] micro-optimize __procfdname
Date: Sat, 5 Mar 2016 01:20:19 -0500	[thread overview]
Message-ID: <20160305062019.GH9349@brightrain.aerifal.cx> (raw)
In-Reply-To: <alpine.LNX.2.20.1603050906560.31711@monopod.intra.ispras.ru>

On Sat, Mar 05, 2016 at 09:14:57AM +0300, Alexander Monakov wrote:
> On Sat, 5 Mar 2016, Rich Felker wrote:
> > > make it really obvious that __procfdname_impl fills in reverse; it might be a
> > > very minor size optimization. I don't mind dropping this add adjusting buf
> > > with '+= procfdbufsize - 1' in the callee.
> > 
> > Yes, making it obvious what's going on is nice too.
> 
> I'm going to keep that adjustment in the macro for now, then.

OK.

> > Actually it would be even nicer if we could use a compound literal
> > inside the macro as the buffer, but that would pessimize with
> > unnecessary initialization and eliminate a lot of the code-size
> > benefit, I think.
> 
> Yep, I did consider that and arrived to a similar conclusion. Well, there's an
> option of using alloca as long as no use is in a loop, but that's a bit uglier,
> and as I recall it wasn't optimized to a static stack allocation.

Yeah, alloca is a lot uglier, an extra extension we don't currently
use, and not something I would want to add.

> I forgot to ask before, shouldn't __procfdname_impl have a visibility
> annotation?
> 
> And likewise for other internal functions.  There are some internal functions
> without hidden/internal visibility annotation, visible outside of libc.so.
> That seems unintended and slightly harmful.

Yes, I'd go with only _slightly_ harmful because visibility does not
help with static linking. But of course in the static case you don't
have to worry about ABI-compat with future libc versions.

I've thought about having libc.h define a macro simply named "hidden"
for declaring things with hidden visibility; then files needing it
could just include libc.h and do stuff like:

hidden char *__procfdname_impl(...);

This would be more a matter of de-uglification than abstraction. Does
anyone particularly like or hate this idea?

Rich


  reply	other threads:[~2016-03-05  6:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-21 11:41 Alexander Monakov
2016-03-05  5:24 ` Rich Felker
2016-03-05  5:42   ` Alexander Monakov
2016-03-05  5:56     ` Rich Felker
2016-03-05  6:14       ` Alexander Monakov
2016-03-05  6:20         ` Rich Felker [this message]
2016-03-05  6:35           ` Alexander Monakov
2016-03-05 15:13           ` Alexander Monakov
2016-03-05 17:30             ` Alexander Monakov

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=20160305062019.GH9349@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).