From 603fb6250816307fc668534a253daa99c90b22fa Mon Sep 17 00:00:00 2001 From: Masami HIRATA Date: Sat, 4 Aug 2012 23:30:46 +0900 Subject: [PATCH 1/2] fixed: Clang for x86_64 zero-extend or sign-extend function parameters in registers to 32-bit if the types are less than 32-bit --- src/x86/ffi64.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c index 1daa1c0..abe6450 100644 --- a/src/x86/ffi64.c +++ b/src/x86/ffi64.c @@ -472,7 +472,17 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[], case X86_64_INTEGER_CLASS: case X86_64_INTEGERSI_CLASS: reg_args->gpr[gprcount] = 0; - memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8); + switch (arg_types[i]->type) + { + case FFI_TYPE_SINT8: + reg_args->gpr[gprcount] = (SINT32) *(SINT8 *) a; + break; + case FFI_TYPE_SINT16: + reg_args->gpr[gprcount] = (SINT32) *(SINT16 *) a; + break; + default: + memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8); + } gprcount++; break; case X86_64_SSE_CLASS: -- 1.7.10 From 805a523c6521c5b9be51a8797508459512b0f482 Mon Sep 17 00:00:00 2001 From: Masami HIRATA Date: Sat, 4 Aug 2012 23:31:59 +0900 Subject: [PATCH 2/2] fixed: Clang warning: comparison of integers of different signs: 'ffi_arg' (aka 'unsigned long') and 'int' [-Wsign-compare] --- testsuite/libffi.call/return_uc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/return_uc.c b/testsuite/libffi.call/return_uc.c index 07c45de..b124203 100644 --- a/testsuite/libffi.call/return_uc.c +++ b/testsuite/libffi.call/return_uc.c @@ -32,7 +32,7 @@ int main (void) uc < (unsigned char) '\xff'; uc++) { ffi_call(&cif, FFI_FN(return_uc), &rint, values); - CHECK(rint == (signed int) uc); + CHECK(rint == (ffi_arg) uc); } exit(0); } -- 1.7.10