OSDN Git Service

2003-12-01 Andreas Tobler <a.tobler@schweiz.ch>
authorandreast <andreast@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 Dec 2003 07:23:28 +0000 (07:23 +0000)
committerandreast <andreast@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 Dec 2003 07:23:28 +0000 (07:23 +0000)
PR other/13221
* testsuite/libffi.call/cls_multi_sshort.c: New test case.
* testsuite/libffi.call/cls_multi_sshortchar.c: Likewise.
* testsuite/libffi.call/cls_multi_uchar.c: Likewise.
* testsuite/libffi.call/cls_multi_schar.c: Likewise.
* testsuite/libffi.call/cls_multi_ushortchar.c: Likewise.
* testsuite/libffi.call/cls_multi_ushort.c: Likewise.

* testsuite/libffi.special/unwindtest.cc: Cosmetics.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74093 138bc75d-0d04-0410-961f-82ee72b054a4

libffi/ChangeLog
libffi/testsuite/libffi.call/cls_multi_schar.c [new file with mode: 0644]
libffi/testsuite/libffi.call/cls_multi_sshort.c [new file with mode: 0644]
libffi/testsuite/libffi.call/cls_multi_sshortchar.c [new file with mode: 0644]
libffi/testsuite/libffi.call/cls_multi_uchar.c [new file with mode: 0644]
libffi/testsuite/libffi.call/cls_multi_ushort.c [new file with mode: 0644]
libffi/testsuite/libffi.call/cls_multi_ushortchar.c [new file with mode: 0644]
libffi/testsuite/libffi.special/unwindtest.cc

index bf030bf..8d0fa81 100644 (file)
@@ -1,3 +1,15 @@
+2003-12-01  Andreas Tobler  <a.tobler@schweiz.ch>
+
+       PR other/13221
+       * testsuite/libffi.call/cls_multi_sshort.c: New test case.
+       * testsuite/libffi.call/cls_multi_sshortchar.c: Likewise.
+       * testsuite/libffi.call/cls_multi_uchar.c: Likewise.
+       * testsuite/libffi.call/cls_multi_schar.c: Likewise.
+       * testsuite/libffi.call/cls_multi_ushortchar.c: Likewise.
+       * testsuite/libffi.call/cls_multi_ushort.c: Likewise.
+
+       * testsuite/libffi.special/unwindtest.cc: Cosmetics.
+
 2003-11-26  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * testsuite/libffi.call/ffitest.h: Include <fcntl.h>.
 2003-11-26  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * testsuite/libffi.call/ffitest.h: Include <fcntl.h>.
