dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/libffi/src ffitest.c,1.1,1.2 java_raw_a


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/libffi/src ffitest.c,1.1,1.2 java_raw_api.c,1.1,1.2 prep_cif.c,1.1,1.2 types.c,1.2,1.3
Date: Wed, 05 Feb 2003 20:15:40 -0500

Update of /cvsroot/dotgnu-pnet/pnet/libffi/src
In directory subversions:/tmp/cvs-serv21586/libffi/src

Modified Files:
        ffitest.c java_raw_api.c prep_cif.c types.c 
Log Message:


Update the libffi library from the gcc CVS tree.


Index: ffitest.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/libffi/src/ffitest.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ffitest.c   10 May 2002 23:04:40 -0000      1.1
--- ffitest.c   6 Feb 2003 01:15:38 -0000       1.2
***************
*** 1,4 ****
  /* -----------------------------------------------------------------------
!    ffitest.c - Copyright (c) 1996, 1997, 1998  Cygnus Solutions
  
     Permission is hereby granted, free of charge, to any person obtaining
--- 1,4 ----
  /* -----------------------------------------------------------------------
!    ffitest.c - Copyright (c) 1996, 1997, 1998, 2002, 2003  Red Hat, Inc.
  
     Permission is hereby granted, free of charge, to any person obtaining
***************
*** 50,53 ****
--- 50,60 ----
  }
  
+ #ifdef X86_WIN32
+ static size_t __attribute__((stdcall)) my_stdcall_strlen(char *s)
+ {
+   return (strlen(s));
+ }
+ #endif /* X86_WIN32 */
+ 
  static int promotion(signed char sc, signed short ss, 
                     unsigned char uc, unsigned short us)
***************
*** 113,116 ****
--- 120,142 ----
  }
  
+ #ifdef X86_WIN32
+ static float __attribute__((stdcall)) stdcall_many(float f1,
+                                                  float f2,
+                                                  float f3,
+                                                  float f4,
+                                                  float f5,
+                                                  float f6,
+                                                  float f7,
+                                                  float f8,
+                                                  float f9,
+                                                  float f10,
+                                                  float f11,
+                                                  float f12,
+                                                  float f13)
+ {
+   return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
+ }
+ #endif /* X86_WIN32 */
+ 
  static double dblit(float f)
  {
***************
*** 154,157 ****
--- 180,210 ----
  } test_structure_5;
  
+ typedef struct
+ {
+   float f;
+   double d;
+ } test_structure_6;
+ 
+ typedef struct
+ {
+   float f1;
+   float f2;
+   double d;
+ } test_structure_7;
+ 
+ typedef struct
+ {
+   float f1;
+   float f2;
+   float f3;
+   float f4;
+ } test_structure_8;
+ 
+ typedef struct
+ {
+   float f;
+   int i;
+ } test_structure_9;
+ 
  static test_structure_1 struct1(test_structure_1 ts)
  {
***************
*** 195,207 ****
  }
  
  /* Take an int and a float argument, together with int userdata, and  */
  /* return the sum.                                                    */
! static void closure_test_fn(ffi_cif* cif,void* resp,void** args, void* 
userdata)
! {
!     *(int*)resp =
!        *(int *)args[0] + (int)(*(float *)args[1]) + (int)(long)userdata;
  }
  
! typedef int (*closure_test_type)(int, float);
  
  int main(/address@hidden@*/ int argc, /address@hidden@*/ char *argv[])
--- 248,408 ----
  }
  
+ static test_structure_6 struct6 (test_structure_6 ts)
+ {
+   ts.f += 1;
+   ts.d += 1;
+ 
+   return ts;
+ }
+ 
+ static test_structure_7 struct7 (test_structure_7 ts)
+ {
+   ts.f1 += 1;
+   ts.f2 += 1;
+   ts.d += 1;
+ 
+   return ts;
+ }
+ 
+ static test_structure_8 struct8 (test_structure_8 ts)
+ {
+   ts.f1 += 1;
+   ts.f2 += 1;
+   ts.f3 += 1;
+   ts.f4 += 1;
+ 
+   return ts;
+ }
+ 
+ static test_structure_9 struct9 (test_structure_9 ts)
+ {
+   ts.f += 1;
+   ts.i += 1;
+ 
+   return ts;
+ }
+ 
  /* Take an int and a float argument, together with int userdata, and  */
  /* return the sum.                                                    */
