summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/x86_64/abi/callabi
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.target/x86_64/abi/callabi
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.target/x86_64/abi/callabi')
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/callabi.exp36
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/callabi.h50
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/func-1.c40
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/func-2a.c27
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/func-2b.c13
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect-2a.c17
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect-2b.c24
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect.c24
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-1.c11
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-2.c25
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/pr38891.c10
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-1.c47
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-2.c47
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-3.c47
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-4a.c24
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-4b.c31
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5a.c17
-rw-r--r--gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5b.c37
18 files changed, 527 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/callabi.exp b/gcc/testsuite/gcc.target/x86_64/abi/callabi/callabi.exp
new file mode 100644
index 000000000..e76d0c101
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/callabi.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+if { (![istarget x86_64-*-*] && ![istarget i?86-*-*])
+ || [is-effective-target ilp32] } then {
+ return
+}
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+dg-init
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+ "" $DEFAULT_CFLAGS
+dg-finish
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/callabi.h b/gcc/testsuite/gcc.target/x86_64/abi/callabi/callabi.h
new file mode 100644
index 000000000..d008ad659
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/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.target/x86_64/abi/callabi/func-1.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-1.c
new file mode 100644
index 000000000..7d0b50636
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/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 } */
+/* { 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;
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-2a.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-2a.c
new file mode 100644
index 000000000..048da6e56
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-2a.c
@@ -0,0 +1,27 @@
+/* Test for cross x86_64<->w64 abi standard calls. */
+/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -mabi=ms -std=gnu99 -ffast-math -fno-builtin" } */
+/* { dg-additional-sources "func-2b.c" } */
+
+extern void __attribute__ ((sysv_abi)) abort (void);
+long double func_cross (long double, double, float, long, int, char);
+
+long double __attribute__ ((sysv_abi))
+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 __attribute__ ((sysv_abi))
+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;
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-2b.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-2b.c
new file mode 100644
index 000000000..fe85dd186
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-2b.c
@@ -0,0 +1,13 @@
+/* Test for cross x86_64<->w64 abi standard calls. */
+/* { dg-options "-mabi=ms -std=gnu99 -ffast-math -fno-builtin" } */
+
+long double 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;
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect-2a.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect-2a.c
new file mode 100644
index 000000000..730b8db9c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect-2a.c
@@ -0,0 +1,17 @@
+/* Test for cross x86_64<->w64 abi standard calls via variable. */
+/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -mabi=ms -std=gnu99 -ffast-math -fno-builtin" } */
+/* { dg-additional-sources "func-indirect-2b.c" } */
+
+extern void __attribute__ ((sysv_abi)) abort (void);
+typedef int (*func)(void *, char *, char *, short, long long);
+extern func get_callback (void);
+
+int __attribute__ ((sysv_abi))
+main ()
+{
+ func callme = get_callback ();
+ if (callme (0, 0, 0, 0x1234, 0x1234567890abcdefLL))
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect-2b.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect-2b.c
new file mode 100644
index 000000000..1a9fccd97
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect-2b.c
@@ -0,0 +1,24 @@
+/* Test for cross x86_64<->w64 abi standard calls via variable. */
+/* { dg-options "-O2 -mabi=ms -std=gnu99 -ffast-math -fno-builtin" } */
+
+typedef int (*func)(void *, char *, char *, short, long long);
+
+static int
+callback (void *ptr, char *string1, char *string2, short number,
+ long long rand)
+{
+ if (ptr != 0
+ || string1 != 0
+ || string2 != 0
+ || number != 0x1234
+ || rand != 0x1234567890abcdefLL)
+ return 1;
+ else
+ return 0;
+}
+
+func
+get_callback (void)
+{
+ return callback;
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect.c
new file mode 100644
index 000000000..0c0cbb271
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-indirect.c
@@ -0,0 +1,24 @@
+/* Test for cross x86_64<->w64 abi standard calls via variable.
+*/
+/* Origin: Kai Tietz <kai.tietz@onevision.com> */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -ffast-math" } */
+#include "callabi.h"
+
+extern void abort (void);
+
+typedef int (CALLABI_CROSS *func)(void *, char *, char *, short, long long);
+
+int CALLABI_CROSS
+callback(void * ptr, char *string1, char *string2, short number, long long rand)
+{
+ return (rand != 0x1234567890abcdefLL);
+}
+
+int main()
+{
+ volatile func callme = callback;
+ if(callme(0, 0, 0, 0, 0x1234567890abcdefLL))
+ abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-1.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-1.c
new file mode 100644
index 000000000..35f8b53ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mabi=sysv" } */
+
+__attribute__ ((ms_abi))
+int foo (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-assembler-not "%rsp" } } */
+
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-2.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-2.c
new file mode 100644
index 000000000..2a54bc89c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-2.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mabi=sysv" } */
+
+extern int glb1, gbl2, gbl3;
+
+__attribute__ ((ms_abi))
+int foo (void)
+{
+ int r = 1;
+ int i, j, k;
+ for (i = 0; i < glb1; i++)
+ {
+ r *= (i + 1);
+ for (j = gbl2; j > 0; --j)
+ {
+ for (k = 0; k < gbl3; k++)
+ r += (i + k * j);
+ }
+ }
+
+ return r;
+}
+
+/* { dg-final { scan-assembler-not "%rsp" } } */
+
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/pr38891.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/pr38891.c
new file mode 100644
index 000000000..d31b8c377
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/pr38891.c
@@ -0,0 +1,10 @@
+/* Test for cross x86_64<->w64 abi standard calls.
+*/
+/* { dg-do compile } */
+/* { dg-options "-mno-sse" } */
+#include "callabi.h"
+
+long double
+CALLABI_CROSS func_cross ()
+{
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-1.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-1.c
new file mode 100644
index 000000000..a6d8463ed
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/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 } */
+/* { 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.target/x86_64/abi/callabi/vaarg-2.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-2.c
new file mode 100644
index 000000000..e281e860f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/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 } */
+/* { 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.target/x86_64/abi/callabi/vaarg-3.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-3.c
new file mode 100644
index 000000000..7cca7ac87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/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 } */
+/* { 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;
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-4a.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-4a.c
new file mode 100644
index 000000000..a44470431
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-4a.c
@@ -0,0 +1,24 @@
+/* Test for cross x86_64<->w64 abi va_list calls. */
+/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -mabi=ms -std=gnu99 -fno-builtin" } */
+/* { dg-additional-sources "vaarg-4b.c" } */
+
+extern __SIZE_TYPE__ __attribute__ ((sysv_abi)) strlen (const char *);
+extern int __attribute__ ((sysv_abi)) sprintf (char *,const char *, ...);
+extern void __attribute__ ((sysv_abi)) abort (void);
+
+extern void do_cpy (char *, ...);
+
+int __attribute__ ((sysv_abi))
+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.target/x86_64/abi/callabi/vaarg-4b.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-4b.c
new file mode 100644
index 000000000..f33906bd2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-4b.c
@@ -0,0 +1,31 @@
+/* Test for cross x86_64<->w64 abi va_list calls. */
+/* { dg-options "-O2 -mabi=ms -std=gnu99 -fno-builtin" } */
+
+#include <stdarg.h>
+
+extern __SIZE_TYPE__ __attribute__ ((sysv_abi)) strlen (const char *);
+extern int __attribute__ ((sysv_abi)) sprintf (char *, const char *, ...);
+
+static void
+vdo_cpy (char *s, va_list argp)
+{
+ __SIZE_TYPE__ len;
+ char *r = s;
+ char *e;
+ *r = 0;
+ for (;;) {
+ e = va_arg (argp, char *);
+ if (*e == 0) break;
+ sprintf (r,"%s", e);
+ r += strlen (r);
+ }
+}
+
+void
+do_cpy (char *s, ...)
+{
+ va_list argp;
+ va_start (argp, s);
+ vdo_cpy (s, argp);
+ va_end (argp);
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5a.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5a.c
new file mode 100644
index 000000000..e9912957e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5a.c
@@ -0,0 +1,17 @@
+/* Test for cross x86_64<->w64 abi va_list calls. */
+/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -mabi=ms -std=gnu99 -fno-builtin" } */
+/* { dg-additional-sources "vaarg-5b.c" } */
+
+extern void __attribute__ ((sysv_abi)) abort (void);
+extern int fct2 (int, ...);
+
+#define SZ_ARGS 1ll,2ll,3ll,4ll,5ll,6ll,7ll,0ll
+
+int __attribute__ ((sysv_abi))
+main()
+{
+ if (fct2 (-1, SZ_ARGS) != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5b.c b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5b.c
new file mode 100644
index 000000000..e5dd4727b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/callabi/vaarg-5b.c
@@ -0,0 +1,37 @@
+/* Test for cross x86_64<->w64 abi va_list calls. */
+/* { dg-options "-O2 -mabi=ms -std=gnu99 -fno-builtin" } */
+
+#include <stdarg.h>
+
+#define SZ_ARGS 1ll,2ll,3ll,4ll,5ll,6ll,7ll,0ll
+
+static int __attribute__ ((sysv_abi))
+fct1 (va_list argp, ...)
+{
+ long long p1,p2;
+ int ret = 1;
+ __builtin_sysv_va_list argp_2;
+
+ __builtin_sysv_va_start (argp_2, argp);
+ do {
+ p1 = va_arg (argp_2, long long);
+ p2 = va_arg (argp, long long);
+ if (p1 != p2)
+ ret = 0;
+ } while (ret && p1 != 0);
+ __builtin_sysv_va_end (argp_2);
+
+ return ret;
+}
+
+int
+fct2 (int dummy, ...)
+{
+ va_list argp;
+ int ret = dummy;
+
+ va_start (argp, dummy);
+ ret += fct1 (argp, SZ_ARGS);
+ va_end (argp);
+ return ret;
+}