this also fixes passing of params > 16 bytes. In riscv they aren't passed by value on stack, but via reference (and because callees are allowed to modify by-ref params the caller must allocate an own copy per call). This fixes the stdarg parts of 73_arm.c.
Showing the changes to include (1 of 4 files). Show all
Unified · Split
| @@ -63,6 +63,16 @@ typedef struct { · 62 unmodified lines | |||
| 63 | #define va_end(ap) ((void)0) | 63 | #define va_end(ap) ((void)0) |
| 64 | #define va_copy(dest, src) ((dest) = (src)) | 64 | #define va_copy(dest, src) ((dest) = (src)) |
| 65 | 65 | ||
| 66 | #elif defined __riscv | ||
| 67 | #define __va_reg_size (__riscv_xlen >> 3) | ||
| 68 | #define _tcc_align(addr,type) (((unsigned long)addr + __alignof__(type) - 1) \ | ||
| 69 | & -(__alignof__(type))) | ||
| 70 | typedef char *va_list; | ||
| 71 | #define va_start __builtin_va_start | ||
| 72 | #define va_arg(ap,type) (*(sizeof(type) > (2*__va_reg_size) ? *(type **)((ap += __va_reg_size) - __va_reg_size) : (ap = (va_list)(_tcc_align(ap,type) + (sizeof(type)+__va_reg_size - 1)& -__va_reg_size), (type *)(ap - ((sizeof(type)+ __va_reg_size - 1)& -__va_reg_size))))) | ||
| 73 | #define va_copy(dest, src) (dest) = (src) | ||
| 74 | #define va_end(ap) ((void)0) | ||
| 75 | |||
| 66 | #else /* __i386__ */ | 76 | #else /* __i386__ */ |
| 67 | typedef char *va_list; | 77 | typedef char *va_list; |
| 68 | /* only correct for i386 */ | 78 | /* only correct for i386 */ |