This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libffi: S/390: Add long double support


Andreas Krebbel wrote:

> *************** ffi_closure_helper_SYSV (ffi_closure *cl
> *** 662,667 ****
> --- 684,692 ----
>         /* Void is easy, and so is struct.  */
>         case FFI_TYPE_VOID:
>         case FFI_TYPE_STRUCT:
> + #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
> +       case FFI_TYPE_LONGDOUBLE:
> + #endif
>   	break;
>   
>         /* Floating point values are returned in fpr 0.  */

This misses handling of long double *arguments* in
ffi_closure_helper_SYSV.

Also, I'm wondering if it wouldn't be easier (and less
redundant) to explicitly treat long double the same as
struct arguments?

E.g. you should be able to replace the whole hunk in
ffi_prep_args:

+ #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ 	  case FFI_TYPE_LONGDOUBLE:
+ 	    p_struct -= ROUND_SIZE ((*ptr)->size);
+ 	    memcpy (p_struct, (char *)arg, (*ptr)->size);
+ 	    arg = &p_struct;
+ 	    if (n_gpr < MAX_GPRARGS)
+ 	      p_gpr[n_gpr++] = (unsigned long)*(unsigned char **) arg;
+ 	    else
+ 	      p_ov[n_ov++] = (unsigned long)*(unsigned char **) arg;
+ 	    break;
+ #endif

by simply adding

#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
  /* 16-byte long double is passed like a struct.  */
  if (type == FFI_TYPE_LONGDOUBLE)
    type = FFI_TYPE_STRUCT;
#endif

before

     /* Check how a structure type is passed.  */
      if (type == FFI_TYPE_STRUCT)
        {
          type = ffi_check_struct_type (*ptr);

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]