[PATCH] A patch for sanitizers' syscalls on FreeBSD

Alexander Potapenko glider at google.com
Fri Feb 28 02:40:10 PST 2014



================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:16
@@ -15,3 +15,3 @@
 #include "sanitizer_platform.h"
-#if SANITIZER_LINUX
+#if SANITIZER_LINUX || SANITIZER_FREEBSD
 
----------------
As suggested in another code review, can we please have these sorted alphabetically?

================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:98
@@ +97,3 @@
+#if SANITIZER_FREEBSD
+  return internal_syscall(SYS_mmap, addr, length, prot, flags, fd, offset);
+#elif SANITIZER_LINUX_USES_64BIT_SYSCALLS
----------------
Looks like the main difference between syscalls on FreeBSD and Linux is the syscall name prefix (SYS_ vs. __NR_)
I'd use a macro to select a proper name instead of duplicating each function call.

================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:168
@@ -135,3 +167,3 @@
 
-#if !SANITIZER_LINUX_USES_64BIT_SYSCALLS
+#if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && !SANITIZER_FREEBSD
 static void stat64_to_stat(struct stat64 *in, struct stat *out) {
----------------
How 'bout setting SANITIZER_LINUX_USES_64BIT_SYSCALLS under FreeBSD?
We can rename it into SANITIZER_POSIX_USES_64BIT_SYSCALLS or something similar.

================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:440
@@ +439,3 @@
+#if SANITIZER_FREEBSD
+  volatile int *locked = (volatile int*)&opaque_storage_;
+  while (__sync_val_compare_and_swap(locked, 0, 1)) {}
----------------
I wonder why not use the atomic_exchange operation like this is done in the code below?


http://llvm-reviews.chandlerc.com/D2900



More information about the llvm-commits mailing list