diff mbox

[2/8,v2] opensm/complib: define macros for for "if" statements with branch prediction hints

Message ID 504F57FD.5090703@mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Alex Netes
Headers show

Commit Message

Yevgeny Kliteynik Sept. 11, 2012, 3:25 p.m. UTC
Defined "PT" and "PF" for "predict true"
and "predict false" respectively.

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
---
 include/complib/cl_types_osd.h | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/complib/cl_types_osd.h b/include/complib/cl_types_osd.h
index ce1a452..2538913 100644
--- a/include/complib/cl_types_osd.h
+++ b/include/complib/cl_types_osd.h
@@ -1,6 +1,6 @@ 
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -64,6 +64,18 @@  BEGIN_C_DECLS
 #include <inttypes.h>
 #include <assert.h>
 #include <string.h>
+
+/*
+ * Branch prediction hints
+ */
+#if defined(HAVE_BUILTIN_EXPECT)
+#define PT(exp)    __builtin_expect( ((uintptr_t)(exp)), 1 )
+#define PF(exp)    __builtin_expect( ((uintptr_t)(exp)), 0 )
+#else
+#define PT(exp)    (exp)
+#define PF(exp)    (exp)
+#endif
+
 #if defined (_DEBUG_)
 #define CL_ASSERT	assert
 #else				/* _DEBUG_ */