[PATCH 02/23] linux: Replace INTERNAL_SYSCALL_ERROR_P macro with a inline function

Adhemerval Zanella adhemerval.zanella@linaro.org
Wed Nov 11 16:30:41 GMT 2020



On 10/11/2020 08:27, Florian Weimer wrote:
> I believe this leads to a miscompilation of lseek on x86-64 x32.  The
> generic syscall_error will ignore top half of the lseek system call
> result there.

The x32 lseek is provided by the arch-specific inloine assembly:

  sysdeps/unix/sysv/linux/x86_64/x32/lseek.S

I have a patchset that moves a lot of assembly implementations that issues
syscalls to C counter-parts and I think since lseek is an outlier it would
be better to provide a arch-specific implementation than parametrize
the generic internal syscall interface to return a 64-bit value for x32
(which might pessimize code generation).

> 
> I suspect that many of the conditions could be changed to ret == 0 or
> ret < 0 (using a signed type for ret, i.e. not what comes from
> INTERNAL_SYSCALL_CALL), resulting in better code.

I do agree and I was doubtful that syscall_error is indeed useful.
In the end I decided to make this change more mechanical and thus
add a direct replacement for INTERNAL_YSCALL_ERROR_P.

Maybe it would be better to just check for 'ret' value directly
instead of using an auxiliary value.


More information about the Libc-alpha mailing list