Skip to content

Commit

Permalink
Fix sanitizer build on sparc64.
Browse files Browse the repository at this point in the history
	* sanitizer_common/sanitizer_linux.cc
	(SANITIZER_LINUX_USES_64BIT_SYSCALLS): Define.
	(internal_mmap): Use it.
	(internal_filesize): Likewise.

From-SVN: r193676
  • Loading branch information
kcc authored and David S. Miller committed Nov 20, 2012
1 parent 26da79f commit b014e12
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions libsanitizer/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2012-11-20 Konstantin Serebryany <[email protected]>

* sanitizer_common/sanitizer_linux.cc
(SANITIZER_LINUX_USES_64BIT_SYSCALLS): Define.
(internal_mmap): Use it.
(internal_filesize): Likewise.

2012-11-16 Tom Tromey <[email protected]>

* configure.ac: Invoke AM_MAINTAINER_MODE.
Expand Down
13 changes: 11 additions & 2 deletions libsanitizer/sanitizer_common/sanitizer_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b014e12

Please sign in to comment.