[PATCH] D55015: Add a new interceptor for nl_langinfo(3) from NetBSD

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 07:11:24 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT348369: Add a new interceptor for nl_langinfo(3) from NetBSD (authored by kamil, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55015?vs=175742&id=176817#toc

Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55015/new/

https://reviews.llvm.org/D55015

Files:
  lib/sanitizer_common/sanitizer_common_interceptors.inc
  lib/sanitizer_common/sanitizer_platform_interceptors.h
  test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc


Index: test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc
===================================================================
--- test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc
+++ test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc
@@ -0,0 +1,18 @@
+// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
+
+#include <langinfo.h>
+
+#include <stdio.h>
+
+int main(void) {
+  printf("nl_langinfo\n");
+
+  char *info = nl_langinfo(DAY_1);
+
+  printf("DAY_1='%s'\n", info);
+
+  // CHECK: nl_langinfo
+  // CHECK: DAY_1='{{.*}}'
+
+  return 0;
+}
Index: lib/sanitizer_common/sanitizer_platform_interceptors.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -520,6 +520,7 @@
   SI_LINUX || SI_MAC)
 #define SANITIZER_INTERCEPT_GETMNTINFO SI_NETBSD
 #define SANITIZER_INTERCEPT_MI_VECTOR_HASH SI_NETBSD
+#define SANITIZER_INTERCEPT_NL_LANGINFO SI_NETBSD
 #define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD
 #define SANITIZER_INTERCEPT_REGEX SI_NETBSD
 #define SANITIZER_INTERCEPT_FTS SI_NETBSD
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -7664,6 +7664,19 @@
 #define INIT_SYSCTLGETMIBINFO
 #endif
 
+#if SANITIZER_INTERCEPT_NL_LANGINFO
+INTERCEPTOR(char *, nl_langinfo, long item) {
+  void *ctx;
+  COMMON_INTERCEPTOR_ENTER(ctx, nl_langinfo, item);
+  char *ret = REAL(nl_langinfo)(item);
+  if (ret)
+    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, REAL(strlen)(ret) + 1);
+  return ret;
+}
+#define INIT_NL_LANGINFO COMMON_INTERCEPT_FUNCTION(nl_langinfo)
+#else
+#define INIT_NL_LANGINFO
+#endif
 
 static void InitializeCommonInterceptors() {
   static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
@@ -7927,6 +7940,7 @@
   INIT_SYSCTL;
   INIT_ASYSCTL;
   INIT_SYSCTLGETMIBINFO;
+  INIT_NL_LANGINFO;
 
   INIT___PRINTF_CHK;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55015.176817.patch
Type: text/x-patch
Size: 2109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181205/8e998664/attachment.bin>


More information about the llvm-commits mailing list