From 4d052a7e7162dea3e15e7281475c51cba907e2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 6 Mar 2024 09:52:03 +0100 Subject: [PATCH] Log endianness when dumping memory stats --- quickjs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/quickjs.c b/quickjs.c index 97db3bc..56b61e8 100644 --- a/quickjs.c +++ b/quickjs.c @@ -1506,6 +1506,15 @@ static inline int is_digit(int c) { return c >= '0' && c <= '9'; } +static inline BOOL is_be(void) +{ + union { + uint16_t a; + uint8_t b; + } u = {0x100}; + return u.b; +} + typedef struct JSClassShortDef { JSAtom class_name; JSClassFinalizer *finalizer; @@ -6148,8 +6157,8 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s) void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt) { - fprintf(fp, "QuickJS-ng memory usage -- %s version, %d-bit, malloc limit: %"PRId64"\n\n", - JS_GetVersion(), (int)sizeof(void *) * 8, s->malloc_limit); + fprintf(fp, "QuickJS-ng memory usage -- %s version, %d-bit, %s Endian, malloc limit: %"PRId64"\n\n", + JS_GetVersion(), (int)sizeof(void *) * 8, is_be() ? "Big" : "Little", s->malloc_limit); if (rt) { static const struct { const char *name; @@ -32335,15 +32344,6 @@ static const char * const bc_tag_str[] = { }; #endif -static inline BOOL is_be(void) -{ - union { - uint16_t a; - uint8_t b; - } u = {0x100}; - return u.b; -} - static void bc_put_u8(BCWriterState *s, uint8_t v) { dbuf_putc(&s->dbuf, v);