mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Re: Custom __set_thread_area for ARM
Date: Wed, 28 Jan 2015 09:47:04 -0500	[thread overview]
Message-ID: <20150128144704.GF4574@brightrain.aerifal.cx> (raw)
In-Reply-To: <54C8200B.8060102@mit.edu>

On Tue, Jan 27, 2015 at 03:32:27PM -0800, Andy Lutomirski wrote:
> Does musl not use inline asm?  ISTM something like:

At present, only in places where it's actually intended to be inlined
efficiently -- that mainly means syscalls and reading the thread
pointer. Both of these are places where it's just an optimization, so
it could be turned off and replaced by an external function if needed.
There has been some interest in making it easy to do that to work with
compilers that don't have any GNU inline asm support, though it's not
at this time a topic of much practical interest to me since most/all
relevant compilers seem to support it.

Also, it's worth noting that some of the other things that actually
need asm (rather than just using it as an optimization) also need it
to external: especially setjmp and vfork cannot be implemented in
inline asm no matter what you do.

> struct user_desc desc;
> memset(&desc, 0, sizeof(desc));
> desc.base = whatever;
> // assign other fields
> if (set_thread_area(&desc) != 0)
>     handle error;
> 
> asm volatile ("mov %0,%%fs" : : "=rm" ((desc.entry_number << 3) | 3));
> 
> would be a lot more comprehensible.

I can see both viewpoints here, but I think the functions where a mix
of C/asm is "more comprehensible" than just asm are a fairly small
set, the difference in readability is probably small, and the compiler
would probably generate moderately larger code (large
prologue/epilogue/stack frames, etc.) so in the absence of a strong
motivation to change it I think this is probably best left alone. Note
on that x86 is pretty unique in having anything that could be made
more readable by mixing C. The other archs have fairly straightforward
set_thread_area -- either loading a GPR or making an arch-specific
syscall.

Rich


      parent reply	other threads:[~2015-01-28 14:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 20:19 Oleg Ranevskyy
2015-01-14  3:09 ` Rich Felker
2015-01-22  1:45   ` Andy Lutomirski
2015-01-22  5:10     ` Rich Felker
2015-01-27 23:32       ` Andy Lutomirski
2015-01-28  8:59         ` Szabolcs Nagy
2015-01-28 14:47         ` Rich Felker [this message]

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=20150128144704.GF4574@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).