Thread (3 messages) flat view 3 messages, 2 authors, 2021-11-19

Re: asm-generic/int-ll64.h wrongly used on x86_64?

From: Cyril Hrubis <chrubis@suse.cz>
Date: 2021-11-19 13:52:07
Also in: ltp
Subsystem: generic include/asm header files, the rest · Maintainers: Arnd Bergmann, Linus Torvalds

Hi!
The correct format depends on whether you use struct statx from the
glibc headers or the Linux UAPI headers.  glibc uses uint64_t, Linux
uses __u64.  uint64_t in glibc prefers unsigned long if the type is
64-bit, Linux uses unsigned long long unconditionally.

One solution is to use %ju and cast to (uintmax_t).  Other cast-based
approaches are possible as well.

I'm not happy with the situation because those casts reduce type safety
and may suppress relevant compiler warnings.
I still do not get why can't the kernel __u64 match the uint64_t at
least in userspace. It should be as easy as:
diff --git a/include/uapi/asm-generic/types.h b/include/uapi/asm-generic/types.h
index dfaa50d99d8f..3c9a1fc5d5c3 100644
--- a/include/uapi/asm-generic/types.h
+++ b/include/uapi/asm-generic/types.h
@@ -2,8 +2,12 @@
 #ifndef _ASM_GENERIC_TYPES_H
 #define _ASM_GENERIC_TYPES_H
 /*
- * int-ll64 is used everywhere now.
+ * int-ll64 is used everywhere in kernel now.
  */
-#include <asm-generic/int-ll64.h>
+#if __BITS_PER_LONG == 64 && !__KERNEL__
+# include <asm-generic/int-l64.h>
+#else
+# include <asm-generic/int-ll64.h>
+#if

 #endif /* _ASM_GENERIC_TYPES_H */

-- 
Cyril Hrubis
chrubis@suse.cz
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help