[PATCH] Avoid reading errno in syscall implementations
H.J. Lu
hjl.tools@gmail.com
Mon Oct 19 17:49:00 GMT 2015
On Mon, Oct 19, 2015 at 10:00 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Mon, 19 Oct 2015, H.J. Lu wrote:
>
>> Reading errno is expensive for x86 PIC. With INTERNAL_SYSCALL,
>> INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO and
>> INLINE_SYSCALL_ERROR_RETURN_VALUE, we can avoid reading errno.
>
> I don't follow how this patch works. How do you ensure that in the cases
> where there is an error that is not ENOSYS, errno does get set as it would
> have been before?
>
>> - int res = INLINE_SYSCALL (eventfd2, 2, count, flags);
>> # ifndef __ASSUME_EVENTFD2
>> - if (res != -1 || errno != ENOSYS)
>> -# endif
>> + INTERNAL_SYSCALL_DECL (err);
>> + int res = INTERNAL_SYSCALL (eventfd2, err, 2, count, flags);
>> + if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))
>> + || INTERNAL_SYSCALL_ERRNO (res, err) != ENOSYS)
>> return res;
>
> E.g. this appears to be semantically different from the previous code -
> the previous code would have set errno here from a non-ENOSYS error, and
> the new code wouldn't.
>
> (__ASSUME_EVENTFD2 is always defined except on alpha. Presumably your "no
> code changes" was because code paths used on x86_64 didn't get changed by
> the patch.)
Here is the updated patch. Only getrlimit64.os and setrlimit64.os
are changed on i686. OK for master?
Thanks.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Avoid-reading-errno-in-syscall-implementations.patch
Type: text/x-patch
Size: 7794 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20151019/2f0bb6b2/attachment.bin>
More information about the Libc-alpha
mailing list