aboutsummaryrefslogtreecommitdiff
path: root/tests/abitest.c
diff options
context:
space:
mode:
authorJames Lyon <jamesly0n@hotmail.com>2013-04-26 16:42:12 +0100
committerJames Lyon <jamesly0n@hotmail.com>2013-04-26 16:42:12 +0100
commit6ee366e765483f6b48537d97fc81ae56f13d1b7f (patch)
treec9365133ee9c4cf1ec4fcee0641ac9adc2fe825d /tests/abitest.c
parent41d76e1fcbe498b0d01e245f5a2d368a23760101 (diff)
downloadtinycc-6ee366e765483f6b48537d97fc81ae56f13d1b7f.tar.gz
tinycc-6ee366e765483f6b48537d97fc81ae56f13d1b7f.tar.bz2
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.
Diffstat (limited to 'tests/abitest.c')
-rw-r--r--tests/abitest.c19
1 files changed, 19 insertions, 0 deletions
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;
}