Skip to content

Commit

Permalink
runtimes/native: Stop assuming little endian in tracef
Browse files Browse the repository at this point in the history
Fixes: aduros#752
  • Loading branch information
yamt committed Aug 15, 2024
1 parent 5f3f011 commit 249595c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions runtimes/native/src/runtime.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "runtime.h"

#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -240,30 +241,30 @@ void w4_runtimeTracef (const uint8_t* str, const void* stack) {
break;
case 'c':
bounds_check(argPtr, 4);
putc(*(char*)argPtr, stdout);
putc((char)w4_read32LE(argPtr), stdout);
argPtr += 4;
break;
case 'd':
bounds_check(argPtr, 4);
printf("%d", *(int32_t*)argPtr);
printf("%" PRId32, w4_read32LE(argPtr));
argPtr += 4;
break;
case 'x':
bounds_check(argPtr, 4);
printf("%x", *(uint32_t*)argPtr);
printf("%" PRIx32, w4_read32LE(argPtr));
argPtr += 4;
break;
case 's':
bounds_check(argPtr, 4);
strPtr = *(uint32_t*)argPtr;
strPtr = w4_read32LE(argPtr);
argPtr += 4;
const char *strPtr_host = (const char *)memory + strPtr;
bounds_check_cstr(strPtr_host);
printf("%s", strPtr_host);
break;
case 'f':
bounds_check(argPtr, 8);
printf("%lg", *(double*)argPtr);
printf("%lg", w4_readf64LE(argPtr));
argPtr += 8;
break;
default:
Expand Down

0 comments on commit 249595c

Please sign in to comment.