Skip to contentSkip to conversation

verbs: Fix C++ compilation break

PATCH New Leon Romanovsky 1 participant 1 message Oct 10, 2017 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 verbs: Fix C++ compilation break

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

The commit 983f80191923 ("verbs: fix compilation error with ICC") fixed warning by using UINTPTR_MAX, however such change breaks compilation of C++ applications.

On some systems, the stdint.h contains the following ifdef to protect UINTPTR_MAX "#if !defined __cplusplus || defined __STDC_LIMIT_MACROS"

The simple inclusion of <cstdint> header is not enough too to fix compilation error, because that file was added in C++11 standard and it produces following error while using it:

/usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

So let's fix C++ compilation break by using numeric_limits to avoid __STDC_LIMIT_MACROS.

Fixes 983f80191923 ("verbs: fix compilation error with ICC")
Cc Nelio Laranjeiro <[email protected]>
Cc Adrien Mazarguil <[email protected]>
Cc Nicolas Morey-Chaisemartin <[email protected]>

---
Travis CI failure is a false alarm (checkpatch):
https://github.com/linux-rdma/rdma-core/pull/224

Changes from v0:
* Updated commit message to better reflect the issue
* Used Jason's code, so added his SOB

---
 libibverbs/verbs.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
libibverbs/verbs.h +6 -1
index cc633a12..4e2f338a 100644
@@ -82,7 +82,12 @@ union ibv_gid {
 
 #define vext_field_avail(type, fld, sz) (offsetof(type, fld) < (sz))
 
-static void *__VERBS_ABI_IS_EXTENDED = (void *)UINTPTR_MAX;
+#ifdef __cplusplus
+#include <limits>
+#define __VERBS_ABI_IS_EXTENDED ((void *)std::numeric_limits<uintptr_t>::max())
+#else
+#define __VERBS_ABI_IS_EXTENDED ((void *)UINTPTR_MAX)
+#endif
 
 enum ibv_node_type {
 	IBV_NODE_UNKNOWN	= -1,

--
2.14.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html