! #if FFI_CLOSURES
! static void
! closure_test_fn(ffi_cif* cif,void* resp,void** args, void* userdata)
! {
!   *(ffi_arg*)resp =
!     (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) +
!     (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] +
!     (int)(*(signed short *)args[4]) +
!     (int)(*(unsigned long long *)args[5]) +
!     (int)*(int *)args[6] + (int)(*(int *)args[7]) +
!     (int)(*(double *)args[8]) + (int)*(int *)args[9] +
!     (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
!     (int)*(int *)args[12] + (int)(*(int *)args[13]) +
!     (int)(*(int *)args[14]) +  *(int *)args[15] + (int)(long)userdata;
! 
!       printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
!              (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]), 
!              (int)(*(unsigned long long *)args[2]),
!              (int)*(int *)args[3], (int)(*(signed short *)args[4]), 
!              (int)(*(unsigned long long *)args[5]),
!              (int)*(int *)args[6], (int)(*(int *)args[7]), 
!              (int)(*(double *)args[8]), (int)*(int *)args[9],
!              (int)(*(int *)args[10]), (int)(*(float *)args[11]),
!              (int)*(int *)args[12], (int)(*(int *)args[13]), 
!              (int)(*(int *)args[14]),*(int *)args[15],
!              (int)(long)userdata, *(int*)resp);
  }
  
! typedef int (*closure_test_type)(unsigned long long, int, unsigned long long, 
!                                int, signed short, unsigned long long, int, 
!                                int, double, int, int, float, int, int, 
!                                int, int);
! 
! static void closure_test_fn1(ffi_cif* cif,void* resp,void** args, 
!                            void* userdata)
!  {
!     *(ffi_arg*)resp =
!       (int)*(float *)args[0] +(int)(*(float *)args[1]) + 
!       (int)(*(float *)args[2]) + (int)*(float *)args[3] +
!       (int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) +
!       (int)*(float *)args[6] + (int)(*(int *)args[7]) + 
!       (int)(*(double*)args[8]) + (int)*(int *)args[9] + 
!       (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + 
!       (int)*(int *)args[12] + (int)(*(int *)args[13]) + 
!       (int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata;
! 
!     printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
!          (int)*(float *)args[0], (int)(*(float *)args[1]), 
!          (int)(*(float *)args[2]), (int)*(float *)args[3], 
!          (int)(*(signed short *)args[4]), (int)(*(float *)args[5]),
!          (int)*(float *)args[6], (int)(*(int *)args[7]),
!          (int)(*(double *)args[8]), (int)*(int *)args[9],
!          (int)(*(int *)args[10]), (int)(*(float *)args[11]),
!          (int)*(int *)args[12], (int)(*(int *)args[13]),
!          (int)(*(int *)args[14]), *(int *)args[15],
!          (int)(long)userdata, *(int*)resp);
! }
! 
! typedef int (*closure_test_type1)(float, float, float, float, signed short, 
!                                 float, float, int, double, int, int, float,
!                                 int, int, int, int);
! 
! static void closure_test_fn2(ffi_cif* cif,void* resp,void** args, 
!                            void* userdata)
!  {
!     *(ffi_arg*)resp =
!       (int)*(double *)args[0] +(int)(*(double *)args[1]) + 
!       (int)(*(double *)args[2]) + (int)*(double *)args[3] +
!       (int)(*(signed short *)args[4]) + (int)(*(double *)args[5]) +
!       (int)*(double *)args[6] + (int)(*(int *)args[7]) + 
!       (int)(*(double *)args[8]) + (int)*(int *)args[9] +
!       (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + 
!       (int)*(int *)args[12] + (int)(*(float *)args[13]) +
!       (int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata;
! 
!     printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
!          (int)*(double *)args[0], (int)(*(double *)args[1]), 
!          (int)(*(double *)args[2]), (int)*(double *)args[3], 
!          (int)(*(signed short *)args[4]), (int)(*(double *)args[5]),
!          (int)*(double *)args[6], (int)(*(int *)args[7]), 
!          (int)(*(double*)args[8]), (int)*(int *)args[9], 
!          (int)(*(int *)args[10]), (int)(*(float *)args[11]),
!          (int)*(int *)args[12], (int)(*(float *)args[13]), 
!          (int)(*(int *)args[14]), *(int *)args[15], (int)(long)userdata, 
!          *(int*)resp);
!  }
! 
! typedef int (*closure_test_type2)(double, double, double, double, signed 
short,
!                                 double, double, int, double, int, int, float,
!                                 int, float, int, int);
! 
! static void closure_test_fn3(ffi_cif* cif,void* resp,void** args,
!                            void* userdata)
!  {
!     *(ffi_arg*)resp =
!       (int)*(float *)args[0] +(int)(*(float *)args[1]) + 
!       (int)(*(float *)args[2]) + (int)*(float *)args[3] +
!       (int)(*(float *)args[4]) + (int)(*(float *)args[5]) +
!       (int)*(float *)args[6] + (int)(*(float *)args[7]) + 
!       (int)(*(double *)args[8]) + (int)*(int *)args[9] +
!       (int)(*(float *)args[10]) + (int)(*(float *)args[11]) + 
!       (int)*(int *)args[12] + (int)(*(float *)args[13]) +
!       (int)(*(float *)args[14]) +  *(int *)args[15] + (int)(long)userdata;
! 
!     printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
!          (int)*(float *)args[0], (int)(*(float *)args[1]), 
!          (int)(*(float *)args[2]), (int)*(float *)args[3], 
!          (int)(*(float *)args[4]), (int)(*(float *)args[5]),
!          (int)*(float *)args[6], (int)(*(float *)args[7]), 
!          (int)(*(double *)args[8]), (int)*(int *)args[9], 
!          (int)(*(float *)args[10]), (int)(*(float *)args[11]),
!          (int)*(int *)args[12], (int)(*(float *)args[13]), 
!          (int)(*(float *)args[14]), *(int *)args[15], (int)(long)userdata,
!          *(int*)resp);
!  }
! 
! typedef int (*closure_test_type3)(float, float, float, float, float, float,
!                                 float, float, double, int, float, float, int,
!                                 float, float, int);
! #endif
  
  int main(/address@hidden@*/ int argc, /address@hidden@*/ char *argv[])
***************
*** 226,229 ****
--- 427,438 ----
    long long rlonglong;
  
+ # if FFI_CLOSURES
+   /* The closure must not be an automatic variable on
+      platforms (Solaris) that forbid stack execution by default. */
+   static ffi_closure cl;
+ #endif
+ 
+   ffi_type * cl_arg_types[17];
+ 
    ffi_type ts1_type;
    ffi_type ts2_type;
***************
*** 231,234 ****
--- 440,447 ----
    ffi_type ts4_type;  
    ffi_type ts5_type;
+   ffi_type ts6_type;
+   ffi_type ts7_type;
+   ffi_type ts8_type;
+   ffi_type ts9_type;
    ffi_type *ts1_type_elements[4];
    ffi_type *ts2_type_elements[3];
***************
*** 236,239 ****
--- 449,456 ----
    ffi_type *ts4_type_elements[4];
    ffi_type *ts5_type_elements[3];
+   ffi_type *ts6_type_elements[3];
+   ffi_type *ts7_type_elements[4];
+   ffi_type *ts8_type_elements[5];
+   ffi_type *ts9_type_elements[3];
  
    ts1_type.size = 0;
***************
*** 257,260 ****
--- 474,493 ----
    ts5_type.type = FFI_TYPE_STRUCT;
  
+   ts6_type.size = 0;
+   ts6_type.alignment = 0;
+   ts6_type.type = FFI_TYPE_STRUCT;
+ 
+   ts7_type.size = 0;
+   ts7_type.alignment = 0;
+   ts7_type.type = FFI_TYPE_STRUCT;
+ 
+   ts8_type.size = 0;
+   ts8_type.alignment = 0;
+   ts8_type.type = FFI_TYPE_STRUCT;
+ 
+   ts9_type.size = 0;
+   ts9_type.alignment = 0;
+   ts9_type.type = FFI_TYPE_STRUCT;
+ 
    /address@hidden@*/
    ts1_type.elements = ts1_type_elements;
***************
*** 263,266 ****
--- 496,503 ----
    ts4_type.elements = ts4_type_elements;
    ts5_type.elements = ts5_type_elements;
+   ts6_type.elements = ts6_type_elements;
+   ts7_type.elements = ts7_type_elements;
+   ts8_type.elements = ts8_type_elements;
+   ts9_type.elements = ts9_type_elements;
    /address@hidden@*/
    
***************
*** 286,289 ****
--- 523,545 ----
    ts5_type_elements[2] = NULL;
  
+   ts6_type_elements[0] = &ffi_type_float;
+   ts6_type_elements[1] = &ffi_type_double;
+   ts6_type_elements[2] = NULL;
+ 
+   ts7_type_elements[0] = &ffi_type_float;
+   ts7_type_elements[1] = &ffi_type_float;
+   ts7_type_elements[2] = &ffi_type_double;
+   ts7_type_elements[3] = NULL;
+ 
+   ts8_type_elements[0] = &ffi_type_float;
+   ts8_type_elements[1] = &ffi_type_float;
+   ts8_type_elements[2] = &ffi_type_float;
+   ts8_type_elements[3] = &ffi_type_float;
+   ts8_type_elements[4] = NULL;
+ 
+   ts9_type_elements[0] = &ffi_type_float;
+   ts9_type_elements[1] = &ffi_type_sint;
+   ts9_type_elements[2] = NULL;
+ 
    ul = 0;
  
***************
*** 327,331 ****
        ul++;
        ffi_call(&cif, FFI_FN(return_sc), &rint, values);
!       CHECK(rint == (int) sc);
        }
  
