diff options
author | 2017-04-14 12:53:06 -0400 | |
---|---|---|
committer | 2017-04-14 18:59:07 +0000 | |
commit | 122f18ede856e5aca736c759f33daed0a903525b (patch) | |
tree | 07f05f9c84252a2e7aa1229c1baa95baadc6c1d3 /src | |
parent | 9f591347e902aa0c59a5da2915d829ae162831f4 (diff) |
skirt std::chrono on MSAN builds
I don't know why, but only std::chrono's calls to clock_gettime() seem
to be affected by this MSAN bug. Other calls into libc++ that call
libc, like std::to_string(int) calling snprintf, work fine.
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN,Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN
BUG=skia:6504
Change-Id: I73fbe8793d2b5b5cca46ed68fb078a77d8748127
Reviewed-on: https://skia-review.googlesource.com/13502
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkTime.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/SkTime.cpp b/src/core/SkTime.cpp index 95270904a8..ca67f4c8a7 100644 --- a/src/core/SkTime.cpp +++ b/src/core/SkTime.cpp @@ -64,8 +64,19 @@ void SkTime::GetDateTime(DateTime* dt) { } #endif // SK_BUILD_FOR_WIN32 +#if !defined(__has_feature) + #define __has_feature(x) 0 +#endif + double SkTime::GetNSecs() { +#if __has_feature(memory_sanitizer) + // See skia:6504 + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC, &tp); + return tp.tv_sec * 1e9 + tp.tv_nsec; +#else auto now = std::chrono::high_resolution_clock::now(); std::chrono::duration<double, std::nano> ns = now.time_since_epoch(); return ns.count(); +#endif } |