All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] uapi: Make __{u,s}64 match {u,}int64_t in userspace
@ 2021-11-22 16:43 ` Cyril Hrubis
  0 siblings, 0 replies; 50+ messages in thread
From: Cyril Hrubis @ 2021-11-22 16:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-api, ltp, libc-alpha, linux-arch, arnd

This changes the __u64 and __s64 in userspace on 64bit platforms from
long long (unsigned) int to just long (unsigned) int in order to match
the uint64_t and int64_t size in userspace.

This allows us to use the kernel structure definitions in userspace. For
example we can use PRIu64 and PRId64 modifiers in printf() to print
structure members. Morever with this there would be no need to redefine
these structures in libc implementations as it is done now.

Consider for example the newly added statx() syscall. If we use the
header from uapi we will get warnings when attempting to print it's
members as:

	printf("%" PRIu64 "\n", stx.stx_size);

We get:

	warning: format '%lu' expects argument of type 'long unsigned int',
	         but argument 5 has type '__u64' {aka 'long long unsigned int'}

After this patch the types match and no warnings are generated.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/uapi/asm-generic/types.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/uapi/asm-generic/types.h b/include/uapi/asm-generic/types.h
index dfaa50d99d8f..ae748a3678a4 100644
--- a/include/uapi/asm-generic/types.h
+++ b/include/uapi/asm-generic/types.h
@@ -1,9 +1,16 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 #ifndef _ASM_GENERIC_TYPES_H
 #define _ASM_GENERIC_TYPES_H
+
+#include <asm/bitsperlong.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 && !defined(__KERNEL__)
+# include <asm-generic/int-l64.h>
+#else
+# include <asm-generic/int-ll64.h>
+#endif
 
 #endif /* _ASM_GENERIC_TYPES_H */
-- 
2.32.0


-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply related	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2022-06-17 15:02 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-22 16:43 [PATCH] uapi: Make __{u,s}64 match {u,}int64_t in userspace Cyril Hrubis
2021-11-22 16:43 ` [LTP] " Cyril Hrubis
2021-11-22 16:51 ` Alejandro Colomar (mailing lists)
2021-11-22 16:51   ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Alejandro Colomar (mailing lists)
2021-11-22 20:48 ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Arnd Bergmann
2021-11-22 20:48   ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Arnd Bergmann
2021-11-23  9:14   ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Cyril Hrubis
2021-11-23  9:14     ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Cyril Hrubis
2021-11-23 14:18     ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Arnd Bergmann
2021-11-23 14:18       ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Arnd Bergmann
2021-11-23 19:50     ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Florian Weimer
2021-11-23 19:50       ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Florian Weimer
2021-11-24 10:17       ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Alejandro Colomar (man-pages)
2021-11-24 10:17         ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Alejandro Colomar (man-pages)
2021-11-22 22:19 ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Zack Weinberg
2021-11-22 22:19   ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Zack Weinberg
2021-11-23  9:15   ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Cyril Hrubis
2021-11-23  9:15     ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Cyril Hrubis
2021-12-02 15:34   ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Rich Felker
2021-12-02 15:34     ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Rich Felker
2021-12-02 23:29     ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Rich Felker
2021-12-02 23:29       ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Rich Felker
2021-12-02 23:43       ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Adhemerval Zanella
2021-12-02 23:43         ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Adhemerval Zanella
2021-12-03  0:10         ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Zack Weinberg
2021-12-03  0:10           ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Zack Weinberg
2021-12-03 12:32           ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Adhemerval Zanella
2021-12-03 12:32             ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Adhemerval Zanella
2021-12-03 12:54             ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Alejandro Colomar (man-pages)
2021-12-03 12:54               ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Alejandro Colomar (man-pages)
2021-11-23 16:47 ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " David Howells
2021-11-23 16:47   ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " David Howells
2021-11-23 16:58   ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " David Laight
2021-11-23 16:58     ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " David Laight
2021-11-29 11:58     ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Cyril Hrubis
2021-11-29 11:58       ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Cyril Hrubis
2021-11-29 14:34       ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Arnd Bergmann
2021-11-29 14:34         ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Arnd Bergmann
2021-12-02 14:55         ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Zack Weinberg
2021-12-02 14:55           ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Zack Weinberg
2021-12-02 15:01           ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " David Howells
2021-12-02 15:01             ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " David Howells
2021-12-02 20:48             ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Zack Weinberg
2021-12-02 20:48               ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Zack Weinberg
2021-12-08 15:33             ` [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Cyril Hrubis
2021-12-08 15:33               ` [LTP] [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Cyril Hrubis
2022-06-17 12:13               ` Ping: [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Alejandro Colomar
2022-06-17 12:13                 ` [LTP] Ping: [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Alejandro Colomar
2022-06-17 15:04                 ` Ping: [PATCH] uapi: Make __{u,s}64 match {u,}int64_t " Cyril Hrubis
2022-06-17 15:04                   ` [LTP] Ping: [PATCH] uapi: Make __{u, s}64 match {u, }int64_t " Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.