--- 583,587 ----
        ul++;
        ffi_call(&cif, FFI_FN(return_sc), &rint, values);
!       CHECK(rint == (ffi_arg) sc);
        }
  
***************
*** 414,418 ****
      ffi_call(&cif, FFI_FN(floating), &rint, values);
  
!     printf ("%d vs %d\n", rint, floating (si1, f, d, ld, si2));
  
      CHECK(rint == floating(si1, f, d, ld, si2));
--- 670,674 ----
      ffi_call(&cif, FFI_FN(floating), &rint, values);
  
!     printf ("%d vs %d\n", (int)rint, floating (si1, f, d, ld, si2));
  
      CHECK(rint == floating(si1, f, d, ld, si2));
***************
*** 484,488 ****
  
      /address@hidden@*/
!     ff =  many(fa[0], fa[1],
               fa[2], fa[3],
               fa[4], fa[5],
--- 740,744 ----
  
      /address@hidden@*/
!     ff = many (fa[0], fa[1],
               fa[2], fa[3],
               fa[4], fa[5],
***************
*** 533,537 ****
              ul++;
              ffi_call(&cif, FFI_FN(promotion), &rint, values);
!             CHECK(rint == (int) sc + (int) ss + (int) uc + (int) us);
            }
      printf("%lu promotion tests run\n", ul);
--- 789,794 ----
              ul++;
              ffi_call(&cif, FFI_FN(promotion), &rint, values);
!             CHECK((int)rint == (signed char) sc + (signed short) ss +
!                   (unsigned char) uc + (unsigned short) us);
            }
      printf("%lu promotion tests run\n", ul);
