[compiler-rt] r348770 - [Sanitizer] expand sysctl/getmntinfo/nl_langinfo to Darwin

David Carlier via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 10 08:29:30 PST 2018


Author: devnexen
Date: Mon Dec 10 08:29:30 2018
New Revision: 348770

URL: http://llvm.org/viewvc/llvm-project?rev=348770&view=rev
Log:
[Sanitizer] expand sysctl/getmntinfo/nl_langinfo to Darwin

Reviewers: vitalybuka, krytarowski, kubamracek

Reviewed By: vitalybuka, krytarowski

Differential Revision: https://reviews.llvm.org/D55473

Added:
    compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/asysctl.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/sysctlgetmibinfo.cc
Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getmntinfo.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sysctl.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=348770&r1=348769&r2=348770&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Mon Dec 10 08:29:30 2018
@@ -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

Added: compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/asysctl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/asysctl.cc?rev=348770&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/asysctl.cc (added)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/asysctl.cc Mon Dec 10 08:29:30 2018
@@ -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: '{{.*}}'
+}

Added: compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/sysctlgetmibinfo.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/sysctlgetmibinfo.cc?rev=348770&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/sysctlgetmibinfo.cc (added)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/sysctlgetmibinfo.cc Mon Dec 10 08:29:30 2018
@@ -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: '{{.*}}'
+}

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getmntinfo.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getmntinfo.cc?rev=348770&r1=348769&r2=348770&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getmntinfo.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getmntinfo.cc Mon Dec 10 08:29:30 2018
@@ -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>
 

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sysctl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sysctl.cc?rev=348770&r1=348769&r2=348770&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sysctl.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sysctl.cc Mon Dec 10 08:29:30 2018
@@ -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;
 }




More information about the llvm-commits mailing list