]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
musl: format-util: use %llu for formatting rlim_t 39687/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 9 Jun 2025 03:00:01 +0000 (12:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 Nov 2025 23:02:05 +0000 (08:02 +0900)
glibc uses uint32_t or uint64_t for rlim_t, while musl uses unsigned long long.

src/basic/format-util.h

index c603e99d8207cdca86103f72d942120a756a43a1..16727c45bd4950315fd9f1a2a866ce12572676c4 100644 (file)
@@ -39,12 +39,18 @@ assert_cc(sizeof(gid_t) == sizeof(uint32_t));
 #  error Unknown timex member size
 #endif
 
-#if SIZEOF_RLIM_T == 8
-#  define RLIM_FMT "%" PRIu64
-#elif SIZEOF_RLIM_T == 4
-#  define RLIM_FMT "%" PRIu32
+#ifdef __GLIBC__
+#  if SIZEOF_RLIM_T == 8
+#    define RLIM_FMT "%" PRIu64
+#  elif SIZEOF_RLIM_T == 4
+#    define RLIM_FMT "%" PRIu32
+#  else
+#    error Unknown rlim_t size
+#  endif
 #else
-#  error Unknown rlim_t size
+/* Assume musl, and it unconditionally uses unsigned long long. */
+assert_cc(SIZEOF_RLIM_T == 8);
+#  define RLIM_FMT "%llu"
 #endif
 
 #if SIZEOF_DEV_T == 8