***************
*** 580,585 ****
      
      /* Initialize the cif */
!     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, 
!                      &ts2_type, args) == FFI_OK);
  
      ts2_arg.d1 = 5.55;
--- 837,841 ----
      
      /* Initialize the cif */
!     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts2_type, args) == FFI_OK);
  
      ts2_arg.d1 = 5.55;
***************
*** 648,653 ****
      
      /* Initialize the cif */
!     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, 
!                      &ts4_type, args) == FFI_OK);
  
      ts4_arg.ui1 = 2;
--- 904,908 ----
      
      /* Initialize the cif */
!     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts4_type, args) == FFI_OK);
  
      ts4_arg.ui1 = 2;
***************
*** 679,684 ****
      
      /* Initialize the cif */
!     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, 
!                      &ts5_type, args) == FFI_OK);
  
      ts5_arg1.c1 = 2;
--- 934,938 ----
      
      /* Initialize the cif */
!     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ts5_type, args) == FFI_OK);
  
      ts5_arg1.c1 = 2;
***************
*** 698,724 ****
    }
  
  #else
    printf("Structure passing doesn't work on Win32.\n");
  #endif /* X86_WIN32 */
  
  # if FFI_CLOSURES
    /* A simple closure test */
      {
!       ffi_closure cl;
!       ffi_type * cl_arg_types[3];
  
!       cl_arg_types[0] = &ffi_type_sint;
        cl_arg_types[1] = &ffi_type_float;
!       cl_arg_types[2] = NULL;
        
        /* Initialize the cif */
!       CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, 
!                        &ffi_type_sint, cl_arg_types) == FFI_OK);
  
!       CHECK(ffi_prep_closure(&cl, &cif, closure_test_fn,
!                            (void *) 3 /* userdata */)
!           == FFI_OK);
!       CHECK((*((closure_test_type)(&cl)))(1, 2.0) == 6);
      }
  # endif
  
--- 952,1298 ----
    }
  
