[libc-commits] [libc] Add bit width length modifier to printf (PR #82461)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed Feb 21 09:57:57 PST 2024
================
@@ -40,6 +42,18 @@ LIBC_INLINE uintmax_t apply_length_modifier(uintmax_t num, LengthModifier lm) {
return num & cpp::numeric_limits<uintptr_t>::max();
case LengthModifier::j:
return num; // j is intmax, so no mask is necessary.
+ case LengthModifier::w:
+ case LengthModifier::wf: {
+ uintmax_t mask;
+ if (bw == 0) {
+ mask = 0;
+ } else if (bw < sizeof(uintmax_t) * 8) {
+ mask = (static_cast<uintmax_t>(1) << bw) - 1;
+ } else {
+ mask = UINTMAX_MAX;
----------------
michaelrj-google wrote:
you should add a test that checks this behavior
https://github.com/llvm/llvm-project/pull/82461
More information about the libc-commits
mailing list