Skip to content

Commit 4d052a7

Browse files
committed
Log endianness when dumping memory stats
1 parent 215f246 commit 4d052a7

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

quickjs.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,15 @@ static inline int is_digit(int c) {
15061506
return c >= '0' && c <= '9';
15071507
}
15081508

1509+
static inline BOOL is_be(void)
1510+
{
1511+
union {
1512+
uint16_t a;
1513+
uint8_t b;
1514+
} u = {0x100};
1515+
return u.b;
1516+
}
1517+
15091518
typedef struct JSClassShortDef {
15101519
JSAtom class_name;
15111520
JSClassFinalizer *finalizer;
@@ -6148,8 +6157,8 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s)
61486157

61496158
void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
61506159
{
6151-
fprintf(fp, "QuickJS-ng memory usage -- %s version, %d-bit, malloc limit: %"PRId64"\n\n",
6152-
JS_GetVersion(), (int)sizeof(void *) * 8, s->malloc_limit);
6160+
fprintf(fp, "QuickJS-ng memory usage -- %s version, %d-bit, %s Endian, malloc limit: %"PRId64"\n\n",
6161+
JS_GetVersion(), (int)sizeof(void *) * 8, is_be() ? "Big" : "Little", s->malloc_limit);
61536162
if (rt) {
61546163
static const struct {
61556164
const char *name;
@@ -32335,15 +32344,6 @@ static const char * const bc_tag_str[] = {
3233532344
};
3233632345
#endif
3233732346

32338-
static inline BOOL is_be(void)
32339-
{
32340-
union {
32341-
uint16_t a;
32342-
uint8_t b;
32343-
} u = {0x100};
32344-
return u.b;
32345-
}
32346-
3234732347
static void bc_put_u8(BCWriterState *s, uint8_t v)
3234832348
{
3234932349
dbuf_putc(&s->dbuf, v);

0 commit comments

Comments
 (0)