[sanitizer] Change NanoTime to use clock_gettime on non-glibc
authorFangrui Song <i@maskray.me>
Thu, 11 Mar 2021 07:02:51 +0000 (23:02 -0800)
committerFangrui Song <i@maskray.me>
Thu, 11 Mar 2021 07:02:51 +0000 (23:02 -0800)
commitaeaf705d5eb5b1a6956bbd64949c872a5ecdee22
tree75eab4b1e950c79eecc1bd478f7cea982d0761f7
parentc7712087cbb505d324e1149fa224f607c91a8c6a
[sanitizer] Change NanoTime to use clock_gettime on non-glibc

This avoids the `__NR_gettimeofday` syscall number, which does not exist on 32-bit musl (it has `__NR_gettimeofday_time32`).

This switched Android to `clock_gettime` as well, which should work according to the old code before D96925.

Tested on Alpine Linux x86-64 (musl) and FreeBSD x86-64.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D98121
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp