[compiler-rt] r349762 - [Sanitizer] Enable vis api on FreeBSD

David Carlier via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 20 06:25:43 PST 2018


Author: devnexen
Date: Thu Dec 20 06:25:43 2018
New Revision: 349762

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

Reviewers: krytarowski

Reviewed By: krytarowski

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

Added:
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/vis.cc
      - copied, changed from r349761, compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.cc
Removed:
    compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.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=349762&r1=349761&r2=349762&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 20 06:25:43 2018
@@ -543,6 +543,6 @@
 #define SANITIZER_INTERCEPT_MD2 SI_NETBSD
 #define SANITIZER_INTERCEPT_SHA2 SI_NETBSD
 #define SANITIZER_INTERCEPT_CDB SI_NETBSD
-#define SANITIZER_INTERCEPT_VIS SI_NETBSD
+#define SANITIZER_INTERCEPT_VIS (SI_NETBSD || SI_FREEBSD)
 
 #endif  // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H

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=349762&r1=349761&r2=349762&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 20 06:25:43 2018
@@ -65,6 +65,7 @@
 #include <term.h>
 #include <utmpx.h>
 #include <wchar.h>
+#include <vis.h>
 
 #define _KERNEL  // to declare 'shminfo' structure
 # include <sys/shm.h>
