OSDN Git Service

2009-07-23 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-osinte-hpux.ads
index c015830..29605b8 100644 (file)
@@ -6,8 +6,8 @@
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---             Copyright (C) 1991-1994, Florida State University            --
---             Copyright (C) 1995-2005, Free Software Foundation, Inc.      --
+--               Copyright (C) 1991-1994, Florida State University          --
+--            Copyright (C) 1995-2008, Free Software Foundation, Inc.       --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -17,8 +17,8 @@
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
 -- Public License  distributed with GNARL; see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
 --                                                                          --
 -- As a special exception,  if other files  instantiate  generics from this --
 -- unit, or you link  this unit with other files  to produce an executable, --
 
 --  This is a HPUX 11.0 (Native THREADS) version of this package
 
---  This package encapsulates all direct interfaces to OS services
---  that are needed by children of System.
-
---  This package encapsulates all direct interfaces to OS services
---  that are needed by children of System.
+--  This package encapsulates all direct interfaces to OS services that are
+--  needed by the tasking run-time (libgnarl).
 
 --  PLEASE DO NOT add any with-clauses to this package or remove the pragma
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package.
 
+with Ada.Unchecked_Conversion;
+
 with Interfaces.C;
-with Unchecked_Conversion;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -88,7 +86,7 @@ package System.OS_Interface is
    SIGILL     : constant := 4; --  illegal instruction (not reset)
    SIGTRAP    : constant := 5; --  trace trap (not reset)
    SIGIOT     : constant := 6; --  IOT instruction
-   SIGABRT    : constant := 6; --  used by abort, replace SIGIOT in the  future
+   SIGABRT    : constant := 6; --  used by abort, replace SIGIOT in the future
    SIGEMT     : constant := 7; --  EMT instruction
    SIGFPE     : constant := 8; --  floating point exception
    SIGKILL    : constant := 9; --  kill (cannot be caught or ignored)
@@ -124,6 +122,7 @@ package System.OS_Interface is
    SIGADAABORT : constant := SIGABRT;
    --  Note: on other targets, we usually use SIGABRT, but on HPUX, it
    --  appears that SIGABRT can't be used in sigwait(), so we use SIGTERM.
+   --  Do we use SIGTERM or SIGABRT???
 
    type Signal_Set is array (Natural range <>) of Signal;
 
@@ -158,7 +157,8 @@ package System.OS_Interface is
    pragma Convention (C, struct_sigaction);
    type struct_sigaction_ptr is access all struct_sigaction;
 
-   SA_SIGINFO  : constant := 16#10#;
+   SA_SIGINFO : constant := 16#10#;
+   SA_ONSTACK : constant := 16#01#;
 
    SIG_BLOCK   : constant := 0;
    SIG_UNBLOCK : constant := 1;
@@ -178,7 +178,7 @@ package System.OS_Interface is
    ----------
 
    Time_Slice_Supported : constant Boolean := True;
-   --  Indicates wether time slicing is supported
+   --  Indicates whether time slicing is supported
 
    type timespec is private;
 
@@ -227,6 +227,10 @@ package System.OS_Interface is
    SCHED_RR    : constant := 1;
    SCHED_OTHER : constant := 2;
 
+   function To_Target_Priority
+     (Prio : System.Any_Priority) return Interfaces.C.int;
+   --  Maps System.Any_Priority to a POSIX priority
+
    -------------
    -- Process --
    -------------
@@ -252,9 +256,10 @@ package System.OS_Interface is
 
    type Thread_Body is access
      function (arg : System.Address) return System.Address;
+   pragma Convention (C, Thread_Body);
 
    function Thread_Body_Access is new
-     Unchecked_Conversion (System.Address, Thread_Body);
+     Ada.Unchecked_Conversion (System.Address, Thread_Body);
 
    type pthread_t           is private;
    subtype Thread_Id        is pthread_t;
@@ -268,30 +273,50 @@ package System.OS_Interface is
 
    PTHREAD_CREATE_DETACHED : constant := 16#de#;
 
+   PTHREAD_SCOPE_PROCESS : constant := 2;
+   PTHREAD_SCOPE_SYSTEM  : constant := 1;
+
    -----------
    -- Stack --
    -----------
 
