Commit 8a0d029244d9b0393db19898e603f24febfb53ee

Thomas Petazzoni 2024-09-15T13:22:36

OpenRISC/or1k build fixes (#854) * src/or1k/ffi.c: fix prototype of ffi_call_SYSV() The current code base of libffi on OpenRISC (or1k) fails to build with GCC 14.x with the following error: ../src/or1k/ffi.c: In function 'ffi_call': ../src/or1k/ffi.c:167:34: error: passing argument 3 of 'ffi_call_SYSV' from incompatible pointer type [-Wincompatible-pointer-types] 167 | ffi_call_SYSV(size, &ecif, ffi_prep_args, rvalue, fn, cif->flags); | ^~~~~~~~~~~~~ | | | void * (*)(char *, extended_cif *) ../src/or1k/ffi.c:113:27: note: expected 'void * (*)(int *, extended_cif *)' but argument is of type 'void * (*)(char *, extended_cif *)' 113 | void *(*)(int *, extended_cif *), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is due to the fact that ffi_prep_args() is in fact defined as: void* ffi_prep_args(char *stack, extended_cif *ecif) so, let's fix the prototype of the function pointer, which anyway gets passed to assembly code, so the typing gets lost. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> * src/or1k/ffi.c: fix incompatible pointer type The current code base of libffi on OpenRISC (or1k) fails to build with GCC 14.x with the following error: ../src/or1k/ffi.c: In function 'ffi_closure_SYSV': ../src/or1k/ffi.c:183:22: error: initialization of 'char *' from incompatible pointer type 'int *' [-Wincompatible-pointer-types] 183 | char *stack_args = sp; | ^~ Indeed: register int *sp __asm__ ("r17"); [..] char *stack_args = sp; Adopt the same logic used for: char *ptr = (char *) register_args; which consists in casting to the desired pointer type. Indeed, later in the code stack_args is assigned to ptr (so they need to be the same pointer type), and some arithmetic is done on ptr, so changing its pointer type would change the behavior. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> --------- Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>