diff options
| author | David Lamparter <equinox@diac24.net> | 2019-05-12 21:11:19 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2019-06-03 16:44:24 +0200 |
| commit | 32b67a0aeb001d3974f432becd8c8783c7ed6d53 (patch) | |
| tree | 9a9b0c0d53762648804dfc03cbf2a81abacea55d /lib/printf/printf-pos.c | |
| parent | 7fa480984edc26617bc3c6bc4d9bc62d3b299a67 (diff) | |
lib/printf: add %Ld/%Lu for int64_t/uint64_t
[u]int64_t is the only type in the intX_t family that needs
special-casing for printf since the calling convention may differ
between 32-bit and 64-bit systems.
Adding the L specifier allows us to eschew the gnarly-looking PRIu64.
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/printf/printf-pos.c')
| -rw-r--r-- | lib/printf/printf-pos.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/printf/printf-pos.c b/lib/printf/printf-pos.c index f4104c52bf..7f83dea1aa 100644 --- a/lib/printf/printf-pos.c +++ b/lib/printf/printf-pos.c @@ -65,8 +65,8 @@ enum typeid { T_UNUSED, TP_SHORT, T_INT, T_U_INT, TP_INT, T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG, T_PTRDIFFT, TP_PTRDIFFT, T_SSIZET, T_SIZET, TP_SSIZET, - T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR, - T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR + T_INT64T, T_UINT64T, T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, + TP_CHAR, TP_SCHAR, T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR }; /* An expandable array of types. */ @@ -145,7 +145,9 @@ addsarg(struct typetable *types, int flags) if (_ensurespace(types)) return (-1); - if (flags & INTMAXT) + if (flags & LONGDBL) + types->table[types->nextarg++] = T_INT64T; + else if (flags & INTMAXT) types->table[types->nextarg++] = T_INTMAXT; else if (flags & SIZET) types->table[types->nextarg++] = T_SSIZET; @@ -166,7 +168,9 @@ adduarg(struct typetable *types, int flags) if (_ensurespace(types)) return (-1); - if (flags & INTMAXT) + if (flags & LONGDBL) + types->table[types->nextarg++] = T_UINT64T; + else if (flags & INTMAXT) types->table[types->nextarg++] = T_UINTMAXT; else if (flags & SIZET) types->table[types->nextarg++] = T_SIZET; @@ -311,11 +315,9 @@ reswitch: switch (ch) { goto rflag; } goto reswitch; -#ifndef NO_FLOATING_POINT case 'L': flags |= LONGDBL; goto rflag; -#endif case 'h': if (flags & SHORTINT) { flags &= ~SHORTINT; @@ -504,11 +506,9 @@ reswitch: switch (ch) { goto rflag; } goto reswitch; -#ifndef NO_FLOATING_POINT case 'L': flags |= LONGDBL; goto rflag; -#endif case 'h': if (flags & SHORTINT) { flags &= ~SHORTINT; @@ -743,6 +743,12 @@ build_arg_table(struct typetable *types, va_list ap, union arg **argtable) case TP_INTMAXT: (*argtable) [n].pintmaxarg = va_arg (ap, intmax_t *); break; + case T_INT64T: + (*argtable) [n].intmaxarg = va_arg (ap, int64_t); + break; + case T_UINT64T: + (*argtable) [n].uintmaxarg = va_arg (ap, uint64_t); + break; case T_DOUBLE: #ifndef NO_FLOATING_POINT (*argtable) [n].doublearg = va_arg (ap, double); |
