Преглед на файлове

* fixed result of failed syscalls (no extra neg is needed)
+ support multi-threaded programs

Jonas Maebe преди 21 години
родител
ревизия
4eb1eb94d1
променени са 1 файла, в които са добавени 165 реда и са изтрити 29 реда
  1. 165 29
      rtl/linux/powerpc/syscall.inc

+ 165 - 29
rtl/linux/powerpc/syscall.inc

@@ -28,13 +28,32 @@ function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYS
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
 }
 }
+var
+  temp, retaddress: longint;
 asm
 asm
   mr  r0,r3
   mr  r0,r3
   sc
   sc
   bns   .LDone
   bns   .LDone
-  neg   r3, r3
+  lis r10,(fpc_threadvar_relocate_proc)@ha
+  lwz   r10,(fpc_threadvar_relocate_proc)@l(r10)
+  cmpwi r10,0
+  bne   .LThreaded
   lis   r4,(Errno+4)@ha
   lis   r4,(Errno+4)@ha
   stw   r3,(Errno+4)@l(r4)
   stw   r3,(Errno+4)@l(r4)
+  b     .LFailed
+.LThreaded:
+  stw   r3,temp
+  mflr  r3
+  mtctr r10
+  lis   r4,(errno)@ha
+  stw   r3,retaddress
+  lwz   r3,(errno)@l(r4)
+  bctrl
+  lwz   r4,temp
+  lwz   r5,retaddress
+  stw   r4,0(r3)
+  mtlr  r5
+.LFailed:
   li    r3,-1
   li    r3,-1
 .LDone:
 .LDone:
 end;
 end;
@@ -44,14 +63,33 @@ function FpSysCall(sysnr,param1:TSysParam):TSysResult; assembler;[public,alias:'
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
 }
 }
+var
+  temp, retaddress: longint;
 asm
 asm
   mr  r0,r3
   mr  r0,r3
   mr  r3,r4
   mr  r3,r4
   sc
   sc
   bns   .LDone
   bns   .LDone
-  neg   r3, r3
+  lis   r10,(fpc_threadvar_relocate_proc)@ha
+  lwz   r10,(fpc_threadvar_relocate_proc)@l(r10)
+  cmpwi r10,0
+  bne   .LThreaded
   lis   r4,(Errno+4)@ha
   lis   r4,(Errno+4)@ha
   stw   r3,(Errno+4)@l(r4)
   stw   r3,(Errno+4)@l(r4)
+  b     .LFailed
+.LThreaded:
+  stw   r3,temp
+  mflr  r3
+  mtctr r10
+  lis   r4,(errno)@ha
+  stw   r3,retaddress
+  lwz   r3,(errno)@l(r4)
+  bctrl
+  lwz   r4,temp
+  lwz   r5,retaddress
+  stw   r4,0(r3)
+  mtlr  r5
+.LFailed:
   li    r3,-1
   li    r3,-1
 .LDone:
 .LDone:
 end;
 end;
@@ -62,16 +100,35 @@ function FpSysCall(sysnr,param1,param2:TSysParam):TSysResult; assembler;[public,
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
 }
 }
+var
+  temp, retaddress: longint;
 asm
 asm
   mr  r0,r3
   mr  r0,r3
   mr  r3,r4
   mr  r3,r4
   mr  r4,r5
   mr  r4,r5
   sc
   sc
-   bns   .LDone
-   neg   r3, r3
-   lis   r4,(Errno+4)@ha
-   stw   r3,(Errno+4)@l(r4)
-   li    r3,-1
+  bns   .LDone
+  lis   r10,(fpc_threadvar_relocate_proc)@ha
+  lwz   r10,(fpc_threadvar_relocate_proc)@l(r10)
+  cmpwi r10,0
+  bne   .LThreaded
+  lis   r4,(Errno+4)@ha
+  stw   r3,(Errno+4)@l(r4)
+  b     .LFailed
+.LThreaded:
+  stw   r3,temp
+  mflr  r3
+  mtctr r10
+  lis   r4,(errno)@ha
+  stw   r3,retaddress
+  lwz   r3,(errno)@l(r4)
+  bctrl
+  lwz   r4,temp
+  lwz   r5,retaddress
+  stw   r4,0(r3)
+  mtlr  r5
+.LFailed:
+  li    r3,-1
 .LDone:
 .LDone:
 end;
 end;
 
 
@@ -80,17 +137,36 @@ function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
 }
 }
+var
+  temp, retaddress: longint;
 asm
 asm
   mr  r0,r3
   mr  r0,r3
   mr  r3,r4
   mr  r3,r4
   mr  r4,r5
   mr  r4,r5
   mr  r5,r6
   mr  r5,r6
   sc
   sc
-   bns   .LDone
-   neg   r3, r3
-   lis   r4,(Errno+4)@ha
-   stw   r3,(Errno+4)@l(r4)
-   li    r3,-1
+  bns   .LDone
+  lis   r10,(fpc_threadvar_relocate_proc)@ha
+  lwz   r10,(fpc_threadvar_relocate_proc)@l(r10)
+  cmpwi r10,0
+  bne   .LThreaded
+  lis   r4,(Errno+4)@ha
+  stw   r3,(Errno+4)@l(r4)
+  b     .LFailed
+.LThreaded:
+  stw   r3,temp
+  mflr  r3
+  mtctr r10
+  lis   r4,(errno)@ha
+  stw   r3,retaddress
+  lwz   r3,(errno)@l(r4)
+  bctrl
+  lwz   r4,temp
+  lwz   r5,retaddress
+  stw   r4,0(r3)
+  mtlr  r5
+.LFailed:
+  li    r3,-1
 .LDone:
 .LDone:
 end;
 end;
 
 
