summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-10-29 19:49:35 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-10-29 19:49:35 +0000
commitf814b43ed659512203439bc8c3f6d468155a1d3f (patch)
treecda77a3cb89b642083697a2831d4ac27a255f554 /lib
parent4b26afda2f4c7465260b22f1094c6699886cc55d (diff)
downloadcompiler-rt-f814b43ed659512203439bc8c3f6d468155a1d3f.tar.gz
[sanitizer] Intercept sincos, remquo, lgamma, lgamma_r.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/msan/tests/msan_test.cc81
-rw-r--r--lib/sanitizer_common/sanitizer_common_interceptors.inc125
-rw-r--r--lib/sanitizer_common/sanitizer_platform_interceptors.h4
-rw-r--r--lib/tsan/rtl/tsan_stat.cc12
-rw-r--r--lib/tsan/rtl/tsan_stat.h12
5 files changed, 234 insertions, 0 deletions
diff --git a/lib/msan/tests/msan_test.cc b/lib/msan/tests/msan_test.cc
index dd9669be0..613367f82 100644
--- a/lib/msan/tests/msan_test.cc
+++ b/lib/msan/tests/msan_test.cc
@@ -1506,6 +1506,87 @@ TEST(MemorySanitizer, modfl) {
EXPECT_NOT_POISONED(y);
}
+TEST(MemorySanitizer, sincos) {
+ double s, c;
+ sincos(0.2, &s, &c);
+ EXPECT_NOT_POISONED(s);
+ EXPECT_NOT_POISONED(c);
+}
+
+TEST(MemorySanitizer, sincosf) {
+ float s, c;
+ sincosf(0.2, &s, &c);
+ EXPECT_NOT_POISONED(s);
+ EXPECT_NOT_POISONED(c);
+}
+
+TEST(MemorySanitizer, sincosl) {
+ long double s, c;
+ sincosl(0.2, &s, &c);
+ EXPECT_NOT_POISONED(s);
+ EXPECT_NOT_POISONED(c);
+}
+
+TEST(MemorySanitizer, remquo) {
+ int quo;
+ double res = remquo(29.0, 3.0, &quo);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(quo);
+}
+
+TEST(MemorySanitizer, remquof) {
+ int quo;
+ float res = remquof(29.0, 3.0, &quo);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(quo);
+}
+
+TEST(MemorySanitizer, remquol) {
+ int quo;
+ long double res = remquof(29.0, 3.0, &quo);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(quo);
+}
+
+TEST(MemorySanitizer, lgamma) {
+ double res = lgamma(1.1);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(signgam);
+}
+
+TEST(MemorySanitizer, lgammaf) {
+ float res = lgammaf(1.1);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(signgam);
+}
+
+TEST(MemorySanitizer, lgammal) {
+ long double res = lgammal(1.1);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(signgam);
+}
+
+TEST(MemorySanitizer, lgamma_r) {
+ int sgn;
+ double res = lgamma_r(1.1, &sgn);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(sgn);
+}
+
+TEST(MemorySanitizer, lgammaf_r) {
+ int sgn;
+ float res = lgammaf_r(1.1, &sgn);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(sgn);
+}
+
+TEST(MemorySanitizer, lgammal_r) {
+ int sgn;
+ long double res = lgammal_r(1.1, &sgn);
+ ASSERT_NE(0.0, res);
+ EXPECT_NOT_POISONED(sgn);
+}
+
TEST(MemorySanitizer, sprintf) { // NOLINT
char buff[10];
break_optimization(buff);
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
index c4b8a30d8..1968e4c30 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -2668,6 +2668,127 @@ INTERCEPTOR(int, pthread_setname_np, uptr thread, const char *name) {
#define INIT_PTHREAD_SETNAME_NP
#endif
+#if SANITIZER_INTERCEPT_SINCOS
+INTERCEPTOR(void, sincos, double x, double *sin, double *cos) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, sincos, x, sin, cos);
+ REAL(sincos)(x, sin, cos);
+ if (sin) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, sin, sizeof(*sin));
+ if (cos) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cos, sizeof(*cos));
+}
+INTERCEPTOR(void, sincosf, float x, float *sin, float *cos) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, sincosf, x, sin, cos);
+ REAL(sincosf)(x, sin, cos);
+ if (sin) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, sin, sizeof(*sin));
+ if (cos) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cos, sizeof(*cos));
+}
+INTERCEPTOR(void, sincosl, long double x, long double *sin, long double *cos) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, sincosl, x, sin, cos);
+ REAL(sincosl)(x, sin, cos);
+ if (sin) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, sin, sizeof(*sin));
+ if (cos) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cos, sizeof(*cos));
+}
+#define INIT_SINCOS \
+ INTERCEPT_FUNCTION(sincos); \
+ INTERCEPT_FUNCTION(sincosf); \
+ INTERCEPT_FUNCTION(sincosl);
+#else
+#define INIT_SINCOS
+#endif
+
+#if SANITIZER_INTERCEPT_REMQUO
+INTERCEPTOR(double, remquo, double x, double y, int *quo) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, remquo, x, y, quo);
+ double res = REAL(remquo)(x, y, quo);
+ if (quo) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, quo, sizeof(*quo));
+ return res;
+}
+INTERCEPTOR(float, remquof, float x, float y, int *quo) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, remquof, x, y, quo);
+ float res = REAL(remquof)(x, y, quo);
+ if (quo) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, quo, sizeof(*quo));
+ return res;
+}
+INTERCEPTOR(long double, remquol, long double x, long double y, int *quo) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, remquol, x, y, quo);
+ long double res = REAL(remquol)(x, y, quo);
+ if (quo) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, quo, sizeof(*quo));
+ return res;
+}
+#define INIT_REMQUO \
+ INTERCEPT_FUNCTION(remquo); \
+ INTERCEPT_FUNCTION(remquof); \
+ INTERCEPT_FUNCTION(remquol);
+#else
+#define INIT_REMQUO
+#endif
+
+#if SANITIZER_INTERCEPT_LGAMMA
+extern int signgam;
+INTERCEPTOR(double, lgamma, double x) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, lgamma, x);
+ double res = REAL(lgamma)(x);
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, &signgam, sizeof(signgam));
+ return res;
+}
+INTERCEPTOR(float, lgammaf, float x) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, lgammaf, x);
+ float res = REAL(lgammaf)(x);
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, &signgam, sizeof(signgam));
+ return res;
+}
+INTERCEPTOR(long double, lgammal, long double x) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, lgammal, x);
+ long double res = REAL(lgammal)(x);
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, &signgam, sizeof(signgam));
+ return res;
+}
+#define INIT_LGAMMA \
+ INTERCEPT_FUNCTION(lgamma); \
+ INTERCEPT_FUNCTION(lgammaf); \
+ INTERCEPT_FUNCTION(lgammal);
+#else
+#define INIT_LGAMMA
+#endif
+
+#if SANITIZER_INTERCEPT_LGAMMA_R
+INTERCEPTOR(double, lgamma_r, double x, int *signp) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, lgamma_r, x, signp);
+ double res = REAL(lgamma_r)(x, signp);
+ if (signp) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, signp, sizeof(*signp));
+ return res;
+}
+INTERCEPTOR(float, lgammaf_r, float x, int *signp) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, lgammaf_r, x, signp);
+ float res = REAL(lgammaf_r)(x, signp);
+ if (signp) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, signp, sizeof(*signp));
+ return res;
+}
+INTERCEPTOR(long double, lgammal_r, long double x, int *signp) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, lgammal_r, x, signp);
+ long double res = REAL(lgammal_r)(x, signp);
+ if (signp) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, signp, sizeof(*signp));
+ return res;
+}
+#define INIT_LGAMMA_R \
+ INTERCEPT_FUNCTION(lgamma_r); \
+ INTERCEPT_FUNCTION(lgammaf_r); \
+ INTERCEPT_FUNCTION(lgammal_r);
+#else
+#define INIT_LGAMMA_R
+#endif
+
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
INIT_STRCMP; \
@@ -2771,4 +2892,8 @@ INTERCEPTOR(int, pthread_setname_np, uptr thread, const char *name) {
INIT_TMPNAM_R; \
INIT_TEMPNAM; \
INIT_PTHREAD_SETNAME_NP; \
+ INIT_SINCOS; \
+ INIT_REMQUO; \
+ INIT_LGAMMA; \
+ INIT_LGAMMA_R; \
/**/
diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
index c2a432a63..92219f7b8 100644
--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -144,6 +144,10 @@
# define SANITIZER_INTERCEPT_TMPNAM SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_TMPNAM_R SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_TEMPNAM SI_NOT_WINDOWS
+# define SANITIZER_INTERCEPT_SINCOS SI_NOT_WINDOWS
+# define SANITIZER_INTERCEPT_REMQUO SI_NOT_WINDOWS
+# define SANITIZER_INTERCEPT_LGAMMA SI_NOT_WINDOWS
+# define SANITIZER_INTERCEPT_LGAMMA_R SI_LINUX
# define SANITIZER_INTERCEPT__EXIT SI_LINUX
diff --git a/lib/tsan/rtl/tsan_stat.cc b/lib/tsan/rtl/tsan_stat.cc
index ee1e3c167..0d0607be5 100644
--- a/lib/tsan/rtl/tsan_stat.cc
+++ b/lib/tsan/rtl/tsan_stat.cc
@@ -398,6 +398,18 @@ void StatOutput(u64 *stat) {
name[StatInt_tmpnam] = " tmpnam ";
name[StatInt_tmpnam_r] = " tmpnam_r ";
name[StatInt_tempnam] = " tempnam ";
+ name[StatInt_sincos] = " sincos ";
+ name[StatInt_sincosf] = " sincosf ";
+ name[StatInt_sincosl] = " sincosl ";
+ name[StatInt_remquo] = " remquo ";
+ name[StatInt_remquof] = " remquof ";
+ name[StatInt_remquol] = " remquol ";
+ name[StatInt_lgamma] = " lgamma ";
+ name[StatInt_lgammaf] = " lgammaf ";
+ name[StatInt_lgammal] = " lgammal ";
+ name[StatInt_lgamma_r] = " lgamma_r ";
+ name[StatInt_lgammaf_r] = " lgammaf_r ";
+ name[StatInt_lgammal_r] = " lgammal_r ";
name[StatInt_pthread_attr_getdetachstate] = " pthread_addr_getdetachstate "; // NOLINT
name[StatInt_pthread_attr_getguardsize] = " pthread_addr_getguardsize "; // NOLINT
diff --git a/lib/tsan/rtl/tsan_stat.h b/lib/tsan/rtl/tsan_stat.h
index 5e6679a74..6c1927e81 100644
--- a/lib/tsan/rtl/tsan_stat.h
+++ b/lib/tsan/rtl/tsan_stat.h
@@ -393,6 +393,18 @@ enum StatType {
StatInt_tmpnam,
StatInt_tmpnam_r,
StatInt_tempnam,
+ StatInt_sincos,
+ StatInt_sincosf,
+ StatInt_sincosl,
+ StatInt_remquo,
+ StatInt_remquof,
+ StatInt_remquol,
+ StatInt_lgamma,
+ StatInt_lgammaf,
+ StatInt_lgammal,
+ StatInt_lgamma_r,
+ StatInt_lgammaf_r,
+ StatInt_lgammal_r,
StatInt_pthread_attr_getdetachstate,
StatInt_pthread_attr_getguardsize,