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

2004-11-23 Thread Florian Klaempfl
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

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2004-11-23 Thread Den Jean
On Tuesday 23 November 2004 11:13 am, Florian Klaempfl wrote:

> This is indeed an improper implemntation of the arm abi, I'll fix it 
> asap. 

Thanks a lot. In the mean time I changed the binding so that it uses
LargeInt instead of TMethod. So the big demo program almosts works :-)

---
QHookH = LargeInt; // was TMethod before
procedure QButton_hook_hook_clicked(handle: QButton_hookH; hook: QHookH); cdecl;

procedure TQButton.Hook_clicked(Proc: QButton_clicked_Event);
begin
  QButton_hook_Hook_clicked(Hooks,LargeInt(TMethod(Proc)));  // Proc gets 
passed by value :-)
end;//   ^^^
---


I am struggling now with (or having fun with, depending on the view point)
 
 * Trigonometric functions. 
So temporarily I am using series like sin x = x- x^3/3! 
Is this related to the fact that there is no Math processor on the 
Zaurus ? 
"dmesg" reveals that there is a Netwinder Floating Point Emulator.
I haven't looked into the details yet. (which values crash what 
functions, I use cos/sin and arctan2). 
I'll do so asap.

 * dynamic arrays : TIntArray = array of integer.
On Intel it works fine but on arm not.
Bindhelp.pas provides TIntArray pascal helper functions to the binding that 
is written in C++

eg. this C-code copies integers from the Qt Int Array to the Pascal dynamic 
Array of integer

---
inline void copyQIntsToPInts(const QValueList &qi, PIntArray pi)
  {
int len = qi.count();
int *ints;
setIntsLength(pi, len); // this is call to a pascal SetIntsLength function
ints = (int *)getIntsPtr(pi);  // this is a call to a pascal GetIntsPtr 
function
for (int i = 0; i < len; i++)
  ints[i] = qi[i]; // here it crashes
  }


I crashes when it uses the address returned by getintsptr
GetIntsPtr is provided by bindhelp.pas:

  // Int array helpers
  function GetIntsPtr(const PA: TIntArray): Pointer; cdecl; export;
  begin
Result := @PA[0];
  end;


It works on intel and not on arm. 
But when I change the definition of GetIntsPtr to:


  function GetIntsPtr(var PA: TIntArray): Pointer; cdecl; export;
  begin
Result := @PA[0];
  end;


Then it works on the arm to. (changed const to var !)

By the way the definition of the pascal library function in the C++ library is:

  typedef void *PIntArray;
  typedef void *(*GetIntsPtr)(PIntArray pi);
  extern GetIntsPtr getIntsPtr;


*  I am using the last arm snapshot you provided because the current cvs 
version does not compile

   
> 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

I have a Zaurus SL6000. As it is rather new, an upgrade was not a priority yet.
I haven't seen update roms for the SL6000 either.
The SL6000 has a libqte.so.2.3.2 and a libqpe.so.1.5.0


kind regards, 

Jan

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal