Browse Source

* Optimization for code size.

git-svn-id: trunk@5331 -
yury 19 years ago
parent
commit
4bfe0e6819
2 changed files with 17 additions and 10 deletions
  1. 7 5
      rtl/inc/system.inc
  2. 10 5
      rtl/win/sysos.inc

+ 7 - 5
rtl/inc/system.inc

@@ -671,6 +671,7 @@ Procedure FinalizeHeap;forward;
 Procedure InternalExit;
 Procedure InternalExit;
 var
 var
   current_exit : Procedure;
   current_exit : Procedure;
+  pstdout : ^Text;
 {$if defined(MSWINDOWS) or defined(OS2)}
 {$if defined(MSWINDOWS) or defined(OS2)}
   i : longint;
   i : longint;
 {$endif}
 {$endif}
@@ -688,18 +689,19 @@ Begin
   { Finalize units }
   { Finalize units }
   FinalizeUnits;
   FinalizeUnits;
   { Show runtime error and exit }
   { Show runtime error and exit }
+  pstdout:=@stdout;
   If erroraddr<>nil Then
   If erroraddr<>nil Then
    Begin
    Begin
-     Writeln(stdout,'Runtime error ',Errorcode,' at $',hexstr(PtrInt(Erroraddr),sizeof(PtrInt)*2));
+     Writeln(pstdout^,'Runtime error ',Errorcode,' at $',hexstr(PtrInt(Erroraddr),sizeof(PtrInt)*2));
      { to get a nice symify }
      { to get a nice symify }
-     Writeln(stdout,BackTraceStrFunc(Erroraddr));
-     dump_stack(stdout,ErrorBase);
-     Writeln(stdout,'');
+     Writeln(pstdout^,BackTraceStrFunc(Erroraddr));
+     dump_stack(pstdout^,ErrorBase);
+     Writeln(pstdout^,'');
    End;
    End;
   { Make sure that all output is written to the redirected file }
   { Make sure that all output is written to the redirected file }
   Flush(Output);
   Flush(Output);
   Flush(ErrOutput);
   Flush(ErrOutput);
-  Flush(StdOut);
+  Flush(pstdout^);
   Flush(StdErr);
   Flush(StdErr);
 {$if defined(MSWINDOWS) or defined(OS2)}
 {$if defined(MSWINDOWS) or defined(OS2)}
   { finally release the heap if possible, especially
   { finally release the heap if possible, especially

+ 10 - 5
rtl/win/sysos.inc

@@ -279,28 +279,33 @@ threadvar
 
 
 
 
    Procedure Errno2InOutRes;
    Procedure Errno2InOutRes;
+   var
+     res : Word;
+     pErrno : ^longint;
    Begin
    Begin
      { DO NOT MODIFY UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING }
      { DO NOT MODIFY UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING }
-     case Errno of
+     pErrno:=@Errno;
+     case pErrno^ of
        ERROR_WRITE_PROTECT..ERROR_GEN_FAILURE :
        ERROR_WRITE_PROTECT..ERROR_GEN_FAILURE :
          begin
          begin
            { This is the offset to the Win32 to add to directly map  }
            { This is the offset to the Win32 to add to directly map  }
            { to the DOS/TP compatible error codes when in this range }
            { to the DOS/TP compatible error codes when in this range }
-           InOutRes := word(errno)+131;
+           res := word(pErrno^)+131;
          end;
          end;
        ERROR_DIR_NOT_EMPTY,
        ERROR_DIR_NOT_EMPTY,
        ERROR_ALREADY_EXISTS,
        ERROR_ALREADY_EXISTS,
        ERROR_SHARING_VIOLATION :
        ERROR_SHARING_VIOLATION :
          begin
          begin
-           InOutRes :=5;
+           res :=5;
          end;
          end;
        else
        else
          begin
          begin
            { other error codes can directly be mapped }
            { other error codes can directly be mapped }
-           InOutRes := Word(errno);
+           res := Word(pErrno^);
          end;
          end;
      end;
      end;
-     errno:=0;
+     pErrno^:=0;
+     InOutRes:=res;
    end;
    end;