Browse Source

* get solaris back in shape

peter 20 years ago
parent
commit
b89a03b903

+ 6 - 8
rtl/solaris/Makefile

@@ -1840,15 +1840,14 @@ dateutils$(PPUEXT): $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT) sysutils$(PPUEXT) mat
 strings$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT) $(INC)/strings.pp $(INC)/stringsi.inc\
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
 		   $(SYSTEMUNIT)$(PPUEXT)
-baseunix$(PPUEXT) : unixtype$(PPUEXT) sysctl$(PPUEXT) errno.inc bunxtype.inc ptypes.inc ctypes.inc \
-  signal.inc bunxh.inc bunxmain.inc ostypes.inc \
-  bunxfunc.inc \
-  $(BSDINC)/ostypes.inc $(BSDINC)/ossysch.inc $(BSDINC)/bunxmacr.inc $(UNIXINC)/gensigset.inc \
+baseunix$(PPUEXT) : unixtype$(PPUEXT) sysctl$(PPUEXT) errno.inc ptypes.inc $(UNIXINC)/ctypes.inc \
+  signal.inc bunxh.inc bunxmain.inc \
+  bunxfunc.inc ostypes.inc osmacro.inc $(UNIXINC)/gensigset.inc \
   $(UNIXINC)/genfuncs.inc $(SYSTEMUNIT)$(PPUEXT)
-unixtype$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT) $(UNIXINC)/unixtype.pp ptypes.inc $(BSDINC)/ctypes.inc $(SYSTEMUNIT)$(PPUEXT)
+unixtype$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT) $(UNIXINC)/unixtype.pp ptypes.inc $(UNIXINC)/ctypes.inc $(SYSTEMUNIT)$(PPUEXT)
 unix$(PPUEXT) : unixtype$(PPUEXT) baseunix$(PPUEXT) unixutil$(PPUEXT) strings$(PPUEXT) $(UNIXINC)/unix.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
-		 sysconst.inc $(UNIXINC)/timezone.inc \
-		 unixsysc.inc baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
+		 unxconst.inc $(UNIXINC)/timezone.inc \
+		 unxfunc.inc baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 unixutil$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT)
 dos$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT) strings$(PPUEXT) unix$(PPUEXT) $(UNIXINC)/dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
 	       unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
@@ -1902,7 +1901,6 @@ errors$(PPUEXT) : $(UNIXINC)/errors.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) s
 ipc$(PPUEXT) : $(UNIXINC)/ipc.pp unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) baseunix$(PPUEXT) syscall$(PPUEXT)
 terminfo$(PPUEXT) : terminfo.pp baseunix$(PPUEXT)
 cmem$(PPUEXT) : $(INC)/cmem.pp $(SYSTEMUNIT)$(PPUEXT)
-sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp $(SYSTEMUNIT)$(PPUEXT)
 cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp systhrds$(PPUEXT) unix$(PPUEXT) sysutils$(PPUEXT)
 initc$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT)
 console$(PPUEXT) : baseunix$(PPUEXT) termio$(PPUEXT)

+ 6 - 9
rtl/solaris/Makefile.fpc

@@ -123,17 +123,16 @@ strings$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT) $(INC)/strings.pp $(INC)/stringsi.inc\
 # System Dependent Units
 #
 
-baseunix$(PPUEXT) : unixtype$(PPUEXT) sysctl$(PPUEXT) errno.inc bunxtype.inc ptypes.inc ctypes.inc \
-  signal.inc bunxh.inc bunxmain.inc ostypes.inc \
-  bunxfunc.inc \
-  $(BSDINC)/ostypes.inc $(BSDINC)/ossysch.inc $(BSDINC)/bunxmacr.inc $(UNIXINC)/gensigset.inc \
+baseunix$(PPUEXT) : unixtype$(PPUEXT) sysctl$(PPUEXT) errno.inc ptypes.inc $(UNIXINC)/ctypes.inc \
+  signal.inc bunxh.inc bunxmain.inc \
+  bunxfunc.inc ostypes.inc osmacro.inc $(UNIXINC)/gensigset.inc \
   $(UNIXINC)/genfuncs.inc $(SYSTEMUNIT)$(PPUEXT)
 
-unixtype$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT) $(UNIXINC)/unixtype.pp ptypes.inc $(BSDINC)/ctypes.inc $(SYSTEMUNIT)$(PPUEXT)
+unixtype$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT) $(UNIXINC)/unixtype.pp ptypes.inc $(UNIXINC)/ctypes.inc $(SYSTEMUNIT)$(PPUEXT)
 
 unix$(PPUEXT) : unixtype$(PPUEXT) baseunix$(PPUEXT) unixutil$(PPUEXT) strings$(PPUEXT) $(UNIXINC)/unix.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
-                 sysconst.inc $(UNIXINC)/timezone.inc \
-                 unixsysc.inc baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
+                 unxconst.inc $(UNIXINC)/timezone.inc \
+                 unxfunc.inc baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 
 unixutil$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT)
 
@@ -248,8 +247,6 @@ terminfo$(PPUEXT) : terminfo.pp baseunix$(PPUEXT)
 
 cmem$(PPUEXT) : $(INC)/cmem.pp $(SYSTEMUNIT)$(PPUEXT)
 
-sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp $(SYSTEMUNIT)$(PPUEXT)
-
 cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp systhrds$(PPUEXT) unix$(PPUEXT) sysutils$(PPUEXT)
 
 initc$(PPUEXT) : $(SYSTEMUNIT)$(PPUEXT)

+ 0 - 173
rtl/solaris/bunxtype.inc

