Index: lib/sanitizer_common/sanitizer_linux.cc =================================================================== --- lib/sanitizer_common/sanitizer_linux.cc +++ lib/sanitizer_common/sanitizer_linux.cc @@ -188,11 +188,11 @@ #if !SANITIZER_OPENBSD uptr internal_munmap(void *addr, uptr length) { - return internal_syscall_ptr(SYSCALL(munmap), (uptr)addr, length); + return internal_syscall(SYSCALL(munmap), (uptr)addr, length); } int internal_mprotect(void *addr, uptr length, int prot) { - return internal_syscall_ptr(SYSCALL(mprotect), (uptr)addr, length, prot); + return internal_syscall(SYSCALL(mprotect), (uptr)addr, length, prot); } #endif @@ -204,7 +204,7 @@ #if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS return internal_syscall(SYSCALL(openat), AT_FDCWD, (uptr)filename, flags); #else - return internal_syscall_ptr(SYSCALL(open), (uptr)filename, flags); + return internal_syscall(SYSCALL(open), (uptr)filename, flags); #endif } @@ -213,21 +213,21 @@ return internal_syscall(SYSCALL(openat), AT_FDCWD, (uptr)filename, flags, mode); #else - return internal_syscall_ptr(SYSCALL(open), (uptr)filename, flags, mode); + return internal_syscall(SYSCALL(open), (uptr)filename, flags, mode); #endif } uptr internal_read(fd_t fd, void *buf, uptr count) { sptr res; - HANDLE_EINTR(res, (sptr)internal_syscall_ptr(SYSCALL(read), fd, (uptr)buf, - count)); + HANDLE_EINTR(res, + (sptr)internal_syscall(SYSCALL(read), fd, (uptr)buf, count)); return res; } uptr internal_write(fd_t fd, const void *buf, uptr count) { sptr res; - HANDLE_EINTR(res, (sptr)internal_syscall_ptr(SYSCALL(write), fd, (uptr)buf, - count)); + HANDLE_EINTR(res, + (sptr)internal_syscall(SYSCALL(write), fd, (uptr)buf, count)); return res; } @@ -307,8 +307,7 @@ uptr internal_stat(const char *path, void *buf) { #if SANITIZER_FREEBSD || SANITIZER_OPENBSD - return internal_syscall_ptr(SYSCALL(fstatat), AT_FDCWD, (uptr)path, (uptr)buf, - 0); + return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path, (uptr)buf, 0); #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf, 0); @@ -365,7 +364,7 @@ kernel_stat_to_stat(&kbuf, (struct stat *)buf); return res; # else - return internal_syscall_ptr(SYSCALL(fstat), fd, (uptr)buf); + return internal_syscall(SYSCALL(fstat), fd, (uptr)buf); # endif #else struct stat64 buf64; @@ -395,10 +394,10 @@ return internal_syscall(SYSCALL(readlinkat), AT_FDCWD, (uptr)path, (uptr)buf, bufsize); #elif SANITIZER_OPENBSD - return internal_syscall_ptr(SYSCALL(readlinkat), AT_FDCWD, (uptr)path, - (uptr)buf, bufsize); + return internal_syscall(SYSCALL(readlinkat), AT_FDCWD, (uptr)path, (uptr)buf, + bufsize); #else - return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize); + return internal_syscall(SYSCALL(readlink), path, buf, bufsize); #endif } @@ -406,7 +405,7 @@ #if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS || SANITIZER_OPENBSD return internal_syscall(SYSCALL(unlinkat), AT_FDCWD, (uptr)path, 0); #else - return internal_syscall_ptr(SYSCALL(unlink), (uptr)path); + return internal_syscall(SYSCALL(unlink), (uptr)path); #endif } @@ -415,7 +414,7 @@ return internal_syscall(SYSCALL(renameat), AT_FDCWD, (uptr)oldpath, AT_FDCWD, (uptr)newpath); #else - return internal_syscall_ptr(SYSCALL(rename), (uptr)oldpath, (uptr)newpath); + return internal_syscall(SYSCALL(rename), (uptr)oldpath, (uptr)newpath); #endif } @@ -436,15 +435,15 @@ struct timespec ts; ts.tv_sec = 1; ts.tv_nsec = 0; - int res = internal_syscall_ptr(SYSCALL(nanosleep), &ts, &ts); + int res = internal_syscall(SYSCALL(nanosleep), &ts, &ts); if (res) return ts.tv_sec; return 0; } uptr internal_execve(const char *filename, char *const argv[], char *const envp[]) { - return internal_syscall_ptr(SYSCALL(execve), (uptr)filename, (uptr)argv, - (uptr)envp); + return internal_syscall(SYSCALL(execve), (uptr)filename, (uptr)argv, + (uptr)envp); } #endif // !SANITIZER_SOLARIS && !SANITIZER_NETBSD @@ -499,12 +498,12 @@ kernel_timeval tv; #endif internal_memset(&tv, 0, sizeof(tv)); - internal_syscall_ptr(SYSCALL(gettimeofday), &tv, 0); + internal_syscall(SYSCALL(gettimeofday), &tv, 0); return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000; } uptr internal_clock_gettime(__sanitizer_clockid_t clk_id, void *tp) { - return internal_syscall_ptr(SYSCALL(clock_gettime), clk_id, tp); + return internal_syscall(SYSCALL(clock_gettime), clk_id, tp); } #endif // !SANITIZER_SOLARIS && !SANITIZER_NETBSD @@ -742,7 +741,7 @@ } uptr internal_waitpid(int pid, int *status, int options) { - return internal_syscall_ptr(SYSCALL(wait4), pid, (uptr)status, options, + return internal_syscall(SYSCALL(wait4), pid, (uptr)status, options, 0 /* rusage */); } @@ -760,7 +759,7 @@ #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count); #else - return internal_syscall_ptr(SYSCALL(getdents), fd, (uptr)dirp, count); + return internal_syscall(SYSCALL(getdents), fd, (uptr)dirp, count); #endif } @@ -775,7 +774,7 @@ #endif uptr internal_sigaltstack(const void *ss, void *oss) { - return internal_syscall_ptr(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss); + return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss); } int internal_fork() { @@ -878,7 +877,7 @@ uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset) { #if SANITIZER_FREEBSD || SANITIZER_OPENBSD - return internal_syscall_ptr(SYSCALL(sigprocmask), how, set, oldset); + return internal_syscall(SYSCALL(sigprocmask), how, set, oldset); #else __sanitizer_kernel_sigset_t *k_set = (__sanitizer_kernel_sigset_t *)set; __sanitizer_kernel_sigset_t *k_oldset = (__sanitizer_kernel_sigset_t *)oldset; Index: lib/sanitizer_common/sanitizer_syscall_generic.inc =================================================================== --- lib/sanitizer_common/sanitizer_syscall_generic.inc +++ lib/sanitizer_common/sanitizer_syscall_generic.inc @@ -11,46 +11,21 @@ // //===----------------------------------------------------------------------===// -#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD || \ - SANITIZER_OPENBSD || SANITIZER_SOLARIS +// NetBSD uses libc calls directly +#if !SANITIZER_NETBSD + +#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_OPENBSD || SANITIZER_SOLARIS # define SYSCALL(name) SYS_ ## name #else # define SYSCALL(name) __NR_ ## name #endif -#if SANITIZER_NETBSD -// We use 3 kinds of internal_syscall's for different types of retval in order -// to address differences in calling conventions (e.g. registers to place the -// return value in). -// - internal_syscall for 32-bit length (int, pid_t) -// - internal_syscall64 for 64-bit length (off_t) -// - internal_syscall_ptr for pointer and (s)size_t -# define internal_syscall syscall -# define internal_syscall64 __syscall -// Handle syscall renames manually -# define SYS_stat SYS___stat50 -# define SYS_lstat SYS___lstat50 -# define SYS_fstat SYS___fstat50 -# define SYS_gettimeofday SYS___gettimeofday50 -# define SYS_wait4 SYS___wait450 -# define SYS_getdents SYS___getdents30 -# define SYS_sigaltstack SYS___sigaltstack14 -# define SYS_sigprocmask SYS___sigprocmask14 -# define SYS_nanosleep SYS___nanosleep50 -# define SYS_clock_gettime SYS___clock_gettime50 -# if SANITIZER_WORDSIZE == 64 -# define internal_syscall_ptr __syscall -# else -# define internal_syscall_ptr syscall -# endif -#elif defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC) +#if defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC) # define internal_syscall __syscall -# define internal_syscall64 __syscall -# define internal_syscall_ptr __syscall # else # define internal_syscall syscall -# define internal_syscall64 syscall -# define internal_syscall_ptr syscall +#endif + #endif bool internal_iserror(uptr retval, int *rverrno) { Index: lib/sanitizer_common/sanitizer_syscall_linux_aarch64.inc =================================================================== --- lib/sanitizer_common/sanitizer_syscall_linux_aarch64.inc +++ lib/sanitizer_common/sanitizer_syscall_linux_aarch64.inc @@ -127,9 +127,6 @@ #define internal_syscall(...) __SYSCALL_DISP(__internal_syscall, __VA_ARGS__) -#define internal_syscall_ptr internal_syscall -#define internal_syscall64 internal_syscall - // Helper function used to avoid cobbler errno. bool internal_iserror(uptr retval, int *rverrno) { if (retval >= (uptr)-4095) { Index: lib/sanitizer_common/sanitizer_syscall_linux_arm.inc =================================================================== --- lib/sanitizer_common/sanitizer_syscall_linux_arm.inc +++ lib/sanitizer_common/sanitizer_syscall_linux_arm.inc @@ -127,9 +127,6 @@ #define internal_syscall(...) __SYSCALL_DISP(__internal_syscall, __VA_ARGS__) -#define internal_syscall_ptr internal_syscall -#define internal_syscall64 internal_syscall - // Helper function used to avoid cobbler errno. bool internal_iserror(uptr retval, int *rverrno) { if (retval >= (uptr)-4095) { Index: lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc =================================================================== --- lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc +++ lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc @@ -20,9 +20,6 @@ return retval; } -#define internal_syscall_ptr internal_syscall -#define internal_syscall64 internal_syscall - template static uptr internal_syscall(u64 nr, T1 arg1) { u64 retval;