This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: [PATCH] Add INLINE_SYSCALL_ERROR_RETURN


On Mon, Aug 24, 2015 at 7:35 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sat, Aug 22, 2015 at 4:24 AM, Florian Weimer <fw@deneb.enyo.de> wrote:
>> * H. J. Lu:
>>
>>> For ia32 PIC, the first thing of many syscalls does is to call
>>> __x86.get_pc_thunk.reg to load PC into reg in case there is an error,
>>> which is required for setting errno.  In most cases, there are no
>>> errors.  But we still call __x86.get_pc_thunk.reg.  This patch adds
>>> INLINE_SYSCALL_ERROR_RETURN so that i386 can optimize setting errno by
>>> branching to the internal __syscall_error without PLT.
>>>
>>> With i386 INLINE_SYSCALL_ERROR_RETURN and i386 syscall inlining
>>> optimization for GCC 5, for sysdeps/unix/sysv/linux/fchmodat.c with
>>> -O2 -march=i686 -mtune=generic, GCC 5.2 now generates:
>>
>> The patch does not seem to contain the i386 optimized
>> INLINE_SYSCALL_ERROR_RETURN definition.
>
> The followup patch is at
>
> https://sourceware.org/git/?p=glibc.git;a=commit;h=47213b3c76a4e21f490bcc0ad1e7d5ca7cf93120
>
> which contains:
>
> +#if IS_IN (libc)
> +# define INLINE_SYSCALL(name, nr, args...) \
> +  ({      \
> +    unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args);      \
> +    __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))      \
> +    ? __syscall_error (-INTERNAL_SYSCALL_ERRNO (resultvar, ))      \
> +    : (int) resultvar; })
>
> and
>
> +/* Set error number and return -1.  Return the internal function,
> +   __syscall_error, which sets errno from the negative error number
> +   and returns -1, to avoid PIC.  */
> +#undef INLINE_SYSCALL_ERROR_RETURN
> +#define INLINE_SYSCALL_ERROR_RETURN(resultvar) \
> +  __syscall_error (-(resultvar))
>
> --
> H.J.

Any other comments, feedbacks, objections?

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]