This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: [PATCH] Add INLINE_SYSCALL_ERROR_RETURN
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 24 Aug 2015 07:35:52 -0700
- Subject: Re: RFC: [PATCH] Add INLINE_SYSCALL_ERROR_RETURN
- Authentication-results: sourceware.org; auth=none
- References: <20150821223858 dot GA3889 at intel dot com> <87lhd3zhtv dot fsf at mid dot deneb dot enyo dot de>
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.