Rewrite of likely, unlikely, barrier and ACCESS_ONCE
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 13 May 2009 15:15:37 +0000 (11:15 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 13 May 2009 15:15:37 +0000 (11:15 -0400)
compiler.h now licensed under MIT-style license.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
LICENSE
compiler.h

diff --git a/LICENSE b/LICENSE
index fa10831b3343830e557839f2b5b2670d1932f4a1..f02264e62788940e90d2c21fb6e249aca810284f 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -38,6 +38,7 @@ This license applies to :
 
 arch_atomic_x86.h
 arch_atomic_ppc.h
+compiler.h
 
 
 * GPLv2
index fb09ca2b9b238ceec418ba5c21c660b4cebcb7fd..717465c4d8570ce443e8cec4bb5b1abe3f3a0765 100644 (file)
  * IBM's contributions to this file may be relicensed under LGPLv2 or later.
  */
 
+#define likely()       __builtin_expect(!!(x), 1)
+#define unlikely()     __builtin_expect(!!(x), 0)
+
+#define        barrier()       asm volatile("" : : : "memory");
+
 /*
  * Instruct the compiler to perform only a single access to a variable
  * (prohibits merging and refetching). The compiler is also forbidden to reorder
@@ -37,5 +42,6 @@
  * use is to mediate communication between process-level code and irq/NMI
  * handlers, all running on the same CPU.
  */
+#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&x)
 
 #endif /* _COMPILER_H */
This page took 0.034204 seconds and 4 git commands to generate.