Skip to contentSkip to conversation

Fix compiler warnings on PPC64 and others

PATCH New Jason Gunthorpe 1 participant 1 message Feb 8, 2018 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix compiler warnings on PPC64 and others

We have places in our code that assume __u64 is unsigned long long, and in general this is the Linux kernel standard. However a few archs still use unsigned long by default and require a -D__SANE_USERSPACE_TYPES__ to get long long.

Detect this and provide the define to eliminate compilation warnings.

---
 CMakeLists.txt | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
CMakeLists.txt +14 -0
index e63f4cf563677a..b08d3fd2cf4246 100644
@@ -250,6 +250,20 @@ CHECK_C_SOURCE_COMPILES("
   HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE
   FAIL_REGEX "warning")
 
+# Linux __u64 is an unsigned long long
+CHECK_C_SOURCE_COMPILES("
+#include <linux/types.h>
+ int main(int argc,const char *argv[]) { __u64 tmp = 0; unsigned long long *tmp2 = &tmp; return *tmp2; }"
+  HAVE_LONG_LONG_U64
+  FAIL_REGEX "warning")
+
+if (NOT HAVE_LONG_LONG_U64)
+  # Modern Linux has switched to use ull in all cases, but to avoid disturbing
+  # userspace some platforms continued to use unsigned long by default. This
+  # define will cause kernel headers to consistently use unsigned long long
+  add_definitions("-D__SANE_USERSPACE_TYPES__")
+endif()
+
 # Provide a shim if C11 stdatomic.h is not supported.
 if (NOT HAVE_SPARSE)
   CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC)
Signature · 6 lines
2.16.1

--
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