Jelajahi Sumber

* solaris updates

peter 20 tahun lalu
induk
melakukan
f4011dabba
7 mengubah file dengan 310 tambahan dan 92 penghapusan
  1. 6 6
      rtl/Makefile
  2. 47 15
      rtl/solaris/ostypes.inc
  3. 82 54
      rtl/solaris/signal.inc
  4. 148 0
      rtl/solaris/sparc/start.inc
  5. 11 15
      rtl/solaris/system.pp
  6. 10 1
      rtl/sparc/math.inc
  7. 6 1
      rtl/unix/sysunixh.inc

+ 6 - 6
rtl/Makefile

@@ -1,10 +1,10 @@
 #
-# Don't edit, this file is generated by FPCMake Version 1.9.8 [2005/01/31]
+# Don't edit, this file is generated by FPCMake Version 1.9.8 [2005/02/14]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-sunos i386-qnx i386-netware i386-openbsd i386-wdosx i386-emx i386-watcom i386-netwlibc m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-sunos x86_64-linux x86_64-freebsd arm-linux
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-emx i386-watcom i386-netwlibc m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd arm-linux
 BSDs = freebsd netbsd openbsd darwin
-UNIXs = linux $(BSDs) sunos qnx
+UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
 FORCE:
 .PHONY: FORCE
@@ -590,7 +590,7 @@ BATCHEXT=.sh
 EXEEXT=
 SHORTSUFFIX=be
 endif
-ifeq ($(OS_TARGET),sunos)
+ifeq ($(OS_TARGET),solaris)
 BATCHEXT=.sh
 EXEEXT=
 SHORTSUFFIX=sun
@@ -716,7 +716,7 @@ STATICLIBEXT=.a
 EXEEXT=
 SHORTSUFFIX=be
 endif
-ifeq ($(OS_TARGET),sunos)
+ifeq ($(OS_TARGET),solaris)
 BATCHEXT=.sh
 PPUEXT=.ppu
 ASMEXT=.s
@@ -1028,7 +1028,7 @@ export UPXPROG
 ZIPOPT=-9
 ZIPEXT=.zip
 ifeq ($(USETAR),bz2)
-TAROPT=vI
+TAROPT=vj
 TAREXT=.tar.bz2
 else
 TAROPT=vz

+ 47 - 15
rtl/solaris/ostypes.inc

@@ -15,7 +15,7 @@
  ***********************************************************************}
 
 {***********************************************************************}
-{                         Base Unix Structures				}
+{                         Base Unix Structures                          }
 {***********************************************************************}
 
 {$IFDEF FPC_IS_SYSTEM}
@@ -29,7 +29,7 @@ CONST
    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;
 
@@ -38,7 +38,7 @@ CONST
 TYPE
     blksize_t = longint;
     blkcnt_t = longint;
-    
+
    { file characteristics services }
    stat = packed record { verify the alignment of the members }
      st_dev : dev_t;
@@ -63,9 +63,32 @@ TYPE
      st_fstype : array[0..ST_FSTYPSZ-1] of char;
      st_pad4 : array[1..8] of longint;
    end;
-   TStat	     = Stat;
-   PStat	     = ^Stat;
-
+   TStat             = Stat;
+   PStat             = ^Stat;
+
+   flock    = record
+                {$ifdef 64bitfs}
+                l_start : off64_t;      { starting offset }
+                l_len   : off64_t;      { len = 0 means until end of file }
+                {$else}
+                l_start : off_t;        { starting offset }
+                l_len   : off_t;        { len = 0 means until end of file }
+                {$endif}
+                l_pid   : pid_t;        { lock owner }
+                l_type  : cshort;       { lock type: read/write, etc. }
+                l_whence: cshort;       { type of l_start }
+                end;
+   TFlock   = flock;
+   pFlock   = ^flock;
+
+   TFDSet    = array[0..(FD_MAXFDSET div 32)-1] of Cardinal;
+   pFDSet    = ^TFDSet;
+
+   timezone = packed record
+     tz_minuteswest,tz_dsttime:cint;
+   end;
+   ptimezone =^timezone;
+   TTimeZone = timezone;
 
    { system information services }
    utsname = packed record   { don't forget to verify the alignment }
@@ -76,6 +99,12 @@ TYPE
      machine : array[0..UTSNAME_LENGTH] of char;
    end;
 
+   UTimBuf   = Record
+                 actime  : time_t;
+                 modtime : time_t;
+                end;
+   TUtimBuf  = UtimBuf;
+   pUtimBuf  = ^UtimBuf;
 
    { directory services }
    pdirent = ^dirent;
@@ -112,17 +141,17 @@ CONST
     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. }