@@ -100,6 +176,8 @@ function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; asse
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
 }
 }
+var
+  temp, retaddress: longint;
 asm
 asm
   mr  r0,r3
   mr  r0,r3
   mr  r3,r4
   mr  r3,r4
@@ -107,11 +185,28 @@ asm
   mr  r5,r6
   mr  r5,r6
   mr  r6,r7
   mr  r6,r7
   sc
   sc
-   bns   .LDone
-   neg   r3, r3
-   lis   r4,(Errno+4)@ha
-   stw   r3,(Errno+4)@l(r4)
-   li    r3,-1
+  bns   .LDone
+  lis   r10,(fpc_threadvar_relocate_proc)@ha
+  lwz   r10,(fpc_threadvar_relocate_proc)@l(r10)
+  cmpwi r10,0
+  bne   .LThreaded
+  lis   r4,(Errno+4)@ha
+  stw   r3,(Errno+4)@l(r4)
+  b     .LFailed
+.LThreaded:
+  stw   r3,temp
+  mflr  r3
+  mtctr r10
+  lis   r4,(errno)@ha
+  stw   r3,retaddress
+  lwz   r3,(errno)@l(r4)
+  bctrl
+  lwz   r4,temp
+  lwz   r5,retaddress
+  stw   r4,0(r3)
+  mtlr  r5
+.LFailed:
+  li    r3,-1
 .LDone:
 .LDone:
 end;
 end;
 
 
@@ -120,6 +215,8 @@ function FpSysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResul
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
 }
 }
+var
+  temp, retaddress: longint;
 asm
 asm
   mr  r0,r3
   mr  r0,r3
   mr  r3,r4
   mr  r3,r4
@@ -128,11 +225,28 @@ asm
   mr  r6,r7
   mr  r6,r7
   mr  r7,r8
   mr  r7,r8
   sc
   sc
-   bns   .LDone
-   neg   r3, r3
-   lis   r4,(Errno+4)@ha
-   stw   r3,(Errno+4)@l(r4)
-   li    r3,-1
+  bns   .LDone
+  lis   r10,(fpc_threadvar_relocate_proc)@ha
+  lwz   r10,(fpc_threadvar_relocate_proc)@l(r10)
+  cmpwi r10,0
+  bne   .LThreaded
+  lis   r4,(Errno+4)@ha
+  stw   r3,(Errno+4)@l(r4)
+  b     .LFailed
+.LThreaded:
+  stw   r3,temp
+  mflr  r3 
+  mtctr r10     
+  lis   r4,(errno)@ha
+  stw   r3,retaddress
+  lwz   r3,(errno)@l(r4)
+  bctrl
+  lwz   r4,temp
+  lwz   r5,retaddress
+  stw   r4,0(r3)  
+  mtlr  r5
+.LFailed:
+  li    r3,-1   
 .LDone:
 .LDone:
 end;
 end;
 
 
@@ -142,6 +256,8 @@ function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TS
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
 }
 }
+var
+  temp, retaddress: longint;
 asm
 asm
   mr  r0,r3
   mr  r0,r3
   mr  r3,r4
   mr  r3,r4
@@ -151,11 +267,28 @@ asm
   mr  r7,r8
   mr  r7,r8
   mr  r8,r9
   mr  r8,r9
   sc
   sc
-   bns   .LDone
-   neg   r3, r3
-   lis   r4,(Errno+4)@ha
-   stw   r3,(Errno+4)@l(r4)
-   li    r3,-1
+  bns   .LDone
+  lis   r10,(fpc_threadvar_relocate_proc)@ha
+  lwz   r10,(fpc_threadvar_relocate_proc)@l(r10)
+  cmpwi r10,0
+  bne   .LThreaded
+  lis   r4,(Errno+4)@ha
+  stw   r3,(Errno+4)@l(r4)
+  b     .LFailed
+.LThreaded:
+  stw   r3,temp
+  mflr  r3 
+  mtctr r10     
+  lis   r4,(errno)@ha
+  stw   r3,retaddress
+  lwz   r3,(errno)@l(r4)
+  bctrl
+  lwz   r4,temp
+  lwz   r5,retaddress
+  stw   r4,0(r3)  
+  mtlr  r5
+.LFailed:
+  li    r3,-1   
 .LDone:
 .LDone:
 end;
 end;
 
 
@@ -179,7 +312,6 @@ asm
 { Go ! }
 { Go ! }
   sc
   sc
   bns  .Lsyscall_ok
   bns  .Lsyscall_ok
-  neg  r3,r3
 .Lsyscall_ok:
 .Lsyscall_ok:
 { Put back the registers... }
 { Put back the registers... }
   stw    r3, 0(r8)
   stw    r3, 0(r8)
@@ -241,7 +373,11 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2003-11-29 22:54:32  jonas
+  Revision 1.11  2003-12-28 20:55:10  jonas
+    * fixed result of failed syscalls (no extra neg is needed)
+    + support multi-threaded programs
+
+  Revision 1.10  2003/11/29 22:54:32  jonas
     * more ppc fixes, hello world works again under linuxppc
     * more ppc fixes, hello world works again under linuxppc
 
 
   Revision 1.8  2003/11/15 19:01:27  florian
   Revision 1.8  2003/11/15 19:01:27  florian