diff options
5 files changed, 85 insertions, 53 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h index 4328899f13d..5f4b3925e0e 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -519,15 +519,15 @@ #define SANITIZER_INTERCEPT_NETENT SI_NETBSD #define SANITIZER_INTERCEPT_SETVBUF (SI_NETBSD || SI_FREEBSD || \ SI_LINUX || SI_MAC) -#define SANITIZER_INTERCEPT_GETMNTINFO (SI_NETBSD || SI_FREEBSD) +#define SANITIZER_INTERCEPT_GETMNTINFO (SI_NETBSD || SI_FREEBSD || SI_MAC) #define SANITIZER_INTERCEPT_MI_VECTOR_HASH SI_NETBSD #define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD #define SANITIZER_INTERCEPT_REGEX SI_NETBSD #define SANITIZER_INTERCEPT_FTS SI_NETBSD -#define SANITIZER_INTERCEPT_SYSCTL (SI_NETBSD || SI_FREEBSD) +#define SANITIZER_INTERCEPT_SYSCTL (SI_NETBSD || SI_FREEBSD || SI_MAC) #define SANITIZER_INTERCEPT_ASYSCTL SI_NETBSD #define SANITIZER_INTERCEPT_SYSCTLGETMIBINFO SI_NETBSD -#define SANITIZER_INTERCEPT_NL_LANGINFO (SI_NETBSD || SI_FREEBSD) +#define SANITIZER_INTERCEPT_NL_LANGINFO (SI_NETBSD || SI_FREEBSD || SI_MAC) #define SANITIZER_INTERCEPT_MODCTL SI_NETBSD #define SANITIZER_INTERCEPT_CAPSICUM SI_FREEBSD #define SANITIZER_INTERCEPT_STRTONUM SI_NETBSD diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/asysctl.cc b/compiler-rt/test/sanitizer_common/TestCases/NetBSD/asysctl.cc new file mode 100644 index 00000000000..acdfb17f28b --- /dev/null +++ b/compiler-rt/test/sanitizer_common/TestCases/NetBSD/asysctl.cc @@ -0,0 +1,44 @@ +// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s + +#include <sys/param.h> +#include <sys/types.h> + +#include <sys/sysctl.h> + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +void test_asysctl() { + int mib[] = {CTL_KERN, KERN_OSTYPE}; + size_t len; + char *buf = (char *)asysctl(mib, __arraycount(mib), &len); + assert(buf); + + printf("asysctl: '%s' size: '%zu'\n", buf, len); + + free(buf); +} + +void test_asysctlbyname() { + size_t len; + char *buf = (char *)asysctlbyname("kern.ostype", &len); + assert(buf); + + printf("asysctlbyname: '%s' size: '%zu'\n", buf, len); + + free(buf); +} + +int main(void) { + printf("asysctl\n"); + + test_asysctl(); + test_asysctlbyname(); + + return 0; + + // CHECK: asysctl + // CHECK: asysctl: '{{.*}}' size: '{{.*}}' + // CHECK: asysctlbyname: '{{.*}}' size: '{{.*}}' +} diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/sysctlgetmibinfo.cc b/compiler-rt/test/sanitizer_common/TestCases/NetBSD/sysctlgetmibinfo.cc new file mode 100644 index 00000000000..d81c1567fc4 --- /dev/null +++ b/compiler-rt/test/sanitizer_common/TestCases/NetBSD/sysctlgetmibinfo.cc @@ -0,0 +1,36 @@ +// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s + +#include <sys/param.h> +#include <sys/types.h> + +#include <sys/sysctl.h> + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +void test_sysctlgetmibinfo() { + int mib[CTL_MAXNAME]; + unsigned int mib_len = __arraycount(mib); + int rv = sysctlgetmibinfo("kern.ostype", &mib[0], &mib_len, NULL, NULL, NULL, + SYSCTL_VERSION); + assert(!rv); + + char buf[100]; + size_t len = sizeof(buf); + rv = sysctl(mib, mib_len, buf, &len, NULL, 0); + assert(!rv); + + printf("sysctlgetmibinfo: '%s' size: '%zu'\n", buf, len); +} + +int main(void) { + printf("sysctlgetmibinfo\n"); + + test_sysctlgetmibinfo(); + + return 0; + + // CHECK: sysctlgetmibinfo + // CHECK: sysctlgetmibinfo: '{{.*}}' size: '{{.*}}' +} diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cc index e6afa4a6076..26c065d4dd1 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cc @@ -1,6 +1,6 @@ // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s // -// UNSUPPORTED: linux, darwin, solaris +// UNSUPPORTED: linux, solaris #include <sys/types.h> diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/sysctl.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/sysctl.cc index 134ea39dc78..2cb8764f34b 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/sysctl.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/sysctl.cc @@ -1,6 +1,6 @@ // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s // -// UNSUPPORTED: linux, darwin, solaris +// UNSUPPORTED: linux, solaris #include <sys/param.h> #include <sys/types.h> @@ -48,65 +48,17 @@ void test_sysctlnametomib() { printf("sysctlnametomib: '%s' size: '%zu'\n", buf, len); } -#if defined(__NetBSD__) -void test_asysctl() { - int mib[] = {CTL_KERN, KERN_OSTYPE}; - size_t len; - char *buf = (char *)asysctl(mib, __arraycount(mib), &len); - assert(buf); - - printf("asysctl: '%s' size: '%zu'\n", buf, len); - - free(buf); -} - -void test_asysctlbyname() { - size_t len; - char *buf = (char *)asysctlbyname("kern.ostype", &len); - assert(buf); - - printf("asysctlbyname: '%s' size: '%zu'\n", buf, len); - - free(buf); -} - -void test_sysctlgetmibinfo() { - int mib[CTL_MAXNAME]; - unsigned int mib_len = __arraycount(mib); - int rv = sysctlgetmibinfo("kern.ostype", &mib[0], &mib_len, NULL, NULL, NULL, - SYSCTL_VERSION); - assert(!rv); - - char buf[100]; - size_t len = sizeof(buf); - rv = sysctl(mib, mib_len, buf, &len, NULL, 0); - assert(!rv); - - printf("sysctlgetmibinfo: '%s' size: '%zu'\n", buf, len); -} -#endif - int main(void) { printf("sysctl\n"); test_sysctl(); test_sysctlbyname(); test_sysctlnametomib(); -#if defined(__NetBSD__) - test_asysctl(); - test_asysctlbyname(); - test_sysctlgetmibinfo(); -#endif // CHECK: sysctl // CHECK: sysctl: '{{.*}}' size: '{{.*}}' // CHECK: sysctlbyname: '{{.*}}' size: '{{.*}}' // CHECK: sysctlnametomib: '{{.*}}' size: '{{.*}}' -#if defined(__NetBSD__) - // CHECK: asysctl: '{{.*}}' size: '{{.*}}' - // CHECK: asysctlbyname: '{{.*}}' size: '{{.*}}' - // CHECK: sysctlgetmibinfo: '{{.*}}' size: '{{.*}}' -#endif return 0; } |