[fpc-pascal] FPC on ARM (eg Zaurus)

Florian Klaempfl F.Klaempfl at gmx.de
Tue Nov 23 17:13:07 CET 2004


Den Jean wrote:
> On Sunday 21 November 2004 11:41 pm, Den Jean wrote:
> 
>>I also debugged it on the zaurus with gdb.
>>
> 
> 
> 
> I debugged somewhat more and this learned me that the record Method 
> is passed by reference instead of by value as it should.
> With a little hack I managed to force a call by value.
> 
> 
> Library extract that shows the function that expects a record by value.
> --------------------------------------------------------------------------------------------------------------
>    // C definition in library of function that expects a record of type TMethod by value (hook parameter)
>    C_EXPORT void QButton_hook_hook_clicked(QButton_hookH handle, QHookH hook);
> 
>   // definition of QHookH in library
>   typedef struct {
>     void *func;
>     void *data;
>   } QHook;
>   typedef QHook QHookH;
> --------------------------------------------------------------------------------------------------------------
> 
> 
> 
> Here is the Pascal code that passed the record by reference instead of by value
> --------------------------------------------------------------------------------------------------------------
>   // Pascal definition of external library function
>   QHookH = TMethod;
>   procedure QButton_hook_hook_clicked(handle: QButton_hookH; hook: QHookH); cdecl;
>   procedure QButton_hook_hook_clicked; external QtShareName name QtNamePrefix + 'QButton_hook_hook_clicked';
>   
>   // pascal code that calls the library function and passes the record by reference instead of by value
>   QButton_hook_hook_clicked(button_hook,Method);
> --------------------------------------------------------------------------------------------------------------
> 
> 
> 
> Here is the hack that enables me to force passing by value (the program than works)
> --------------------------------------------------------------------------------------------------------------
>   procedure QButton_hook_hook_clicked2(handle: QButton_hookH; func: integer; data: integer); cdecl;
>   procedure QButton_hook_hook_clicked2; external QtShareName name QtNamePrefix + 'QButton_hook_hook_clicked';
> 
>   // this call works
>   QButton_hook_hook_clicked2(button_hook,integer(Method.code),integer(Method.data));
> --------------------------------------------------------------------------------------------------------------
> 
> 
> 
> I hope this helps in fixing the arm-port. :-)
> 

This is indeed an improper implemntation of the arm abi, I'll fix it 
asap. BTW: What OS do you run on your Zaurus? I've a lot of trouble with 
OZ 3.5.1 e.g. with that ridiculous dropbear ssh demon used by OZ 3.5.1




More information about the fpc-pascal mailing list