diff options
-rw-r--r-- | machine/fdt.c | 5 | ||||
-rw-r--r-- | pk/pk.c | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/machine/fdt.c b/machine/fdt.c index 07b574f..4ec1530 100644 --- a/machine/fdt.c +++ b/machine/fdt.c @@ -9,9 +9,14 @@ static inline uint32_t bswap(uint32_t x) { +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ uint32_t y = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >> 8; uint32_t z = (y & 0x0000FFFF) << 16 | (y & 0xFFFF0000) >> 16; return z; +#else + /* No need to swap on big endian */ + return x; +#endif } static inline int isstring(char c) @@ -129,15 +129,15 @@ static void run_loaded_program(size_t argc, char** argv, uintptr_t kstack_top) // place argc, argv, envp, auxp on stack #define PUSH_ARG(type, value) do { \ *((type*)sp) = (type)value; \ - sp += sizeof(type); \ + sp ++; \ } while (0) #define STACK_INIT(type) do { \ unsigned naux = sizeof(aux)/sizeof(aux[0]); \ stack_top -= (1 + argc + 1 + envc + 1 + 2*naux) * sizeof(type); \ stack_top &= -16; \ - long sp = stack_top; \ - PUSH_ARG(type, argc); \ + type *sp = (void*)stack_top; \ + PUSH_ARG(int, argc); \ for (unsigned i = 0; i < argc; i++) \ PUSH_ARG(type, argv[i]); \ PUSH_ARG(type, 0); /* argv[argc] = NULL */ \ |