Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc @@ -591,7 +591,7 @@ // this information. See also . ps_strings *pss; size_t sz = sizeof(pss); - if (sysctlbyname("kern.ps_strings", &pss, &sz, NULL, 0) == -1) { + if (internal_sysctlbyname("kern.ps_strings", &pss, &sz, NULL, 0) == -1) { Printf("sysctl kern.ps_strings failed\n"); Die(); } @@ -796,6 +796,16 @@ return sysctl(name, namelen, oldp, (size_t *)oldlenp, newp, (size_t)newlen); #endif } + +int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp, + const void *newp, uptr newlen) { +#if SANITIZER_OPENBSD + return sysctlbyname(sname, oldp, (size_t *)oldlenp, (void *)newp, + (size_t)newlen); +#else + return sysctlbyname(sname, oldp, (size_t *)oldlenp, newp, (size_t)newlen); +#endif +} #endif #if SANITIZER_LINUX Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc @@ -219,6 +219,12 @@ const_cast(newp), (size_t)newlen); } +int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp, + const void *newp, uptr newlen) { + return sysctlbyname(sname, oldp, (size_t *)oldlenp, const_cast(newp), + (size_t)newlen); +} + int internal_forkpty(int *amaster) { int master, slave; if (openpty(&master, &slave, nullptr, nullptr, nullptr) == -1) return -1; Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_netbsd.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_netbsd.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_netbsd.cc @@ -297,6 +297,14 @@ return __sysctl(name, namelen, oldp, (size_t *)oldlenp, newp, (size_t)newlen); } +DEFINE_INTERNAL(int, sysctlbyname, const char *sname, void *oldp, uptr *oldlenp, + const void *newp, uptr newlen) { + DEFINE__REAL(int, sysctlbyname, const char *a, void *b, size_t *c, + const void *d, size_t e); + return _REAL(sysctlbyname, sname, oldp, (size_t *)oldlenp, newp, + (size_t)newlen); +} + DEFINE_INTERNAL(uptr, sigprocmask, int how, __sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset) { CHECK(&_sys___sigprocmask14); Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h @@ -62,6 +62,8 @@ int internal_sysctl(const int *name, unsigned int namelen, void *oldp, uptr *oldlenp, const void *newp, uptr newlen); +int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp, + const void *newp, uptr newlen); // These functions call appropriate pthread_ functions directly, bypassing // the interceptor. They are weak and may not be present in some tools. Index: compiler-rt/trunk/lib/xray/xray_x86_64.cc =================================================================== --- compiler-rt/trunk/lib/xray/xray_x86_64.cc +++ compiler-rt/trunk/lib/xray/xray_x86_64.cc @@ -1,5 +1,6 @@ #include "cpuid.h" #include "sanitizer_common/sanitizer_common.h" +#include "sanitizer_common/sanitizer_posix.h" #include "xray_defs.h" #include "xray_interface_internal.h" @@ -87,14 +88,14 @@ size_t tscfreqsz = sizeof(TSCFrequency); #if SANITIZER_OPENBSD int Mib[2] = { CTL_MACHDEP, CPU_TSCFREQ }; - if (sysctl(Mib, 2, &TSCFrequency, &tscfreqsz, NULL, 0) != -1) { + if (internal_sysctl(Mib, 2, &TSCFrequency, &tscfreqsz, NULL, 0) != -1) { #elif SANITIZER_MAC - if (sysctlbyname("machdep.tsc.frequency", &TSCFrequency, &tscfreqsz, - NULL, 0) != -1 ) { + if (internal_sysctlbyname("machdep.tsc.frequency", &TSCFrequency, + &tscfreqsz, NULL, 0) != -1) { #else - if (sysctlbyname("machdep.tsc_freq", &TSCFrequency, &tscfreqsz, - NULL, 0) != -1) { + if (internal_sysctlbyname("machdep.tsc_freq", &TSCFrequency, &tscfreqsz, + NULL, 0) != -1) { #endif return static_cast(TSCFrequency); } else {