aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/int64.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-24 19:04:37 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-24 19:06:23 -0500
commitcb336b312e7012dc05fe7d8ac1c0e924dbc6c840 (patch)
treed2b8242e46452d12bfb1f7812f6965e64ddf9dfa /src/stdlib/int64.c
parent649977aae7e5922f992cd69eb84da0a2db368580 (diff)
Shuffle dependencies around so header files aren't needed after tomo has
been compiled
Diffstat (limited to 'src/stdlib/int64.c')
-rw-r--r--src/stdlib/int64.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/stdlib/int64.c b/src/stdlib/int64.c
index 754ac619..131d77ab 100644
--- a/src/stdlib/int64.c
+++ b/src/stdlib/int64.c
@@ -1,3 +1,19 @@
#define INTX_C_H__INT_BITS 64
#include "intX.c.h"
#undef INTX_C_H__INT_BITS
+
+public
+int Int64$print(FILE *f, int64_t n) {
+ char buf[21] = {[20] = 0}; // Big enough for INT64_MIN + '\0'
+ char *p = &buf[19];
+ bool negative = n < 0;
+
+ do {
+ *(p--) = '0' + (n % 10);
+ n /= 10;
+ } while (n > 0);
+
+ if (negative) *(p--) = '-';
+
+ return fwrite(p + 1, sizeof(char), (size_t)(&buf[19] - p), f);
+}