+   /* struct tests */
+   {
+     test_structure_6 ts6_arg;
+ 
+     /* This is a hack to get a properly aligned result buffer */
+     test_structure_6 *ts6_result = 
+       (test_structure_6 *) malloc (sizeof(test_structure_6));
+ 
+     args[0] = &ts6_type;
+     values[0] = &ts6_arg;
+ 
+     /* Initialize the cif */
+     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts6_type, args) == FFI_OK);
+ 
+     ts6_arg.f = 5.55f;
+     ts6_arg.d = 6.66;
+ 
+     printf ("%g\n", ts6_arg.f);
+     printf ("%g\n", ts6_arg.d);
+ 
+     ffi_call(&cif, FFI_FN(struct6), ts6_result, values);
+ 
+     printf ("%g\n", ts6_result->f);
+     printf ("%g\n", ts6_result->d);
+ 
+     CHECK(ts6_result->f == 5.55f + 1);
+     CHECK(ts6_result->d == 6.66 + 1);
+ 
+     printf("structure test 6 ok!\n");
+ 
+     free (ts6_result);
+   }
+ 
+   /* struct tests */
+   {
+     test_structure_7 ts7_arg;
+ 
+     /* This is a hack to get a properly aligned result buffer */
+     test_structure_7 *ts7_result = 
+       (test_structure_7 *) malloc (sizeof(test_structure_7));
+ 
+     args[0] = &ts7_type;
+     values[0] = &ts7_arg;
+ 
+     /* Initialize the cif */
+     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts7_type, args) == FFI_OK);
+ 
+     ts7_arg.f1 = 5.55f;
+     ts7_arg.f2 = 55.5f;
+     ts7_arg.d = 6.66;
+ 
+     printf ("%g\n", ts7_arg.f1);
+     printf ("%g\n", ts7_arg.f2);
+     printf ("%g\n", ts7_arg.d);
+ 
+     ffi_call(&cif, FFI_FN(struct7), ts7_result, values);
+ 
+     printf ("%g\n", ts7_result->f1);
+     printf ("%g\n", ts7_result->f2);
+     printf ("%g\n", ts7_result->d);
+ 
+     CHECK(ts7_result->f1 == 5.55f + 1);
+     CHECK(ts7_result->f2 == 55.5f + 1);
+     CHECK(ts7_result->d == 6.66 + 1);
+ 
+     printf("structure test 7 ok!\n");
+ 
+     free (ts7_result);
+   }
+ 
+   /* struct tests */
+   {
+     test_structure_8 ts8_arg;
+ 
+     /* This is a hack to get a properly aligned result buffer */
+     test_structure_8 *ts8_result = 
+       (test_structure_8 *) malloc (sizeof(test_structure_8));
+ 
+     args[0] = &ts8_type;
+     values[0] = &ts8_arg;
+ 
+     /* Initialize the cif */
+     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts8_type, args) == FFI_OK);
+ 
+     ts8_arg.f1 = 5.55f;
+     ts8_arg.f2 = 55.5f;
+     ts8_arg.f3 = -5.55f;
+     ts8_arg.f4 = -55.5f;
+ 
+     printf ("%g\n", ts8_arg.f1);
+     printf ("%g\n", ts8_arg.f2);
+     printf ("%g\n", ts8_arg.f3);
+     printf ("%g\n", ts8_arg.f4);
+ 
+     ffi_call(&cif, FFI_FN(struct8), ts8_result, values);
+ 
+     printf ("%g\n", ts8_result->f1);
+     printf ("%g\n", ts8_result->f2);
+     printf ("%g\n", ts8_result->f3);
+     printf ("%g\n", ts8_result->f4);
+ 
+     CHECK(ts8_result->f1 == 5.55f + 1);
+     CHECK(ts8_result->f2 == 55.5f + 1);
+     CHECK(ts8_result->f3 == -5.55f + 1);
+     CHECK(ts8_result->f4 == -55.5f + 1);
+ 
+     printf("structure test 8 ok!\n");
+ 
+     free (ts8_result);
+   }
+ 
+   /* struct tests */
+   {
+     test_structure_9 ts9_arg;
+ 
+     /* This is a hack to get a properly aligned result buffer */
+     test_structure_9 *ts9_result = 
+       (test_structure_9 *) malloc (sizeof(test_structure_9));
+ 
+     args[0] = &ts9_type;
+     values[0] = &ts9_arg;
+ 
+     /* Initialize the cif */
+     CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts9_type, args) == FFI_OK);
+ 
+     ts9_arg.f = 5.55f;
+     ts9_arg.i = 5;
+ 
+     printf ("%g\n", ts9_arg.f);
+     printf ("%d\n", ts9_arg.i);
+ 
+     ffi_call(&cif, FFI_FN(struct9), ts9_result, values);
+ 
+     printf ("%g\n", ts9_result->f);
+     printf ("%d\n", ts9_result->i);
+ 
+     CHECK(ts9_result->f == 5.55f + 1);
+     CHECK(ts9_result->i == 5 + 1);
+ 
+     printf("structure test 9 ok!\n");
+ 
+     free (ts9_result);
+   }
+ 
  #else
    printf("Structure passing doesn't work on Win32.\n");
  #endif /* X86_WIN32 */
  
