Source: zfs-linux
Version: 0.8.4-2
Severity: wishlist
Tags: patch

Hi!

I'd recently ported the SPL to x32 [1], but didn't post it here because
the mailing list setup confused me a bit at the time and thought 0.9.0
would come sooner rather than later.

However, I've now found the list, failed to post to it twice, so I'm
opening this bug and attaching my patches, up/downdated for 0.8.4-2;
they're plug-and-play and I've been running them like this since early
May, but I'm not sure if there's anything more to be done on the
packaging side.

Best,
наб

[1]: https://github.com/openzfs/zfs/pull/10357
From 478e589977e6137dca88eefe3e8114a200163021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczlew...@nabijaczleweli.xyz>
Date: Mon, 18 May 2020 00:00:49 +0200
Subject: [PATCH 1/2] Correctly handle the x32 ABI

__x86_64__ && _ILP32 => don't forcibly define _LP64

Closes #844
---
 include/spl/sys/isa_defs.h        | 6 +++++-
 lib/libspl/include/sys/isa_defs.h | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/spl/sys/isa_defs.h b/include/spl/sys/isa_defs.h
index b62a021ee..61072da33 100644
--- a/include/spl/sys/isa_defs.h
+++ b/include/spl/sys/isa_defs.h
@@ -40,9 +40,13 @@
 #define	__x86
 #endif
 
+#if defined(_ILP32)
+/* x32-specific defines; careful to *not* define _LP64 here */
+#else
 #if !defined(_LP64)
 #define	_LP64
 #endif
+#endif
 
 #define	_ALIGNMENT_REQUIRED	1
 
@@ -209,7 +213,7 @@
 #else
 /*
  * Currently supported:
- * x86_64, i386, arm, powerpc, s390, sparc, mips and risc-v
+ * x86_64, x32, i386, arm, powerpc, s390, sparc, mips and risc-v
  */
 #error "Unsupported ISA type"
 #endif
diff --git a/lib/libspl/include/sys/isa_defs.h b/lib/libspl/include/sys/isa_defs.h
index 35f500f71..b2ad2a1f4 100644
--- a/lib/libspl/include/sys/isa_defs.h
+++ b/lib/libspl/include/sys/isa_defs.h
@@ -46,9 +46,13 @@ extern "C" {
 #define	__x86
 #endif
 
+#if defined(_ILP32)
+/* x32-specific defines; careful to *not* define _LP64 here */
+#else
 #if !defined(_LP64)
 #define	_LP64
 #endif
+#endif
 
 #if !defined(_LITTLE_ENDIAN)
 #define	_LITTLE_ENDIAN
@@ -204,7 +208,7 @@ extern "C" {
 #else
 /*
  * Currently supported:
- * x86_64, i386, arm, powerpc, s390, sparc, and mips, riscv64
+ * x86_64, x32, i386, arm, powerpc, s390, sparc, and mips, riscv64
  */
 #error "Unsupported ISA type"
 #endif
-- 
2.28.0.rc1

From ade28f70e0098e4f58b194c07da80881763803ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczlew...@nabijaczleweli.xyz>
Date: Thu, 21 May 2020 21:53:13 +0200
Subject: [PATCH 2/2] Always use "%lld" for formatting time_ts

Given the following test program:
  #include <time.h>
  #include <stdio.h>
  #include <stdint.h>
  int main() {
    printf("time_t:    %d\n", sizeof(time_t));
    printf("long:      %d\n", sizeof(long));
    printf("long long: %d\n", sizeof(long long));
  }

These are output on various x86 architectures:
  x32$   time_t:    8
  x32$   long:      4
  x32$   long long: 8

  amd64$ time_t:    8
  amd64$ long:      8
  amd64$ long long: 8

  i386$  time_t:    4
  i386$  long:      4
  i386$  long long: 8

Therefore code using "%l[du]" to format time_ts produced warnings on x32
---
 lib/libspl/timestamp.c       | 2 +-
 lib/libzfs/libzfs_sendrecv.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/libspl/timestamp.c b/lib/libspl/timestamp.c
index eab15f3f1..22ecb3940 100644
--- a/lib/libspl/timestamp.c
+++ b/lib/libspl/timestamp.c
@@ -51,7 +51,7 @@ print_timestamp(uint_t timestamp_fmt)
 		fmt = nl_langinfo(_DATE_FMT);
 
 	if (timestamp_fmt == UDATE) {
-		(void) printf("%ld\n", t);
+		(void) printf("%lld\n", (longlong_t)t);
 	} else if (timestamp_fmt == DDATE) {
 		char dstr[64];
 		int len;
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index 10241f530..21e5c7d85 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -4606,8 +4606,8 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
 		zfs_nicebytes(bytes, buf1, sizeof (buf1));
 		zfs_nicebytes(bytes/delta, buf2, sizeof (buf1));
 
-		(void) printf("received %s stream in %lu seconds (%s/sec)\n",
-		    buf1, delta, buf2);
+		(void) printf("received %s stream in %lld seconds (%s/sec)\n",
+		    buf1, (longlong_t)delta, buf2);
 	}
 
 	err = 0;
-- 
2.28.0.rc1

Attachment: signature.asc
Description: PGP signature

Reply via email to