Skip to contentSkip to conversation

powerpc: use "long long" for 64-bit types in userspace

PATCH In review Thomas Bertschinger 3 participants 3 messages Feb 23, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: use "long long" for 64-bit types in userspace

This resolves build warnings and failures for architectures where the Linux userspace asm/types.h header defines 64-bit types (u64, s64) as long instead of long long.

By defining __SANE_USERSPACE_TYPES__, these types are defined as long long instead.

---
 Makefile              | 1 +
 include/linux/types.h | 2 ++
 2 files changed, 3 insertions(+)
Makefile +1 -0
index 6e5d0e5..7363d5d 100644
@@ -42,6 +42,7 @@ CFLAGS+=-std=gnu11 -O2 -g -MMD -Wall -fPIC			\
 	-DNO_BCACHEFS_FS					\
 	-DNO_BCACHEFS_SYSFS					\
 	-DVERSION_STRING='"$(VERSION)"'				\
+	-D__SANE_USERSPACE_TYPES__				\
 	$(EXTRA_CFLAGS)
 
 # Intenionally not doing the above to $(LDFLAGS) because we rely on
include/linux/types.h +2 -0
index 6ae97c4..004d5eb 100644
@@ -10,7 +10,9 @@
 #include <sys/types.h>
 #include <linux/posix_types.h>
 
+#ifndef __SANE_USERSPACE_TYPES__
 #define __SANE_USERSPACE_TYPES__	/* For PPC64, to get LL64 types */
+#endif
 #include <asm/types.h>
 
 #include <linux/cache.h>
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Thomas Bertschinger

This resolves build warnings and failures for architectures where the Linux userspace asm/types.h header defines 64-bit types (u64, s64) as long instead of long long.

By defining __SANE_USERSPACE_TYPES__, these types are defined as long long instead.

Never realized this was a thing! This fixes all the printf format madness.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Bertschinger
Quoted 41 lines · Thomas Bertschinger

This resolves build warnings and failures for architectures where the Linux userspace asm/types.h header defines 64-bit types (u64, s64) as long instead of long long.

By defining __SANE_USERSPACE_TYPES__, these types are defined as long long instead.

---
 Makefile              | 1 +
 include/linux/types.h | 2 ++
 2 files changed, 3 insertions(+)
Makefile +1 -0
index 6e5d0e5..7363d5d 100644
@@ -42,6 +42,7 @@ CFLAGS+=-std=gnu11 -O2 -g -MMD -Wall -fPIC                    \
        -DNO_BCACHEFS_FS                                        \
        -DNO_BCACHEFS_SYSFS                                     \
        -DVERSION_STRING='"$(VERSION)"'                         \
+       -D__SANE_USERSPACE_TYPES__                              \
        $(EXTRA_CFLAGS)
 
 # Intenionally not doing the above to $(LDFLAGS) because we rely on
include/linux/types.h +2 -1
index 6ae97c4..004d5eb 100644
@@ -10,7 +10,9 @@
 #include <sys/types.h>
 #include <linux/posix_types.h>
 
+#ifndef __SANE_USERSPACE_TYPES__
 #define __SANE_USERSPACE_TYPES__       /* For PPC64, to get LL64 types */
+#endif
 #include <asm/types.h>
 
 #include <linux/cache.h>
--
Quoted 3 lines

2.43.0

This looks good, works, and fixes the build for Fedora on ppc64le.

Signature · 1 line
真実はいつも一つ!/ Always, there's only one truth!