+ #ifdef X86_WIN32
+   /* stdcall strlen tests */
+   {
+     args[0] = &ffi_type_pointer;
+     values[0] = (void*) &s;
+ 
+     /* Initialize the cif */
+     CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 1,
+                      &ffi_type_sint, args) == FFI_OK);
+ 
+     s = "a";
+     ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values);
+     CHECK(rint == 1);
+ 
+     s = "1234567";
+     ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values);
+     CHECK(rint == 7);
+ 
+     s = "1234567890123456789012345";
+     ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values);
+     CHECK(rint == 25);
+ 
+     printf("stdcall strlen tests passed\n");
+   }
+ 
+   /* stdcall many arg tests */
+   {
+     float ff;
+     float fa[13];
+ 
+     for (ul = 0; ul < 13; ul++)
+       {
+       args[ul] = &ffi_type_float;
+       values[ul] = &fa[ul];
+       fa[ul] = (float) ul;
+       }
+ 
+     /* Initialize the cif */
+     CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 13,
+                      &ffi_type_float, args) == FFI_OK);
+ 
+     /address@hidden@*/
+     ff =  stdcall_many(fa[0], fa[1],
+              fa[2], fa[3],
+              fa[4], fa[5],
+              fa[6], fa[7],
+              fa[8], fa[9],
+              fa[10],fa[11],fa[12]);
+     /address@hidden@*/
+ 
+     ffi_call(&cif, FFI_FN(stdcall_many), &f, values);
+ 
+     /address@hidden@*/
+     if (f - ff < FLT_EPSILON)
+     /address@hidden@*/
+       printf("stdcall many arg tests ok!\n");
+     else
+         CHECK(0);
+   }
+ #endif /* X86_WIN32 */
+ 
  # if FFI_CLOSURES
    /* A simple closure test */
      {
!       (void) puts("\nEnter FFI_CLOSURES\n");
! 
!       cl_arg_types[0] = &ffi_type_uint64;
!       cl_arg_types[1] = &ffi_type_uint;
!       cl_arg_types[2] = &ffi_type_uint64;
!       cl_arg_types[3] = &ffi_type_uint;
!       cl_arg_types[4] = &ffi_type_sshort;
!       cl_arg_types[5] = &ffi_type_uint64;
!       cl_arg_types[6] = &ffi_type_uint;
!       cl_arg_types[7] = &ffi_type_uint;
!       cl_arg_types[8] = &ffi_type_double;
!       cl_arg_types[9] = &ffi_type_uint;
!       cl_arg_types[10] = &ffi_type_uint;
!       cl_arg_types[11] = &ffi_type_float;
!       cl_arg_types[12] = &ffi_type_uint;
!       cl_arg_types[13] = &ffi_type_uint;
!       cl_arg_types[14] = &ffi_type_uint;
!       cl_arg_types[15] = &ffi_type_uint;
!       cl_arg_types[16] = NULL;   
! 
!       /* Initialize the cif */
!       CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
!                        &ffi_type_sint, cl_arg_types) == FFI_OK);
! 
!       CHECK(ffi_prep_closure(&cl, &cif, closure_test_fn,
!                            (void *) 3 /* userdata */) == FFI_OK);
!       
!       CHECK((*((closure_test_type)(&cl)))
!           (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13, 
!            19, 21, 1) == 680);
!     }
! 
!     {
  
!       cl_arg_types[0] = &ffi_type_float;
        cl_arg_types[1] = &ffi_type_float;
!       cl_arg_types[2] = &ffi_type_float;
!       cl_arg_types[3] = &ffi_type_float;
!       cl_arg_types[4] = &ffi_type_sshort;
!       cl_arg_types[5] = &ffi_type_float;
!       cl_arg_types[6] = &ffi_type_float;
!       cl_arg_types[7] = &ffi_type_uint;
!       cl_arg_types[8] = &ffi_type_double;
!       cl_arg_types[9] = &ffi_type_uint;
!       cl_arg_types[10] = &ffi_type_uint;
!       cl_arg_types[11] = &ffi_type_float;
!       cl_arg_types[12] = &ffi_type_uint;
!       cl_arg_types[13] = &ffi_type_uint;
!       cl_arg_types[14] = &ffi_type_uint;
!       cl_arg_types[15] = &ffi_type_uint;
!       cl_arg_types[16] = NULL;
        
        /* Initialize the cif */
!       CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
!                        &ffi_type_sint, cl_arg_types) == FFI_OK);
  
!       CHECK(ffi_prep_closure(&cl, &cif, closure_test_fn1,
!                            (void *) 3 /* userdata */)  == FFI_OK);
!       
!       CHECK((*((closure_test_type1)(&cl)))
!           (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13,
!            19, 21, 1) == 255);
      }
+ 
+     {
+ 
+       cl_arg_types[0] = &ffi_type_double;
+       cl_arg_types[1] = &ffi_type_double;
+       cl_arg_types[2] = &ffi_type_double;
+       cl_arg_types[3] = &ffi_type_double;
+       cl_arg_types[4] = &ffi_type_sshort;
+       cl_arg_types[5] = &ffi_type_double;
+       cl_arg_types[6] = &ffi_type_double;
+       cl_arg_types[7] = &ffi_type_uint;
+       cl_arg_types[8] = &ffi_type_double;
+       cl_arg_types[9] = &ffi_type_uint;
+       cl_arg_types[10] = &ffi_type_uint;
+       cl_arg_types[11] = &ffi_type_float;
+       cl_arg_types[12] = &ffi_type_uint;
+       cl_arg_types[13] = &ffi_type_float;
+       cl_arg_types[14] = &ffi_type_uint;
+       cl_arg_types[15] = &ffi_type_uint;
+       cl_arg_types[16] = NULL;
+       
+       /* Initialize the cif */
+       CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+                        &ffi_type_sint, cl_arg_types) == FFI_OK);
+ 
+       CHECK(ffi_prep_closure(&cl, &cif, closure_test_fn2,
+                            (void *) 3 /* userdata */) == FFI_OK);
+ 
+       CHECK((*((closure_test_type2)(&cl)))
+           (1, 2, 3, 4, 127, 5, 6, 8, 9, 10, 11, 12.0, 13,
+            19.0, 21, 1) == 255);
+ 
+     }
+ 
+     {
+ 
+       cl_arg_types[0] = &ffi_type_float;
+       cl_arg_types[1] = &ffi_type_float;
+       cl_arg_types[2] = &ffi_type_float;
+       cl_arg_types[3] = &ffi_type_float;
+       cl_arg_types[4] = &ffi_type_float;
+       cl_arg_types[5] = &ffi_type_float;
+       cl_arg_types[6] = &ffi_type_float;
+       cl_arg_types[7] = &ffi_type_float;
+       cl_arg_types[8] = &ffi_type_double;
+       cl_arg_types[9] = &ffi_type_uint;
+       cl_arg_types[10] = &ffi_type_float;
+       cl_arg_types[11] = &ffi_type_float;
+       cl_arg_types[12] = &ffi_type_uint;
+       cl_arg_types[13] = &ffi_type_float;
+       cl_arg_types[14] = &ffi_type_float;
+       cl_arg_types[15] = &ffi_type_uint;
+       cl_arg_types[16] = NULL;
+       
+       /* Initialize the cif */
+       CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+                        &ffi_type_sint, cl_arg_types) == FFI_OK);
+ 
+       CHECK(ffi_prep_closure(&cl, &cif, closure_test_fn3,
+                            (void *) 3 /* userdata */)  == FFI_OK);
+       
+       CHECK((*((closure_test_type3)(&cl)))
+           (1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9, 10, 11.11, 12.0, 13,
+            19.19, 21.21, 1) == 135);
+     }
+ 
+     (void) puts("\nFinished FFI_CLOSURES\n");
+ 
  # endif
  