+   type stack_t is record
+      ss_sp    : System.Address;
+      ss_flags : int;
+      ss_size  : size_t;
+   end record;
+   pragma Convention (C, stack_t);
+
+   function sigaltstack
+     (ss  : not null access stack_t;
+      oss : access stack_t) return int;
+   pragma Import (C, sigaltstack, "sigaltstack");
+
+   Alternate_Stack : aliased System.Address;
+   pragma Import (C, Alternate_Stack, "__gnat_alternate_stack");
+   --  The alternate signal stack for stack overflows
+
+   Alternate_Stack_Size : constant := 16 * 1024;
+   --  This must be in keeping with init.c:__gnat_alternate_stack
+
    Stack_Base_Available : constant Boolean := False;
-   --  Indicates wether the stack base is available on this target.
+   --  Indicates whether the stack base is available on this target
 
    function Get_Stack_Base (thread : pthread_t) return Address;
    pragma Inline (Get_Stack_Base);
-   --  returns the stack base of the specified thread.
-   --  Only call this function when Stack_Base_Available is True.
+   --  Returns the stack base of the specified thread. Only call this function
+   --  when Stack_Base_Available is True.
 
    function Get_Page_Size return size_t;
    function Get_Page_Size return Address;
    pragma Import (C, Get_Page_Size, "getpagesize");
-   --  returns the size of a page, or 0 if this is not relevant on this
-   --  target
+   --  Returns the size of a page, or 0 if this is not relevant on this target
 
    PROT_NONE  : constant := 0;
    PROT_READ  : constant := 1;
    PROT_WRITE : constant := 2;
    PROT_EXEC  : constant := 4;
    PROT_ALL   : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
-
    PROT_ON    : constant := PROT_READ;
    PROT_OFF   : constant := PROT_ALL;
 
@@ -320,12 +345,10 @@ package System.OS_Interface is
       sig    : Signal) return int;
    pragma Import (C, pthread_kill, "pthread_kill");
 
-   type sigset_t_ptr is access all sigset_t;
-
    function pthread_sigmask
      (how  : int;
-      set  : sigset_t_ptr;
-      oset : sigset_t_ptr) return int;
+      set  : access sigset_t;
+      oset : access sigset_t) return int;
    pragma Import (C, pthread_sigmask, "pthread_sigmask");
 
    --------------------------
@@ -484,6 +507,7 @@ package System.OS_Interface is
    pragma Import (C, pthread_getspecific, "pthread_getspecific");
 
    type destructor_pointer is access procedure (arg : System.Address);
+   pragma Convention (C, destructor_pointer);
 
    function pthread_key_create
      (key        : access pthread_key_t;
@@ -526,29 +550,36 @@ private
    type int_array is array (Natural range <>) of int;
 
    type pthread_mutex_t is record
-      m_short  : short_array (0 .. 1);
-      m_int    : int;
-      m_int1   : int_array (0 .. 3);
-      m_pad    : int;  --  needed for 32 bit ABI, but *not* for 64 bit
-      m_ptr    : System.Address;
+      m_short : short_array (0 .. 1);
+      m_int   : int;
+      m_int1  : int_array (0 .. 3);
+      m_pad   : int;
+
+      m_ptr : int;
+      --  actually m_ptr is a void*, and on 32 bit ABI, m_pad is added so that
+      --  this field takes 64 bits. On 64 bit ABI, m_pad is gone, and m_ptr is
+      --  a 64 bit void*. Assume int'Size = 32.
+
       m_int2   : int_array (0 .. 1);
       m_int3   : int_array (0 .. 3);
       m_short2 : short_array (0 .. 1);
       m_int4   : int_array (0 .. 4);
       m_int5   : int_array (0 .. 1);
    end record;
+   for pthread_mutex_t'Alignment use System.Address'Alignment;
    pragma Convention (C, pthread_mutex_t);
 
    type pthread_cond_t is record
       c_short : short_array (0 .. 1);
       c_int   : int;
       c_int1  : int_array (0 .. 3);
-      m_pad   : int;  --  needed for 32 bit ABI, but *not* for 64 bit
-      m_ptr   : System.Address;
+      m_pad   : int;
+      m_ptr   : int;  --  see comment in pthread_mutex_t
       c_int2  : int_array (0 .. 1);
       c_int3  : int_array (0 .. 1);
       c_int4  : int_array (0 .. 1);
    end record;
+   for pthread_cond_t'Alignment use System.Address'Alignment;
    pragma Convention (C, pthread_cond_t);
 
    type pthread_key_t is new int;