Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20150128144704.GF4574@brightrain.aerifal.cx>
Date: Wed, 28 Jan 2015 09:47:04 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: Re: Custom __set_thread_area for ARM

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.