@@ -338,6 +339,8 @@ namespace __sanitizer {
 
   const int si_SEGV_MAPERR = SEGV_MAPERR;
   const int si_SEGV_ACCERR = SEGV_ACCERR;
+  const int unvis_valid = UNVIS_VALID;
+  const int unvis_validpush = UNVIS_VALIDPUSH;
 } // namespace __sanitizer
 
 using namespace __sanitizer;

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=349762&r1=349761&r2=349762&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 20 06:25:43 2018
@@ -62,6 +62,8 @@ namespace __sanitizer {
   extern unsigned struct_rlimit_sz;
   extern unsigned struct_utimbuf_sz;
   extern unsigned struct_timespec_sz;
+  extern const int unvis_valid;
+  extern const int unvis_validpush;
 
   struct __sanitizer_iocb {
     u64   aio_data;

Removed: compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.cc?rev=349761&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.cc (removed)
@@ -1,245 +0,0 @@
-// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
-
-#include <ctype.h>
-#include <err.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <vis.h>
-
-void test_vis() {
-  char visout[5];
-  int ch = toascii(0x1);
-  vis(visout, ch, VIS_SAFE | VIS_NOSLASH, 0);
-  printf("vis: %s\n", visout);
-}
-
-void test_nvis() {
-  char visout[5];
-  int ch = toascii(0x2);
-  nvis(visout, sizeof visout, ch, VIS_SAFE | VIS_NOSLASH, 0);
-  printf("nvis: %s\n", visout);
-}
-
-void test_strvis() {
-  char visout[5];
-  strvis(visout, "\3", VIS_SAFE | VIS_NOSLASH);
-  printf("strvis: %s\n", visout);
-}
-
-void test_stravis() {
-  char *visout;
-  stravis(&visout, "\4", VIS_SAFE | VIS_NOSLASH);
-  printf("stravis: %s\n", visout);
-  free(visout);
-}
-
-void test_strnvis() {
-  char visout[5];
-  strnvis(visout, sizeof visout, "\5", VIS_SAFE | VIS_NOSLASH);
-  printf("strnvis: %s\n", visout);
-}
-
-void test_strvisx() {
-  char visout[5];
-  char src[] = "\6";
-  strvisx(visout, src, sizeof src - 1 /* skip final \0 */,
-          VIS_SAFE | VIS_NOSLASH);
-  printf("strvisx: %s\n", visout);
-}
-
-void test_strnvisx() {
-  char visout[5];
-  char src[] = "\1";
-  strnvisx(visout, sizeof visout, src, sizeof src - 1 /* skip final \0 */,
-           VIS_SAFE | VIS_NOSLASH);
-  printf("strnvisx: %s\n", visout);
-}
-
-void test_strenvisx() {
-  char visout[5];
-  char src[] = "\2";
-  strenvisx(visout, sizeof visout, src, sizeof src - 1 /* skip final \0 */,
-            VIS_SAFE | VIS_NOSLASH, NULL);
-  printf("strenvisx: %s\n", visout);
-}
-
-void test_svis() {
-  char visout[5];
-  int ch = toascii(0x3);
-  svis(visout, ch, VIS_SAFE | VIS_NOSLASH, 0, "x");
-  printf("svis: %s\n", visout);
-}
-
-void test_snvis() {
-  char visout[5];
-  int ch = toascii(0x2);
-  snvis(visout, sizeof visout, ch, VIS_SAFE | VIS_NOSLASH, 0, "x");
-  printf("snvis: %s\n", visout);
-}
-
-void test_strsvis() {
-  char visout[5];
-  strsvis(visout, "\4", VIS_SAFE | VIS_NOSLASH, "x");
-  printf("strsvis: %s\n", visout);
-}
-
-void test_strsnvis() {
-  char visout[5];
-  strsnvis(visout, sizeof visout, "\5", VIS_SAFE | VIS_NOSLASH, "x");
-  printf("strsnvis: %s\n", visout);
-}
-
-void test_strsvisx() {
-  char visout[5];
-  char src[] = "\5";
-  strsvisx(visout, src, sizeof src - 1 /* skip final \0 */,
-           VIS_SAFE | VIS_NOSLASH, "x");
-  printf("strsvisx: %s\n", visout);
-}
-
-void test_strsnvisx() {
-  char visout[5];
-  char src[] = "\6";
-  strsnvisx(visout, sizeof visout, src, sizeof src - 1 /* skip final \0 */,
-            VIS_SAFE | VIS_NOSLASH, "x");
-  printf("strsnvisx: %s\n", visout);
-}
-
-void test_strsenvisx() {
-  char visout[5];
-  char src[] = "\1";
-  strsenvisx(visout, sizeof visout, src, sizeof src - 1 /* skip final \0 */,
-             VIS_SAFE | VIS_NOSLASH, "x", NULL);
-  printf("strsenvisx: %s\n", visout);
-}
-
-void test_unvis() {
-  char visout[5];
-  int ch = toascii(0x1);
-  vis(visout, ch, VIS_SAFE, 0);
-
-  int state = 0;
-  char out;
-  char *p = visout;
-  while ((ch = *(p++)) != '\0') {
-  again:
-    switch (unvis(&out, ch, &state, 0)) {
-    case 0:
-    case UNVIS_NOCHAR:
-      break;
-    case UNVIS_VALID:
-      printf("unvis: %" PRIx8 "\n", (unsigned char)out);
-      break;
-    case UNVIS_VALIDPUSH:
-      printf("unvis: %" PRIx8 "\n", (unsigned char)out);
-      goto again;
-    case UNVIS_SYNBAD:
-      errx(1, "Bad character sequence!");
-    }
-  }
-  if (unvis(&out, '\0', &state, UNVIS_END) == UNVIS_VALID)
-    printf("unvis: %" PRIx8 "\n", (unsigned char)out);
-}
-
-void test_strunvis() {
-  char visout[5];
-  int ch = toascii(0x2);
-  vis(visout, ch, VIS_SAFE, 0);
-
-  char p[5];
-  strunvis(p, visout);
-
-  char *pp = p;
-  while ((ch = *(pp++)) != '\0')
-    printf("strunvis: %" PRIx8 "\n", (unsigned char)ch);
-}
-
-void test_strnunvis() {
-  char visout[5];
-  int ch = toascii(0x3);
-  vis(visout, ch, VIS_SAFE, 0);
-
-  char p[5];
-  strnunvis(p, sizeof p, visout);
-
-  char *pp = p;
-  while ((ch = *(pp++)) != '\0')
-    printf("strnunvis: %" PRIx8 "\n", (unsigned char)ch);
-}
-
-void test_strunvisx() {
-  char visout[5];
-  int ch = toascii(0x4);
-  vis(visout, ch, VIS_SAFE, 0);
-
-  char p[5];
-  strunvisx(p, visout, VIS_SAFE);
-
-  char *pp = p;
-  while ((ch = *(pp++)) != '\0')
-    printf("strunvisx: %" PRIx8 "\n", (unsigned char)ch);
-}
-
-void test_strnunvisx() {
-  char visout[5];
-  int ch = toascii(0x5);
-  vis(visout, ch, VIS_SAFE, 0);
-
-  char p[5];
-  strnunvisx(p, sizeof p, visout, VIS_SAFE);
-
-  char *pp = p;
-  while ((ch = *(pp++)) != '\0')
-    printf("strnunvisx: %" PRIx8 "\n", (unsigned char)ch);
-}
-
-int main(void) {
-  printf("vis\n");
-
-  test_vis();
-  test_nvis();
-  test_strvis();
-  test_stravis();
-  test_strnvis();
-  test_strvisx();
-  test_strnvisx();
-  test_strenvisx();
-  test_svis();
-  test_snvis();
-  test_strsvis();
-  test_strsnvis();
-  test_strsvisx();
-  test_strsnvisx();
-  test_strsenvisx();
-  test_unvis();
-  test_strunvis();
-  test_strnunvis();
-  test_strunvisx();
-  test_strnunvisx();
-
-  // CHECK: vis
-  // CHECK: vis: ^A
-  // CHECK: nvis: ^B
-  // CHECK: strvis: ^C
-  // CHECK: stravis: ^D
-  // CHECK: strnvis: ^E
-  // CHECK: strvisx: ^F
-  // CHECK: strnvisx: ^A
-  // CHECK: strenvisx: ^B
-  // CHECK: svis: ^C
-  // CHECK: snvis: ^B
-  // CHECK: strsvis: ^D
-  // CHECK: strsnvis: ^E
-  // CHECK: strsvisx: ^E
-  // CHECK: strsnvisx: ^F
-  // CHECK: strsenvisx: ^A
-  // CHECK: unvis: 1
-  // CHECK: strunvis: 2
-  // CHECK: strnunvis: 3
-  // CHECK: strunvisx: 4
-  // CHECK: strnunvisx: 5
-
-  return 0;
-}

Copied: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/vis.cc (from r349761, compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/vis.cc?p2=compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/vis.cc&p1=compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.cc&r1=349761&r2=349762&rev=349762&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/vis.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/vis.cc Thu Dec 20 06:25:43 2018
@@ -1,4 +1,6 @@
 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
+//
+// UNSUPPORTED: linux, solaris, darwin
 
 #include <ctype.h>
 #include <err.h>




More information about the llvm-commits mailing list