From 6ee366e765483f6b48537d97fc81ae56f13d1b7f Mon Sep 17 00:00:00 2001 From: James Lyon Date: Fri, 26 Apr 2013 16:42:12 +0100 Subject: Fixed x86-64 long double passing. long double arguments require 16-byte alignment on the stack, which requires adjustment when the the stack offset is not an evven number of 8-byte words. --- tests/abitest.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/abitest.c') diff --git a/tests/abitest.c b/tests/abitest.c index a51eb9b..7b12144 100644 --- a/tests/abitest.c +++ b/tests/abitest.c @@ -389,6 +389,24 @@ static int stdarg_struct_test(void) { return run_callback(src, stdarg_struct_test_callback); } +/* Test that x86-64 arranges the stack correctly for arguments with alignment >8 bytes */ + +typedef LONG_DOUBLE (*arg_align_test_callback_type) (LONG_DOUBLE,int,LONG_DOUBLE,int,LONG_DOUBLE); + +static int arg_align_test_callback(void *ptr) { + arg_align_test_callback_type f = (arg_align_test_callback_type)ptr; + long double x = f(12, 0, 25, 0, 37); + return (x == 74) ? 0 : -1; +} + +static int arg_align_test(void) { + const char *src = + "long double f(long double a, int b, long double c, int d, long double e) {\n" + " return a + c + e;\n" + "}\n"; + return run_callback(src, arg_align_test_callback); +} + #define RUN_TEST(t) \ if (!testname || (strcmp(#t, testname) == 0)) { \ fputs(#t "... ", stdout); \ @@ -432,5 +450,6 @@ int main(int argc, char **argv) { RUN_TEST(many_struct_test_2); RUN_TEST(stdarg_test); RUN_TEST(stdarg_struct_test); + RUN_TEST(arg_align_test); return retval; } -- cgit v1.3.1