Index: java_raw_api.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/libffi/src/java_raw_api.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** java_raw_api.c      10 May 2002 23:04:40 -0000      1.1
--- java_raw_api.c      6 Feb 2003 01:15:38 -0000       1.2
***************
*** 82,100 ****
        case FFI_TYPE_UINT8:
        case FFI_TYPE_SINT8:
!         *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 1);
          break;
          
        case FFI_TYPE_UINT16:
        case FFI_TYPE_SINT16:
!         *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 2);
          break;
  
- #if SIZEOF_ARG >= 4     
-       case FFI_TYPE_UINT32:
-       case FFI_TYPE_SINT32:
-         *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 4);
-         break;
- #endif
-       
  #if SIZEOF_ARG == 8     
        case FFI_TYPE_UINT64:
--- 82,93 ----
        case FFI_TYPE_UINT8:
        case FFI_TYPE_SINT8:
!         *args = (void*) ((char*)(raw++) + 3);
          break;
          
        case FFI_TYPE_UINT16:
        case FFI_TYPE_SINT16:
!         *args = (void*) ((char*)(raw++) + 2);
          break;
  
  #if SIZEOF_ARG == 8     
        case FFI_TYPE_UINT64:
***************
*** 158,186 ****
        {
        case FFI_TYPE_UINT8:
          (raw++)->uint = *(UINT8*) (*args);
          break;
  
        case FFI_TYPE_SINT8:
          (raw++)->sint = *(SINT8*) (*args);
          break;
  
        case FFI_TYPE_UINT16:
          (raw++)->uint = *(UINT16*) (*args);
          break;
  
        case FFI_TYPE_SINT16:
          (raw++)->sint = *(SINT16*) (*args);
          break;
  
- #if SIZEOF_ARG >= 4
        case FFI_TYPE_UINT32:
          (raw++)->uint = *(UINT32*) (*args);
          break;
  
        case FFI_TYPE_SINT32:
          (raw++)->sint = *(SINT32*) (*args);
-         break;
  #endif
!         case FFI_TYPE_FLOAT:
          (raw++)->flt = *(FLOAT32*) (*args);
          break;
--- 151,202 ----
        {
        case FFI_TYPE_UINT8:
+ #if WORDS_BIGENDIAN
+         *(UINT32*)(raw++) = *(UINT8*) (*args);
+ #else
          (raw++)->uint = *(UINT8*) (*args);
+ #endif
          break;
  
        case FFI_TYPE_SINT8:
+ #if WORDS_BIGENDIAN
+         *(SINT32*)(raw++) = *(SINT8*) (*args);
+ #else
          (raw++)->sint = *(SINT8*) (*args);
+ #endif
          break;
  
        case FFI_TYPE_UINT16:
+ #if WORDS_BIGENDIAN
+         *(UINT32*)(raw++) = *(UINT16*) (*args);
+ #else
          (raw++)->uint = *(UINT16*) (*args);
+ #endif
          break;
  
        case FFI_TYPE_SINT16:
+ #if WORDS_BIGENDIAN
+         *(SINT32*)(raw++) = *(SINT16*) (*args);
+ #else
          (raw++)->sint = *(SINT16*) (*args);
+ #endif
          break;
  
        case FFI_TYPE_UINT32:
+ #if WORDS_BIGENDIAN
+         *(UINT32*)(raw++) = *(UINT32*) (*args);
+ #else
          (raw++)->uint = *(UINT32*) (*args);
+ #endif
          break;
  
        case FFI_TYPE_SINT32:
+ #if WORDS_BIGENDIAN
+         *(SINT32*)(raw++) = *(SINT32*) (*args);
+ #else
          (raw++)->sint = *(SINT32*) (*args);
  #endif
!         break;
! 
!       case FFI_TYPE_FLOAT:
          (raw++)->flt = *(FLOAT32*) (*args);
          break;
***************
*** 212,215 ****
--- 228,280 ----
  #if !FFI_NATIVE_RAW_API
  
+ static void
+ ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue)
+ {
+ #if WORDS_BIGENDIAN && SIZEOF_ARG == 8
+   switch (cif->rtype->type)
+     {
+     case FFI_TYPE_UINT8:
+     case FFI_TYPE_UINT16:
+     case FFI_TYPE_UINT32:
+       *(UINT64 *)rvalue <<= 32;
+       break;
+ 
+     case FFI_TYPE_SINT8:
+     case FFI_TYPE_SINT16:
+     case FFI_TYPE_SINT32:
+     case FFI_TYPE_INT:
+       *(SINT64 *)rvalue <<= 32;
+       break;
+ 
+     default:
+       break;
+     }
+ #endif
+ }
+ 
+ static void
+ ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue)
+ {
+ #if WORDS_BIGENDIAN && SIZEOF_ARG == 8
+   switch (cif->rtype->type)
+     {
+     case FFI_TYPE_UINT8:
+     case FFI_TYPE_UINT16:
+     case FFI_TYPE_UINT32:
+       *(UINT64 *)rvalue >>= 32;
+       break;
+ 
+     case FFI_TYPE_SINT8:
+     case FFI_TYPE_SINT16:
+     case FFI_TYPE_SINT32:
+     case FFI_TYPE_INT:
+       *(SINT64 *)rvalue >>= 32;
+       break;
+ 
+     default:
+       break;
+     }
+ #endif
+ }
  
  /* This is a generic definition of ffi_raw_call, to be used if the
***************
*** 228,231 ****
--- 293,297 ----
    ffi_java_raw_to_ptrarray (cif, raw, avalue);
    ffi_call (cif, fn, rvalue, avalue);
+   ffi_java_rvalue_to_raw (cif, rvalue);
  }
  
***************
*** 241,244 ****
--- 307,311 ----
    ffi_java_ptrarray_to_raw (cif, avalue, raw);
    (*cl->fun) (cif, rvalue, raw, cl->user_data);
+   ffi_java_raw_to_rvalue (cif, rvalue);
  }
  

Index: prep_cif.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/libffi/src/prep_cif.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** prep_cif.c  10 May 2002 23:04:40 -0000      1.1
--- prep_cif.c  6 Feb 2003 01:15:38 -0000       1.2
***************
*** 104,108 ****
    FFI_ASSERT(ffi_type_test(cif->rtype));
  
! #ifndef M68K
    /* Make space for the return structure pointer */
    if (cif->rtype->type == FFI_TYPE_STRUCT
--- 104,109 ----
    FFI_ASSERT(ffi_type_test(cif->rtype));
  
!   /* x86-64 and s390 stack space allocation is handled in prep_machdep.  */
! #if !defined M68K && !defined __x86_64__ && !defined S390
    /* Make space for the return structure pointer */
    if (cif->rtype->type == FFI_TYPE_STRUCT
***************
*** 123,126 ****
--- 124,128 ----
        return FFI_BAD_TYPEDEF;
  
+ #if !defined __x86_64__ && !defined S390
  #ifdef SPARC
        if (((*ptr)->type == FFI_TYPE_STRUCT
***************
*** 138,141 ****
--- 140,144 ----
          bytes += STACK_ARG_SIZE((*ptr)->size);
        }
+ #endif
      }
  

Index: types.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/libffi/src/types.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** types.c     22 Nov 2002 23:33:35 -0000      1.2
--- types.c     6 Feb 2003 01:15:38 -0000       1.3
***************
*** 43,47 ****
  FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
  
! #if defined ALPHA || defined SPARC64 || defined IA64
  
  FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER);
--- 43,48 ----
  FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
  
! #if defined ALPHA || defined SPARC64 || defined X86_64 || defined S390X \
!     || defined IA64
  
  FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER);
