mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 05:20:25 +08:00
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
This commit is contained in:
parent
dcef3dac7f
commit
b6b02c5528
@ -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.
|
||||
|
50
gcc/testsuite/gcc.dg/callabi/callabi.h
Normal file
50
gcc/testsuite/gcc.dg/callabi/callabi.h
Normal file
@ -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
|
40
gcc/testsuite/gcc.dg/callabi/func-1.c
Normal file
40
gcc/testsuite/gcc.dg/callabi/func-1.c
Normal file
@ -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;
|
||||
}
|
47
gcc/testsuite/gcc.dg/callabi/vaarg-1.c
Normal file
47
gcc/testsuite/gcc.dg/callabi/vaarg-1.c
Normal file
@ -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;
|
||||
}
|
47
gcc/testsuite/gcc.dg/callabi/vaarg-2.c
Normal file
47
gcc/testsuite/gcc.dg/callabi/vaarg-2.c
Normal file
@ -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;
|
||||
}
|
47
gcc/testsuite/gcc.dg/callabi/vaarg-3.c
Normal file
47
gcc/testsuite/gcc.dg/callabi/vaarg-3.c
Normal file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user