Message ID | 20121120.155705.982750470062898456.davem@davemloft.net |
---|---|
State | New |
Headers | show |
David Miller <davem@davemloft.net> writes: > +// Are we using 32-bit or 64-bit syscalls? > +// x32 (which defines __x86_64__) has __WORDSIZE == 32 > +// but it still needs to use 64-bit syscalls. > +#if defined(__x86_64__) || __WORDSIZE == 64 I don't think it is a good idea to use a glibc-internal macro. How about __LP64__? Andreas.
On Wed, Nov 21, 2012 at 2:50 AM, Andreas Schwab <schwab@linux-m68k.org> wrote: > David Miller <davem@davemloft.net> writes: > >> +// Are we using 32-bit or 64-bit syscalls? >> +// x32 (which defines __x86_64__) has __WORDSIZE == 32 >> +// but it still needs to use 64-bit syscalls. >> +#if defined(__x86_64__) || __WORDSIZE == 64 > > I don't think it is a good idea to use a glibc-internal macro. How > about __LP64__? __WORDSIZE is used throughout the library; it is also redefined properly for the compilers which don't have it and may not have __LP64__ The upstream fix for the problem David is solving here also uses __WORDSIZE. --kcc > > Andreas. > > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 > "And now for something completely different."
Konstantin Serebryany <konstantin.s.serebryany@gmail.com> writes: > On Wed, Nov 21, 2012 at 2:50 AM, Andreas Schwab <schwab@linux-m68k.org> wrote: >> David Miller <davem@davemloft.net> writes: >> >>> +// Are we using 32-bit or 64-bit syscalls? >>> +// x32 (which defines __x86_64__) has __WORDSIZE == 32 >>> +// but it still needs to use 64-bit syscalls. >>> +#if defined(__x86_64__) || __WORDSIZE == 64 >> >> I don't think it is a good idea to use a glibc-internal macro. How >> about __LP64__? > > __WORDSIZE is used throughout the library; That doesn't make it any better. > it is also redefined > properly for the compilers which don't have it and may not have > __LP64__ ??? __WORDSIZE is only defined by glibc. __LP64__ (or _LP64) is a standard macro defined by the compiler. Andreas.
On Wed, Nov 21, 2012 at 12:23 PM, Andreas Schwab <schwab@linux-m68k.org> wrote: > Konstantin Serebryany <konstantin.s.serebryany@gmail.com> writes: > >> On Wed, Nov 21, 2012 at 2:50 AM, Andreas Schwab <schwab@linux-m68k.org> wrote: >>> David Miller <davem@davemloft.net> writes: >>> >>>> +// Are we using 32-bit or 64-bit syscalls? >>>> +// x32 (which defines __x86_64__) has __WORDSIZE == 32 >>>> +// but it still needs to use 64-bit syscalls. >>>> +#if defined(__x86_64__) || __WORDSIZE == 64 >>> >>> I don't think it is a good idea to use a glibc-internal macro. How >>> about __LP64__? >> >> __WORDSIZE is used throughout the library; > > That doesn't make it any better. > >> it is also redefined >> properly for the compilers which don't have it and may not have >> __LP64__ > > ??? __WORDSIZE is only defined by glibc. __LP64__ (or _LP64) is a > standard macro defined by the compiler. libsanitizer is a third party library, its primary repository is not gcc. If we make such change (use __LP64__ instead of __WORDSIZE), we should make it upstream first. --kcc > > Andreas. > > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 > "And now for something completely different."
On Wed, Nov 21, 2012 at 04:10:24PM +0400, Konstantin Serebryany wrote: > >> it is also redefined > >> properly for the compilers which don't have it and may not have > >> __LP64__ > > > > ??? __WORDSIZE is only defined by glibc. __LP64__ (or _LP64) is a > > standard macro defined by the compiler. > > libsanitizer is a third party library, its primary repository is not gcc. > If we make such change (use __LP64__ instead of __WORDSIZE), we should > make it upstream first. That is true, but it really should change, __WORDSIZE is a glibc private macro that other programs just shouldn't use. Jakub
>> >> libsanitizer is a third party library, its primary repository is not gcc. >> If we make such change (use __LP64__ instead of __WORDSIZE), we should >> make it upstream first. > > That is true, but it really should change, __WORDSIZE is a glibc private > macro that other programs just shouldn't use. Ok... I've committed http://llvm.org/viewvc/llvm-project?view=rev&revision=168424 upstream. (This defines SANITIZER_WORDSIZE based on __LP64__ and WIN64). --kcc
Konstantin Serebryany <konstantin.s.serebryany@gmail.com> writes:
> libsanitizer is a third party library, its primary repository is not gcc.
_LP64 is also defined by other compilers.
Andreas.
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index 7aade50..22f65b2 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,10 @@ +2012-11-20 Konstantin Serebryany <konstantin.s.serebryany@gmail.com> + + * sanitizer_common/sanitizer_linux.cc + (SANITIZER_LINUX_USES_64BIT_SYSCALLS): Define. + (internal_mmap): Use it. + (internal_filesize): Likewise. + 2012-11-16 Tom Tromey <tromey@redhat.com> * configure.ac: Invoke AM_MAINTAINER_MODE. diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc index e90a68c..f2a0d39 100644 --- a/libsanitizer/sanitizer_common/sanitizer_linux.cc +++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc @@ -29,12 +29,21 @@ #include <unistd.h> #include <errno.h> +// Are we using 32-bit or 64-bit syscalls? +// x32 (which defines __x86_64__) has __WORDSIZE == 32 +// but it still needs to use 64-bit syscalls. +#if defined(__x86_64__) || __WORDSIZE == 64 +# define SANITIZER_LINUX_USES_64BIT_SYSCALLS 1 +#else +# define SANITIZER_LINUX_USES_64BIT_SYSCALLS 0 +#endif + namespace __sanitizer { // --------------- sanitizer_libc.h void *internal_mmap(void *addr, uptr length, int prot, int flags, int fd, u64 offset) { -#if defined __x86_64__ +#if SANITIZER_LINUX_USES_64BIT_SYSCALLS return (void *)syscall(__NR_mmap, addr, length, prot, flags, fd, offset); #else return (void *)syscall(__NR_mmap2, addr, length, prot, flags, fd, offset); @@ -67,7 +76,7 @@ uptr internal_write(fd_t fd, const void *buf, uptr count) { } uptr internal_filesize(fd_t fd) { -#if defined __x86_64__ +#if SANITIZER_LINUX_USES_64BIT_SYSCALLS struct stat st; if (syscall(__NR_fstat, fd, &st)) return -1;