aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Tietz <kai.tietz@onevision.com>2008-07-06 14:49:32 +0000
committerKai Tietz <ktietz@gcc.gnu.org>2008-07-06 16:49:32 +0200
commitb6b02c5528b662733f3555dec2a397b3269c22d6 (patch)
tree5dac5ee0ea03c30192820f3daa8f85da24272f8d
parentdcef3dac7f7d7d6fdcd21451f3c9a570aaa8a50d (diff)
downloadgcc-b6b02c5528b662733f3555dec2a397b3269c22d6.zip
gcc-b6b02c5528b662733f3555dec2a397b3269c22d6.tar.gz
gcc-b6b02c5528b662733f3555dec2a397b3269c22d6.tar.bz2
callabi.h: New.
2008-07-06 Kai Tietz <kai.tietz@onevision.com> * gcc.dg/callabi/callabi.h: New. * gcc.dg/callabi/vaarg-1.c: New. * gcc.dg/callabi/vaarg-2.c: New. * gcc.dg/callabi/vaarg-3.c: New. * gcc.dg/callabi/func-1.c: New. From-SVN: r137524
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/callabi/callabi.h50
-rw-r--r--gcc/testsuite/gcc.dg/callabi/func-1.c40
-rw-r--r--gcc/testsuite/gcc.dg/callabi/vaarg-1.c47
-rw-r--r--gcc/testsuite/gcc.dg/callabi/vaarg-2.c47
-rw-r--r--gcc/testsuite/gcc.dg/callabi/vaarg-3.c47
6 files changed, 239 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7eb21a4..cf6ba6b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2008-07-06 Kai Tietz <kai.tietz@onevision.com>
+
+ * gcc.dg/callabi/callabi.h: New.
+ * gcc.dg/callabi/vaarg-1.c: New.
+ * gcc.dg/callabi/vaarg-2.c: New.
+ * gcc.dg/callabi/vaarg-3.c: New.
+ * gcc.dg/callabi/func-1.c: New.
+
2008-07-05 Andrew Pinski <andrew_pinski@playstation.sony.com>
* g++.dg/tree-ssa/ptrmemfield.C: New testcase.
diff --git a/gcc/testsuite/gcc.dg/callabi/callabi.h b/gcc/testsuite/gcc.dg/callabi/callabi.h
new file mode 100644
index 0000000..d008ad6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/callabi/callabi.h
@@ -0,0 +1,50 @@
+/* First the default target definition. */
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST
+ typedef __builtin_va_list __gnuc_va_list;
+#endif
+
+#ifndef _VA_LIST_DEFINED
+#define _VA_LIST_DEFINED
+ typedef __gnuc_va_list va_list;
+#endif
+
+#define __va_copy(d,s) __builtin_va_copy(d,s)
+#define __va_start(v,l) __builtin_va_start(v,l)
+#define __va_arg(v,l) __builtin_va_arg(v,l)
+#define __va_end(v) __builtin_va_end(v)
+
+#define __ms_va_copy(d,s) __builtin_ms_va_copy(d,s)
+#define __ms_va_start(v,l) __builtin_ms_va_start(v,l)
+#define __ms_va_arg(v,l) __builtin_va_arg(v,l)
+#define __ms_va_end(v) __builtin_ms_va_end(v)
+
+#define __sysv_va_copy(d,s) __builtin_sysv_va_copy(d,s)
+#define __sysv_va_start(v,l) __builtin_sysv_va_start(v,l)
+#define __sysv_va_arg(v,l) __builtin_va_arg(v,l)
+#define __sysv_va_end(v) __builtin_sysv_va_end(v)
+
+#define CALLABI_NATIVE
+
+#ifdef _WIN64
+#define CALLABI_CROSS __attribute__ ((sysv_abi))
+
+#define CROSS_VA_LIST __builtin_sysv_va_list
+
+#define CROSS_VA_COPY(d,s) __sysv_va_copy(d,s)
+#define CROSS_VA_START(v,l) __sysv_va_start(v,l)
+#define CROSS_VA_ARG(v,l) __sysv_va_arg(v,l)
+#define CROSS_VA_END(v) __sysv_va_end(v)
+
+#else
+
+#define CALLABI_CROSS __attribute__ ((ms_abi))
+
+#define CROSS_VA_LIST __builtin_ms_va_list
+
+#define CROSS_VA_COPY(d,s) __ms_va_copy(d,s)
+#define CROSS_VA_START(v,l) __ms_va_start(v,l)
+#define CROSS_VA_ARG(v,l) __ms_va_arg(v,l)
+#define CROSS_VA_END(v) __ms_va_end(v)
+
+#endif \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/callabi/func-1.c b/gcc/testsuite/gcc.dg/callabi/func-1.c
new file mode 100644
index 0000000..c727dbe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/callabi/func-1.c
@@ -0,0 +1,40 @@
+/* Test for cross x86_64<->w64 abi standard calls.
+*/
+/* Origin: Kai Tietz <kai.tietz@onevision.com> */
+/* { dg-do run { target { x86_64-*-* } } } */
+/* { dg-options "-std=gnu99 -ffast-math" } */
+#include "callabi.h"
+
+extern void abort (void);
+
+long double
+CALLABI_CROSS func_cross (long double a, double b, float c, long d, int e,
+ char f)
+{
+ long double ret;
+ ret = a + (long double) b + (long double) c;
+ ret *= (long double) (d + (long) e);
+ if (f>0)
+ ret += func_cross (a,b,c,d,e,-f);
+ return ret;
+}
+
+long double
+CALLABI_NATIVE func_native (long double a, double b, float c, long d, int e,
+ char f)
+{
+ long double ret;
+ ret = a + (long double) b + (long double) c;
+ ret *= (long double) (d + (long) e);
+ if (f>0)
+ ret += func_native (a,b,c,d,e,-f);
+ return ret;
+}
+
+int main ()
+{
+ if (func_cross (1.0,2.0,3.0,1,2,3)
+ != func_native (1.0,2.0,3.0,1,2,3))
+ abort ();
+ return 0;
+} \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/callabi/vaarg-1.c b/gcc/testsuite/gcc.dg/callabi/vaarg-1.c
new file mode 100644
index 0000000..1e745e5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/callabi/vaarg-1.c
@@ -0,0 +1,47 @@
+/* Test for cross x86_64<->w64 abi va_list calls.
+*/
+/* Origin: Kai Tietz <kai.tietz@onevision.com> */
+/* { dg-do run { target { x86_64-*-* } } } */
+/* { dg-options "-std=gnu99" } */
+#include "callabi.h"
+
+extern __SIZE_TYPE__ strlen (const char *);
+extern int sprintf (char *,const char *, ...);
+extern void abort (void);
+
+static
+void CALLABI_CROSS vdo_cpy (char *s, CROSS_VA_LIST argp)
+{
+ __SIZE_TYPE__ len;
+ char *r = s;
+ char *e;
+ *r = 0;
+ for (;;) {
+ e = CROSS_VA_ARG (argp,char *);
+ if (*e == 0) break;
+ sprintf (r,"%s", e);
+ r += strlen (r);
+ }
+}
+
+static
+void CALLABI_CROSS do_cpy (char *s, ...)
+{
+ CROSS_VA_LIST argp;
+ CROSS_VA_START (argp, s);
+ vdo_cpy (s, argp);
+ CROSS_VA_END (argp);
+}
+
+int main ()
+{
+ char s[256];
+
+ do_cpy (s, "1","2","3","4", "5", "6", "7", "");
+
+ if (s[0] != '1' || s[1] !='2' || s[2] != '3' || s[3] != '4'
+ || s[4] != '5' || s[5] != '6' || s[6] != '7' || s[7] != 0)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/callabi/vaarg-2.c b/gcc/testsuite/gcc.dg/callabi/vaarg-2.c
new file mode 100644
index 0000000..c9b7161
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/callabi/vaarg-2.c
@@ -0,0 +1,47 @@
+/* Test for cross x86_64<->w64 abi va_list calls.
+*/
+/* Origin: Kai Tietz <kai.tietz@onevision.com> */
+/* { dg-do run { target { x86_64-*-* } } } */
+/* { dg-options "-std=gnu99" } */
+#include "callabi.h"
+
+extern void abort (void);
+
+#define SZ_ARGS 1ll,2ll,3ll,4ll,5ll,6ll,7ll,0ll
+
+static
+int CALLABI_CROSS fct1 (va_list argp, ...)
+{
+ long long p1,p2;
+ int ret = 1;
+ CROSS_VA_LIST argp_2;
+ CROSS_VA_START (argp_2,argp);
+
+ do {
+ p1 = CROSS_VA_ARG (argp_2, long long);
+ p2 = __va_arg (argp, long long);
+ if (p1 != p2)
+ ret = 0;
+ } while (ret && p1 != 0);
+ CROSS_VA_END (argp_2);
+ return ret;
+}
+
+static
+int fct2 (int dummy, ...)
+{
+ va_list argp;
+ int ret = dummy;
+
+ __va_start (argp, dummy);
+ ret += fct1 (argp, SZ_ARGS);
+ __va_end (argp);
+ return ret;
+}
+
+int main()
+{
+ if (fct2 (-1, SZ_ARGS) != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/callabi/vaarg-3.c b/gcc/testsuite/gcc.dg/callabi/vaarg-3.c
new file mode 100644
index 0000000..d0d0687
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/callabi/vaarg-3.c
@@ -0,0 +1,47 @@
+/* Test for cross x86_64<->w64 abi va_list calls.
+*/
+/* Origin: Kai Tietz <kai.tietz@onevision.com> */
+/* { dg-do run { target { x86_64-*-* } } } */
+/* { dg-options "-std=gnu99" } */
+#include "callabi.h"
+
+extern void abort (void);
+
+#define SZ_ARGS 1ll,2ll,3ll,4ll,5ll,6ll,7ll,0ll
+
+static
+int fct1 (CROSS_VA_LIST argp, ...)
+{
+ long long p1,p2;
+ int ret = 1;
+ va_list argp_2;
+
+ __va_start (argp_2,argp);
+ do {
+ p1 = __va_arg (argp_2, long long);
+ p2 = CROSS_VA_ARG (argp, long long);
+ if (p1 != p2)
+ ret = 0;
+ } while (ret && p1 != 0);
+ __va_end (argp_2);
+ return ret;
+}
+
+static
+int CALLABI_CROSS fct2 (int dummy, ...)
+{
+ CROSS_VA_LIST argp;
+ int ret = dummy;
+
+ CROSS_VA_START (argp, dummy);
+ ret += fct1 (argp, SZ_ARGS);
+ CROSS_VA_END (argp);
+ return ret;
+}
+
+int main()
+{
+ if (fct2 (-1, SZ_ARGS) != 0)
+ abort ();
+ return 0;
+}