Libffi problem on darwin (MacOSX)

Ronald Oussoren oussoren@cistron.nl
Sun May 25 20:49:00 GMT 2003


On Saturday, May 17, 2003, at 17:21 Europe/Amsterdam, Andreas Tobler  
wrote:

>> I just noticed that this might well be stupidity on my part, I tried  
>> to write a minimal program that demonstrates the problem and that  
>> runs without problems. Our real code builds ffi_cifs and ffi_closures  
>> at runtime, and maybe that code is bogus.
>
> Could be, but if I remember right, I didn't complete the structure  
> passings. Maybe it works, but if not, then I certainly have to check  
> again. Well, I'll do that anyway.

The following hack seems to work for the limited tests that I've done.  
Note that this is *not* based on any understanding of the PPC calling  
conventions, and therefore likely incorrect.

Ronald

***  
/Volumes/Data/Users/ronald/Python-CVS/gcc/libffi/src/powerpc/ 
ffi_darwin.c   Sat Feb 22 20:10:14 2003
--- ffi_darwin.c        Sat May 24 22:02:44 2003
***************
*** 612,619 ****
--- 612,633 ----
           case FFI_TYPE_SINT32:
           case FFI_TYPE_UINT32:
           case FFI_TYPE_POINTER:
+ //        case FFI_TYPE_STRUCT:
+         /* there are 8 gpr registers used to pass values */
+           if (ng < 8) {
+              avalue[i] = pgr;
+              ng++;
+              pgr++;
+           } else {
+              avalue[i] = pst;
+              pst++;
+           }
+           break;
+
           case FFI_TYPE_STRUCT:
           /* there are 8 gpr registers used to pass values */
+       {
+           int left = (arg_types[i]->size);
             if (ng < 8) {
                avalue[i] = pgr;
                ng++;
***************
*** 622,627 ****
--- 636,654 ----
                avalue[i] = pst;
                pst++;
             }
+
+         /* Structs are in registers, skip values */
+         left -= sizeof(long);
+         while (left > 0) {
+                 if (ng < 8) {
+                    ng++;
+                    pgr++;
+                 } else {
+                    pst++;
+                 }
+                 left -= sizeof(long);
+         }
+       }
             break;

           case FFI_TYPE_SINT64:



More information about the Gcc mailing list