@@ -1,173 +0,0 @@
-{
-    $Id$
-    This file is part of the Free Pascal run time library.
-    Copyright (c) 2001 by Free Pascal development team
-
-    Types and structures for the BaseUnix unit.
-
-    See the file COPYING.FPC, included in this distribution,
-    for details about the copyright.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- ***********************************************************************}
-
-{***********************************************************************}
-{                         Base Unix Structures				}
-{***********************************************************************}
-
-{$IFDEF FPC_IS_SYSTEM}
-{$i ptypes.inc}
-{$ENDIF}
-
-CONST
-    UTSNAME_LENGTH = 256;   { 256 + 1 in pchar format }
-    UTSNAME_NODENAME_LENGTH = 256;
-
-    ST_FSTYPSZ = 16;           {* array size for file system type name *}
-
-TYPE
-    { the following type definitions are compiler dependant }
-    { and system dependant                                  }
-
-    cint  = longint;    { minimum range is : 32-bit                   }
-    cuint = cardinal;   { minimum range is : 32-bit                   }
-
-
-    dev_t  = longint;     { used for device numbers      }
-    gid_t  = longint;     { used for group IDs           }
-    ino_t  = cardinal;    { used for file serial numbers }
-    mode_t = cardinal;    { used for file attributes     }
-    nlink_t  = cardinal;  { used for link counts         }
-    off_t  = longint;     { used for file sizes          }
-    pid_t  = longint;     { used as process identifier   }
-    size_t = cardinal;    { as definied in the C standard }
-    ssize_t = longint;    { used by function for returning number of bytes }
-    uid_t = longint;      { used for user ID type        }
-    time_t = longint;     { used for returning the time  }
-    blksize_t = longint;
-    blkcnt_t = longint;
-
-   { file characteristics services }
-   stat = packed record { verify the alignment of the members }
-     st_dev : dev_t;
-     st_pad1 : array[1..3] of longint;  { reserve for dev expansion }
-     st_ino : ino_t;
-     st_mode : mode_t;
-     st_nlink : nlink_t;
-     st_uid : uid_t;
-     st_gid : gid_t;
-     st_rdev : dev_t;
-     st_pad2 : array[1..2] of longint;
-     st_size : off_t;
-     st_pad3 : longint;   {* reserve pad for future off_t expansion *}
-     st_atime : time_t;
-     st_atimens : longint;    { access time nanosecond field         }
-     st_mtime : time_t;
-     st_mtimens : longint;    { modification time nanosecond field   }
-     st_ctime : time_t;
-     st_ctimens : longint;    { modification time nanosecond field   }
-     st_blksize : blksize_t;
-     st_blocks : blkcnt_t;
-     st_fstype : array[0..ST_FSTYPSZ-1] of char;
-     st_pad4 : array[1..8] of longint;
-   end;
-   TStat	     = Stat;
-   PStat	     = ^Stat;
-
-
-   { system information services }
-   utsname = packed record   { don't forget to verify the alignment }
-     sysname : array[0..UTSNAME_LENGTH] of char;
-     nodename : array[0..UTSNAME_LENGTH] of char;
-     release : array[0..UTSNAME_LENGTH] of char;
-     version : array[0..UTSNAME_LENGTH] of char;
-     machine : array[0..UTSNAME_LENGTH] of char;
-   end;
-
-
-   { directory services }
-   pdirent = ^dirent;
-   dirent = packed record    { directory entry record - verify alignment }
-     d_ino : ino_t;                  {* "inode number" of entry *}
-     d_off : off_t;                  {* offset of disk directory entry *}
-     d_reclen : word;                {* length of this record *}
-     d_name : array[0..255] of char; { name of file            }
-   end;
-
-
-   pdir = ^dir;
-   dir = packed record
-    d_fd : cint;               {* file descriptor *}
-    d_loc : cint;              {* offset in block *}
-    d_size : cint;             {* amount of valid data *}
-    d_buf : pchar;             { directory block   }
-   end;
-
-
-
-{***********************************************************************}
-{                  POSIX CONSTANT ROUTINE DEFINITIONS                   }
-{***********************************************************************}
-CONST
-    { access routine - these maybe OR'ed together }
-    F_OK        = 0;   { test for existence of file }
-    R_OK        = 4;   { test for read permission on file }
-    W_OK        = 2;   { test for write permission on file }
-    X_OK        = 1;   { test for execute or search permission }
-    { seek routine }
-    SEEK_SET    = 0;    { seek from beginning of file }
-    SEEK_CUR    = 1;    { seek from current position  }
-    SEEK_END    = 2;    { seek from end of file       }
-    { open routine                                 }
-    { File access modes for `open' and `fcntl'.    }
-    O_RDONLY    = 0;	{ Open read-only.  }
-    O_WRONLY    = 1;	{ Open write-only. }
-    O_RDWR      = 2;	{ Open read/write. }
-    { Bits OR'd into the second argument to open.  }
-    O_CREAT     = $100; { Create file if it doesn't exist.  }
-    O_EXCL      = $400;	{ Fail if file already ??????.      }
-    O_TRUNC     = $200;	{ Truncate file to zero length.     }
-    O_NOCTTY    = $800;	{ Don't assign a controlling terminal. }
-    { File status flags for `open' and `fcntl'.  }
-    O_APPEND    =  $08;	{ Writes append to the file.        }
-    O_NONBLOCK	=  $80;	{ Non-blocking I/O.                 }
-
-
-    { mode_t possible values                                 }
-    S_IRUSR = $100;           { Read permission for owner   }
-    S_IWUSR = $080;           { Write permission for owner  }
-    S_IXUSR = $040;           { Exec  permission for owner  }
-    S_IRGRP = $020;           { Read permission for group   }
-    S_IWGRP = $010;           { Write permission for group  }
-    S_IXGRP = $008;           { Exec permission for group   }
-    S_IROTH = $004;           { Read permission for world   }
-    S_IWOTH = $002;           { Write permission for world  }
-    S_IXOTH = $001;           { Exec permission for world   }
-
-    { Used for waitpid }
-    WNOHANG   = $40;            { don't block waiting               }
-    WUNTRACED = $04;            { report status of stopped children }
-
-    { POSIX limits, used for buffer and stack allocation }
-    ARG_MAX = 1048320;  { Maximum number of argument size     }
-    { Maximum number of bytes in filename - depends on file system }
-    { type, and no define possible, TRUE value is available through}
-    { pathconf variable.                                           }
-    NAME_MAX = 1024;    { put a big value , just in case      }
-    PATH_MAX = 1024;    { Maximum number of bytes in pathname }
-
-
-{$i signal.inc}
-
-
-{
-  $Log$
-  Revision 1.1  2005-02-10 17:30:54  peter
-    * renamed to solaris
-
-  Revision 1.1  2004/11/06 22:22:28  florian
-    * some sunos stuff from 1.0.x merged
-}

+ 81 - 0
rtl/solaris/i386/sighnd.inc

@@ -0,0 +1,81 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    Signal handler is arch dependant due to processor to language
+    exception conversion.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
+var
+  res,fpustate : word;
+begin
+  res:=0;
+  case sig of
+    SIGFPE :
+          begin
+          res:=200;
+(*	  
+          fpustate:=GetFPUState(SigContext^);
+          if (FpuState and FPU_All) <> 0 then
+            begin
+              { first check the more precise options }
+              if (FpuState and FPU_DivisionByZero)<>0 then
+                res:=200
+              else if (FpuState and FPU_Overflow)<>0 then
+                res:=205
+              else if (FpuState and FPU_Underflow)<>0 then
+                res:=206
+              else if (FpuState and FPU_Denormal)<>0 then
+                res:=216
+              else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow or FPU_Invalid))<>0 Then
+                res:=207
+              else
+                res:=207;  {'Coprocessor Error'}
+            end;
+*)	    
+            sysResetFPU;
+        end;
+    SIGILL,
+    SIGBUS,
+    SIGSEGV :
+        res:=216;
+  end;
+{ give runtime error at the position where the signal was raised }
+  if res<>0 then
+    HandleErrorAddrFrame(res,pointer(SigContext^.eip),pointer(SigContext^.ebp));
+end;
+
+{
+  $Log$
+  Revision 1.1  2005-02-13 22:13:20  peter
+    * get solaris back in shape
+
+  Revision 1.5  2005/01/30 18:01:15  peter
+    * signal cleanup for linux
+    * sigactionhandler instead of tsigaction for bsds
+    * sigcontext moved to cpu dir
+
+  Revision 1.4  2004/08/08 09:36:09  florian
+    * fixed runerror for invalid operation
+
+  Revision 1.3  2004/02/05 01:16:12  florian
+    + completed x86-64/linux system unit
+
+  Revision 1.2  2003/11/01 01:58:11  marco
+   * more small fixes.
+
+  Revision 1.1  2003/11/01 01:27:20  marco
+   * initial version from 1.0.x branch
+}

+ 36 - 0
rtl/solaris/i386/sighndh.inc

@@ -0,0 +1,36 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Jonas Maebe,
+    member of the Free Pascal development team.
+
+    Sigcontext and Sigaction
+    
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{$packrecords C}
+
+type
+  PSigContext = ^TSigContext;
+  TSigContext = record
+  end;
+  
+{
+  $Log$
+  Revision 1.1  2005-02-13 22:13:20  peter
+    * get solaris back in shape
+
+  Revision 1.1  2005/01/30 18:01:15  peter
+    * signal cleanup for linux
+    * sigactionhandler instead of tsigaction for bsds
+    * sigcontext moved to cpu dir
+
+}
+

+ 4 - 1
rtl/solaris/bunxmacr.inc → rtl/solaris/osmacro.inc

@@ -91,7 +91,10 @@ end;
 
 {
   $Log$
-  Revision 1.2  2005-02-13 21:47:56  peter
+  Revision 1.1  2005-02-13 22:13:20  peter
+    * get solaris back in shape
+
+  Revision 1.2  2005/02/13 21:47:56  peter
     * include file cleanup part 2
 
   Revision 1.4  2005/02/13 20:01:38  peter

+ 0 - 284
rtl/solaris/osmain.inc

@@ -1,284 +0,0 @@
-{
-    $Id$
-    This file is part of the Free Pascal run time library.
-
-    Main OS dependant body of the system unit, loosely modelled
-    after POSIX.  *BSD version (Linux version is near identical)
-
-    See the file COPYING.FPC, included in this distribution,
-    for details about the copyright.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- **********************************************************************}
-
-{*****************************************************************************
-                       Misc. System Dependent Functions
-*****************************************************************************}
-
-procedure System_exit;
-begin
-   Fpexit(cint(ExitCode));
-End;
-
-
-Function ParamCount: Longint;
-Begin
-  Paramcount:=argc-1
-End;
-
-
-function BackPos(c:char; const s: shortstring): integer;
-var
- i: integer;
-Begin
-  for i:=length(s) downto 0 do
-    if s[i] = c then break;
-  if i=0 then
-    BackPos := 0
-  else
-    BackPos := i;
-end;
-
-
- { variable where full path and filename and executable is stored }
- { is setup by the startup of the system unit.                    }
-var
- execpathstr : shortstring;
-
-function paramstr(l: longint) : string;
- var
-  s: string;
-  s1: string;
- begin
-   { stricly conforming POSIX applications  }
-   { have the executing filename as argv[0] }
-//   if l=0 then
-//     begin
-//       paramstr := execpathstr;
-//     end
-//   else
-     paramstr:=strpas(argv[l]);
- end;
-
-Procedure Randomize;
-Begin
-  randseed:=longint(Fptime(nil));
-End;
-
-
-{*****************************************************************************
-                          Low Level File Routines
-*****************************************************************************}
-
-{
-  The lowlevel file functions should take care of setting the InOutRes to the
-  correct value if an error has occured, else leave it untouched
-}
-
-Function PosixToRunError  (PosixErrno : longint) : longint;
-{
-  Convert ErrNo error to the correct Inoutres value
-}
-
-begin
-  if PosixErrNo=0 then { Else it will go through all the cases }
-   exit(0);
-  case PosixErrNo of
-   ESysENFILE,
-   ESysEMFILE : Inoutres:=4;
-   ESysENOENT : Inoutres:=2;
-    ESysEBADF : Inoutres:=6;
-   ESysENOMEM,
-   ESysEFAULT : Inoutres:=217;
-   ESysEINVAL : Inoutres:=218;
-    ESysEPIPE,
-    ESysEINTR,
-      ESysEIO,
-   ESysEAGAIN,
-   ESysENOSPC : Inoutres:=101;
- ESysENAMETOOLONG : Inoutres := 3;
-    ESysEROFS,
-   ESysEEXIST,
-   ESysENOTEMPTY,
-   ESysEACCES : Inoutres:=5;
-   ESysEISDIR : InOutRes:=5;
-  else
-    begin
-       InOutRes := Integer(PosixErrno);
-    end;
-  end;
- PosixToRunError:=InOutRes;
-end;
-
-Function Errno2InoutRes : longint;
-
-begin
-  Errno2InoutRes:=PosixToRunError(getErrno);
-  InoutRes:=Errno2InoutRes;
-end;
-
-
-{*****************************************************************************
-                         SystemUnit Initialization
-*****************************************************************************}
-
-function  reenable_signal(sig : longint) : boolean;
-var
-  e,oe : TSigSet;
-  i,j : byte;
-begin
-  fillchar(e,sizeof(e),#0);
-  fillchar(oe,sizeof(oe),#0);
-  { set is 1 based PM }
-  dec(sig);
-  i:=sig mod 32;
-  j:=sig div 32;
-  e[j]:=1 shl i;
-  fpsigprocmask(SIG_UNBLOCK,@e,@oe);
-  reenable_signal:=geterrno=0;
-end;
-
-{$i sighnd.inc}
-
-var
-  act: SigActionRec;
-
-Procedure InstallSignals;
-var
-  oldact: SigActionRec;
-begin
-  { Initialize the sigaction structure }
-  { all flags and information set to zero }
-  FillChar(act, sizeof(SigActionRec),0);
-  { initialize handler                    }
-  act.sa_handler :=@SignalToRunError;
-  act.sa_flags:=SA_SIGINFO;
-  FpSigAction(SIGFPE,act,oldact);
-  FpSigAction(SIGSEGV,act,oldact);
-  FpSigAction(SIGBUS,act,oldact);
-  FpSigAction(SIGILL,act,oldact);
-end;
-
-
-procedure SetupCmdLine;
-var
-  bufsize,
-  len,j,
-  size,i : longint;
-  found  : boolean;
-  buf    : pchar;
-
-  procedure AddBuf;
-  begin
-    reallocmem(cmdline,size+bufsize);
-    move(buf^,cmdline[size],bufsize);
-    inc(size,bufsize);
-    bufsize:=0;
-  end;
-
-begin
-  GetMem(buf,ARG_MAX);
-  size:=0;
-  bufsize:=0;
-  i:=0;
-  while (i<argc) do
-   begin
-     len:=strlen(argv[i]);
-     if len>ARG_MAX-2 then
-      len:=ARG_MAX-2;
-     found:=false;
-     for j:=1 to len do
-      if argv[i][j]=' ' then
-       begin
-         found:=true;
-         break;
-       end;
-     if bufsize+len>=ARG_MAX-2 then
-      AddBuf;
-     if found then
-      begin
-        buf[bufsize]:='"';
-        inc(bufsize);
-      end;
-     move(argv[i]^,buf[bufsize],len);
-     inc(bufsize,len);
-     if found then
-      begin
-        buf[bufsize]:='"';
-        inc(bufsize);
-      end;
-     if i<argc then
-      buf[bufsize]:=' '
-     else
-      buf[bufsize]:=#0;
-     inc(bufsize);
-     inc(i);
-   end;
-  AddBuf;
-  FreeMem(buf,ARG_MAX);
-end;
-
-{
-   $Log$
-   Revision 1.1  2005-02-10 17:30:54  peter
-     * renamed to solaris
-
-   Revision 1.2  2005/02/07 22:17:26  peter
-     * updated for 1.9.x unix rtl
-
-   Revision 1.1  2004/11/06 22:22:28  florian
-     * some sunos stuff from 1.0.x merged
-
-   Revision 1.16  2004/10/25 15:38:59  peter
-     * compiler defined HEAP and HEAPSIZE removed
-
-   Revision 1.15  2004/07/17 15:20:55  jonas
-     * don't use O_CREATE when opening a file for appending (fixes tw1744)
-
-   Revision 1.14  2004/05/16 18:51:20  peter
-     * use thandle in do_*
-
-   Revision 1.13  2004/04/22 21:10:56  peter
-     * do_read/do_write addr argument changed to pointer
-
-   Revision 1.12  2004/01/06 15:42:05  marco
-    * o_creat added when o_append
-
-   Revision 1.11  2004/01/03 14:56:10  marco
-    * typo fix
-
-   Revision 1.10  2004/01/03 12:35:39  marco
-    * sighnd to separate file, like linux. Some comments removed
-
-   Revision 1.9  2003/12/30 12:26:21  marco
-    * FPC_USE_LIBC
-
-   Revision 1.8  2003/12/21 20:31:50  peter
-     * fix getdir when directory contains files that give EACCESS
-
-   Revision 1.7  2003/12/14 14:47:02  marco
-    * fix for repeating 'x' bug
-
-   Revision 1.6  2003/11/18 10:12:25  marco
-    * Small fixes for EAGAIN. bunxfunc only has comments added.
-
-   Revision 1.5  2003/10/27 17:12:45  marco
-    * fixes for signal handling.
-
-   Revision 1.4  2003/10/26 17:01:04  marco
-    * moved sigprocmask to system
-
-   Revision 1.3  2003/09/27 13:04:58  peter
-     * fpISxxx renamed
-
-   Revision 1.2  2003/05/29 20:54:09  marco
-    * progname fix.
-
-   Revision 1.1  2003/01/05 19:01:28  marco
-    * FreeBSD compiles now with baseunix mods.
-
-
-}

+ 0 - 40
rtl/solaris/ossysc.inc

@@ -1,40 +0,0 @@
-{
-    $Id$
-    Copyright (c) 2002 by Marco van de Voort
-
-    The base *BSD syscalls required to implement the system unit. These
-    are aliased for use in other units (to avoid poluting the system units
-    interface)
-
-    See the file COPYING.FPC, included in this distribution,
-    for details about the copyright.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- ****************************************************************************
-}
-
-{$i ostypes.inc}
-
-{$ifdef FPC_USE_LIBC}
-  {$Linklib c}
-  // Out of date atm.
-
-{$ifdef FPC_IS_SYSTEM}
-{$i oscdeclh.inc}
-{$endif}
-{$I bunxmacr.inc}
-
-{
-  $Log$
-  Revision 1.1  2005-02-10 17:30:54  peter
-    * renamed to solaris
-
-  Revision 1.1  2005/02/07 22:17:26  peter
-    * updated for 1.9.x unix rtl
-
-}
-
-

+ 140 - 82
rtl/solaris/ostypes.inc

@@ -1,56 +1,144 @@
 {
     $Id$
-    Copyright (c) 2000-2002 by Marco van de Voort
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
 
-    Some non POSIX BSD types used internally in the system unit.
+    Types and structures for the BaseUnix unit.
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ***********************************************************************}
 
- ****************************************************************************
-}
+{***********************************************************************}
+{                         Base Unix Structures				}
+{***********************************************************************}
+
+{$IFDEF FPC_IS_SYSTEM}
+  {$i ptypes.inc}
+{$ENDIF}
 
-(*
-Type
-  timezone = packed record
-    tz_minuteswest,
-    tz_dsttime  : cint;
-  end;
-  ptimezone =^timezone;
-  TTimeZone = timezone;
-  rusage = packed record
-        ru_utime    : timeval;          { user time used }
-        ru_stime    : timeval;          { system time used }
-        ru_maxrss   : clong;            { max resident set size }
-        ru_ixrss    : clong;            { integral shared memory size }
-        ru_idrss    : clong;            { integral unshared data " }
-        ru_isrss    : clong;            { integral unshared stack " }
-        ru_minflt   : clong;            { page reclaims }
-        ru_majflt   : clong;            { page faults }
-        ru_nswap    : clong;            { swaps }
-        ru_inblock  : clong;            { block input operations }
-        ru_oublock  : clong;            { block output operations }
-        ru_msgsnd   : clong;            { messages sent }
-        ru_msgrcv   : clong;            { messages received }
-        ru_nsignals : clong;            { signals received }
-        ru_nvcsw    : clong;            { voluntary context switches }
-        ru_nivcsw   : clong;            { involuntary " }
-        end;
-// #define      ru_last         ru_nivcsw
-// #define      ru_first        ru_ixrss
-{ auto generated by a c prog, statmacr.c}
-*)
+CONST
+   FD_MAXFDSET     = 1024;
+   BITSINWORD      = 8*sizeof(longint);
+   wordsinsigset   = SIG_MAXSIG DIV BITSINWORD;         // words in sigset_t
+   wordsinfdset    = FD_MAXFDSET DIV BITSINWORD;        // words in fdset_t
+   ln2bitsinword   = 5;         { 32bit : ln(32)/ln(2)=5 }
+   ln2bitmask      = 1 shl ln2bitsinword - 1;
+   
+    UTSNAME_LENGTH = 256;   { 256 + 1 in pchar format }
+    UTSNAME_NODENAME_LENGTH = 256;
+
+    ST_FSTYPSZ = 16;           {* array size for file system type name *}
+
+TYPE
+    blksize_t = longint;
+    blkcnt_t = longint;
+    
+   { file characteristics services }
+   stat = packed record { verify the alignment of the members }
+     st_dev : dev_t;
+     st_pad1 : array[1..3] of longint;  { reserve for dev expansion }
+     st_ino : ino_t;
+     st_mode : mode_t;
+     st_nlink : nlink_t;
+     st_uid : uid_t;
+     st_gid : gid_t;
+     st_rdev : dev_t;
+     st_pad2 : array[1..2] of longint;
+     st_size : off_t;
+     st_pad3 : longint;   {* reserve pad for future off_t expansion *}
+     st_atime : time_t;
+     st_atimens : longint;    { access time nanosecond field         }
+     st_mtime : time_t;
+     st_mtimens : longint;    { modification time nanosecond field   }
+     st_ctime : time_t;
+     st_ctimens : longint;    { modification time nanosecond field   }
+     st_blksize : blksize_t;
+     st_blocks : blkcnt_t;
+     st_fstype : array[0..ST_FSTYPSZ-1] of char;
+     st_pad4 : array[1..8] of longint;
+   end;
+   TStat	     = Stat;
+   PStat	     = ^Stat;
+
+
+   { system information services }
+   utsname = packed record   { don't forget to verify the alignment }
+     sysname : array[0..UTSNAME_LENGTH] of char;
+     nodename : array[0..UTSNAME_LENGTH] of char;
+     release : array[0..UTSNAME_LENGTH] of char;
+     version : array[0..UTSNAME_LENGTH] of char;
+     machine : array[0..UTSNAME_LENGTH] of char;
+   end;
+
+
+   { directory services }
+   pdirent = ^dirent;
+   dirent = packed record    { directory entry record - verify alignment }
+     d_ino : ino_t;                  {* "inode number" of entry *}
+     d_off : off_t;                  {* offset of disk directory entry *}
+     d_reclen : word;                {* length of this record *}
+     d_name : array[0..255] of char; { name of file            }
+   end;
+
+
+   pdir = ^dir;
+   dir = packed record
+    d_fd : cint;               {* file descriptor *}
+    d_loc : cint;              {* offset in block *}
+    d_size : cint;             {* amount of valid data *}
+    d_buf : pchar;             { directory block   }
+   end;
+
+
+
+{***********************************************************************}
+{                  POSIX CONSTANT ROUTINE DEFINITIONS                   }
+{***********************************************************************}
+CONST
+    { access routine - these maybe OR'ed together }
+    F_OK        = 0;   { test for existence of file }
+    R_OK        = 4;   { test for read permission on file }
+    W_OK        = 2;   { test for write permission on file }
+    X_OK        = 1;   { test for execute or search permission }
+    { seek routine }
+    SEEK_SET    = 0;    { seek from beginning of file }
+    SEEK_CUR    = 1;    { seek from current position  }
+    SEEK_END    = 2;    { seek from end of file       }
+    { open routine                                 }
+    { File access modes for `open' and `fcntl'.    }
+    O_RDONLY    = 0;	{ Open read-only.  }
+    O_WRONLY    = 1;	{ Open write-only. }
+    O_RDWR      = 2;	{ Open read/write. }
+    { Bits OR'd into the second argument to open.  }
+    O_CREAT     = $100; { Create file if it doesn't exist.  }
+    O_EXCL      = $400;	{ Fail if file already ??????.      }
+    O_TRUNC     = $200;	{ Truncate file to zero length.     }
+    O_NOCTTY    = $800;	{ Don't assign a controlling terminal. }
+    { File status flags for `open' and `fcntl'.  }
+    O_APPEND    =  $08;	{ Writes append to the file.        }
+    O_NONBLOCK	=  $80;	{ Non-blocking I/O.                 }
+
+
+    { mode_t possible values                                 }
+    S_IRUSR = $100;           { Read permission for owner   }
+    S_IWUSR = $080;           { Write permission for owner  }
+    S_IXUSR = $040;           { Exec  permission for owner  }
+    S_IRGRP = $020;           { Read permission for group   }
+    S_IWGRP = $010;           { Write permission for group  }
+    S_IXGRP = $008;           { Exec permission for group   }
+    S_IROTH = $004;           { Read permission for world   }
+    S_IWOTH = $002;           { Write permission for world  }
+    S_IXOTH = $001;           { Exec permission for world   }
+
+    { Used for waitpid }
+    WNOHANG   = $40;            { don't block waiting               }
+    WUNTRACED = $04;            { report status of stopped children }
 
 Const
   S_IFMT  = 61440;
@@ -71,47 +159,17 @@ CONST
 
 
 
-{
- $Log$
- Revision 1.1  2005-02-10 17:30:54  peter
-   * renamed to solaris
-
- Revision 1.1  2005/02/07 22:17:26  peter
-   * updated for 1.9.x unix rtl
-
- Revision 1.7  2005/02/06 12:16:52  peter
-   * bsd thread updates
-
- Revision 1.6  2004/12/02 11:22:11  marco
-  * tz_ prefixed for timezone
+{$i signal.inc}
 
- Revision 1.5  2003/09/27 13:45:58  peter
-   * fpnanosleep exported in baseunix
-   * fpnanosleep has pointer arguments to be C compliant
 
- Revision 1.4  2003/09/17 11:52:05  marco
-  * stat macro fixes voor BSD
-
- Revision 1.3  2003/09/15 07:23:51  marco
-  * fix
-
- Revision 1.2  2003/09/14 20:15:01  marco
-  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
-
- Revision 1.1  2003/01/05 19:01:28  marco
-  * FreeBSD compiles now with baseunix mods.
-
- Revision 1.4  2002/10/27 17:21:29  marco
-  * Only "difficult" functions + execvp + termios + rewinddir left to do
-
- Revision 1.3  2002/10/27 11:58:30  marco
-  * Modifications from Saturday.
-
- Revision 1.2  2002/09/07 16:01:17  peter
-   * old logs removed and tabs fixed
-
- Revision 1.1  2002/08/19 12:29:11  marco
-  * First working POSIX *BSD system unit.
+{
+  $Log$
+  Revision 1.2  2005-02-13 22:13:20  peter
+    * get solaris back in shape
 
+  Revision 1.1  2005/02/10 17:30:54  peter
+    * renamed to solaris
 
+  Revision 1.1  2004/11/06 22:22:28  florian
+    * some sunos stuff from 1.0.x merged
 }

+ 71 - 15
rtl/solaris/signal.inc

@@ -15,20 +15,6 @@
 
  **********************************************************************}
 
-   { requires osposixh types first }
-type
-   sigset_t = array[0..3] of cardinal; { used for additional signal   }
-
-   sighandler_t = procedure (signo: cint); cdecl;
-
-   { signal services }
-   sigactionrec = packed record
-     sa_flags : cint;
-     sa_handler : sighandler_t;   { this is overlapped with sa_sigaction field on solaris }
-     sa_mask : sigset_t;
-     sa_resv : array[1..2] of cint;  { for non-_LP64 platforms only                       }
-   end;
-
 const
     {************************ signals *****************************}
     { more can be provided. Herein are only included the required  }
@@ -78,9 +64,79 @@ const
     SIGCANCEL  = 36;	{ thread cancellation signal used by libthread }
     SIGLOST    = 37;	{ resource lost (eg, record-lock lost) }
 
+const
+  SI_PAD_SIZE   = ((128 div sizeof(longint)) - 3);
+
+type
+  SigSet  =  array[0..wordsinsigset-1] of cint;
+  sigset_t= SigSet;
+  PSigSet = ^SigSet;
+  psigset_t=psigset;
+  TSigSet = SigSet;
+
+  psiginfo = ^tsiginfo;
+  tsiginfo = record
+       si_signo : longint;
+       si_errno : longint;
+       si_code : longint;
+       _sifields : record
+           case longint of
+              0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
+              1 : ( _kill : record
+                   _pid : pid_t;
+                   _uid : uid_t;
+                end );
+              2 : ( _timer : record
+                   _timer1 : dword;
+                   _timer2 : dword;
+                end );
+              3 : ( _rt : record
+                   _pid : pid_t;
+                   _uid : uid_t;
+                   _sigval : pointer;
+                end );
+              4 : ( _sigchld : record
+                   _pid : pid_t;
+                   _uid : uid_t;
+                   _status : longint;
+                   _utime : clock_t;
+                   _stime : clock_t;
+                end );
+              5 : ( _sigfault : record
+                   _addr : pointer;
+                end );
+              6 : ( _sigpoll : record
+                   _band : longint;
+                   _fd : longint;
+                end );
+           end;
+    end;
+
+{ CPU dependent TSigContext }
+{$i sighndh.inc}
+
+type
+  SignalHandler   = Procedure(Sig : Longint);cdecl;
+  PSignalHandler  = ^SignalHandler;
+  SignalRestorer  = Procedure;cdecl;
+  PSignalRestorer = ^SignalRestorer;
+  SigActionHandler = procedure(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
+
+  SigActionRec = packed record  // this is temporary for the migration
+    Sa_Flags    : cuint;
+    sa_handler  : SigActionHandler;
+    Sa_Mask     : SigSet;
+    sa_resv : array[1..2] of cint;  { for non-_LP64 platforms only                       }
+  end;
+  TSigActionRec = SigActionRec;
+  PSigActionRec = ^SigActionRec;
+
 {
   $Log$
-  Revision 1.2  2005-02-10 17:30:54  peter
+  Revision 1.3  2005-02-13 22:13:20  peter
+    * get solaris back in shape
+
+  Revision 1.2  2005/02/10 17:30:54  peter
     * renamed to solaris
 
   Revision 1.2  2004/11/06 22:22:28  florian

+ 116 - 0
rtl/solaris/sparc/sighnd.inc

@@ -0,0 +1,116 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    Signal handler is arch dependant due to processor to language
+    exception conversion.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+const
+  FPE_INTDIV = 1;
+  FPE_INTOVF = 2;
+  FPE_FLTDIV = 3;
+  FPE_FLTOVF = 4;
+  FPE_FLTUND = 5;
+  FPE_FLTRES = 6;
+  FPE_FLTINV = 7;
+  FPE_FLTSUB = 8;
+
+
+procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
+var
+  res : word;
+  addr : pointer;
+begin
+  res:=0;
+  addr:=nil;
+  case sig of
+    SIGFPE :
+        begin
+          addr := siginfo^._sifields._sigfault._addr;
+          res := 207;
+          case  siginfo^.si_code of
+            FPE_INTDIV:
+              res:=200;
+            FPE_INTOVF:
+              res:=205;
+            FPE_FLTDIV:
+              res:=200;
+            FPE_FLTOVF:
+              res:=205;
+            FPE_FLTUND:
+              res:=206;
+            FPE_FLTRES,
+            FPE_FLTINV,
+            FPE_FLTSUB:
+              res:=216;
+            else
+              res:=207;
+          end;
+        end;
+    SIGILL,
+    SIGBUS,
+    SIGSEGV :
+        begin
+          addr := siginfo^._sifields._sigfault._addr;
+          res:=216;
+        end;
+  end;
+  { give runtime error at the position where the signal was raised }
+  if res<>0 then
+    HandleErrorAddrFrame(res,addr,nil);
+end;
+
+{
+  $Log$
+  Revision 1.1  2005-02-13 22:13:20  peter
+    * get solaris back in shape
+
+  Revision 1.8  2005/02/05 23:46:12  peter
+    * set addr:=nil for other signals
+
+  Revision 1.7  2005/02/05 23:45:38  peter
+    * sigcontext is invalid, use siginfo only
+
+  Revision 1.6  2005/01/30 18:01:15  peter
+    * signal cleanup for linux
+    * sigactionhandler instead of tsigaction for bsds
+    * sigcontext moved to cpu dir
+
+  Revision 1.5  2004/11/06 22:48:16  florian
+    * fixed errno setting in mt sparc/linux mt programs
+
+  Revision 1.4  2004/08/04 19:27:10  florian
+    * fixed floating point and integer exception handling on sparc/linux
+
+  Revision 1.3  2004/05/31 20:25:04  peter
+    * removed warnings
+
+  Revision 1.2  2003/11/06 16:28:52  peter
+    * compile fix
+
+  Revision 1.1  2003/11/06 16:22:01  peter
+    * sparc
+
+  Revision 1.1  2003/11/02 14:53:06  jonas
+    + sighand and associated record definitions for ppc. Untested.
+
+  Revision 1.2  2003/11/01 01:58:11  marco
+   * more small fixes.
+
+  Revision 1.1  2003/11/01 01:27:20  marco
+   * initial version from 1.0.x branch
+
+
+}
+

+ 36 - 0
rtl/solaris/sparc/sighndh.inc

@@ -0,0 +1,36 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Jonas Maebe,
+    member of the Free Pascal development team.
+
+    Sigcontext and Sigaction
+    
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{$packrecords C}
+
+type
+  PSigContext = ^TSigContext;
+  TSigContext = record
+  end;
+  
+{
+  $Log$
+  Revision 1.1  2005-02-13 22:13:20  peter
+    * get solaris back in shape
+
+  Revision 1.1  2005/01/30 18:01:15  peter
+    * signal cleanup for linux
+    * sigactionhandler instead of tsigaction for bsds
+    * sigcontext moved to cpu dir
+
+}
+

+ 56 - 8
rtl/solaris/sysos.inc

@@ -37,18 +37,63 @@ end;
 { OS dependant parts  }
 
 {$I errno.inc}                          // error numbers
-{$I bunxtype.inc}                       // c-types, unix base types, unix
-                                        //    base structures
+{$I ostypes.inc}                        // c-types, unix base types, unix base structures
+{$I osmacro.inc}
+
+{$Linklib c}
+{$i oscdeclh.inc}
 
 {*****************************************************************************
-                 Extra cdecl declarations for FPC_USE_LIBC for this os
+                            Error conversion
 *****************************************************************************}
 
-Function fpReadLink(name,linkname:pchar;maxlen:cint):cint;  cdecl; external name 'readlink';
-function fpgetcwd(buf:pchar;_size:size_t):pchar; cdecl; external name 'getcwd';
+Function PosixToRunError  (PosixErrno : longint) : longint;
+{
+  Convert ErrNo error to the correct Inoutres value
+}
+
+begin
+  if PosixErrNo=0 then { Else it will go through all the cases }
+   exit(0);
+  case PosixErrNo of
+   ESysENFILE,
+   ESysEMFILE : Inoutres:=4;
+   ESysENOENT : Inoutres:=2;
+    ESysEBADF : Inoutres:=6;
+   ESysENOMEM,
+   ESysEFAULT : Inoutres:=217;
+   ESysEINVAL : Inoutres:=218;
+    ESysEPIPE,
+    ESysEINTR,
+      ESysEIO,
+   ESysEAGAIN,
+   ESysENOSPC : Inoutres:=101;
+ ESysENAMETOOLONG : Inoutres := 3;
+    ESysEROFS,
+   ESysEEXIST,
+   ESysENOTEMPTY,
+   ESysEACCES : Inoutres:=5;
+   ESysEISDIR : InOutRes:=5;
+  else
+    begin
+       InOutRes := Integer(PosixErrno);
+    end;
+  end;
+ PosixToRunError:=InOutRes;
+end;
 
-{$I ossysc.inc}                         // base syscalls
-{$I osmain.inc}                         // base wrappers *nix RTL (derivatives)
+Function Errno2InoutRes : longint;
+
+begin
+  Errno2InoutRes:=PosixToRunError(getErrno);
+  InoutRes:=Errno2InoutRes;
+end;
+
+
+
+{*****************************************************************************
+                          Low Level File Routines
+*****************************************************************************}
 
 function do_isdevice(handle:longint):boolean;
 begin
@@ -59,7 +104,10 @@ end;
 
 {
    $Log$
-   Revision 1.1  2005-02-10 17:30:54  peter
+   Revision 1.2  2005-02-13 22:13:20  peter
+     * get solaris back in shape
+
+   Revision 1.1  2005/02/10 17:30:54  peter
      * renamed to solaris
 
    Revision 1.1  2005/02/07 22:17:26  peter

+ 160 - 1
rtl/solaris/system.pp

@@ -29,6 +29,162 @@ implementation
 
 {$I system.inc}
 
+{*****************************************************************************
+                       Misc. System Dependent Functions
+*****************************************************************************}
+
+procedure System_exit;
+begin
+   Fpexit(cint(ExitCode));
+End;
+
+
+Function ParamCount: Longint;
+Begin
+  Paramcount:=argc-1
+End;
+
+
+function BackPos(c:char; const s: shortstring): integer;
+var
+ i: integer;
+Begin
+  for i:=length(s) downto 0 do
+    if s[i] = c then break;
+  if i=0 then
+    BackPos := 0
+  else
+    BackPos := i;
+end;
+
+
+ { variable where full path and filename and executable is stored }
+ { is setup by the startup of the system unit.                    }
+var
+ execpathstr : shortstring;
+
+function paramstr(l: longint) : string;
+ var
+  s: string;
+  s1: string;
+ begin
+   { stricly conforming POSIX applications  }
+   { have the executing filename as argv[0] }
+//   if l=0 then
+//     begin
+//       paramstr := execpathstr;
+//     end
+//   else
+     paramstr:=strpas(argv[l]);
+ end;
+
+Procedure Randomize;
+Begin
+  randseed:=longint(Fptime(nil));
+End;
+
+
+{*****************************************************************************
+                         SystemUnit Initialization
+*****************************************************************************}
+
+function  reenable_signal(sig : longint) : boolean;
+var
+  e,oe : TSigSet;
+  i,j : byte;
+begin
+  fillchar(e,sizeof(e),#0);
+  fillchar(oe,sizeof(oe),#0);
+  { set is 1 based PM }
+  dec(sig);
+  i:=sig mod 32;
+  j:=sig div 32;
+  e[j]:=1 shl i;
+  fpsigprocmask(SIG_UNBLOCK,@e,@oe);
+  reenable_signal:=geterrno=0;
+end;
+
+{$i sighnd.inc}
+
+var
+  act: SigActionRec;
+
+Procedure InstallSignals;
+var
+  oldact: SigActionRec;
+begin
+  { Initialize the sigaction structure }
+  { all flags and information set to zero }
+  FillChar(act, sizeof(SigActionRec),0);
+  { initialize handler                    }
+  act.sa_handler :=@SignalToRunError;
+{$warning TODO SIGINFO}  
+  act.sa_flags:=SA_SIGINFO;
+  FpSigAction(SIGFPE,act,oldact);
+  FpSigAction(SIGSEGV,act,oldact);
+  FpSigAction(SIGBUS,act,oldact);
+  FpSigAction(SIGILL,act,oldact);
+end;
+
+
+procedure SetupCmdLine;
+var
+  bufsize,
+  len,j,
+  size,i : longint;
+  found  : boolean;
+  buf    : pchar;
+
+  procedure AddBuf;
+  begin
+    reallocmem(cmdline,size+bufsize);
+    move(buf^,cmdline[size],bufsize);
+    inc(size,bufsize);
+    bufsize:=0;
+  end;
+
+begin
+  GetMem(buf,ARG_MAX);
+  size:=0;
+  bufsize:=0;
+  i:=0;
+  while (i<argc) do
+   begin
+     len:=strlen(argv[i]);
+     if len>ARG_MAX-2 then
+      len:=ARG_MAX-2;
+     found:=false;
+     for j:=1 to len do
+      if argv[i][j]=' ' then
+       begin
+         found:=true;
+         break;
+       end;
+     if bufsize+len>=ARG_MAX-2 then
+      AddBuf;
+     if found then
+      begin
+        buf[bufsize]:='"';
+        inc(bufsize);
+      end;
+     move(argv[i]^,buf[bufsize],len);
+     inc(bufsize,len);
+     if found then
+      begin
+        buf[bufsize]:='"';
+        inc(bufsize);
+      end;
+     if i<argc then
+      buf[bufsize]:=' '
+     else
+      buf[bufsize]:=#0;
+     inc(bufsize);
+     inc(i);
+   end;
+  AddBuf;
+  FreeMem(buf,ARG_MAX);
+end;
+
 
 procedure SysInitStdIO;
 begin
@@ -86,7 +242,10 @@ End.
 
 {
  $Log$
- Revision 1.3  2005-02-13 21:47:56  peter
+ Revision 1.4  2005-02-13 22:13:20  peter
+   * get solaris back in shape
+
+ Revision 1.3  2005/02/13 21:47:56  peter
    * include file cleanup part 2
 
  Revision 1.2  2005/02/10 17:30:54  peter