+    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. }
+    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.                 }
+    O_APPEND    =  $08; { Writes append to the file.        }
+    O_NONBLOCK  =  $80; { Non-blocking I/O.                 }
 
 
     { mode_t possible values                                 }
@@ -164,7 +193,10 @@ CONST
 
 {
   $Log$
-  Revision 1.2  2005-02-13 22:13:20  peter
+  Revision 1.3  2005-02-14 16:32:41  peter
+    * solaris updates
+
+  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

+ 82 - 54
rtl/solaris/signal.inc

@@ -16,56 +16,76 @@
  **********************************************************************}
 
 const
-    {************************ signals *****************************}
-    { more can be provided. Herein are only included the required  }
-    { values.                                                      }
-    {**************************************************************}
-    SIGABRT    =  6;     { abnormal termination           }
-    SIGALRM    = 14;     { alarm clock (used with alarm() }
-    SIGFPE     =  8;     { illegal arithmetic operation   }
-    SIGHUP     =  1;     { Hangup                         }
-    SIGILL     =  4;     { Illegal instruction            }
-    SIGINT     =  2;     { Interactive attention signal   }
-    SIGKILL    =  9;     { Kill, cannot be caught         }
-    SIGPIPE    = 13;     { Broken pipe signal             }
-    SIGQUIT    =  3;     { Interactive termination signal }
-    SIGSEGV    = 11;     { Detection of invalid memory reference }
-    SIGTERM    = 15;     { Termination request           }
-    SIGUSR1    = 16;     { Application defined signal 1  }
-    SIGUSR2    = 17;     { Application defined signal 2  }
-    SIGCHLD    = 18;     { Child process terminated / stopped }
-    SIGCONT    = 25;     { Continue if stopped               }
-    SIGSTOP    = 23;     { Stop signal. cannot be cuaght     }
-    SIGSTP     = 24;     { Interactive stop signal           }
-    SIGTTIN    = 26;     { Background read from TTY          }
-    SIGTTOU    = 27;     { Background write to TTY           }
-    SIGBUS     = 10;     { Access to undefined memory        }
-
-    { Solaris specific signals                               }
-
-    SIGTRAP    =  5;	{ trace trap (not reset when caught) }
-    SIGIOT     =  6;	{ IOT instruction }
-    SIGEMT     =  7;	{ EMT instruction }
-    SIGSYS     = 12;	{ bad argument to system call }
-    SIGCLD     = 18;	{ child status change }
-    SIGPWR     = 19;	{ power-fail restart }
-    SIGWINCH   = 20;	{ window size change }
-    SIGURG     = 21;	{ urgent socket condition }
-    SIGPOLL    = 22;	{ pollable event occured }
-    SIGIO      = SIGPOLL;{ socket I/O possible (SIGPOLL alias) }
-    SIGVTALRM  = 28;	{ virtual timer expired }
-    SIGPROF    = 29;	{ profiling timer expired }
-    SIGXCPU    = 30;	{ exceeded cpu limit }
-    SIGXFSZ    = 31;	{ exceeded file size limit }
-    SIGWAITING = 32;	{ process's lwps are blocked }
-    SIGLWP     = 33;	{ special signal used by thread library }
-    SIGFREEZE  = 34;	{ special signal used by CPR }
-    SIGTHAW    = 35;	{ special signal used by CPR }
-    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);
+  {************************ signals *****************************}
+  { more can be provided. Herein are only included the required  }
+  { values.                                                      }
+  {**************************************************************}
+  SIGABRT    =  6;     { abnormal termination           }
+  SIGALRM    = 14;     { alarm clock (used with alarm() }
+  SIGFPE     =  8;     { illegal arithmetic operation   }
+  SIGHUP     =  1;     { Hangup                         }
+  SIGILL     =  4;     { Illegal instruction            }
+  SIGINT     =  2;     { Interactive attention signal   }
+  SIGKILL    =  9;     { Kill, cannot be caught         }
+  SIGPIPE    = 13;     { Broken pipe signal             }
+  SIGQUIT    =  3;     { Interactive termination signal }
+  SIGSEGV    = 11;     { Detection of invalid memory reference }
+  SIGTERM    = 15;     { Termination request           }
+  SIGUSR1    = 16;     { Application defined signal 1  }
+  SIGUSR2    = 17;     { Application defined signal 2  }
+  SIGCHLD    = 18;     { Child process terminated / stopped }
+  SIGCONT    = 25;     { Continue if stopped               }
+  SIGSTOP    = 23;     { Stop signal. cannot be cuaght     }
+  SIGSTP     = 24;     { Interactive stop signal           }
+  SIGTTIN    = 26;     { Background read from TTY          }
+  SIGTTOU    = 27;     { Background write to TTY           }
+  SIGBUS     = 10;     { Access to undefined memory        }
+
+  { Solaris specific signals                               }
+
+  SIGTRAP    =  5;      { trace trap (not reset when caught) }
+  SIGIOT     =  6;      { IOT instruction }
+  SIGEMT     =  7;      { EMT instruction }
+  SIGSYS     = 12;      { bad argument to system call }
+  SIGCLD     = 18;      { child status change }
+  SIGPWR     = 19;      { power-fail restart }
+  SIGWINCH   = 20;      { window size change }
+  SIGURG     = 21;      { urgent socket condition }
+  SIGPOLL    = 22;      { pollable event occured }
+  SIGIO      = SIGPOLL;{ socket I/O possible (SIGPOLL alias) }
+  SIGVTALRM  = 28;      { virtual timer expired }
+  SIGPROF    = 29;      { profiling timer expired }
+  SIGXCPU    = 30;      { exceeded cpu limit }
+  SIGXFSZ    = 31;      { exceeded file size limit }
+  SIGWAITING = 32;      { process's lwps are blocked }
+  SIGLWP     = 33;      { special signal used by thread library }
+  SIGFREEZE  = 34;      { special signal used by CPR }
+  SIGTHAW    = 35;      { special signal used by CPR }
+  SIGCANCEL  = 36;      { thread cancellation signal used by libthread }
+  SIGLOST    = 37;      { resource lost (eg, record-lock lost) }
+
+  SIG_BLOCK   = 0;
+  SIG_UNBLOCK = 1;
+  SIG_SETMASK = 2;
+
+  SIG_DFL = 0 ;
+  SIG_IGN = 1 ;
+  SIG_ERR = -1 ;
+
+  { definitions for the sa_flags field }
+  SA_ONSTACK   = $00000001;
+  SA_RESETHAND = $00000002;
+  SA_RESTART   = $00000004;
+  SA_SIGINFO   = $00000008;
+  SA_NODEFER   = $00000010;
+  SA_NOCLDWAIT = $00010000;
+  SA_WAITSIG   = $00010000;
+
+{$ifdef cpu64}
+  SI_PAD_SIZE   = ((256 div sizeof(cint)) - 4);
+{$else}
+  SI_PAD_SIZE   = ((128 div sizeof(cint)) - 3);
+{$endif}
 
 type
   SigSet  =  array[0..wordsinsigset-1] of cint;
@@ -76,9 +96,12 @@ type
 
   psiginfo = ^tsiginfo;
   tsiginfo = record
-       si_signo : longint;
-       si_errno : longint;
-       si_code : longint;
+       si_signo : cint;
+       si_errno : cint;
+       si_code  : cint;
+{$ifdef cpu64}
+       si_pad   : cint;
+{$endif cpu64}
        _sifields : record
            case longint of
               0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
@@ -104,6 +127,8 @@ type
                 end );
               5 : ( _sigfault : record
                    _addr : pointer;
+                   _trapno : cint;
+                   _pc    : pointer;
                 end );
               6 : ( _sigpoll : record
                    _band : longint;
@@ -133,7 +158,10 @@ type
 
 {
   $Log$
-  Revision 1.3  2005-02-13 22:13:20  peter
+  Revision 1.4  2005-02-14 16:32:41  peter
+    * solaris updates
+
+  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

+ 148 - 0
rtl/solaris/sparc/start.inc

@@ -0,0 +1,148 @@
+{
+    $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.
+
+    Program startup
+
+    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.
+
+ **********************************************************************}
+
+type
+   TCdeclProcedure = procedure; cdecl;
+function atexit(proc:TCdeclProcedure):longint;cdecl;external 'c' name 'atexit';
+procedure _cleanup;cdecl;external 'c' name '_cleanup';
+procedure _DYNAMIC;cdecl;external 'c' name '_DYNAMIC';
+procedure __fpstart;cdecl;external 'c' name '__fpstart';
+procedure PascalMain;cdecl;external name 'PASCALMAIN';
+
+procedure _start;assembler;nostackframe;public name '_start';
+asm
+        // Terminate the stack frame, and reserve space for functions to
+        //   drop their arguments.
+        mov     %g0, %fp
+        sub     %sp, 6*4, %sp
+
+        // Extract the arguments and environment as encoded on the stack.  The
+        //   argument info starts after one register window (16 words) past the SP.
+        ld      [%sp+22*4], %o2
+        sethi   %hi(argc),%o1
+        or      %o1,%lo(argc),%o1
+        st      %o2, [%o1]
+
+        add     %sp, 23*4, %o0
+        sethi   %hi(argv),%o1
+        or      %o1,%lo(argv),%o1
+        st      %o0, [%o1]
+
+        // envp=(argc+1)*4+argv
+        inc     %o2
+        sll     %o2, 2, %o2
+        add     %o2, %o0, %o2
+        sethi   %hi(envp),%o1
+        or      %o1,%lo(envp),%o1
+        st      %o2, [%o1]
+
+        // Check to see if there is an _cleanup() function linked in, and if
+        // so, register it with atexit() as the last thing to be run by
+        // atexit().
+        sethi   %hi(_cleanup), %o0
+        or      %o0, %lo(_cleanup), %o0
+        cmp     %o0,%g0
+        be      .L1
+        nop
+        call    atexit
+        nop
+.L1:
+
+        // Now check to see if we have an _DYNAMIC table, and if so then
+        // we need to register the function pointer previously in %edx, but
+        // now conveniently saved on the stack as the argument to pass to
+        // atexit().
+        sethi   %hi(_DYNAMIC), %o0
+        or      %o0, %lo(_DYNAMIC), %o0
+        cmp     %o0,%g0
+        be      .L2
+        nop
+        call    atexit
+        nop
+.L2:
+
+        // Register _fini() with atexit().  We will take care of calling _init()
+        // directly.
+        //
+        //      sethi   %hi(_fini), %o0
+        //      or      %o0, %lo(_fini), %o0
+        //      call    atexit
+
+        // Call _init(argc, argv, environ), _fpstart(argc, argv, environ), and
+        // main(argc, argv, environ).
+        ld      [%sp+22*4], %o0
+        add     %sp, 23*4, %o1
+        add     %o0, 1, %o2
+        sll     %o2, 2, %o2
+        add     %o2, %o1, %o2
+
+        call    __fpstart
+        nop
+
+        call    PASCALMAIN
+        nop
+
+        // Die very horribly if exit returns
+        unimp
+end;
+
+{
+  $Log$
+  Revision 1.1  2005-02-14 16:32:41  peter
+    * solaris updates
+
+  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
+
+
+}
+

+ 11 - 15
rtl/solaris/system.pp

@@ -23,6 +23,11 @@ interface
 
 {$I sysunixh.inc}
 
+var argc:longint;
+    argv:PPchar;
+    envp:PPchar;
+
+
 implementation
 
 { OS independant parts}
@@ -33,6 +38,8 @@ implementation
                        Misc. System Dependent Functions
 *****************************************************************************}
 
+{$i start.inc}
+
 procedure System_exit;
 begin
    Fpexit(cint(ExitCode));
@@ -118,7 +125,6 @@ begin
   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);
@@ -202,19 +208,6 @@ begin
 end;
 
 
-procedure pascalmain; external name 'PASCALMAIN';
-
-{ Main entry point in C style, needed to capture program parameters. }
-procedure main(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
-
-begin
-  argc:= argcparam;
-  argv:= argvparam;
-  envp:= envpparam;
-  pascalmain;  {run the pascal main program}
-end;
-
-
 Begin
   IsConsole := TRUE;
   IsLibrary := FALSE;
@@ -242,7 +235,10 @@ End.
 
 {
  $Log$
- Revision 1.4  2005-02-13 22:13:20  peter
+ Revision 1.5  2005-02-14 16:32:41  peter
+   * solaris updates
+
+ 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

+ 10 - 1
rtl/sparc/math.inc

@@ -17,6 +17,7 @@
 
 {$ifdef INTERNCONSTINTF}
 
+{$ifndef FPC_SYSTEM_HAS_ABS}
     {$define FPC_SYSTEM_HAS_ABS}
     function fpc_abs_real(d : valreal) : valreal;compilerproc;
     begin
@@ -24,7 +25,9 @@
       runerror(207);
       result:=0;
     end;
+{$endif}
 
+{$ifndef FPC_SYSTEM_HAS_SQR}
     {$define FPC_SYSTEM_HAS_SQR}
     function fpc_sqr_real(d : valreal) : valreal;compilerproc;
     begin
@@ -32,7 +35,9 @@
       runerror(207);
       result:=0;
     end;
+{$endif}
 
+{$ifndef FPC_SYSTEM_HAS_SQRT}
     {$define FPC_SYSTEM_HAS_SQRT}
     function fpc_sqrt_real(d : valreal) : valreal;compilerproc;
     begin
@@ -40,6 +45,7 @@
       runerror(207);
       result:=0;
     end;
+{$endif}
 
 {$else}
 
@@ -56,7 +62,10 @@
 
 {
   $Log$
-  Revision 1.12  2004-11-21 19:11:33  peter
+  Revision 1.13  2005-02-14 16:32:41  peter
+    * solaris updates
+
+  Revision 1.12  2004/11/21 19:11:33  peter
     * fix bootstrapping
 
   Revision 1.11  2004/11/21 15:35:23  peter

+ 6 - 1
rtl/unix/sysunixh.inc

@@ -45,15 +45,20 @@ const
   sLineBreak = LineEnding;
   DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF;
 
+{$ifndef Solaris}
 {$ifndef Darwin}
 var argc:longint;external name 'operatingsystem_parameter_argc';
     argv:PPchar;external name 'operatingsystem_parameter_argv';
     envp:PPchar;external name 'operatingsystem_parameter_envp';
 {$endif}
+{$endif}
 
 {
   $Log$
-  Revision 1.23  2005-02-06 11:20:52  peter
+  Revision 1.24  2005-02-14 16:32:41  peter
+    * solaris updates
+
+  Revision 1.23  2005/02/06 11:20:52  peter
     * threading in system unit
     * removed systhrds unit