This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Avoid reading errno in syscall implementations
- From: Joseph Myers <joseph at codesourcery dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 19 Oct 2015 17:00:36 +0000
- Subject: Re: [PATCH] Avoid reading errno in syscall implementations
- Authentication-results: sourceware.org; auth=none
- References: <20151019164832 dot GA28619 at intel dot com>
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.)
--
Joseph S. Myers
joseph@codesourcery.com