[libc-commits] [libc] 838b118 - [libc] Fix missing UINTMAX_WIDTH (#87092)
via libc-commits
libc-commits at lists.llvm.org
Fri Mar 29 10:32:37 PDT 2024
Author: Michael Jones
Date: 2024-03-29T10:32:33-07:00
New Revision: 838b118d394138a746ffb4c113fb97b0f8904bd2
URL: https://github.com/llvm/llvm-project/commit/838b118d394138a746ffb4c113fb97b0f8904bd2
DIFF: https://github.com/llvm/llvm-project/commit/838b118d394138a746ffb4c113fb97b0f8904bd2.diff
LOG: [libc] Fix missing UINTMAX_WIDTH (#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.
Added:
Modified:
libc/test/src/stdio/sprintf_test.cpp
Removed:
################################################################################
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