[compiler-rt] r350090 - [Sanitizer] Enable FTS api on FreeBSD

David Carlier via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 27 04:56:54 PST 2018


Author: devnexen
Date: Thu Dec 27 04:56:54 2018
New Revision: 350090

URL: http://llvm.org/viewvc/llvm-project?rev=350090&view=rev
Log:
[Sanitizer] Enable FTS api on FreeBSD

Reviewers: krytarowski, vitalybuka

Reviewed By: krytarowski

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

Added:
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fts.cc
      - copied, changed from r350089, compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc
Removed:
    compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc
Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h

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=350090&r1=350089&r2=350090&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Thu Dec 27 04:56:54 2018
@@ -524,7 +524,7 @@
 #define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD
 #define SANITIZER_INTERCEPT_REGEX (SI_NETBSD || SI_FREEBSD)
 #define SANITIZER_INTERCEPT_REGEXSUB SI_NETBSD
-#define SANITIZER_INTERCEPT_FTS SI_NETBSD
+#define SANITIZER_INTERCEPT_FTS (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

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc?rev=350090&r1=350089&r2=350090&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc Thu Dec 27 04:56:54 2018
@@ -18,6 +18,7 @@
 
 #include <arpa/inet.h>
 #include <dirent.h>
+#include <fts.h>
 #include <grp.h>
 #include <limits.h>
 #include <net/if.h>
@@ -128,6 +129,8 @@ namespace __sanitizer {
   unsigned struct_shm_info_sz = sizeof(struct shm_info);
   unsigned struct_regmatch_sz = sizeof(regmatch_t);
   unsigned struct_regex_sz = sizeof(regex_t);
+  unsigned struct_FTS_sz = sizeof(FTS);
+  unsigned struct_FTSENT_sz = sizeof(FTSENT);
 
   const uptr sig_ign = (uptr)SIG_IGN;
   const uptr sig_dfl = (uptr)SIG_DFL;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h?rev=350090&r1=350089&r2=350090&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h Thu Dec 27 04:56:54 2018
@@ -64,6 +64,8 @@ namespace __sanitizer {
   extern unsigned struct_timespec_sz;
   extern unsigned struct_regmatch_sz;
   extern unsigned struct_regex_sz;
+  extern unsigned struct_FTS_sz;
+  extern unsigned struct_FTSENT_sz;
   extern const int unvis_valid;
   extern const int unvis_validpush;
 

Removed: compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc?rev=350089&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc (removed)
@@ -1,40 +0,0 @@
-// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
-
-#include <sys/param.h>
-#include <sys/types.h>
-
-#include <sys/stat.h>
-
-#include <assert.h>
-#include <fts.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int main() {
-  char *const paths[] = {(char *)"/etc", 0};
-  FTS *ftsp = fts_open(paths, FTS_LOGICAL, NULL);
-  assert(ftsp);
-
-  FTSENT *chp = fts_children(ftsp, 0);
-  assert(chp);
-
-  size_t n = 0;
-  for (FTSENT *p = fts_read(ftsp); p; p = fts_read(ftsp)) {
-    /* Skip recursively subdirectories */
-    if (p->fts_info == FTS_D && p->fts_level != FTS_ROOTLEVEL) /* pre-order */
-      fts_set(ftsp, p, FTS_SKIP);
-    else if (p->fts_info == FTS_DP) /* post-order */
-      continue;
-    else if (p->fts_info == FTS_F) /* regular file */
-      n++;
-  }
-
-  int rv = fts_close(ftsp);
-  assert(!rv);
-
-  printf("Number of files in /etc: '%zu'\n", n);
-
-  return EXIT_SUCCESS;
-
-  // CHECK: Number of files in /etc: '{{.*}}'
-}

Copied: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fts.cc (from r350089, compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fts.cc?p2=compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fts.cc&p1=compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc&r1=350089&r2=350090&rev=350090&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/fts.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fts.cc Thu Dec 27 04:56:54 2018
@@ -1,4 +1,6 @@
 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
+//
+// UNSUPPORTED: linux, darwin, solaris
 
 #include <sys/param.h>
 #include <sys/types.h>




More information about the llvm-commits mailing list