From ab1e36dcf9b7182d18704f627aff461ce87d7d09 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Thu, 17 Dec 2015 11:41:10 +0000
Subject: [PATCH] py/mpprint: Implement %llu and %lld format specifiers for
 mp_printf.

Only enabled for MICROPY_OBJ_REPR_D.
---
 py/mpprint.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/py/mpprint.c b/py/mpprint.c
index f751e9a5e..30bbe3c6d 100644
--- a/py/mpprint.c
+++ b/py/mpprint.c
@@ -526,6 +526,20 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
                 break;
             }
 #endif
+            // Because 'l' is eaten above, another 'l' means %ll.  We need to support
+            // this length specifier for OBJ_REPR_D (64-bit NaN boxing).
+            // TODO Either enable this unconditionally, or provide a specific config var.
+            #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
+            case 'l': {
+                unsigned long long int arg_value = va_arg(args, unsigned long long int);
+                ++fmt;
+                if (*fmt == 'u' || *fmt == 'd') {
+                    chrs += mp_print_int(print, arg_value, *fmt == 'd', 10, 'a', flags, fill, width);
+                    break;
+                }
+                // fall through to default case to print unknown format char
+            }
+            #endif
             default:
                 print->print_strn(print->data, fmt, 1);
                 chrs += 1;
-- 
GitLab