This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] tst-setcontext2: avoid bug from compiler optimization
On Wed, 25 Jan 2017, Chris Metcalf wrote:
> I'm not sure we need or want the returns_twice attribute, given that
> gcc already has special code for recognizing setjmp, vfork, etc. Currently
> glibc does not use the returns_twice attribute anywhere in its source tree.
> If getcontext or swapcontext is missing from gcc (and I don't know that
> it is) then presumably it's a gcc bug.
Recognizing based on function names and setting ECF_* is definitely an
obsolescent approach in GCC, compared to the approach of GCC defining
built-in functions using the appropriate attributes (and defining built-in
functions is problematic for some of these functions because of the
header-defined types involved in the function prototypes). Defining
built-in functions has the limitation of not providing the attribute with
-fno-builtin.
Where an attribute is needed for correctness, as here, it should be
included in the glibc headers. GCC could then in future eliminate the
special_function_p special-casing, replacing it either by built-in
functions or by making fixincludes add the attribute to headers that don't
already have it.
(Should clone have this attribute, just like vfork? If so, that's a case
missing from GCC.)
--
Joseph S. Myers
joseph@codesourcery.com