#include <stdlib.h>
#include <sys/time.h>
+/*
+ * On Linux, define the membarrier system call number if not yet available in
+ * the system headers.
+ */
+#if (defined(__linux__) && !defined(__NR_membarrier))
+#define __NR_membarrier 343
+#endif
+
#define HAS_CAA_GET_CYCLES
-typedef unsigned long cycles_t;
+typedef unsigned long caa_cycles_t;
-static inline cycles_t caa_get_cycles(void)
+static inline caa_cycles_t caa_get_cycles(void)
{
- cycles_t cycles;
+ caa_cycles_t cycles;
asm volatile("mfctl 16, %0" : "=r" (cycles));
return cycles;