Browse Source

* Some emx code removed

yuri 22 years ago
parent
commit
bf1b07f088
2 changed files with 33 additions and 183 deletions
  1. 24 147
      rtl/os2/sysutils.pp
  2. 9 36
      rtl/os2/thread.inc

+ 24 - 147
rtl/os2/sysutils.pp

@@ -345,7 +345,7 @@ end;
 
 procedure FileClose (Handle: longint);
 begin
-    if (Handle > 4) or ((os_mode = osOS2) and (Handle > 2)) then
+    if Handle > 2 then
         asm
             push ebx
             mov eax, 3E00h
@@ -433,44 +433,24 @@ var SR: PSearchRec;
     Err: longint;
 
 begin
-    if os_mode = osOS2 then
-        begin
-            New (FStat);
-            Rslt.FindHandle := $FFFFFFFF;
-            Count := 1;
-            Err := DosFindFirst (PChar (Path), Rslt.FindHandle,
-                 Attr and FindResvdMask, FStat, SizeOf (FStat^), Count,
-                                                                   ilStandard);
-            if (Err = 0) and (Count = 0) then Err := 18;
-            FindFirst := -Err;
-            if Err = 0 then
-                begin
-                    Rslt.Name := FStat^.Name;
-                    Rslt.Size := FStat^.FileSize;
-                    Rslt.Attr := FStat^.AttrFile;
-                    Rslt.ExcludeAttr := 0;
-                    TRec (Rslt.Time).T := FStat^.TimeLastWrite;
-                    TRec (Rslt.Time).D := FStat^.DateLastWrite;
-                end;
-            Dispose (FStat);
-        end
-    else
-        begin
-            Err := DOS.DosError;
-            GetMem (SR, SizeOf (SearchRec));
-            Rslt.FindHandle := longint(SR);
-            DOS.FindFirst (Path, Attr, SR^);
-            FindFirst := -DOS.DosError;
-            if DosError = 0 then
-                begin
-                    Rslt.Time := SR^.Time;
-                    Rslt.Size := SR^.Size;
-                    Rslt.Attr := SR^.Attr;
-                    Rslt.ExcludeAttr := 0;
-                    Rslt.Name := SR^.Name;
-                end;
-            DOS.DosError := Err;
-        end;
+  New (FStat);
+  Rslt.FindHandle := $FFFFFFFF;
+  Count := 1;
+  Err := DosFindFirst (PChar (Path), Rslt.FindHandle,
+               Attr and FindResvdMask, FStat, SizeOf (FStat^), Count,
+                                                          ilStandard);
+  if (Err = 0) and (Count = 0) then Err := 18;
+  FindFirst := -Err;
+  if Err = 0 then
+  begin
+    Rslt.Name := FStat^.Name;
+    Rslt.Size := FStat^.FileSize;
+    Rslt.Attr := FStat^.AttrFile;
+    Rslt.ExcludeAttr := 0;
+    TRec (Rslt.Time).T := FStat^.TimeLastWrite;
+    TRec (Rslt.Time).D := FStat^.DateLastWrite;
+  end;
+  Dispose (FStat);
 end;
 
 
@@ -482,8 +462,6 @@ var SR: PSearchRec;
     Err: longint;
 
 begin
