peter vor 27 Jahren
Ursprung
Commit
795801f770
1 geänderte Dateien mit 100 neuen und 136 gelöschten Zeilen
  1. 100 136
      rtl/linux/linux.pp

+ 100 - 136
rtl/linux/linux.pp

@@ -1,4 +1,5 @@
 {
 {
+    $Id$
     This file is part of the Free Pascal run time library.
     This file is part of the Free Pascal run time library.
     Copyright (c) 1993,97 by Michael Van Canneyt,
     Copyright (c) 1993,97 by Michael Van Canneyt,
     member of the Free Pascal development team.
     member of the Free Pascal development team.
@@ -154,16 +155,13 @@ Type
   SigSet  = Integer;
   SigSet  = Integer;
   PSigSet = ^SigSet;
   PSigSet = ^SigSet;
 
 
-
-{$PACKRECORDS 1}
-  SigActionRec = record
+  SigActionRec = packed record
     Sa_Handler : SignalHandler;
     Sa_Handler : SignalHandler;
     Sa_Mask : longint;
     Sa_Mask : longint;
     Sa_Flags : Integer;
     Sa_Flags : Integer;
     Sa_restorer : SignalRestorer;{ Obsolete - Don't use }
     Sa_restorer : SignalRestorer;{ Obsolete - Don't use }
   end;
   end;
   PSigActionRec = ^SigActionRec;
   PSigActionRec = ^SigActionRec;
-{$PACKRECORDS NORMAL}
 
 
 
 
 {********************
 {********************
@@ -240,15 +238,14 @@ Const
 
 
 
 
 Type
 Type
-{$PACKRECORDS 1}
-  winsize = record
+  winsize = packed record
     ws_row,
     ws_row,
     ws_col,
     ws_col,
     ws_xpixel,
     ws_xpixel,
-    ws_ypixel : byte;
+    ws_ypixel : word;
   end;
   end;
 
 
-  TermIO = record
+  TermIO = packed record
     c_iflag,                             { input mode flags }
     c_iflag,                             { input mode flags }
     c_oflag,                             { output mode flags }
     c_oflag,                             { output mode flags }
     c_cflag,                             { control mode flags }
     c_cflag,                             { control mode flags }
@@ -257,19 +254,14 @@ Type
     c_cc     : array [0..NCC-1] of char;{ control characters }
     c_cc     : array [0..NCC-1] of char;{ control characters }
   end;
   end;
 
 
-  TermIOS = record
+  TermIOS = packed record
     c_iflag,
     c_iflag,
-
     c_oflag,
     c_oflag,
-
     c_cflag,
     c_cflag,
-
     c_lflag  : longint;
     c_lflag  : longint;
     c_line  : char;
     c_line  : char;
-
     c_cc     : array[0..NCCS-1] of byte;
     c_cc     : array[0..NCCS-1] of byte;
   end;
   end;
-{$PACKRECORDS 2}
 
 
 const
 const
   InitCC:array[0..NCCS-1] of byte=(3,34,177,25,4,0,1,0,21,23,32,0,22,17,27,26,0,0,0);
   InitCC:array[0..NCCS-1] of byte=(3,34,177,25,4,0,1,0,21,23,32,0,22,17,27,26,0,0,0);
@@ -437,12 +429,11 @@ const
 ********************}
 ********************}
 
 
 Type
 Type
-{$PACKRECORDS 1}
-  utimbuf = record
+  utimbuf = packed record
     actime,modtime : Longint;
     actime,modtime : Longint;
   end;
   end;
 
 
-  TSysinfo = record
+  TSysinfo = packed record
     uptime    : longint;
     uptime    : longint;
     loads     : array[1..3] of longint;
     loads     : array[1..3] of longint;
     totalram,
     totalram,
@@ -454,7 +445,7 @@ Type
     procs     : integer;
     procs     : integer;
     s         : string[18];
     s         : string[18];
   end;
   end;
-{$PACKRECORDS 2}
+
 
 
 {******************************************************************************
 {******************************************************************************
                             Procedure/Functions
                             Procedure/Functions
@@ -1163,7 +1154,6 @@ begin
 end;
 end;
 
 
 
 
-
 Function GetEpochTime:longint;
 Function GetEpochTime:longint;
 {
 {
   Get the number of seconds since 00:00, January 1 1970, GMT
   Get the number of seconds since 00:00, January 1 1970, GMT
@@ -1188,7 +1178,6 @@ begin
 end;
 end;
 
 
 
 
-
 Procedure EpochToLocal(epoch:longint;var year,month,day,hour,minute,second:Word);
 Procedure EpochToLocal(epoch:longint;var year,month,day,hour,minute,second:Word);
 {
 {
   Transforms Epoch time(seconds since 00:00, january 1 1970, corrected for
   Transforms Epoch time(seconds since 00:00, january 1 1970, corrected for
@@ -1208,7 +1197,6 @@ Begin { Beginning of Localtime }
 End;
 End;
 
 
 
 
-
 Function LocalToEpoch(year,month,day,hour,minute,second:Word):Longint;
 Function LocalToEpoch(year,month,day,hour,minute,second:Word):Longint;
 {
 {
   Transforms local time (year,month,day,hour,minutes,second) to Epoch time
   Transforms local time (year,month,day,hour,minutes,second) to Epoch time
@@ -1220,7 +1208,6 @@ Begin
 End;
 End;
 
 
 
 
-
 Procedure GetTime(Var Hour,Minute,Second:Word);
 Procedure GetTime(Var Hour,Minute,Second:Word);
 {
 {
   Gets the current time, adjusted to local time, but not DST,
   Gets the current time, adjusted to local time, but not DST,
@@ -1294,7 +1281,6 @@ end;
 
 
 
 
 Function  fdOpen(pathname:pchar;flags:longint):longint;
 Function  fdOpen(pathname:pchar;flags:longint):longint;
-
 begin
 begin
   fdOpen:=Sys_Open(pathname,flags,0);
   fdOpen:=Sys_Open(pathname,flags,0);
   LinuxError:=Errno;
   LinuxError:=Errno;
@@ -1302,9 +1288,7 @@ end;
 
 
 
 
 
 
-
 Function  fdOpen(pathname:pchar;flags,mode:longint):longint;
 Function  fdOpen(pathname:pchar;flags,mode:longint):longint;
-
 begin
 begin
   fdOpen:=Sys_Open(pathname,flags,mode);
   fdOpen:=Sys_Open(pathname,flags,mode);
   LinuxError:=Errno;
   LinuxError:=Errno;
@@ -1361,11 +1345,8 @@ end;
 
 
 
 
 Function  fdFlush (fd : Longint) : Boolean;
 Function  fdFlush (fd : Longint) : Boolean;
-
-
 var
 var
   SR: SysCallRegs;
   SR: SysCallRegs;
-
 begin
 begin
   SR.reg2 := fd;
   SR.reg2 := fd;
   fdFlush := (SysCall(syscall_nr_fsync, SR)=0);
   fdFlush := (SysCall(syscall_nr_fsync, SR)=0);
@@ -1424,7 +1405,6 @@ var
   sr : Syscallregs;
   sr : Syscallregs;
 begin
 begin
   if (cmd in [F_SetFd,F_SetFl,F_GetLk,F_SetLk,F_SetLkw,F_SetOwn]) then
   if (cmd in [F_SetFd,F_SetFl,F_GetLk,F_SetLk,F_SetLkw,F_SetOwn]) then
-
    begin
    begin
      sr.reg2:=textrec(fd).handle;
      sr.reg2:=textrec(fd).handle;
      sr.reg3:=cmd;
      sr.reg3:=cmd;
@@ -1487,8 +1467,8 @@ end;
 
 
 
 
 Function  Flock (fd,mode : longint) : boolean;
 Function  Flock (fd,mode : longint) : boolean;
-
-var sr : Syscallregs;
+var
+  sr : Syscallregs;
 begin
 begin
   sr.reg2:=fd;
   sr.reg2:=fd;
   sr.reg3:=mode;
   sr.reg3:=mode;
@@ -1499,15 +1479,13 @@ end;
 
 
 
 
 Function Flock (var T : text;mode : longint) : boolean;
 Function Flock (var T : text;mode : longint) : boolean;
-
 begin
 begin
-  Flock:=Flock( TextRec(T).Handle,mode );
+  Flock:=Flock(TextRec(T).Handle,mode);
 end;
 end;
 
 
 
 
 
 
 Function  Flock (var F : File;mode : longint) : boolean;
 Function  Flock (var F : File;mode : longint) : boolean;
-
 begin
 begin
   Flock:=Flock(FileRec(F).Handle,mode);
   Flock:=Flock(FileRec(F).Handle,mode);
 end;
 end;
@@ -1772,13 +1750,13 @@ Function Dup2(var oldfile,newfile:text):Boolean;
 var
 var
   tmphandle : word;
   tmphandle : word;
 begin
 begin
- flush(oldfile);{ We cannot share buffers, so we flush them. }
- flush(newfile);
- tmphandle:=textrec(newfile).handle;
- textrec(newfile):=textrec(oldfile);
- textrec(newfile).handle:=tmphandle;
- textrec(newfile).bufptr:=@(textrec(newfile).buffer);{ No shared buffer. }
- Dup2:=Dup2(textrec(oldfile).handle,textrec(newfile).handle);
+  flush(oldfile);{ We cannot share buffers, so we flush them. }
+  flush(newfile);
+  tmphandle:=textrec(newfile).handle;
+  textrec(newfile):=textrec(oldfile);
+  textrec(newfile).handle:=tmphandle;
+  textrec(newfile).bufptr:=@(textrec(newfile).buffer);{ No shared buffer. }
+  Dup2:=Dup2(textrec(oldfile).handle,textrec(newfile).handle);
 end;
 end;
 
 
 
 
@@ -1982,7 +1960,6 @@ begin
      AssignPipe:=false;
      AssignPipe:=false;
      exit;
      exit;
    end;
    end;
-
 { Set up input }
 { Set up input }
   Assign(Pipe_in,'.');
   Assign(Pipe_in,'.');
   Textrec(Pipe_in).Handle:=f_in;
   Textrec(Pipe_in).Handle:=f_in;
@@ -2019,7 +1996,6 @@ begin
      AssignPipe:=false;
      AssignPipe:=false;
      exit;
      exit;
    end;
    end;
-
 { Set up input }
 { Set up input }
   Assign(Pipe_in,'.');
   Assign(Pipe_in,'.');
   Filerec(Pipe_in).Handle:=f_in;
   Filerec(Pipe_in).Handle:=f_in;
@@ -2037,12 +2013,10 @@ end;
 
 
 
 
 Function PClose(Var F:text) :longint;
 Function PClose(Var F:text) :longint;
-
 var
 var
   sr  : syscallregs;
   sr  : syscallregs;
   pl  : ^longint;
   pl  : ^longint;
   res : longint;
   res : longint;
-
 begin
 begin
   flush (f);
   flush (f);
   sr.reg2:=Textrec(F).Handle;
   sr.reg2:=Textrec(F).Handle;
@@ -2059,8 +2033,6 @@ var
   sr : syscallregs;
   sr : syscallregs;
   pl : ^longint;
   pl : ^longint;
   res : longint;
   res : longint;
-
-
 begin
 begin
   sr.reg2:=FileRec(F).Handle;
   sr.reg2:=FileRec(F).Handle;
   SysCall (Syscall_nr_close,sr);
   SysCall (Syscall_nr_close,sr);
@@ -2075,7 +2047,6 @@ Procedure PCloseText(Var F:text);
 {
 {
   May not use @PClose due overloading
   May not use @PClose due overloading
 }
 }
-
 begin
 begin
   PClose(f);
   PClose(f);
 end;
 end;
@@ -2311,13 +2282,11 @@ begin
    begin
    begin
    { we're in the parent}
    { we're in the parent}
    {
    {
-
      Let's redraw the schedule :
      Let's redraw the schedule :
           Parent      Child
           Parent      Child
           pipo[1] --> pipi[1]
           pipo[1] --> pipi[1]
           pipi[0] <-- pipo[0]
           pipi[0] <-- pipo[0]
       }
       }
-
      close(pipo);
      close(pipo);
      // dup(pipi[0],streamin);
      // dup(pipi[0],streamin);
      // close (pipi[0]);
      // close (pipi[0]);
@@ -2325,7 +2294,6 @@ begin
      // dup(pipo[1],streamout);
      // dup(pipo[1],streamout);
      // close (pipo[1]);
      // close (pipo[1]);
    end;
    end;
-
 end;
 end;
 
 
 
 
@@ -2614,13 +2582,11 @@ begin
   with tios do
   with tios do
    begin
    begin
      c_iflag:=c_iflag and (not (IGNBRK or BRKINT or PARMRK or ISTRIP or
      c_iflag:=c_iflag and (not (IGNBRK or BRKINT or PARMRK or ISTRIP or
-
                                 INLCR or IGNCR or ICRNL or IXON));
                                 INLCR or IGNCR or ICRNL or IXON));
      c_oflag:=c_oflag and (not OPOST);
      c_oflag:=c_oflag and (not OPOST);
      c_lflag:=c_lflag and (not (ECHO or ECHONL or ICANON or ISIG or IEXTEN));
      c_lflag:=c_lflag and (not (ECHO or ECHONL or ICANON or ISIG or IEXTEN));
      c_cflag:=(c_cflag and (not (CSIZE or PARENB))) or CS8;
      c_cflag:=(c_cflag and (not (CSIZE or PARENB))) or CS8;
    end;
    end;
-
 end;
 end;
 
 
 
 
@@ -2815,7 +2781,6 @@ end;
 
 
 
 
 
 
-
 Function FExpand(Const Path:PathStr):PathStr;
 Function FExpand(Const Path:PathStr):PathStr;
 var
 var
   temp : pathstr;
   temp : pathstr;
@@ -2846,7 +2811,6 @@ Begin
       inc(i);
       inc(i);
      temp:=temp+'/'+copy(path,i,length(path)-i+1)+'/';
      temp:=temp+'/'+copy(path,i,length(path)-i+1)+'/';
    end;
    end;
-
 {First remove all references to '/./'}
 {First remove all references to '/./'}
   while pos('/./',temp)<>0 do
   while pos('/./',temp)<>0 do
    delete(temp,pos('/./',temp),2);
    delete(temp,pos('/./',temp),2);
@@ -2911,7 +2875,6 @@ Begin
        if NewDir[Length(NewDir)]<>'/' then
        if NewDir[Length(NewDir)]<>'/' then
         NewDir:=NewDir+'/';
         NewDir:=NewDir+'/';
        NewDir:=NewDir+Path;
        NewDir:=NewDir+Path;
-
        Delete(DirList,1,p1);
        Delete(DirList,1,p1);
        if FStat(NewDir,Info) then
        if FStat(NewDir,Info) then
         Begin
         Begin
@@ -2984,7 +2947,6 @@ end;
 
 
 
 
 Function FNMatch(const Pattern,Name:string):Boolean;
 Function FNMatch(const Pattern,Name:string):Boolean;
-
 Var
 Var
   LenPat,LenName : longint;
   LenPat,LenName : longint;
 
 
@@ -3320,8 +3282,8 @@ Function  IOperm (From,Num : Cardinal; Value : Longint) : boolean;
   this works ONLY as root.
   this works ONLY as root.
 }
 }
 
 
-Var Sr : Syscallregs;
-
+Var
+  Sr : Syscallregs;
 begin
 begin
   Sr.Reg2:=From;
   Sr.Reg2:=From;
   Sr.Reg3:=Num;
   Sr.Reg3:=Num;
@@ -3336,13 +3298,12 @@ Procedure WritePort (Port : Longint; Value : Byte);
 {
 {
   Writes 'Value' to port 'Port'
   Writes 'Value' to port 'Port'
 }
 }
-
 begin
 begin
-	asm
-	movl 8(%ebp),%edx
-	movb 12(%ebp),%al
-	outb %al,%dx
-	end;
+        asm
+        movl 8(%ebp),%edx
+        movb 12(%ebp),%al
+        outb %al,%dx
+        end;
 end;
 end;
 
 
 Procedure WritePort (Port : Longint; Value : Word);
 Procedure WritePort (Port : Longint; Value : Word);
@@ -3351,11 +3312,11 @@ Procedure WritePort (Port : Longint; Value : Word);
 }
 }
 
 
 begin
 begin
-	asm
-	movl 8(%ebp),%edx
-	movw 12(%ebp),%ax
-	outw %ax,%dx
-	end ['EAX','EBX'];
+        asm
+        movl 8(%ebp),%edx
+        movw 12(%ebp),%ax
+        outw %ax,%dx
+        end ['EAX','EBX'];
 end;
 end;
 
 
 
 
@@ -3366,27 +3327,27 @@ Procedure WritePort (Port : Longint; Value : Longint);
 }
 }
 
 
 begin
 begin
-	asm
-	movl 8(%ebp),%edx
-	movl 12(%ebp),%eax
-	outl %eax,%dx
-	end ['EAX','EBX'];
+        asm
+        movl 8(%ebp),%edx
+        movl 12(%ebp),%eax
+        outl %eax,%dx
+        end ['EAX','EBX'];
 end;
 end;
 
 
 
 
 
 
 Procedure WritePortl (Port : Longint; Var Buf; Count: longint);
 Procedure WritePortl (Port : Longint; Var Buf; Count: longint);
 {
 {
- Writes 'Count' longints from 'Buf' to Port
+  Writes 'Count' longints from 'Buf' to Port
 }
 }
 begin
 begin
   asm
   asm
-	movl 16(%ebp),%ecx
-	movl 12(%ebp),%esi
-	movl 8(%ebp),%edx
-	cld
-	rep
-	outsl
+        movl 16(%ebp),%ecx
+        movl 12(%ebp),%esi
+        movl 8(%ebp),%edx
+        cld
+        rep
+        outsl
   end ['ECX','ESI','EDX'];
   end ['ECX','ESI','EDX'];
 end;
 end;
 
 
@@ -3394,16 +3355,16 @@ end;
 
 
 Procedure WritePortW (Port : Longint; Var Buf; Count: longint);
 Procedure WritePortW (Port : Longint; Var Buf; Count: longint);
 {
 {
- Writes 'Count' words from 'Buf' to Port
+  Writes 'Count' words from 'Buf' to Port
 }
 }
 begin
 begin
   asm
   asm
-	movl 16(%ebp),%ecx
-	movl 12(%ebp),%esi
-	movl 8(%ebp),%edx
-	cld
-	rep
-	outsw
+        movl 16(%ebp),%ecx
+        movl 12(%ebp),%esi
+        movl 8(%ebp),%edx
+        cld
+        rep
+        outsw
   end ['ECX','ESI','EDX'];
   end ['ECX','ESI','EDX'];
 end;
 end;
 
 
@@ -3411,16 +3372,16 @@ end;
 
 
 Procedure WritePortB (Port : Longint; Var Buf; Count: longint);
 Procedure WritePortB (Port : Longint; Var Buf; Count: longint);
 {
 {
- Writes 'Count' bytes from 'Buf' to Port
+  Writes 'Count' bytes from 'Buf' to Port
 }
 }
 begin
 begin
   asm
   asm
-	movl 16(%ebp),%ecx
-	movl 12(%ebp),%esi
-	movl 8(%ebp),%edx
-	cld
-	rep
-	outsb
+        movl 16(%ebp),%ecx
+        movl 12(%ebp),%esi
+        movl 8(%ebp),%edx
+        cld
+        rep
+        outsb
   end ['ECX','ESI','EDX'];
   end ['ECX','ESI','EDX'];
 end;
 end;
 
 
@@ -3430,14 +3391,13 @@ Procedure ReadPort (Port : Longint; Var Value : Byte);
 {
 {
   Reads 'Value' from port 'Port'
   Reads 'Value' from port 'Port'
 }
 }
-
 begin
 begin
-	asm
-	movl 8(%ebp),%edx
-	inb %dx,%al
-	andl $255,%eax
-	movl %eax,12(%ebp)
-	end ['EAX','EBX'];
+        asm
+        movl 8(%ebp),%edx
+        inb %dx,%al
+        andl $255,%eax
+        movl %eax,12(%ebp)
+        end ['EAX','EBX'];
 end;
 end;
 
 
 
 
@@ -3446,14 +3406,13 @@ Procedure ReadPort (Port : Longint; Var Value : Word);
 {
 {
   Reads 'Value' from port 'Port'
   Reads 'Value' from port 'Port'
 }
 }
-
 begin
 begin
-	asm
-	movl 8(%ebp),%edx
-	inw %dx,%ax
-	andl $65535,%eax
-	movl %eax,12(%ebp)
-	end ['EAX','EBX'];
+        asm
+        movl 8(%ebp),%edx
+        inw %dx,%ax
+        andl $65535,%eax
+        movl %eax,12(%ebp)
+        end ['EAX','EBX'];
 end;
 end;
 
 
 
 
@@ -3462,27 +3421,27 @@ Procedure ReadPort (Port : Longint; Var Value : Longint);
 {
 {
   Reads 'Value' from port 'Port'
   Reads 'Value' from port 'Port'
 }
 }
-
 begin
 begin
-	asm
-	movl 8(%ebp),%edx
-	inl %dx,%eax
-	movl %eax,12(%ebp)
-	end ['EAX','EBX'];
+        asm
+        movl 8(%ebp),%edx
+        inl %dx,%eax
+        movl %eax,12(%ebp)
+        end ['EAX','EBX'];
 end;
 end;
 
 
+
 Procedure ReadPortL (Port : Longint; Var Buf; Count: longint);
 Procedure ReadPortL (Port : Longint; Var Buf; Count: longint);
 {
 {
   Reads 'Count' longints from port 'Port' to 'Buf'.
   Reads 'Count' longints from port 'Port' to 'Buf'.
 }
 }
 begin
 begin
   asm
   asm
-	movl 16(%ebp),%ecx
-	movl 12(%ebp),%edi
-	movl 8(%ebp),%edx
-	cld
-	rep
-	insl
+        movl 16(%ebp),%ecx
+        movl 12(%ebp),%edi
+        movl 8(%ebp),%edx
+        cld
+        rep
+        insl
   end ['ECX','ESI','EDX'];
   end ['ECX','ESI','EDX'];
 end;
 end;
 
 
@@ -3494,12 +3453,12 @@ Procedure ReadPortW (Port : Longint; Var Buf; Count: longint);
 }
 }
 begin
 begin
   asm
   asm
-	movl 16(%ebp),%ecx
-	movl 12(%ebp),%edi
-	movl 8(%ebp),%edx
-	cld
-	rep
-	insw
+        movl 16(%ebp),%ecx
+        movl 12(%ebp),%edi
+        movl 8(%ebp),%edx
+        cld
+        rep
+        insw
   end ['ECX','ESI','EDX'];
   end ['ECX','ESI','EDX'];
 end;
 end;
 
 
@@ -3511,25 +3470,30 @@ Procedure ReadPortB (Port : Longint; Var Buf; Count: longint);
 }
 }
 begin
 begin
   asm
   asm
-	movl 16(%ebp),%ecx
-	movl 12(%ebp),%edi
-	movl 8(%ebp),%edx
-	cld
-	rep
-	insb
+        movl 16(%ebp),%ecx
+        movl 12(%ebp),%edi
+        movl 8(%ebp),%edx
+        cld
+        rep
+        insb
   end ['ECX','ESI','EDX'];
   end ['ECX','ESI','EDX'];
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
 
 
-
 Begin
 Begin
   InitEpochToLocal;
   InitEpochToLocal;
 End.
 End.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.18  1998-09-08 13:01:51  michael
+  Revision 1.19  1998-09-18 09:56:33  peter
+    * merged
+
+  Revision 1.18.2.1  1998/09/18 09:53:46  peter
+    * fixed winsize record
+
+  Revision 1.18  1998/09/08 13:01:51  michael
   + Signal call now correctly implemented
   + Signal call now correctly implemented
 
 
   Revision 1.17  1998/08/19 00:50:31  peter
   Revision 1.17  1998/08/19 00:50:31  peter