This is the mail archive of the
mailing list for the glibc project.
Re: Make sem_timedwait use FUTEX_CLOCK_REALTIME (bug 18138)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>, <triegel at redhat dot com>, <carlos at redhat dot com>
- Date: Wed, 18 Mar 2015 23:45:17 +0000
- Subject: Re: Make sem_timedwait use FUTEX_CLOCK_REALTIME (bug 18138)
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 10 dot 1503180027220 dot 9536 at digraph dot polyomino dot org dot uk>
It's come to my attention that in fact my patch does not fix the bug for
32-bit x86, since that has its own lowlevellock-futex.h which does not
The reason 32-bit x86 cannot use the generic Linux lowlevellock-futex.h
(at least, as stated in
unavailability of six-argument syscalls from C. The sixth syscall
argument goes in %ebp (the frame pointer), leaving no general-purpose
registers other than %esp free at the time of the syscall.
The effect is that using a six-argument syscall from C would require the
frame pointer to be eliminated in any function using such a syscall, as
well as requiring the compiler to handle an inline asm that leaves no
registers free other than the stack pointer.
It is or was also the case that asms clobbering the hard frame pointer do
not work with GCC; this resulted in problems for Thumb-2 glibc.
Furthermore, if you make the asms save and restore the frame pointer
internally (necessarily on the stack in the x86 case, given the lack of
other registers), you need to represent this in CFI.
The problem with representing frame pointer save and restore resulted in
Thumb-2 glibc using out-of-line syscalls; see
<https://sourceware.org/ml/libc-ports/2010-04/msg00001.html>. With DWARF
it should be possible to represent "at this point, the CFA is derived in
this way from the value saved in this stack location". It's not clear to
me, however, how that could be done in an inline asm in such a way to work
with whatever choice the compiler has made for the CFA for that function
(which might be based on either %ebp or %esp, at an offset unknown to the
inline asm) - normal register saves and restores inside inline asm are
fine, saving %ebp on the stack may be harder.
So it seems natural to me for six-argument syscalls to use an out-of-line
helper on x86, as for Thumb-2. Which options would people prefer?
For how the helper is defined:
* Some way I haven't thought of to keep the syscalls inline while having
* Out-of-line in libc, normal calling convention.
* Out-of-line in libpthread only (given the current need for such syscalls
only in libpthread), normal calling convention.
* Out-of-line in libpthread only, special calling convention.
For how it is used:
* Used in some way by the INTERNAL_SYSCALL macro for the six-argument
* Used only by some special macro in lowlevellock-futex.h.
For how large the initial fix is:
* Implement only lll_futex_timed_wait_bitset with the new facility,
deferring other futex features until there is some known case for them.
* Completely move to the generic lowlevellock-futex.h (implies making
INTERNAL_SYSCALL handle the six-argument case).
Joseph S. Myers