-    if os_mode = osOS2 then
-        begin
             New (FStat);
             Count := 1;
             Err := DosFindNext (Rslt.FindHandle, FStat, SizeOf (FStat^),
@@ -500,24 +478,6 @@ begin
                     TRec (Rslt.Time).D := FStat^.DateLastWrite;
                 end;
             Dispose (FStat);
-        end
-    else
-        begin
-            SR := PSearchRec (Rslt.FindHandle);
-            if SR <> nil then
-                begin
-                    DOS.FindNext (SR^);
-                    FindNext := -DosError;
-                    if DosError = 0 then
-                        begin
-                            Rslt.Time := SR^.Time;
-                            Rslt.Size := SR^.Size;
-                            Rslt.Attr := SR^.Attr;
-                            Rslt.ExcludeAttr := 0;
-                            Rslt.Name := SR^.Name;
-                        end;
-                end;
-        end;
 end;
 
 
@@ -526,16 +486,7 @@ procedure FindClose (var F: TSearchrec);
 var SR: PSearchRec;
 
 begin
-    if os_mode = osOS2 then
-        begin
-            DosFindClose (F.FindHandle);
-        end
-    else
-        begin
-            SR := PSearchRec (F.FindHandle);
-            DOS.FindClose (SR^);
-            FreeMem (SR, SizeOf (SearchRec));
-        end;
+    DosFindClose (F.FindHandle);
     F.FindHandle := 0;
 end;
 
@@ -557,8 +508,6 @@ function FileSetDate (Handle, Age: longint): longint;
 var FStat: PFileStatus0;
     RC: longint;
 begin
-    if os_mode = osOS2 then
-        begin
             New (FStat);
             RC := DosQueryFileInfo (Handle, ilStandard, FStat,
                                                               SizeOf (FStat^));
@@ -578,21 +527,6 @@ begin
                         FileSetDate := 0;
                 end;
             Dispose (FStat);
-        end
-    else
-        asm
-            push ebx
-            mov ax, 5701h
-            mov ebx, Handle
-            mov cx, word ptr [Age]
-            mov dx, word ptr [Age + 2]
-            call syscall
-            jnc @FSetDateEnd
-            mov eax, -1
-@FSetDateEnd:
-            mov Result, eax
-            pop ebx
-        end ['eax', 'ecx', 'edx'];
 end;
 
 
@@ -732,39 +666,13 @@ var FI: TFSinfo;
     RC: longint;
 
 begin
-    if (os_mode = osDOS) or (os_mode = osDPMI) then
-    {Function 36 is not supported in OS/2.}
-        asm
-            pushl %ebx
-            movb Drive,%dl
-            movb $0x36,%ah
-            call syscall
-            cmpw $-1,%ax
-            je .LDISKFREE1
-            mulw %cx
-            mulw %bx
-            shll $16,%edx
-            movw %ax,%dx
-            movl $0,%eax
-            xchgl %edx,%eax
-            jmp .LDISKFREE2
-         .LDISKFREE1:
-            cltd
-         .LDISKFREE2:
-            popl %ebx
-            leave
-            ret
-        end
-    else
         {In OS/2, we use the filesystem information.}
-        begin
             RC := DosQueryFSInfo (Drive, 1, FI, SizeOf (FI));
             if RC = 0 then
                 DiskFree := int64 (FI.Free_Clusters) *
                    int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
             else
                 DiskFree := -1;
-        end;
 end;
 
 function DiskSize (Drive: byte): int64;
@@ -773,40 +681,13 @@ var FI: TFSinfo;
     RC: longint;
 
 begin
-    if (os_mode = osDOS) or (os_mode = osDPMI) then
-        {Function 36 is not supported in OS/2.}
-        asm
-            pushl %ebx
-            movb Drive,%dl
-            movb $0x36,%ah
-            call syscall
-            movw %dx,%bx
-            cmpw $-1,%ax
-            je .LDISKSIZE1
-            mulw %cx
-            mulw %bx
-            shll $16,%edx
-            movw %ax,%dx
-            movl $0,%eax
-            xchgl %edx,%eax
-            jmp .LDISKSIZE2
-         .LDISKSIZE1:
-            cltd
-         .LDISKSIZE2:
-            popl %ebx
-            leave
-            ret
-        end
-    else
         {In OS/2, we use the filesystem information.}
-        begin
             RC := DosQueryFSinfo (Drive, 1, FI, SizeOf (FI));
             if RC = 0 then
                 DiskSize := int64 (FI.Total_Clusters) *
                    int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
             else
                 DiskSize := -1;
-        end;
 end;
 
 
@@ -930,15 +811,8 @@ begin
     for I := 0 to 255 do
         UpperCaseTable [I] := Chr (I);
     Move (UpperCaseTable, LowerCaseTable, SizeOf (UpperCaseTable));
-    if os_mode = osOS2 then
-        begin
             FillChar (Country, SizeOf (Country), 0);
             DosMapCase (SizeOf (UpperCaseTable), Country, @UpperCaseTable);
-        end
-    else
-        begin
-(* !!! TODO: DOS/DPMI mode support!!! *)
-        end;
     for I := 0 to 255 do
         if UpperCaseTable [I] <> Chr (I) then
             LowerCaseTable [Ord (UpperCaseTable [I])] := Chr (I);
@@ -1012,7 +886,10 @@ end.
 
 {
   $Log$
-  Revision 1.31  2003-10-07 21:26:34  hajny
+  Revision 1.32  2003-10-08 05:22:47  yuri
+  * Some emx code removed
+
+  Revision 1.31  2003/10/07 21:26:34  hajny
     * stdcall fixes and asm routines cleanup
 
   Revision 1.30  2003/10/03 21:46:41  peter

+ 9 - 36
rtl/os2/thread.inc

@@ -90,7 +90,7 @@ begin
  Inc (ThreadVarBlockSize, Size);
 end;
 
-type ltvInitEntry = 
+type ltvInitEntry =
   record
     varaddr : pdword;
     size    : longint;
@@ -111,10 +111,10 @@ type TltvInitTablesTable =
     count : dword;
     tables: array [1..32767] of pltvInitEntry;
   end;
-  
+
 var
   ThreadvarTablesTable : TltvInitTablesTable; external name 'FPC_LOCALTHREADVARTABLES';
-  
+
 procedure init_all_unit_threadvars; [public,alias: 'FPC_INITIALIZELOCALTHREADVARS'];
 var i : integer;
 begin
@@ -139,25 +139,14 @@ begin
  { exceptions which use threadvars but      }
  { these aren't allocated yet ...           }
  { allocate room on the heap for the thread vars }
- if os_mode = osOS2 then
- begin
   if DosAllocMem (DataIndex^, ThreadVarBlockSize, pag_Read or pag_Write
                                       or pag_Commit) <> 0 then HandleError (8);
- end else
- begin
-  (* Allocate the DOS memory here. *)
-
- end;
 end;
 
 procedure ReleaseThreadVars;
 begin
  { release thread vars }
- if os_mode = osOS2 then DosFreeMem (DataIndex^) else
- begin
-  (* Deallocate the DOS memory here. *)
-
- end;
+ DosFreeMem (DataIndex^)
 end;
 
 procedure InitThread;
@@ -182,16 +171,6 @@ begin
  ReleaseThreadVars;
  DosGetInfoBlocks (@PTIB, @PPIB);
  ThreadID := PTIB^.TIB2^.TID;
-{$IFDEF EMX}
-{$ASMMODE INTEL}
- if os_mode = osOS2 then
- asm
-  mov eax, 7F2Dh
-  mov edx, ThreadID
-  call syscall
- end ['eax', 'ecx', 'edx'];
-{$ASMMODE DEFAULT}
-{$ENDIF EMX}
 end;
 
 function ThreadMain (Param: pointer): dword; cdecl;
@@ -280,8 +259,6 @@ end;
 
 procedure InitCriticalSection (var CS: TRTLCriticalSection);
 begin
- if os_mode = osOS2 then
- begin
   if DosCreateMutExSem (nil, CS.LockSemaphore2, 0, true) <> 0 then
                                                                HandleError (8);
   DosEnterCritSec;
@@ -289,12 +266,11 @@ begin
   CS.OwningThread := $FFFF;
   DosExitCritSec;
   DosReleaseMutexSem (CS.LockSemaphore2);
- end;
 end;
 
 procedure DoneCriticalSection (var CS: TRTLCriticalSection);
 begin
- if os_mode = osOS2 then DosCloseMutExSem (CS.LockSemaphore2);
+ DosCloseMutExSem (CS.LockSemaphore2);
 end;
 
 procedure EnterCriticalSection (var CS: TRTLCriticalSection);
@@ -303,8 +279,6 @@ var
  PTIB: PThreadInfoBlock;
  PPIB: PProcessInfoBlock;
 begin
- if os_mode = osOS2 then
- begin
   DosGetInfoBlocks (@PTIB, @PPIB);
   DosEnterCritSec;
   with CS do if (LockCount = 0) and
@@ -329,7 +303,6 @@ begin
    OwningThread2 := PTIB^.TIB2^.TID;
    DosExitCritSec;
   end;
- end;
 end;
 
 procedure LeaveCriticalSection (var CS: TRTLCriticalSection);
@@ -338,8 +311,6 @@ var
  PPIB: PProcessInfoBlock;
  Err: boolean;
 begin
- if os_mode = osOS2 then
- begin
   Err := false;
   DosGetInfoBlocks (@PTIB, @PPIB);
   DosEnterCritSec;
@@ -358,14 +329,16 @@ begin
    DosExitCritSec;
   end;
   if Err then HandleError (5);
- end;
 end;
 
 {$ENDIF MT}
 
 {
   $Log$
-  Revision 1.11  2003-10-07 21:26:35  hajny
+  Revision 1.12  2003-10-08 05:22:47  yuri
+  * Some emx code removed
+
+  Revision 1.11  2003/10/07 21:26:35  hajny
     * stdcall fixes and asm routines cleanup
 
   Revision 1.10  2003/02/20 17:09:49  hajny