***************
*** 53,72 ****
  #endif
  
! #ifdef X86
  
  FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
  FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
  
! #elif defined X86_WIN32
! 
! FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
! FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
! 
! #elif defined ARM
! 
! FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
! FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
! 
! #elif defined M68K
  
  FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
--- 54,63 ----
  #endif
  
! #if defined X86 || defined X86_WIN32 || defined ARM || defined M68K
  
  FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
  FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
  
! #elif defined SH
  
  FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
***************
*** 81,90 ****
  
  
! #ifdef X86
! 
! FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
! FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
! 
! #elif defined X86_WIN32
  
  FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
--- 72,76 ----
  
  
! #if defined X86 || defined X86_WIN32 || defined M68K
  
  FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
***************
*** 96,122 ****
  FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
  
! #elif defined M68K
  
  FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
! FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
! 
! #elif defined IA64
! 
! FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
! FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
  
  #elif defined SPARC
  
  FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
- 
  #ifdef SPARC64
- 
  FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
- 
  #else
- 
  FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
- 
  #endif
  
  #else
--- 82,103 ----
  FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
  
! #elif defined SH
  
  FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
! FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
  
  #elif defined SPARC
  
  FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
  #ifdef SPARC64
  FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
  #else
  FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
  #endif
+ 
+ #elif defined X86_64 || defined IA64
+ 
+ FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
+ FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
  
  #else





reply via email to

[Prev in Thread] Current Thread [Next in Thread]