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: [PATCH] Avoid reading errno in syscall implementations


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


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