[libc-commits] [libc] [libc] Fix missing UINTMAX_WIDTH (PR #87092)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Fri Mar 29 10:29:18 PDT 2024
https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/87092
In patch #82461 the sprintf tests were made to use UINTMAX_WIDTH which
isn't defined on all systems. This patch changes it to
sizeof(uintmax_t)*CHAR_BIT which is more portable.
>From 88af0688b1b90ef9ed704c4571d454ccf62feb78 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Fri, 29 Mar 2024 10:27:56 -0700
Subject: [PATCH] [libc] Fix missing UINTMAX_WIDTH
In patch #82461 the sprintf tests were made to use UINTMAX_WIDTH which
isn't defined on all systems. This patch changes it to
sizeof(uintmax_t)*CHAR_BIT which is more portable.
---
libc/test/src/stdio/sprintf_test.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libc/test/src/stdio/sprintf_test.cpp b/libc/test/src/stdio/sprintf_test.cpp
index ba31034146fedf..8e9870f71a9595 100644
--- a/libc/test/src/stdio/sprintf_test.cpp
+++ b/libc/test/src/stdio/sprintf_test.cpp
@@ -203,9 +203,10 @@ TEST(LlvmLibcSPrintfTest, IntConv) {
char format[64];
char uintmax[128];
- LIBC_NAMESPACE::sprintf(format, "%%w%du", UINTMAX_WIDTH);
- const int uintmax_len = LIBC_NAMESPACE::sprintf(uintmax, "%ju", UINTMAX_MAX);
- written = LIBC_NAMESPACE::sprintf(buff, format, UINTMAX_MAX);
+ LIBC_NAMESPACE::sprintf(format, "%%w%du", sizeof(uintmax_t) * CHAR_BIT);
+ const int uintmax_len =
+ LIBC_NAMESPACE::sprintf(uintmax, "%ju", sizeof(uintmax_t) * CHAR_BIT);
+ written = LIBC_NAMESPACE::sprintf(buff, format, sizeof(uintmax_t) * CHAR_BIT);
EXPECT_EQ(written, uintmax_len);
ASSERT_STREQ(buff, uintmax);
More information about the libc-commits
mailing list