From 2b4c03cbc84090174a3cf5d27887bac8fb052b57 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 7 Sep 2015 14:37:40 +0200 Subject: kern: fix loop reading the time value Previously, recent versions of gcc would hoist the loads out of the loop reading the time value. * kern/macros.h (access_once): New macro. * kern/mach_clock.c (host_get_time): Use the new macro to prevent the loads from being hoisted out of the loop. --- kern/macros.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'kern/macros.h') diff --git a/kern/macros.h b/kern/macros.h index 7cc579d..c2e8545 100644 --- a/kern/macros.h +++ b/kern/macros.h @@ -52,6 +52,8 @@ #define structof(ptr, type, member) \ ((type *)((char *)(ptr) - offsetof(type, member))) +#define access_once(x) (*(volatile typeof(x) *)&(x)) + #define alignof(x) __alignof__(x) #ifndef likely -- cgit v1.2.3