diff options
| author | Kostya Serebryany <kcc@google.com> | 2012-11-19 07:53:36 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2012-11-19 07:53:36 +0000 |
| commit | cb9f62189ba72eb30c0b468fd18c0a04470d7b14 (patch) | |
| tree | b950d18f172fe041d96408c5d6ddad5ffab5195c /compiler-rt | |
| parent | a5b0dc888469fb60f5c8b683c6bbd670ce9e7462 (diff) | |
| download | bcm5719-llvm-cb9f62189ba72eb30c0b468fd18c0a04470d7b14.tar.gz bcm5719-llvm-cb9f62189ba72eb30c0b468fd18c0a04470d7b14.zip | |
[asan] support PowerPC and SPARC in sanitizer_linux.cc
llvm-svn: 168301
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_linux.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc index 51ad4ceeef3..3f79163fca5 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc @@ -31,12 +31,22 @@ #include <unistd.h> #include <errno.h> +// Are we using 32-bit or 64-bit syscalls? +// We need to list the 64-bit architecures explicitly because for x32 +// (which defines __x86_64__) we have __WORDSIZE == 32, +// but we still need to use 64-bit syscalls. +#if defined(__x86_64__) || defined(__powerpc64__) || defined(__sparc64__) +# 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); @@ -69,7 +79,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; @@ -95,7 +105,7 @@ int internal_sched_yield() { // ----------------- sanitizer_common.h bool FileExists(const char *filename) { -#if defined __x86_64__ +#if SANITIZER_LINUX_USES_64BIT_SYSCALLS struct stat st; if (syscall(__NR_stat, filename, &st)) return false; |

