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 2/6] Use INLINE_SYSCALL_ERROR_RETURN


On Tue, Oct 13, 2015 at 6:49 AM, Andreas Schwab <schwab@suse.de> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> diff --git a/sysdeps/unix/sysv/linux/mmap64.c b/sysdeps/unix/sysv/linux/mmap64.c
>> index 1c9d3c1..8d5b0a4 100644
>> --- a/sysdeps/unix/sysv/linux/mmap64.c
>> +++ b/sysdeps/unix/sysv/linux/mmap64.c
>> @@ -46,7 +46,7 @@ __mmap64 (void *addr, size_t len, int prot, int
>> flags, int fd, off64_t offset)
>>      }
>>  #endif
>>    if (offset & ((1 << page_shift) - 1))
>> -    return (void *) INLINE_SYSCALL_ERROR_RETURN (EINVAL);
>> +    return (void *) (ptrdiff_t) INLINE_SYSCALL_ERROR_RETURN (EINVAL);
>
> That's doesn't look like a good change, since you lose the warning if
> INLINE_SYSCALL_ERROR_RETURN returns something different from the size of
> a pointer.
>

INLINE_SYSCALL_ERROR_RETURN always returns -1 and we want
to cast -1 to (void *).  I tried:

[hjl@gnu-tools-1 tmp]$ cat x.c
void *p;

void
foo (void)
{
  p = (void *) -1;
}
[hjl@gnu-tools-1 tmp]$ gcc -S -O2 x.c
[hjl@gnu-tools-1 tmp]$ cat x.s
.file "x.c"
.section .text.unlikely,"ax",@progbits
.LCOLDB0:
.text
.LHOTB0:
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movq $-1, p(%rip)
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.section .text.unlikely
.LCOLDE0:
.text
.LHOTE0:
.comm p,8,8
.ident "GCC: (GNU) 5.2.1 20150929 (Red Hat 5.2.1-3)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-tools-1 tmp]$

It looks (ptrdiff_t) isn't needed.

-- 
H.J.


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