diff --git a/libffi/testsuite/libffi.call/cls_multi_schar.c b/libffi/testsuite/libffi.call/cls_multi_schar.c
new file mode 100644 (file)
index 0000000..6457336
--- /dev/null
@@ -0,0 +1,81 @@
+/* Area:       ffi_call, closure_call
+   Purpose:    Check passing of multiple signed char values.
+   Limitations:        none.
+   PR:         PR13221.
+   Originator: <hos@tamanegi.org> 20031129  */
+
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+signed char test_func_fn(signed char a1, signed char a2)
+{
+  signed char result;
+
+  result = a1 + a2;
+
+  printf("%d %d: %d\n", a1, a2, result);
+
+  return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif, void *rval, void **avals, void *data)
+{
+  signed char a1, a2;
+
+  a1 = *(signed char *)avals[0];
+  a2 = *(signed char *)avals[1];
+
+  *(ffi_arg *)rval = test_func_fn(a1, a2);
+
+}
+
+typedef signed char (*test_type)(signed char, signed char);
+
+int main (void)
+{
+  ffi_cif cif;
+#ifndef USING_MMAP
+  static ffi_closure cl;
+#endif
+  ffi_closure *pcl;
+  void * args_dbl[3];
+  ffi_type * cl_arg_types[3];
+  ffi_arg res_call;
+  signed char a, b, res_closure;
+
+#ifdef USING_MMAP
+  pcl = allocate_mmap (sizeof(ffi_closure));
+#else
+  pcl = &cl;
+#endif
+
+  a = 2;
+  b = 125;
+
+  args_dbl[0] = &a;
+  args_dbl[1] = &b;
+  args_dbl[3] = NULL;
+
+  cl_arg_types[0] = &ffi_type_schar;
+  cl_arg_types[1] = &ffi_type_schar;
+  cl_arg_types[2] = NULL;
+
+  /* Initialize the cif */
+  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+                    &ffi_type_schar, cl_arg_types) == FFI_OK);
+
+  ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+  /* { dg-output "2 125: 127" } */
+  printf("res: %d\n", res_call);
+  /* { dg-output "\nres: 127" } */
+
+  CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL)  == FFI_OK);
+
+  res_closure = (*((test_type)pcl))(2, 125);
+  /* { dg-output "\n2 125: 127" } */
+  printf("res: %d\n", res_closure);
+  /* { dg-output "\nres: 127" } */
+
+  exit(0);
+}
diff --git a/libffi/testsuite/libffi.call/cls_multi_sshort.c b/libffi/testsuite/libffi.call/cls_multi_sshort.c
new file mode 100644 (file)
index 0000000..eaa15d8
--- /dev/null
@@ -0,0 +1,81 @@
+/* Area:       ffi_call, closure_call
+   Purpose:    Check passing of multiple signed short values.
+   Limitations:        none.
+   PR:         PR13221.
+   Originator: <andreast@gcc.gnu.org> 20031129  */
+
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+signed short test_func_fn(signed short a1, signed short a2)
+{
+  signed short result;
+
+  result = a1 + a2;
+
+  printf("%d %d: %d\n", a1, a2, result);
+
+  return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif, void *rval, void **avals, void *data)
+{
+  signed short a1, a2;
+
+  a1 = *(signed short *)avals[0];
+  a2 = *(signed short *)avals[1];
+
+  *(ffi_arg *)rval = test_func_fn(a1, a2);
+
+}
+
+typedef signed short (*test_type)(signed short, signed short);
+
+int main (void)
+{
+  ffi_cif cif;
+#ifndef USING_MMAP
+  static ffi_closure cl;
+#endif
+  ffi_closure *pcl;
+  void * args_dbl[3];
+  ffi_type * cl_arg_types[3];
+  ffi_arg res_call;
+  unsigned short a, b, res_closure;
+
+#ifdef USING_MMAP
+  pcl = allocate_mmap (sizeof(ffi_closure));
+#else
+  pcl = &cl;
+#endif
+
+  a = 2;
+  b = 32765;
+
+  args_dbl[0] = &a;
+  args_dbl[1] = &b;
+  args_dbl[3] = NULL;
+
+  cl_arg_types[0] = &ffi_type_sshort;
+  cl_arg_types[1] = &ffi_type_sshort;
+  cl_arg_types[2] = NULL;
+
+  /* Initialize the cif */
+  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+                    &ffi_type_sshort, cl_arg_types) == FFI_OK);
+
+  ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+  /* { dg-output "2 32765: 32767" } */
+  printf("res: %d\n", res_call);
+  /* { dg-output "\nres: 32767" } */
+
+  CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL)  == FFI_OK);
+
+  res_closure = (*((test_type)pcl))(2, 32765);
+  /* { dg-output "\n2 32765: 32767" } */
+  printf("res: %d\n", res_closure);
+  /* { dg-output "\nres: 32767" } */
+
+  exit(0);
+}
diff --git a/libffi/testsuite/libffi.call/cls_multi_sshortchar.c b/libffi/testsuite/libffi.call/cls_multi_sshortchar.c
new file mode 100644 (file)
index 0000000..ae5ce7f
--- /dev/null
@@ -0,0 +1,93 @@
+/* Area:       ffi_call, closure_call
+   Purpose:    Check passing of multiple signed short/char values.
+   Limitations:        none.
+   PR:         PR13221.
+   Originator: <andreast@gcc.gnu.org> 20031129  */
+
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+signed short test_func_fn(signed char a1, signed short a2,
+                         signed char a3, signed short a4)
+{
+  signed short result;
+
+  result = a1 + a2 + a3 + a4;
+
+  printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
+
+  return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif, void *rval, void **avals, void *data)
+{
+  signed char a1, a3;
+  signed short a2, a4;
+
+  a1 = *(signed char *)avals[0];
+  a2 = *(signed short *)avals[1];
+  a3 = *(signed char *)avals[2];
+  a4 = *(signed short *)avals[3];
+
+  *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4);
+
+}
+
+typedef signed short (*test_type)(signed char, signed short,
+                                 signed char, signed short);
+
+int main (void)
+{
+  ffi_cif cif;
+#ifndef USING_MMAP
+  static ffi_closure cl;
+#endif
+  ffi_closure *pcl;
+  void * args_dbl[5];
+  ffi_type * cl_arg_types[5];
+  ffi_arg res_call;
+  signed char a, c;
+  signed short b, d, res_closure;
+
+#ifdef USING_MMAP
+  pcl = allocate_mmap (sizeof(ffi_closure));
+#else
+  pcl = &cl;
+#endif
+
+  a = 1;
+  b = 32765;
+  c = 127;
+  d = -128;
+
+  args_dbl[0] = &a;
+  args_dbl[1] = &b;
+  args_dbl[2] = &c;
+  args_dbl[3] = &d;
+  args_dbl[4] = NULL;
+
+  cl_arg_types[0] = &ffi_type_schar;
+  cl_arg_types[1] = &ffi_type_sshort;
+  cl_arg_types[2] = &ffi_type_schar;
+  cl_arg_types[3] = &ffi_type_sshort;
+  cl_arg_types[4] = NULL;
+
+  /* Initialize the cif */
+  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+                    &ffi_type_sshort, cl_arg_types) == FFI_OK);
+
+  ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+  /* { dg-output "1 32765 127 -128: 32765" } */
+  printf("res: %d\n", res_call);
+  /* { dg-output "\nres: 32765" } */
+
+  CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL)  == FFI_OK);
+
+  res_closure = (*((test_type)pcl))(1, 32765, 127, -128);
+  /* { dg-output "\n1 32765 127 -128: 32765" } */
+  printf("res: %d\n", res_closure);
+  /* { dg-output "\nres: 32765" } */
+
+  exit(0);
+}
diff --git a/libffi/testsuite/libffi.call/cls_multi_uchar.c b/libffi/testsuite/libffi.call/cls_multi_uchar.c
new file mode 100644 (file)
index 0000000..0b00bc3
--- /dev/null
@@ -0,0 +1,96 @@
+/* Area:       ffi_call, closure_call
+   Purpose:    Check passing of multiple unsigned char values.
+   Limitations:        none.
+   PR:         PR13221.
+   Originator: <andreast@gcc.gnu.org> 20031129  */
+
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+unsigned char test_func_fn(unsigned char a1, unsigned char a2,
+                          unsigned char a3, unsigned char a4)
+{
+  unsigned char result;
+
+  result = a1 + a2 + a3 + a4;
+
+  printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
+
+  return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif, void *rval, void **avals, void *data)
+{
+  unsigned char a1, a2, a3, a4;
+
+  a1 = *(unsigned char *)avals[0];
+  a2 = *(unsigned char *)avals[1];
+  a3 = *(unsigned char *)avals[2];
+  a4 = *(unsigned char *)avals[3];
+
+  *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4);
+
+}
+
+typedef unsigned char (*test_type)(unsigned char, unsigned char,
+                                  unsigned char, unsigned char);
+void test_func(ffi_cif *cif, void *rval, void **avals, void *data)
+{
+  printf("%d %d %d %d\n", *(unsigned char *)avals[0],
+        *(unsigned char *)avals[1], *(unsigned char *)avals[2],
+        *(unsigned char *)avals[3]);
+}
+int main (void)
+{
+  ffi_cif cif;
+#ifndef USING_MMAP
+  static ffi_closure cl;
+#endif
+  ffi_closure *pcl;
+  void * args_dbl[5];
+  ffi_type * cl_arg_types[5];
+  ffi_arg res_call;
+  unsigned char a, b, c, d, res_closure;
+
+#ifdef USING_MMAP
+  pcl = allocate_mmap (sizeof(ffi_closure));
+#else
+  pcl = &cl;
+#endif
+
+  a = 1;
+  b = 2;
+  c = 127;
+  d = 125;
+
+  args_dbl[0] = &a;
+  args_dbl[1] = &b;
+  args_dbl[2] = &c;
+  args_dbl[3] = &d;
+  args_dbl[4] = NULL;
+
+  cl_arg_types[0] = &ffi_type_uchar;
+  cl_arg_types[1] = &ffi_type_uchar;
+  cl_arg_types[2] = &ffi_type_uchar;
+  cl_arg_types[3] = &ffi_type_uchar;
+  cl_arg_types[4] = NULL;
+
+  /* Initialize the cif */
+  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+                    &ffi_type_uchar, cl_arg_types) == FFI_OK);
+
+  ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+  /* { dg-output "1 2 127 125: 255" } */
+  printf("res: %d\n", res_call);
+  /* { dg-output "\nres: 255" } */
+
+  CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL)  == FFI_OK);
+
+  res_closure = (*((test_type)pcl))(1, 2, 127, 125);
+  /* { dg-output "\n1 2 127 125: 255" } */
+  printf("res: %d\n", res_closure);
+  /* { dg-output "\nres: 255" } */
+
+  exit(0);
+}
diff --git a/libffi/testsuite/libffi.call/cls_multi_ushort.c b/libffi/testsuite/libffi.call/cls_multi_ushort.c
new file mode 100644 (file)
index 0000000..e6ae9aa
--- /dev/null
@@ -0,0 +1,81 @@
+/* Area:       ffi_call, closure_call
+   Purpose:    Check passing of multiple unsigned short values.
+   Limitations:        none.
+   PR:         PR13221.
+   Originator: <andreast@gcc.gnu.org> 20031129  */
+
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+unsigned short test_func_fn(unsigned short a1, unsigned short a2)
+{
+  unsigned short result;
+
+  result = a1 + a2;
+
+  printf("%d %d: %d\n", a1, a2, result);
+
+  return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif, void *rval, void **avals, void *data)
+{
+  unsigned short a1, a2;
+
+  a1 = *(unsigned short *)avals[0];
+  a2 = *(unsigned short *)avals[1];
+
+  *(ffi_arg *)rval = test_func_fn(a1, a2);
+
+}
+
+typedef unsigned short (*test_type)(unsigned short, unsigned short);
+
+int main (void)
+{
+  ffi_cif cif;
+#ifndef USING_MMAP
+  static ffi_closure cl;
+#endif
+  ffi_closure *pcl;
+  void * args_dbl[3];
+  ffi_type * cl_arg_types[3];
+  ffi_arg res_call;
+  unsigned short a, b, res_closure;
+
+#ifdef USING_MMAP
+  pcl = allocate_mmap (sizeof(ffi_closure));
+#else
+  pcl = &cl;
+#endif
+
+  a = 2;
+  b = 32765;
+
+  args_dbl[0] = &a;
+  args_dbl[1] = &b;
+  args_dbl[3] = NULL;
+
+  cl_arg_types[0] = &ffi_type_ushort;
+  cl_arg_types[1] = &ffi_type_ushort;
+  cl_arg_types[2] = NULL;
+
+  /* Initialize the cif */
+  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+                    &ffi_type_ushort, cl_arg_types) == FFI_OK);
+
+  ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+  /* { dg-output "2 32765: 32767" } */
+  printf("res: %d\n", res_call);
+  /* { dg-output "\nres: 32767" } */
+
+  CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL)  == FFI_OK);
+
+  res_closure = (*((test_type)pcl))(2, 32765);
+  /* { dg-output "\n2 32765: 32767" } */
+  printf("res: %d\n", res_closure);
+  /* { dg-output "\nres: 32767" } */
+
+  exit(0);
+}
diff --git a/libffi/testsuite/libffi.call/cls_multi_ushortchar.c b/libffi/testsuite/libffi.call/cls_multi_ushortchar.c
new file mode 100644 (file)
index 0000000..2458fc5
--- /dev/null
@@ -0,0 +1,93 @@
+/* Area:       ffi_call, closure_call
+   Purpose:    Check passing of multiple unsigned short/char values.
+   Limitations:        none.
+   PR:         PR13221.
+   Originator: <andreast@gcc.gnu.org> 20031129  */
+
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+unsigned short test_func_fn(unsigned char a1, unsigned short a2,
+                           unsigned char a3, unsigned short a4)
+{
+  unsigned short result;
+
+  result = a1 + a2 + a3 + a4;
+
+  printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
+
+  return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif, void *rval, void **avals, void *data)
+{
+  unsigned char a1, a3;
+  unsigned short a2, a4;
+
+  a1 = *(unsigned char *)avals[0];
+  a2 = *(unsigned short *)avals[1];
+  a3 = *(unsigned char *)avals[2];
+  a4 = *(unsigned short *)avals[3];
+
+  *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4);
+
+}
+
+typedef unsigned short (*test_type)(unsigned char, unsigned short,
+                                  unsigned char, unsigned short);
+
+int main (void)
+{
+  ffi_cif cif;
+#ifndef USING_MMAP
+  static ffi_closure cl;
+#endif
+  ffi_closure *pcl;
+  void * args_dbl[5];
+  ffi_type * cl_arg_types[5];
+  ffi_arg res_call;
+  unsigned char a, c;
+  unsigned short b, d, res_closure;
+
+#ifdef USING_MMAP
+  pcl = allocate_mmap (sizeof(ffi_closure));
+#else
+  pcl = &cl;
+#endif
+
+  a = 1;
+  b = 2;
+  c = 127;
+  d = 128;
+
+  args_dbl[0] = &a;
+  args_dbl[1] = &b;
+  args_dbl[2] = &c;
+  args_dbl[3] = &d;
+  args_dbl[4] = NULL;
+
+  cl_arg_types[0] = &ffi_type_uchar;
+  cl_arg_types[1] = &ffi_type_ushort;
+  cl_arg_types[2] = &ffi_type_uchar;
+  cl_arg_types[3] = &ffi_type_ushort;
+  cl_arg_types[4] = NULL;
+
+  /* Initialize the cif */
+  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+                    &ffi_type_ushort, cl_arg_types) == FFI_OK);
+
+  ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+  /* { dg-output "1 2 127 128: 258" } */
+  printf("res: %d\n", res_call);
+  /* { dg-output "\nres: 258" } */
+
+  CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL)  == FFI_OK);
+
+  res_closure = (*((test_type)pcl))(1, 2, 127, 128);
+  /* { dg-output "\n1 2 127 128: 258" } */
+  printf("res: %d\n", res_closure);
+  /* { dg-output "\nres: 258" } */
+
+  exit(0);
+}
index 36fd78d..4fec44c 100644 (file)
@@ -56,7 +56,7 @@ int main (void)
   ffi_type * cl_arg_types[17];
   int res;
 #ifdef USING_MMAP
   ffi_type * cl_arg_types[17];
   int res;
 #ifdef USING_MMAP
-  pcl = (ffi_closure*) allocate_mmap (sizeof(ffi_closure));
+  pcl = (ffi_closure *) allocate_mmap (sizeof(ffi_closure));
 #else
   pcl = &cl;
 #endif
 #else
   pcl = &cl;
 #endif