[compiler-rt] 5a3077f - [sanitizer][fuchsia] Avoid deprecated syscall.

Roland McGrath via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 29 10:52:10 PDT 2020


Author: Jody Sankey
Date: 2020-10-29T10:51:59-07:00
New Revision: 5a3077f3a7b3ca15cffda078a8a706663ba1cb8e

URL: https://github.com/llvm/llvm-project/commit/5a3077f3a7b3ca15cffda078a8a706663ba1cb8e
DIFF: https://github.com/llvm/llvm-project/commit/5a3077f3a7b3ca15cffda078a8a706663ba1cb8e.diff

LOG: [sanitizer][fuchsia] Avoid deprecated syscall.

The zx_clock_get syscall on Fuchsia is deprecated - ref
https://fuchsia.dev/fuchsia-src/reference/syscalls/clock_get
This changes to the recommended replacement; calling zx_clock_read on
the userspace UTC clock.

Reviewed By: mcgrathr, phosek

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

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
index a6034ebda936..80c1592de0b2 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
@@ -14,10 +14,6 @@
 #include "sanitizer_fuchsia.h"
 #if SANITIZER_FUCHSIA
 
-#include "sanitizer_common.h"
-#include "sanitizer_libc.h"
-#include "sanitizer_mutex.h"
-
 #include <limits.h>
 #include <pthread.h>
 #include <stdlib.h>
@@ -25,6 +21,11 @@
 #include <zircon/errors.h>
 #include <zircon/process.h>
 #include <zircon/syscalls.h>
+#include <zircon/utc.h>
+
+#include "sanitizer_common.h"
+#include "sanitizer_libc.h"
+#include "sanitizer_mutex.h"
 
 namespace __sanitizer {
 
@@ -47,8 +48,10 @@ unsigned int internal_sleep(unsigned int seconds) {
 }
 
 u64 NanoTime() {
+  zx_handle_t utc_clock = _zx_utc_reference_get();
+  CHECK_NE(utc_clock, ZX_HANDLE_INVALID);
   zx_time_t time;
-  zx_status_t status = _zx_clock_get(ZX_CLOCK_UTC, &time);
+  zx_status_t status = _zx_clock_read(utc_clock, &time);
   CHECK_EQ(status, ZX_OK);
   return time;
 }


        


More information about the llvm-commits mailing list