diff -urN gcc-4.3.2-orig/gcc/ada/gsocket.h gcc-4.3.2/gcc/ada/gsocket.h
--- gcc-4.3.2-orig/gcc/ada/gsocket.h	2008-02-13 13:04:53.000000000 -0600
+++ gcc-4.3.2/gcc/ada/gsocket.h	2008-09-09 13:07:24.000000000 -0500
@@ -175,7 +175,7 @@
 
 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
-#elif defined (sgi) || defined (linux) || (defined (sun) && defined (__SVR4) && !defined (__vxworks))
+#elif defined (sgi) || defined (linux) || (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || defined(__rtems__)
 # define HAVE_GETxxxBYyyy_R 1
 #endif
 
diff -urN gcc-4.3.2-orig/gcc/ada/g-socthi-rtems.adb gcc-4.3.2/gcc/ada/g-socthi-rtems.adb
--- gcc-4.3.2-orig/gcc/ada/g-socthi-rtems.adb	1969-12-31 18:00:00.000000000 -0600
+++ gcc-4.3.2/gcc/ada/g-socthi-rtems.adb	2008-11-05 14:32:53.000000000 -0600
@@ -0,0 +1,546 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         GNAT COMPILER COMPONENTS                         --
+--                                                                          --
+--                    G N A T . S O C K E T S . T H I N                     --
+--                                                                          --
+--                                 B o d y                                  --
+--                                                                          --
+--                     Copyright (C) 2001-2008, AdaCore                     --
+--                                                                          --
+-- GNAT 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- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- 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 GNAT;  see file COPYING.  If not, write --
+-- 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  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.                                      --
+--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
+--                                                                          --
+------------------------------------------------------------------------------
+
+--  This package provides a target dependent thin interface to the sockets
+--  layer for use by the GNAT.Sockets package (g-socket.ads). This package
+--  should not be directly with'ed by an applications program.
+
+--  This is the default version
+
+with GNAT.OS_Lib; use GNAT.OS_Lib;
+with GNAT.Task_Lock;
+
+with Interfaces.C; use Interfaces.C;
+
+package body GNAT.Sockets.Thin is
+
+   Non_Blocking_Sockets : constant Fd_Set_Access :=
+                            New_Socket_Set (No_Socket_Set);
+   --  When this package is initialized with Process_Blocking_IO set
+   --  to True, sockets are set in non-blocking mode to avoid blocking
+   --  the whole process when a thread wants to perform a blocking IO
+   --  operation. But the user can also set a socket in non-blocking
+   --  mode by purpose. In order to make a difference between these
+   --  two situations, we track the origin of non-blocking mode in
+   --  Non_Blocking_Sockets. If S is in Non_Blocking_Sockets, it has
+   --  been set in non-blocking mode by the user.
+
+   Quantum : constant Duration := 0.2;
+   --  When Constants.Thread_Blocking_IO is False, we set sockets in
+   --  non-blocking mode and we spend a period of time Quantum between
+   --  two attempts on a blocking operation.
+
+   Unknown_System_Error : constant C.Strings.chars_ptr :=
+                            C.Strings.New_String ("Unknown system error");
+
+   --  Comments required for following functions ???
+
+   function Syscall_Accept
+     (S       : C.int;
+      Addr    : System.Address;
+      Addrlen : not null access C.int) return C.int;
+   pragma Import (C, Syscall_Accept, "accept");
+
+   function Syscall_Connect
+     (S       : C.int;
+      Name    : System.Address;
+      Namelen : C.int) return C.int;
+   pragma Import (C, Syscall_Connect, "connect");
+
+   function Syscall_Ioctl
+     (S    : C.int;
+      Req  : C.int;
+      Arg  : Int_Access) return C.int;
+   pragma Import (C, Syscall_Ioctl, "ioctl");
+
+   function Syscall_Recv
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int) return C.int;
+   pragma Import (C, Syscall_Recv, "recv");
+
+   function Syscall_Recvfrom
+     (S       : C.int;
+      Msg     : System.Address;
+      Len     : C.int;
+      Flags   : C.int;
+      From    : Sockaddr_In_Access;
+      Fromlen : not null access C.int) return C.int;
+   pragma Import (C, Syscall_Recvfrom, "recvfrom");
+
+   function Syscall_Send
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int) return C.int;
+   pragma Import (C, Syscall_Send, "send");
+
+   function Syscall_Sendto
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int;
+      To    : Sockaddr_In_Access;
+      Tolen : C.int) return C.int;
+   pragma Import (C, Syscall_Sendto, "sendto");
+
+   function Syscall_Socket
+     (Domain   : C.int;
+      Typ      : C.int;
+      Protocol : C.int) return C.int;
+   pragma Import (C, Syscall_Socket, "socket");
+
+   procedure Disable_SIGPIPE (S : C.int);
+   pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe");
+
+   procedure Disable_All_SIGPIPEs;
+   pragma Import (C, Disable_All_SIGPIPEs, "__gnat_disable_all_sigpipes");
+   --  Sets the process to ignore all SIGPIPE signals on platforms that
+   --  don't support Disable_SIGPIPE for particular streams.
+
+   function Non_Blocking_Socket (S : C.int) return Boolean;
+   procedure Set_Non_Blocking_Socket (S : C.int; V : Boolean);
+
+   --------------
+   -- C_Accept --
+   --------------
+
+   function C_Accept
+     (S       : C.int;
+      Addr    : System.Address;
+      Addrlen : not null access C.int) return C.int
+   is
+      R   : C.int;
+      Val : aliased C.int := 1;
+
+      Discard : C.int;
+      pragma Warnings (Off, Discard);
+
+   begin
+      loop
+         R := Syscall_Accept (S, Addr, Addrlen);
+         exit when Constants.Thread_Blocking_IO
+           or else R /= Failure
+           or else Non_Blocking_Socket (S)
+           or else Errno /= Constants.EWOULDBLOCK;
+         delay Quantum;
+      end loop;
+
+      if not Constants.Thread_Blocking_IO
+        and then R /= Failure
+      then
+         --  A socket inherits the properties ot its server especially
+         --  the FIONBIO flag. Do not use C_Ioctl as this subprogram
+         --  tracks sockets set in non-blocking mode by user.
+
+         Set_Non_Blocking_Socket (R, Non_Blocking_Socket (S));
+         Discard := Syscall_Ioctl (R, Constants.FIONBIO, Val'Unchecked_Access);
+      end if;
+
+      Disable_SIGPIPE (R);
+      return R;
+   end C_Accept;
+
+   ---------------
+   -- C_Connect --
+   ---------------
+
+   function C_Connect
+     (S       : C.int;
+      Name    : System.Address;
+      Namelen : C.int) return C.int
+   is
+      Res : C.int;
+
+   begin
+      Res := Syscall_Connect (S, Name, Namelen);
+
+      if Constants.Thread_Blocking_IO
+        or else Res /= Failure
+        or else Non_Blocking_Socket (S)
+        or else Errno /= Constants.EINPROGRESS
+      then
+         return Res;
+      end if;
+
+      declare
+         WSet : Fd_Set_Access;
+         Now  : aliased Timeval;
+
+      begin
+         WSet := New_Socket_Set (No_Socket_Set);
+         loop
+            Insert_Socket_In_Set (WSet, S);
+            Now := Immediat;
+            Res := C_Select
+              (S + 1,
+               No_Fd_Set,
+               WSet,
+               No_Fd_Set,
+               Now'Unchecked_Access);
+
+            exit when Res > 0;
+
+            if Res = Failure then
+               Free_Socket_Set (WSet);
+               return Res;
+            end if;
+
+            delay Quantum;
+         end loop;
+
+         Free_Socket_Set (WSet);
+      end;
+
+      Res := Syscall_Connect (S, Name, Namelen);
+
+      if Res = Failure
+        and then Errno = Constants.EISCONN
+      then
+         return Thin.Success;
+      else
+         return Res;
+      end if;
+   end C_Connect;
+
+   -------------
+   -- C_Ioctl --
+   -------------
+
+   function C_Ioctl
+     (S   : C.int;
+      Req : C.int;
+      Arg : Int_Access) return C.int
+   is
+   begin
+      if not Constants.Thread_Blocking_IO
+        and then Req = Constants.FIONBIO
+      then
+         if Arg.all /= 0 then
+            Set_Non_Blocking_Socket (S, True);
+         end if;
+      end if;
+
+      return Syscall_Ioctl (S, Req, Arg);
+   end C_Ioctl;
+
+   ------------
+   -- C_Recv --
+   ------------
+
+   function C_Recv
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int) return C.int
+   is
+      Res : C.int;
+
+   begin
+      loop
+         Res := Syscall_Recv (S, Msg, Len, Flags);
+         exit when Constants.Thread_Blocking_IO
+           or else Res /= Failure
+           or else Non_Blocking_Socket (S)
+           or else Errno /= Constants.EWOULDBLOCK;
+         delay Quantum;
+      end loop;
+
+      return Res;
+   end C_Recv;
+
+   ----------------
+   -- C_Recvfrom --
+   ----------------
+
+   function C_Recvfrom
+     (S       : C.int;
+      Msg     : System.Address;
+      Len     : C.int;
+      Flags   : C.int;
+      From    : Sockaddr_In_Access;
+      Fromlen : not null access C.int) return C.int
+   is
+      Res : C.int;
+
+   begin
+      loop
+         Res := Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen);
+         exit when Constants.Thread_Blocking_IO
+           or else Res /= Failure
+           or else Non_Blocking_Socket (S)
+           or else Errno /= Constants.EWOULDBLOCK;
+         delay Quantum;
+      end loop;
+
+      return Res;
+   end C_Recvfrom;
+
+   ------------
+   -- C_Send --
+   ------------
+
+   function C_Send
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int) return C.int
+   is
+      Res : C.int;
+
+   begin
+      loop
+         Res := Syscall_Send (S, Msg, Len, Flags);
+         exit when Constants.Thread_Blocking_IO
+           or else Res /= Failure
+           or else Non_Blocking_Socket (S)
+           or else Errno /= Constants.EWOULDBLOCK;
+         delay Quantum;
+      end loop;
+
+      return Res;
+   end C_Send;
+
+   --------------
+   -- C_Sendto --
+   --------------
+
+   function C_Sendto
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int;
+      To    : Sockaddr_In_Access;
+      Tolen : C.int) return C.int
+   is
+      Res : C.int;
+
+   begin
+      loop
+         Res := Syscall_Sendto (S, Msg, Len, Flags, To, Tolen);
+         exit when Constants.Thread_Blocking_IO
+           or else Res /= Failure
+           or else Non_Blocking_Socket (S)
+           or else Errno /= Constants.EWOULDBLOCK;
+         delay Quantum;
+      end loop;
+
+      return Res;
+   end C_Sendto;
+
+   --------------
+   -- C_Socket --
+   --------------
+
+   function C_Socket
+     (Domain   : C.int;
+      Typ      : C.int;
+      Protocol : C.int) return C.int
+   is
+      R   : C.int;
+      Val : aliased C.int := 1;
+
+      Discard : C.int;
+      pragma Unreferenced (Discard);
+
+   begin
+      R := Syscall_Socket (Domain, Typ, Protocol);
+
+      if not Constants.Thread_Blocking_IO
+        and then R /= Failure
+      then
+         --  Do not use C_Ioctl as this subprogram tracks sockets set
+         --  in non-blocking mode by user.
+
+         Discard := Syscall_Ioctl (R, Constants.FIONBIO, Val'Unchecked_Access);
+         Set_Non_Blocking_Socket (R, False);
+      end if;
+      Disable_SIGPIPE (R);
+      return R;
+   end C_Socket;
+
+   --------------
+   -- Finalize --
+   --------------
+
+   procedure Finalize is
+   begin
+      null;
+   end Finalize;
+
+   -------------------------
+   -- Host_Error_Messages --
+   -------------------------
+
+   package body Host_Error_Messages is separate;
+
+   ----------------
+   -- Initialize --
+   ----------------
+
+   procedure Initialize is
+   begin
+      Disable_All_SIGPIPEs;
+   end Initialize;
+
+   -------------------------
+   -- Non_Blocking_Socket --
+   -------------------------
+
+   function Non_Blocking_Socket (S : C.int) return Boolean is
+      R : Boolean;
+   begin
+      Task_Lock.Lock;
+      R := (Is_Socket_In_Set (Non_Blocking_Sockets, S) /= 0);
+      Task_Lock.Unlock;
+      return R;
+   end Non_Blocking_Socket;
+
+   -----------------
+   -- Set_Address --
+   -----------------
+
+   procedure Set_Address
+     (Sin     : Sockaddr_In_Access;
+      Address : In_Addr)
+   is
+   begin
+      Sin.Sin_Addr := Address;
+   end Set_Address;
+
+   ----------------
+   -- Set_Family --
+   ----------------
+
+   procedure Set_Family
+     (Sin    : Sockaddr_In_Access;
+      Family : C.int)
+   is
+   begin
+      Sin.Sin_Family := C.unsigned_char (Family);
+   end Set_Family;
+
+   ----------------
+   -- Set_Length --
+   ----------------
+
+   procedure Set_Length
+     (Sin : Sockaddr_In_Access;
+      Len : C.int)
+   is
+      pragma Unreferenced (Sin);
+      pragma Unreferenced (Len);
+
+   begin
+      null;
+   end Set_Length;
+
+   -----------------------------
+   -- Set_Non_Blocking_Socket --
+   -----------------------------
+
+   procedure Set_Non_Blocking_Socket (S : C.int; V : Boolean) is
+   begin
+      Task_Lock.Lock;
+
+      if V then
+         Insert_Socket_In_Set (Non_Blocking_Sockets, S);
+      else
+         Remove_Socket_From_Set (Non_Blocking_Sockets, S);
+      end if;
+
+      Task_Lock.Unlock;
+   end Set_Non_Blocking_Socket;
+
+   --------------
+   -- Set_Port --
+   --------------
+
+   procedure Set_Port
+     (Sin  : Sockaddr_In_Access;
+      Port : C.unsigned_short)
+   is
+   begin
+      Sin.Sin_Port   := Port;
+   end Set_Port;
+
+   --------------------
+   -- Signalling_Fds --
+   --------------------
+
+   package body Signalling_Fds is
+
+      --  In this default implementation, we use a C version of these
+      --  subprograms provided by socket.c.
+
+      function C_Create (Fds : not null access Fd_Pair) return C.int;
+      function C_Read (Rsig : C.int) return C.int;
+      function C_Write (Wsig : C.int) return C.int;
+      procedure C_Close (Sig : C.int);
+
+      pragma Import (C, C_Create, "__gnat_create_signalling_fds");
+      pragma Import (C, C_Read,   "__gnat_read_signalling_fd");
+      pragma Import (C, C_Write,  "__gnat_write_signalling_fd");
+      pragma Import (C, C_Close,  "__gnat_close_signalling_fd");
+
+      function Create
+        (Fds : not null access Fd_Pair) return C.int renames C_Create;
+      function Read (Rsig : C.int) return C.int renames C_Read;
+      function Write (Wsig : C.int) return C.int renames C_Write;
+      procedure Close (Sig : C.int) renames C_Close;
+
+   end Signalling_Fds;
+
+   --------------------------
+   -- Socket_Error_Message --
+   --------------------------
+
+   function Socket_Error_Message
+     (Errno : Integer) return C.Strings.chars_ptr
+   is
+      use type Interfaces.C.Strings.chars_ptr;
+
+      C_Msg : C.Strings.chars_ptr;
+
+   begin
+      C_Msg := C_Strerror (C.int (Errno));
+
+      if C_Msg = C.Strings.Null_Ptr then
+         return Unknown_System_Error;
+      else
+         return C_Msg;
+      end if;
+   end Socket_Error_Message;
+
+end GNAT.Sockets.Thin;
diff -urN gcc-4.3.2-orig/gcc/ada/g-socthi-rtems.ads gcc-4.3.2/gcc/ada/g-socthi-rtems.ads
--- gcc-4.3.2-orig/gcc/ada/g-socthi-rtems.ads	1969-12-31 18:00:00.000000000 -0600
+++ gcc-4.3.2/gcc/ada/g-socthi-rtems.ads	2008-11-05 14:33:00.000000000 -0600
@@ -0,0 +1,492 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         GNAT COMPILER COMPONENTS                         --
+--                                                                          --
+--                    G N A T . S O C K E T S . T H I N                     --
+--                                                                          --
+--                                 S p e c                                  --
+--                                                                          --
+--                     Copyright (C) 2001-2008, AdaCore                     --
+--                                                                          --
+-- GNAT 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- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- 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 GNAT;  see file COPYING.  If not, write --
+-- 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  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.                                      --
+--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
+--                                                                          --
+------------------------------------------------------------------------------
+
+--  This package provides a target dependent thin interface to the sockets
+--  layer for use by the GNAT.Sockets package (g-socket.ads). This package
+--  should not be directly with'ed by an applications program.
+
+--  This is the RTEMS version.
+--
+
+with Interfaces.C.Pointers;
+with Interfaces.C.Strings;
+
+with GNAT.OS_Lib;
+with GNAT.Sockets.Constants;
+
+with System;
+
+package GNAT.Sockets.Thin is
+
+   --  This package is intended for hosts implementing BSD sockets with a
+   --  standard interface. It will be used as a default for all the platforms
+   --  that do not have a specific version of this file.
+
+   package C renames Interfaces.C;
+
+   use type C.int;
+   --  This is so we can declare the Failure constant below
+
+   Success : constant C.int :=  0;
+   Failure : constant C.int := -1;
+
+   function Socket_Errno return Integer renames GNAT.OS_Lib.Errno;
+   --  Returns last socket error number
+
+   function Socket_Error_Message (Errno : Integer) return C.Strings.chars_ptr;
+   --  Returns the error message string for the error number Errno. If Errno is
+   --  not known, returns "Unknown system error".
+
+   function Host_Errno return Integer;
+   pragma Import (C, Host_Errno, "__gnat_get_h_errno");
+   --  Returns last host error number
+
+   package Host_Error_Messages is
+
+      function Host_Error_Message
+        (H_Errno : Integer) return C.Strings.chars_ptr;
+      --  Returns the error message string for the host error number H_Errno.
+      --  If H_Errno is not known, returns "Unknown system error".
+
+   end Host_Error_Messages;
+
+   subtype Fd_Set_Access is System.Address;
+   No_Fd_Set : constant Fd_Set_Access := System.Null_Address;
+
+   type time_t is
+     range -2 ** (8 * Constants.SIZEOF_tv_sec - 1)
+         .. 2 ** (8 * Constants.SIZEOF_tv_sec - 1) - 1;
+   for time_t'Size use 8 * Constants.SIZEOF_tv_sec;
+   pragma Convention (C, time_t);
+
+   type suseconds_t is
+     range -2 ** (8 * Constants.SIZEOF_tv_usec - 1)
+         .. 2 ** (8 * Constants.SIZEOF_tv_usec - 1) - 1;
+   for suseconds_t'Size use 8 * Constants.SIZEOF_tv_usec;
+   pragma Convention (C, suseconds_t);
+
+   type Timeval is record
+      Tv_Sec  : time_t;
+      Tv_Usec : suseconds_t;
+   end record;
+   pragma Convention (C, Timeval);
+
+   type Timeval_Access is access all Timeval;
+   pragma Convention (C, Timeval_Access);
+
+   Immediat : constant Timeval := (0, 0);
+
+   type Int_Access is access all C.int;
+   pragma Convention (C, Int_Access);
+   --  Access to C integers
+
+   type Chars_Ptr_Array is array (C.size_t range <>) of
+     aliased C.Strings.chars_ptr;
+
+   package Chars_Ptr_Pointers is
+      new C.Pointers (C.size_t, C.Strings.chars_ptr, Chars_Ptr_Array,
+                      C.Strings.Null_Ptr);
+   --  Arrays of C (char *)
+
+   type In_Addr is record
+      S_B1, S_B2, S_B3, S_B4 : C.unsigned_char;
+   end record;
+   for In_Addr'Alignment use C.int'Alignment;
+   pragma Convention (C, In_Addr);
+   --  IPv4 address, represented as a network-order C.int. Note that the
+   --  underlying operating system may assume that values of this type have
+   --  C.int alignment, so we need to provide a suitable alignment clause here.
+
+   type In_Addr_Access is access all In_Addr;
+   pragma Convention (C, In_Addr_Access);
+   --  Access to internet address
+
+   Inaddr_Any : aliased constant In_Addr := (others => 0);
+   --  Any internet address (all the interfaces)
+
+   type In_Addr_Access_Array is array (C.size_t range <>)
+     of aliased In_Addr_Access;
+   pragma Convention (C, In_Addr_Access_Array);
+
+   package In_Addr_Access_Pointers is
+     new C.Pointers (C.size_t, In_Addr_Access, In_Addr_Access_Array, null);
+   --  Array of internet addresses
+
+   type Sockaddr is record
+      Sa_Len    : C.unsigned_char;
+      Sa_Family : C.unsigned_char;
+      Sa_Data   : C.char_array (1 .. 14);
+   end record;
+   pragma Convention (C, Sockaddr);
+   --  Socket address
+
+   type Sockaddr_Access is access all Sockaddr;
+   pragma Convention (C, Sockaddr_Access);
+   --  Access to socket address
+
+   type Sockaddr_In is record
+      Sin_Len    : C.unsigned_char       := 0;
+      Sin_Family : C.unsigned_char       := Constants.AF_INET;
+      Sin_Port   : C.unsigned_short      := 0;
+      Sin_Addr   : In_Addr               := Inaddr_Any;
+      Sin_Zero   : C.char_array (1 .. 8) := (others => C.char'Val (0));
+   end record;
+   pragma Convention (C, Sockaddr_In);
+   --  Internet socket address
+
+   type Sockaddr_In_Access is access all Sockaddr_In;
+   pragma Convention (C, Sockaddr_In_Access);
+   --  Access to internet socket address
+
+   procedure Set_Length
+     (Sin : Sockaddr_In_Access;
+      Len : C.int);
+   pragma Inline (Set_Length);
+   --  Set Sin.Sin_Length to Len.
+   --  On this platform, nothing is done as there is no such field.
+
+   procedure Set_Family
+     (Sin    : Sockaddr_In_Access;
+      Family : C.int);
+   pragma Inline (Set_Family);
+   --  Set Sin.Sin_Family to Family
+
+   procedure Set_Port
+     (Sin  : Sockaddr_In_Access;
+      Port : C.unsigned_short);
+   pragma Inline (Set_Port);
+   --  Set Sin.Sin_Port to Port
+
+   procedure Set_Address
+     (Sin     : Sockaddr_In_Access;
+      Address : In_Addr);
+   pragma Inline (Set_Address);
+   --  Set Sin.Sin_Addr to Address
+
+   type Hostent is record
+      H_Name      : C.Strings.chars_ptr;
+      H_Aliases   : Chars_Ptr_Pointers.Pointer;
+      H_Addrtype  : C.int;
+      H_Length    : C.int;
+      H_Addr_List : In_Addr_Access_Pointers.Pointer;
+   end record;
+   pragma Convention (C, Hostent);
+   --  Host entry
+
+   type Hostent_Access is access all Hostent;
+   pragma Convention (C, Hostent_Access);
+   --  Access to host entry
+
+   type Servent is record
+      S_Name    : C.Strings.chars_ptr;
+      S_Aliases : Chars_Ptr_Pointers.Pointer;
+      S_Port    : C.int;
+      S_Proto   : C.Strings.chars_ptr;
+   end record;
+   pragma Convention (C, Servent);
+   --  Service entry
+
+   type Servent_Access is access all Servent;
+   pragma Convention (C, Servent_Access);
+   --  Access to service entry
+
+   type Two_Ints is array (0 .. 1) of C.int;
+   pragma Convention (C, Two_Ints);
+   --  Container for two int values
+
+   subtype Fd_Pair is Two_Ints;
+   --  Two_Ints as used for Create_Signalling_Fds: a pair of connected file
+   --  descriptors, one of which (the "read end" of the connection) being used
+   --  for reading, the other one (the "write end") being used for writing.
+
+   Read_End  : constant := 0;
+   Write_End : constant := 1;
+   --  Indices into an Fd_Pair value providing access to each of the connected
+   --  file descriptors.
+
+   --------------------------------
+   -- Standard library functions --
+   --------------------------------
+
+   function C_Accept
+     (S       : C.int;
+      Addr    : System.Address;
+      Addrlen : not null access C.int) return C.int;
+
+   function C_Bind
+     (S       : C.int;
+      Name    : System.Address;
+      Namelen : C.int) return C.int;
+
+   function C_Close
+     (Fd : C.int) return C.int;
+
+   function C_Connect
+     (S       : C.int;
+      Name    : System.Address;
+      Namelen : C.int) return C.int;
+
+   function C_Gethostname
+     (Name    : System.Address;
+      Namelen : C.int) return C.int;
+
+   function C_Getpeername
+     (S       : C.int;
+      Name    : System.Address;
+      Namelen : not null access C.int) return C.int;
+
+   function C_Getsockname
+     (S       : C.int;
+      Name    : System.Address;
+      Namelen : not null access C.int) return C.int;
+
+   function C_Getsockopt
+     (S       : C.int;
+      Level   : C.int;
+      Optname : C.int;
+      Optval  : System.Address;
+      Optlen  : not null access C.int) return C.int;
+
+   function C_Inet_Addr
+     (Cp : C.Strings.chars_ptr) return C.int;
+
+   function C_Ioctl
+     (S    : C.int;
+      Req  : C.int;
+      Arg  : Int_Access) return C.int;
+
+   function C_Listen
+     (S       : C.int;
+      Backlog : C.int) return C.int;
+
+   function C_Readv
+     (Fd     : C.int;
+      Iov    : System.Address;
+      Iovcnt : C.int) return C.int;
+
+   function C_Recv
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int) return C.int;
+
+   function C_Recvfrom
+     (S       : C.int;
+      Msg     : System.Address;
+      Len     : C.int;
+      Flags   : C.int;
+      From    : Sockaddr_In_Access;
+      Fromlen : not null access C.int) return C.int;
+
+   function C_Select
+     (Nfds      : C.int;
+      Readfds   : Fd_Set_Access;
+      Writefds  : Fd_Set_Access;
+      Exceptfds : Fd_Set_Access;
+      Timeout   : Timeval_Access) return C.int;
+
+   function C_Send
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int) return C.int;
+
+   function C_Sendto
+     (S     : C.int;
+      Msg   : System.Address;
+      Len   : C.int;
+      Flags : C.int;
+      To    : Sockaddr_In_Access;
+      Tolen : C.int) return C.int;
+
+   function C_Setsockopt
+     (S       : C.int;
+      Level   : C.int;
+      Optname : C.int;
+      Optval  : System.Address;
+      Optlen  : C.int) return C.int;
+
+   function C_Shutdown
+     (S   : C.int;
+      How : C.int) return C.int;
+
+   function C_Socket
+     (Domain   : C.int;
+      Typ      : C.int;
+      Protocol : C.int) return C.int;
+
+   function C_Strerror
+     (Errnum : C.int) return C.Strings.chars_ptr;
+
+   function C_System
+     (Command : System.Address) return C.int;
+
+   function C_Writev
+     (Fd     : C.int;
+      Iov    : System.Address;
+      Iovcnt : C.int) return C.int;
+
+   -------------------------------------------------------
+   -- Signalling file descriptors for selector abortion --
+   -------------------------------------------------------
+
+   package Signalling_Fds is
+
+      function Create (Fds : not null access Fd_Pair) return C.int;
+      pragma Convention (C, Create);
+      --  Create a pair of connected descriptors suitable for use with C_Select
+      --  (used for signalling in Selector objects).
+
+      function Read (Rsig : C.int) return C.int;
+      pragma Convention (C, Read);
+      --  Read one byte of data from rsig, the read end of a pair of signalling
+      --  fds created by Create_Signalling_Fds.
+
+      function Write (Wsig : C.int) return C.int;
+      pragma Convention (C, Write);
+      --  Write one byte of data to wsig, the write end of a pair of signalling
+      --  fds created by Create_Signalling_Fds.
+
+      procedure Close (Sig : C.int);
+      pragma Convention (C, Close);
+      --  Close one end of a pair of signalling fds (ignoring any error)
+
+   end Signalling_Fds;
+
+   ----------------------------
+   -- Socket sets management --
+   ----------------------------
+
+   procedure Free_Socket_Set
+     (Set : Fd_Set_Access);
+   --  Free system-dependent socket set
+
+   procedure Get_Socket_From_Set
+     (Set    : Fd_Set_Access;
+      Socket : Int_Access;
+      Last   : Int_Access);
+   --  Get last socket in Socket and remove it from the socket set. The
+   --  parameter Last is a maximum value of the largest socket. This hint is
+   --  used to avoid scanning very large socket sets. After a call to
+   --  Get_Socket_From_Set, Last is set back to the real largest socket in the
+   --  socket set.
+
+   procedure Insert_Socket_In_Set
+     (Set    : Fd_Set_Access;
+      Socket : C.int);
+   --  Insert socket in the socket set
+
+   function  Is_Socket_In_Set
+     (Set    : Fd_Set_Access;
+      Socket : C.int) return C.int;
+   --  Check whether Socket is in the socket set, return a non-zero
+   --  value if it is, zero if it is not.
+
+   procedure Last_Socket_In_Set
+     (Set    : Fd_Set_Access;
+      Last   : Int_Access);
+   --  Find the largest socket in the socket set. This is needed for select().
+   --  When Last_Socket_In_Set is called, parameter Last is a maximum value of
+   --  the largest socket. This hint is used to avoid scanning very large
+   --  socket sets. After the call, Last is set back to the real largest socket
+   --  in the socket set.
+
+   function  New_Socket_Set
+     (Set : Fd_Set_Access) return Fd_Set_Access;
+   --  Allocate a new socket set which is a system-dependent structure and
+   --  initialize by copying Set if it is non-null, by making it empty
+   --  otherwise.
+
+   procedure Remove_Socket_From_Set
+     (Set    : Fd_Set_Access;
+      Socket : C.int);
+   --  Remove socket from the socket set
+
+   -------------------------------------------
+   -- Nonreentrant network databases access --
+   -------------------------------------------
+
+   --  The following are used only on systems that have nonreentrant
+   --  getXXXbyYYY functions, and do NOT have corresponding getXXXbyYYY_
+   --  functions. Currently, LynxOS is the only such system.
+
+   function Nonreentrant_Gethostbyname
+     (Name : C.char_array) return Hostent_Access;
+
+   function Nonreentrant_Gethostbyaddr
+     (Addr      : System.Address;
+      Addr_Len  : C.int;
+      Addr_Type : C.int) return Hostent_Access;
+
+   function Nonreentrant_Getservbyname
+     (Name  : C.char_array;
+      Proto : C.char_array) return Servent_Access;
+
+   function Nonreentrant_Getservbyport
+     (Port  : C.int;
+      Proto : C.char_array) return Servent_Access;
+
+   procedure Initialize;
+   procedure Finalize;
+
+private
+   pragma Import (C, C_Bind, "bind");
+   pragma Import (C, C_Close, "close");
+   pragma Import (C, C_Gethostname, "gethostname");
+   pragma Import (C, C_Getpeername, "getpeername");
+   pragma Import (C, C_Getsockname, "getsockname");
+   pragma Import (C, C_Getsockopt, "getsockopt");
+   pragma Import (C, C_Inet_Addr, "inet_addr");
+   pragma Import (C, C_Listen, "listen");
+   pragma Import (C, C_Readv, "readv");
+   pragma Import (C, C_Select, "select");
+   pragma Import (C, C_Setsockopt, "setsockopt");
+   pragma Import (C, C_Shutdown, "shutdown");
+   pragma Import (C, C_Strerror, "strerror");
+   pragma Import (C, C_System, "system");
+   pragma Import (C, C_Writev, "writev");
+
+   pragma Import (C, Free_Socket_Set, "__gnat_free_socket_set");
+   pragma Import (C, Get_Socket_From_Set, "__gnat_get_socket_from_set");
+   pragma Import (C, Is_Socket_In_Set, "__gnat_is_socket_in_set");
+   pragma Import (C, Last_Socket_In_Set, "__gnat_last_socket_in_set");
+   pragma Import (C, New_Socket_Set, "__gnat_new_socket_set");
+   pragma Import (C, Insert_Socket_In_Set, "__gnat_insert_socket_in_set");
+   pragma Import (C, Remove_Socket_From_Set, "__gnat_remove_socket_from_set");
+
+   pragma Import (C, Nonreentrant_Gethostbyname, "gethostbyname");
+   pragma Import (C, Nonreentrant_Gethostbyaddr, "gethostbyaddr");
+   pragma Import (C, Nonreentrant_Getservbyname, "getservbyname");
+   pragma Import (C, Nonreentrant_Getservbyport, "getservbyport");
+
+end GNAT.Sockets.Thin;
diff -urN gcc-4.3.2-orig/gcc/ada/Makefile.in gcc-4.3.2/gcc/ada/Makefile.in
--- gcc-4.3.2-orig/gcc/ada/Makefile.in	2008-02-13 13:04:53.000000000 -0600
+++ gcc-4.3.2/gcc/ada/Makefile.in	2008-11-05 14:36:48.000000000 -0600
@@ -392,7 +392,7 @@
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
-  s-interr.adb<s-interr-vxworks.adb \
+  s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
   s-osinte.adb<s-osinte-vxworks.adb \
@@ -473,7 +473,7 @@
     EXTRA_GNATRTL_NONTASKING_OBJS=s-vxwexc.o
   else
     LIBGNAT_TARGET_PAIRS += \
-    s-interr.adb<s-interr-vxworks.adb \
+    s-interr.adb<s-interr-hwint.adb \
     s-tpopsp.adb<s-tpopsp-vxworks.adb \
     system.ads<system-vxworks-ppc.ads
 
@@ -506,7 +506,7 @@
   g-io.adb<g-io-vxworks-ppc-cert.adb \
   g-io.ads<g-io-vxworks-ppc-cert.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
-  s-interr.adb<s-interr-vxworks.adb \
+  s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
   s-osinte.adb<s-osinte-vxworks.adb \
@@ -553,7 +553,7 @@
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
-  s-interr.adb<s-interr-vxworks.adb \
+  s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
   s-osinte.adb<s-osinte-vxworks.adb \
@@ -628,7 +628,7 @@
     EXTRA_GNATRTL_NONTASKING_OBJS=s-vxwexc.o
   else
     LIBGNAT_TARGET_PAIRS += \
-    s-interr.adb<s-interr-vxworks.adb \
+    s-interr.adb<s-interr-hwint.adb \
     s-tpopsp.adb<s-tpopsp-vxworks.adb \
     system.ads<system-vxworks-x86.ads
 
@@ -656,7 +656,7 @@
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
-  s-interr.adb<s-interr-vxworks.adb \
+  s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
   s-osinte.adb<s-osinte-vxworks.adb \
@@ -1148,7 +1148,10 @@
   s-taspri.ads<s-taspri-posix.ads \
   s-tpopsp.adb<s-tpopsp-rtems.adb \
   g-soccon.ads<g-soccon-rtems.ads \
-  s-stchop.adb<s-stchop-rtems.adb
+  s-stchop.adb<s-stchop-rtems.adb \
+  s-interr.adb<s-interr-hwint.adb \
+  g-socthi.ads<g-socthi-rtems.ads \
+  g-socthi.adb<g-socthi-rtems.adb
 endif
 
 ifeq ($(strip $(filter-out alpha% dec osf%,$(targ))),)
diff -urN gcc-4.3.2-orig/gcc/ada/s-interr-hwint.adb gcc-4.3.2/gcc/ada/s-interr-hwint.adb
--- gcc-4.3.2-orig/gcc/ada/s-interr-hwint.adb	1969-12-31 18:00:00.000000000 -0600
+++ gcc-4.3.2/gcc/ada/s-interr-hwint.adb	2008-09-09 13:07:24.000000000 -0500
@@ -0,0 +1,1139 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
+--                                                                          --
+--                     S Y S T E M . I N T E R R U P T S                    --
+--                                                                          --
+--                                  B o d y                                 --
+--                                                                          --
+--         Copyright (C) 1992-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- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- 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,  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  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.                                      --
+--                                                                          --
+-- GNARL was developed by the GNARL team at Florida State University.       --
+-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
+--                                                                          --
+------------------------------------------------------------------------------
+
+--  Invariants:
+
+--  All user-handleable signals are masked at all times in all tasks/threads
+--  except possibly for the Interrupt_Manager task.
+
+--  When a user task wants to have the effect of masking/unmasking an signal,
+--  it must call Block_Interrupt/Unblock_Interrupt, which will have the effect
+--  of unmasking/masking the signal in the Interrupt_Manager task. These
+--  comments do not apply to vectored hardware interrupts, which may be masked
+--  or unmasked using routined interfaced to the relevant embedded RTOS system
+--  calls.
+
+--  Once we associate a Signal_Server_Task with an signal, the task never goes
+--  away, and we never remove the association. On the other hand, it is more
+--  convenient to terminate an associated Interrupt_Server_Task for a vectored
+--  hardware interrupt (since we use a binary semaphore for synchronization
+--  with the umbrella handler).
+
+--  There is no more than one signal per Signal_Server_Task and no more than
+--  one Signal_Server_Task per signal. The same relation holds for hardware
+--  interrupts and Interrupt_Server_Task's at any given time. That is, only
+--  one non-terminated Interrupt_Server_Task exists for a give interrupt at
+--  any time.
+
+--  Within this package, the lock L is used to protect the various status
+--  tables. If there is a Server_Task associated with a signal or interrupt,
+--  we use the per-task lock of the Server_Task instead so that we protect the
+--  status between Interrupt_Manager and Server_Task. Protection among
+--  service requests are ensured via user calls to the Interrupt_Manager
+--  entries.
+
+--  This is reasonably generic version of this package, supporting vectored
+--  hardware interrupts using non-RTOS specific adapter routines which
+--  should easily implemented on any RTOS capable of supporting GNAT.
+
+with Unchecked_Conversion;
+
+with System.OS_Interface; use System.OS_Interface;
+
+with Ada.Task_Identification;
+--  used for Task_Id type
+
+with Ada.Exceptions;
+--  used for Raise_Exception
+
+with System.Interrupt_Management;
+--  used for Reserve
+
+with System.Task_Primitives.Operations;
+--  used for Write_Lock
+--           Unlock
+--           Abort
+--           Wakeup_Task
+--           Sleep
+--           Initialize_Lock
+
+with System.Storage_Elements;
+--  used for To_Address
+--           To_Integer
+--           Integer_Address
+
+with System.Tasking.Utilities;
+--  used for Make_Independent
+
+with System.Tasking.Rendezvous;
+--  used for Call_Simple
+pragma Elaborate_All (System.Tasking.Rendezvous);
+
+package body System.Interrupts is
+
+   use Tasking;
+   use Ada.Exceptions;
+
+   package POP renames System.Task_Primitives.Operations;
+
+   function To_Ada is new Unchecked_Conversion
+     (System.Tasking.Task_Id, Ada.Task_Identification.Task_Id);
+
+   function To_System is new Unchecked_Conversion
+     (Ada.Task_Identification.Task_Id, Task_Id);
+
+   -----------------
+   -- Local Tasks --
+   -----------------
+
+   --  WARNING: System.Tasking.Stages performs calls to this task with
+   --  low-level constructs. Do not change this spec without synchronizing it.
+
+   task Interrupt_Manager is
+      entry Detach_Interrupt_Entries (T : Task_Id);
+
+      entry Attach_Handler
+        (New_Handler : Parameterless_Handler;
+         Interrupt   : Interrupt_ID;
+         Static      : Boolean;
+         Restoration : Boolean := False);
+
+      entry Exchange_Handler
+        (Old_Handler : out Parameterless_Handler;
+         New_Handler : Parameterless_Handler;
+         Interrupt   : Interrupt_ID;
+         Static      : Boolean);
+
+      entry Detach_Handler
+        (Interrupt : Interrupt_ID;
+         Static    : Boolean);
+
+      entry Bind_Interrupt_To_Entry
+        (T         : Task_Id;
+         E         : Task_Entry_Index;
+         Interrupt : Interrupt_ID);
+
+      pragma Interrupt_Priority (System.Interrupt_Priority'First);
+   end Interrupt_Manager;
+
+   task type Interrupt_Server_Task
+     (Interrupt : Interrupt_ID; Int_Sema : Binary_Semaphore_Id) is
+      --  Server task for vectored hardware interrupt handling
+      pragma Interrupt_Priority (System.Interrupt_Priority'First + 2);
+   end Interrupt_Server_Task;
+
+   type Interrupt_Task_Access is access Interrupt_Server_Task;
+
+   -------------------------------
+   -- Local Types and Variables --
+   -------------------------------
+
+   type Entry_Assoc is record
+      T : Task_Id;
+      E : Task_Entry_Index;
+   end record;
+
+   type Handler_Assoc is record
+      H      : Parameterless_Handler;
+      Static : Boolean;   --  Indicates static binding;
+   end record;
+
+   User_Handler : array (Interrupt_ID) of Handler_Assoc :=
+     (others => (null, Static => False));
+   pragma Volatile_Components (User_Handler);
+   --  Holds the protected procedure handler (if any) and its Static
+   --  information  for each interrupt or signal. A handler is static
+   --  iff it is specified through the pragma Attach_Handler.
+
+   User_Entry : array (Interrupt_ID) of Entry_Assoc :=
+     (others => (T => Null_Task, E => Null_Task_Entry));
+   pragma Volatile_Components (User_Entry);
+   --  Holds the task and entry index (if any) for each interrupt / signal
+
+   --  Type and Head, Tail of the list containing Registered Interrupt
+   --  Handlers. These definitions are used to register the handlers
+   --  specified by the pragma Interrupt_Handler.
+
+   type Registered_Handler;
+   type R_Link is access all Registered_Handler;
+
+   type Registered_Handler is record
+      H    : System.Address := System.Null_Address;
+      Next : R_Link := null;
+   end record;
+
+   Registered_Handler_Head : R_Link := null;
+   Registered_Handler_Tail : R_Link := null;
+
+   Server_ID : array (Interrupt_ID) of System.Tasking.Task_Id :=
+     (others => System.Tasking.Null_Task);
+   pragma Atomic_Components (Server_ID);
+   --  Holds the Task_Id of the Server_Task for each interrupt / signal.
+   --  Task_Id is needed to accomplish locking per interrupt base. Also
+   --  is needed to determine whether to create a new Server_Task.
+
+   Semaphore_ID_Map : array
+     (Interrupt_ID range 0 .. System.OS_Interface.Max_HW_Interrupt)
+      of Binary_Semaphore_Id := (others => 0);
+   --  Array of binary semaphores associated with vectored interrupts
+   --  Note that the last bound should be Max_HW_Interrupt, but this will raise
+   --  Storage_Error if Num_HW_Interrupts is null, so use an extra 4 bytes
+   --  instead.
+
+   Interrupt_Access_Hold : Interrupt_Task_Access;
+   --  Variable for allocating an Interrupt_Server_Task
+
+   Default_Handler : array (HW_Interrupt) of
+      System.OS_Interface.Interrupt_Handler;
+   --  Vectored interrupt handlers installed prior to program startup.
+   --  These are saved only when the umbrella handler is installed for
+   --  a given interrupt number.
+
+   -----------------------
+   -- Local Subprograms --
+   -----------------------
+
+   procedure Check_Reserved_Interrupt (Interrupt : Interrupt_ID);
+   --  Check if Id is a reserved interrupt, and if so raise Program_Error
+   --  with an appropriate message, otherwise return.
+
+   procedure Finalize_Interrupt_Servers;
+   --  Unbind the handlers for hardware interrupt server tasks at program
+   --  termination.
+
+   function Is_Registered (Handler : Parameterless_Handler) return Boolean;
+   --  See if Handler has been "pragma"ed using Interrupt_Handler.
+   --  Always consider a null handler as registered.
+
+   procedure Notify_Interrupt (Param : System.Address);
+   pragma Convention (C, Notify_Interrupt);
+   --  Umbrella handler for vectored interrupts (not signals)
+
+   procedure Install_Default_Action (Interrupt : HW_Interrupt);
+   --  Restore a handler that was in place prior to program execution
+
+   procedure Install_Umbrella_Handler
+     (Interrupt : HW_Interrupt;
+      Handler   : System.OS_Interface.Interrupt_Handler);
+   --  Install the runtime umbrella handler for a vectored hardware
+   --  interrupt
+
+   procedure Unimplemented (Feature : String);
+   pragma No_Return (Unimplemented);
+   --  Used to mark a call to an unimplemented function. Raises Program_Error
+   --  with an appropriate message noting that Feature is unimplemented.
+
+   --------------------
+   -- Attach_Handler --
+   --------------------
+
+   --  Calling this procedure with New_Handler = null and Static = True
+   --  means we want to detach the current handler regardless of the
+   --  previous handler's binding status (ie. do not care if it is a
+   --  dynamic or static handler).
+
+   --  This option is needed so that during the finalization of a PO, we
+   --  can detach handlers attached through pragma Attach_Handler.
+
+   procedure Attach_Handler
+     (New_Handler : Parameterless_Handler;
+      Interrupt   : Interrupt_ID;
+      Static      : Boolean := False) is
+   begin
+      Check_Reserved_Interrupt (Interrupt);
+      Interrupt_Manager.Attach_Handler (New_Handler, Interrupt, Static);
+   end Attach_Handler;
+
+   -----------------------------
+   -- Bind_Interrupt_To_Entry --
+   -----------------------------
+
+   --  This procedure raises a Program_Error if it tries to
+   --  bind an interrupt to which an Entry or a Procedure is
+   --  already bound.
+
+   procedure Bind_Interrupt_To_Entry
+     (T       : Task_Id;
+      E       : Task_Entry_Index;
+      Int_Ref : System.Address)
+   is
+      Interrupt : constant Interrupt_ID :=
+        Interrupt_ID (Storage_Elements.To_Integer (Int_Ref));
+
+   begin
+      Check_Reserved_Interrupt (Interrupt);
+      Interrupt_Manager.Bind_Interrupt_To_Entry (T, E, Interrupt);
+   end Bind_Interrupt_To_Entry;
+
+   ---------------------
+   -- Block_Interrupt --
+   ---------------------
+
+   procedure Block_Interrupt (Interrupt : Interrupt_ID) is
+   begin
+      Unimplemented ("Block_Interrupt");
+   end Block_Interrupt;
+
+   ------------------------------
+   -- Check_Reserved_Interrupt --
+   ------------------------------
+
+   procedure Check_Reserved_Interrupt (Interrupt : Interrupt_ID) is
+   begin
+      if Is_Reserved (Interrupt) then
+         Raise_Exception
+           (Program_Error'Identity,
+            "Interrupt" & Interrupt_ID'Image (Interrupt) & " is reserved");
+      else
+         return;
+      end if;
+   end Check_Reserved_Interrupt;
+
+   ---------------------
+   -- Current_Handler --
+   ---------------------
+
+   function Current_Handler
+     (Interrupt : Interrupt_ID) return Parameterless_Handler
+   is
+   begin
+      Check_Reserved_Interrupt (Interrupt);
+
+      --  ??? Since Parameterless_Handler is not Atomic, the
+      --  current implementation is wrong. We need a new service in
+      --  Interrupt_Manager to ensure atomicity.
+
+      return User_Handler (Interrupt).H;
+   end Current_Handler;
+
+   --------------------
+   -- Detach_Handler --
+   --------------------
+
+   --  Calling this procedure with Static = True means we want to Detach the
+   --  current handler regardless of the previous handler's binding status
+   --  (i.e. do not care if it is a dynamic or static handler).
+
+   --  This option is needed so that during the finalization of a PO, we can
+   --  detach handlers attached through pragma Attach_Handler.
+
+   procedure Detach_Handler
+     (Interrupt : Interrupt_ID;
+      Static    : Boolean := False) is
+   begin
+      Check_Reserved_Interrupt (Interrupt);
+      Interrupt_Manager.Detach_Handler (Interrupt, Static);
+   end Detach_Handler;
+
+   ------------------------------
+   -- Detach_Interrupt_Entries --
+   ------------------------------
+
+   procedure Detach_Interrupt_Entries (T : Task_Id) is
+   begin
+      Interrupt_Manager.Detach_Interrupt_Entries (T);
+   end Detach_Interrupt_Entries;
+
+   ----------------------
+   -- Exchange_Handler --
+   ----------------------
+
+   --  Calling this procedure with New_Handler = null and Static = True
+   --  means we want to detach the current handler regardless of the
+   --  previous handler's binding status (ie. do not care if it is a
+   --  dynamic or static handler).
+
+   --  This option is needed so that during the finalization of a PO, we
+   --  can detach handlers attached through pragma Attach_Handler.
+
+   procedure Exchange_Handler
+     (Old_Handler : out Parameterless_Handler;
+      New_Handler : Parameterless_Handler;
+      Interrupt   : Interrupt_ID;
+      Static      : Boolean := False)
+   is
+   begin
+      Check_Reserved_Interrupt (Interrupt);
+      Interrupt_Manager.Exchange_Handler
+        (Old_Handler, New_Handler, Interrupt, Static);
+   end Exchange_Handler;
+
+   --------------
+   -- Finalize --
+   --------------
+
+   procedure Finalize (Object : in out Static_Interrupt_Protection) is
+   begin
+      --  ??? loop to be executed only when we're not doing library level
+      --  finalization, since in this case all interrupt / signal tasks are
+      --  gone.
+
+      if not Interrupt_Manager'Terminated then
+         for N in reverse Object.Previous_Handlers'Range loop
+            Interrupt_Manager.Attach_Handler
+              (New_Handler => Object.Previous_Handlers (N).Handler,
+               Interrupt   => Object.Previous_Handlers (N).Interrupt,
+               Static      => Object.Previous_Handlers (N).Static,
+               Restoration => True);
+         end loop;
+      end if;
+
+      Tasking.Protected_Objects.Entries.Finalize
+        (Tasking.Protected_Objects.Entries.Protection_Entries (Object));
+   end Finalize;
+
+   --------------------------------
+   -- Finalize_Interrupt_Servers --
+   --------------------------------
+
+   --  Restore default handlers for interrupt servers
+
+   --  This is called by the Interrupt_Manager task when it receives the abort
+   --  signal during program finalization.
+
+   procedure Finalize_Interrupt_Servers is
+      HW_Interrupts : constant Boolean := HW_Interrupt'Last >= 0;
+
+   begin
+      if HW_Interrupts then
+         for Int in HW_Interrupt loop
+            if Server_ID (Interrupt_ID (Int)) /= null
+              and then
+                not Ada.Task_Identification.Is_Terminated
+                 (To_Ada (Server_ID (Interrupt_ID (Int))))
+            then
+               Interrupt_Manager.Attach_Handler
+                 (New_Handler => null,
+                  Interrupt => Interrupt_ID (Int),
+                  Static => True,
+                  Restoration => True);
+            end if;
+         end loop;
+      end if;
+   end Finalize_Interrupt_Servers;
+
+   -------------------------------------
+   -- Has_Interrupt_Or_Attach_Handler --
+   -------------------------------------
+
+   function Has_Interrupt_Or_Attach_Handler
+     (Object : access Dynamic_Interrupt_Protection)
+      return   Boolean
+   is
+      pragma Unreferenced (Object);
+   begin
+      return True;
+   end Has_Interrupt_Or_Attach_Handler;
+
+   function Has_Interrupt_Or_Attach_Handler
+     (Object : access Static_Interrupt_Protection)
+      return   Boolean
+   is
+      pragma Unreferenced (Object);
+   begin
+      return True;
+   end Has_Interrupt_Or_Attach_Handler;
+
+   ----------------------
+   -- Ignore_Interrupt --
+   ----------------------
+
+   procedure Ignore_Interrupt (Interrupt : Interrupt_ID) is
+   begin
+      Unimplemented ("Ignore_Interrupt");
+   end Ignore_Interrupt;
+
+   ----------------------------
+   -- Install_Default_Action --
+   ----------------------------
+
+   procedure Install_Default_Action (Interrupt : HW_Interrupt) is
+   begin
+      --  Restore original interrupt handler
+
+      Interrupt_Vector_Set
+        (System.OS_Interface.Interrupt_Number_To_Vector (int (Interrupt)),
+         Default_Handler (Interrupt));
+      Default_Handler (Interrupt) := null;
+   end Install_Default_Action;
+
+   ----------------------
+   -- Install_Handlers --
+   ----------------------
+
+   procedure Install_Handlers
+     (Object       : access Static_Interrupt_Protection;
+      New_Handlers : New_Handler_Array)
+   is
+   begin
+      for N in New_Handlers'Range loop
+
+         --  We need a lock around this ???
+
+         Object.Previous_Handlers (N).Interrupt := New_Handlers (N).Interrupt;
+         Object.Previous_Handlers (N).Static    := User_Handler
+           (New_Handlers (N).Interrupt).Static;
+
+         --  We call Exchange_Handler and not directly Interrupt_Manager.
+         --  Exchange_Handler so we get the Is_Reserved check.
+
+         Exchange_Handler
+           (Old_Handler => Object.Previous_Handlers (N).Handler,
+            New_Handler => New_Handlers (N).Handler,
+            Interrupt   => New_Handlers (N).Interrupt,
+            Static      => True);
+      end loop;
+   end Install_Handlers;
+
+   ------------------------------
+   -- Install_Umbrella_Handler --
+   ------------------------------
+
+   procedure Install_Umbrella_Handler
+     (Interrupt : HW_Interrupt;
+      Handler   : System.OS_Interface.Interrupt_Handler)
+   is
+      Vec : constant Interrupt_Vector :=
+              Interrupt_Number_To_Vector (int (Interrupt));
+
+      Old_Handler : constant System.OS_Interface.Interrupt_Handler :=
+         Interrupt_Vector_Get (Interrupt_Number_To_Vector (int (Interrupt)));
+
+      Status : int;
+      pragma Unreferenced (Status);
+      --  ??? shouldn't we test Stat at least in a pragma Assert?
+   begin
+      --  Only install umbrella handler when no Ada handler has already been
+      --  installed. Note that the interrupt number is passed as a parameter
+      --  when an interrupt occurs, so the umbrella handler has a different
+      --  wrapper generated by intConnect for each interrupt number.
+
+      if Default_Handler (Interrupt) = null then
+         Status := Interrupt_Connect
+            (Vec, Handler, System.Address (Interrupt));
+         Default_Handler (Interrupt) := Old_Handler;
+      end if;
+   end Install_Umbrella_Handler;
+
+   ----------------
+   -- Is_Blocked --
+   ----------------
+
+   function Is_Blocked (Interrupt : Interrupt_ID) return Boolean is
+   begin
+      Unimplemented ("Is_Blocked");
+      return False;
+   end Is_Blocked;
+
+   -----------------------
+   -- Is_Entry_Attached --
+   -----------------------
+
+   function Is_Entry_Attached (Interrupt : Interrupt_ID) return Boolean is
+   begin
+      Check_Reserved_Interrupt (Interrupt);
+      return User_Entry (Interrupt).T /= Null_Task;
+   end Is_Entry_Attached;
+
+   -------------------------
+   -- Is_Handler_Attached --
+   -------------------------
+
+   function Is_Handler_Attached (Interrupt : Interrupt_ID) return Boolean is
+   begin
+      Check_Reserved_Interrupt (Interrupt);
+      return User_Handler (Interrupt).H /= null;
+   end Is_Handler_Attached;
+
+   ----------------
+   -- Is_Ignored --
+   ----------------
+
+   function Is_Ignored (Interrupt : Interrupt_ID) return Boolean is
+   begin
+      Unimplemented ("Is_Ignored");
+      return False;
+   end Is_Ignored;
+
+   -------------------
+   -- Is_Registered --
+   -------------------
+
+   function Is_Registered (Handler : Parameterless_Handler) return Boolean is
+      type Fat_Ptr is record
+         Object_Addr  : System.Address;
+         Handler_Addr : System.Address;
+      end record;
+
+      function To_Fat_Ptr is new Unchecked_Conversion
+        (Parameterless_Handler, Fat_Ptr);
+
+      Ptr : R_Link;
+      Fat : Fat_Ptr;
+
+   begin
+      if Handler = null then
+         return True;
+      end if;
+
+      Fat := To_Fat_Ptr (Handler);
+
+      Ptr := Registered_Handler_Head;
+
+      while Ptr /= null loop
+         if Ptr.H = Fat.Handler_Addr then
+            return True;
+         end if;
+
+         Ptr := Ptr.Next;
+      end loop;
+
+      return False;
+   end Is_Registered;
+
+   -----------------
+   -- Is_Reserved --
+   -----------------
+
+   function Is_Reserved (Interrupt : Interrupt_ID) return Boolean is
+      use System.Interrupt_Management;
+   begin
+      return Reserve (System.Interrupt_Management.Interrupt_ID (Interrupt));
+   end Is_Reserved;
+
+   ----------------------
+   -- Notify_Interrupt --
+   ----------------------
+
+   --  Umbrella handler for vectored hardware interrupts (as opposed to
+   --  signals and exceptions).  As opposed to the signal implementation,
+   --  this handler is only installed in the vector table while there is
+   --  an active association of an Ada handler to the interrupt.
+
+   --  Otherwise, the handler that existed prior to program startup is
+   --  in the vector table.  This ensures that handlers installed by
+   --  the BSP are active unless explicitly replaced in the program text.
+
+   --  Each Interrupt_Server_Task has an associated binary semaphore
+   --  on which it pends once it's been started.  This routine determines
+   --  The appropriate semaphore and and issues a Binary_Semaphore_Release
+   --  call, waking the server task.  When a handler is unbound,
+   --  System.Interrupts.Unbind_Handler issues a Binary_Semaphore_Flush,
+   --  and the server task deletes its semaphore and terminates.
+
+   procedure Notify_Interrupt (Param : System.Address) is
+      Interrupt : constant Interrupt_ID := Interrupt_ID (Param);
+
+      Status : int;
+      pragma Unreferenced (Status);
+      --  ??? shouldn't we test Stat at least in a pragma Assert?
+   begin
+      Status := Binary_Semaphore_Release (Semaphore_ID_Map (Interrupt));
+   end Notify_Interrupt;
+
+   ---------------
+   -- Reference --
+   ---------------
+
+   function Reference (Interrupt : Interrupt_ID) return System.Address is
+   begin
+      Check_Reserved_Interrupt (Interrupt);
+      return Storage_Elements.To_Address
+        (Storage_Elements.Integer_Address (Interrupt));
+   end Reference;
+
+   --------------------------------
+   -- Register_Interrupt_Handler --
+   --------------------------------
+
+   procedure Register_Interrupt_Handler (Handler_Addr : System.Address) is
+      New_Node_Ptr : R_Link;
+
+   begin
+      --  This routine registers a handler as usable for dynamic
+      --  interrupt handler association. Routines attaching and detaching
+      --  handlers dynamically should determine whether the handler is
+      --  registered. Program_Error should be raised if it is not registered.
+
+      --  Pragma Interrupt_Handler can only appear in a library
+      --  level PO definition and instantiation. Therefore, we do not need
+      --  to implement an unregister operation. Nor do we need to
+      --  protect the queue structure with a lock.
+
+      pragma Assert (Handler_Addr /= System.Null_Address);
+
+      New_Node_Ptr := new Registered_Handler;
+      New_Node_Ptr.H := Handler_Addr;
+
+      if Registered_Handler_Head = null then
+         Registered_Handler_Head := New_Node_Ptr;
+         Registered_Handler_Tail := New_Node_Ptr;
+
+      else
+         Registered_Handler_Tail.Next := New_Node_Ptr;
+         Registered_Handler_Tail := New_Node_Ptr;
+      end if;
+   end Register_Interrupt_Handler;
+
+   -----------------------
+   -- Unblock_Interrupt --
+   -----------------------
+
+   procedure Unblock_Interrupt (Interrupt : Interrupt_ID) is
+   begin
+      Unimplemented ("Unblock_Interrupt");
+   end Unblock_Interrupt;
+
+   ------------------
+   -- Unblocked_By --
+   ------------------
+
+   function Unblocked_By
+     (Interrupt : Interrupt_ID) return System.Tasking.Task_Id
+   is
+   begin
+      Unimplemented ("Unblocked_By");
+      return Null_Task;
+   end Unblocked_By;
+
+   ------------------------
+   -- Unignore_Interrupt --
+   ------------------------
+
+   procedure Unignore_Interrupt (Interrupt : Interrupt_ID) is
+   begin
+      Unimplemented ("Unignore_Interrupt");
+   end Unignore_Interrupt;
+
+   -------------------
+   -- Unimplemented --
+   -------------------
+
+   procedure Unimplemented (Feature : String) is
+   begin
+      Raise_Exception
+        (Program_Error'Identity,
+         Feature & " not implemented for hardware interrupts");
+   end Unimplemented;
+
+   -----------------------
+   -- Interrupt_Manager --
+   -----------------------
+
+   task body Interrupt_Manager is
+
+      --------------------
+      -- Local Routines --
+      --------------------
+
+      procedure Bind_Handler (Interrupt : Interrupt_ID);
+      --  This procedure does not do anything if a signal is blocked.
+      --  Otherwise, we have to interrupt Server_Task for status change through
+      --  a wakeup signal.
+
+      procedure Unbind_Handler (Interrupt : Interrupt_ID);
+      --  This procedure does not do anything if a signal is blocked.
+      --  Otherwise, we have to interrupt Server_Task for status change
+      --  through an abort signal.
+
+      procedure Unprotected_Exchange_Handler
+        (Old_Handler : out Parameterless_Handler;
+         New_Handler : Parameterless_Handler;
+         Interrupt   : Interrupt_ID;
+         Static      : Boolean;
+         Restoration : Boolean := False);
+
+      procedure Unprotected_Detach_Handler
+        (Interrupt : Interrupt_ID;
+         Static    : Boolean);
+
+      ------------------
+      -- Bind_Handler --
+      ------------------
+
+      procedure Bind_Handler (Interrupt : Interrupt_ID) is
+      begin
+         Install_Umbrella_Handler
+           (HW_Interrupt (Interrupt), Notify_Interrupt'Access);
+      end Bind_Handler;
+
+      --------------------
+      -- Unbind_Handler --
+      --------------------
+
+      procedure Unbind_Handler (Interrupt : Interrupt_ID) is
+         Status : int;
+         pragma Unreferenced (Status);
+         --  ??? shouldn't we test Stat at least in a pragma Assert?
+      begin
+         --  Hardware interrupt
+
+         Install_Default_Action (HW_Interrupt (Interrupt));
+
+         --  Flush server task off semaphore, allowing it to terminate
+
+         Status := Binary_Semaphore_Flush (Semaphore_ID_Map (Interrupt));
+      end Unbind_Handler;
+
+      --------------------------------
+      -- Unprotected_Detach_Handler --
+      --------------------------------
+
+      procedure Unprotected_Detach_Handler
+        (Interrupt : Interrupt_ID;
+         Static    : Boolean)
+      is
+         Old_Handler : Parameterless_Handler;
+      begin
+         if User_Entry (Interrupt).T /= Null_Task then
+            --  If an interrupt entry is installed raise
+            --  Program_Error. (propagate it to the caller).
+
+            Raise_Exception (Program_Error'Identity,
+              "An interrupt entry is already installed");
+         end if;
+
+         --  Note : Static = True will pass the following check. This is the
+         --  case when we want to detach a handler regardless of the static
+         --  status of the Current_Handler.
+
+         if not Static and then User_Handler (Interrupt).Static then
+
+            --  Trying to detach a static Interrupt Handler. raise
+            --  Program_Error.
+
+            Raise_Exception (Program_Error'Identity,
+              "Trying to detach a static Interrupt Handler");
+         end if;
+
+         Old_Handler := User_Handler (Interrupt).H;
+
+         --  The new handler
+
+         User_Handler (Interrupt).H := null;
+         User_Handler (Interrupt).Static := False;
+
+         if Old_Handler /= null then
+            Unbind_Handler (Interrupt);
+         end if;
+      end Unprotected_Detach_Handler;
+
+      ----------------------------------
+      -- Unprotected_Exchange_Handler --
+      ----------------------------------
+
+      procedure Unprotected_Exchange_Handler
+        (Old_Handler : out Parameterless_Handler;
+         New_Handler : Parameterless_Handler;
+         Interrupt   : Interrupt_ID;
+         Static      : Boolean;
+         Restoration : Boolean := False)
+      is
+      begin
+         if User_Entry (Interrupt).T /= Null_Task then
+
+            --  If an interrupt entry is already installed, raise
+            --  Program_Error. (propagate it to the caller).
+
+            Raise_Exception
+              (Program_Error'Identity,
+               "An interrupt is already installed");
+         end if;
+
+         --  Note : A null handler with Static = True will
+         --  pass the following check. This is the case when we want to
+         --  detach a handler regardless of the Static status
+         --  of Current_Handler.
+         --  We don't check anything if Restoration is True, since we
+         --  may be detaching a static handler to restore a dynamic one.
+
+         if not Restoration and then not Static
+           and then (User_Handler (Interrupt).Static
+
+            --  Trying to overwrite a static Interrupt Handler with a
+            --  dynamic Handler
+
+            --  The new handler is not specified as an
+            --  Interrupt Handler by a pragma.
+
+           or else not Is_Registered (New_Handler))
+         then
+            Raise_Exception
+              (Program_Error'Identity,
+               "Trying to overwrite a static Interrupt Handler with a " &
+               "dynamic Handler");
+         end if;
+
+         --  Save the old handler
+
+         Old_Handler := User_Handler (Interrupt).H;
+
+         --  The new handler
+
+         User_Handler (Interrupt).H := New_Handler;
+
+         if New_Handler = null then
+
+            --  The null handler means we are detaching the handler
+
+            User_Handler (Interrupt).Static := False;
+
+         else
+            User_Handler (Interrupt).Static := Static;
+         end if;
+
+         --  Invoke a corresponding Server_Task if not yet created.
+         --  Place Task_Id info in Server_ID array.
+
+         if New_Handler /= null
+           and then
+            (Server_ID (Interrupt) = Null_Task
+              or else
+                Ada.Task_Identification.Is_Terminated
+                  (To_Ada (Server_ID (Interrupt))))
+         then
+            Interrupt_Access_Hold :=
+              new Interrupt_Server_Task (Interrupt, Binary_Semaphore_Create);
+            Server_ID (Interrupt) :=
+              To_System (Interrupt_Access_Hold.all'Identity);
+         end if;
+
+         if (New_Handler = null) and then Old_Handler /= null then
+
+            --  Restore default handler
+
+            Unbind_Handler (Interrupt);
+
+         elsif Old_Handler = null then
+
+            --  Save default handler
+
+            Bind_Handler (Interrupt);
+         end if;
+      end Unprotected_Exchange_Handler;
+
+      --  Start of processing for Interrupt_Manager
+
+   begin
+      --  By making this task independent of any master, when the process
+      --  goes away, the Interrupt_Manager will terminate gracefully.
+
+      System.Tasking.Utilities.Make_Independent;
+
+      loop
+         --  A block is needed to absorb Program_Error exception
+
+         declare
+            Old_Handler : Parameterless_Handler;
+
+         begin
+            select
+               accept Attach_Handler
+                 (New_Handler : Parameterless_Handler;
+                  Interrupt   : Interrupt_ID;
+                  Static      : Boolean;
+                  Restoration : Boolean := False)
+               do
+                  Unprotected_Exchange_Handler
+                    (Old_Handler, New_Handler, Interrupt, Static, Restoration);
+               end Attach_Handler;
+
+            or
+               accept Exchange_Handler
+                 (Old_Handler : out Parameterless_Handler;
+                  New_Handler : Parameterless_Handler;
+                  Interrupt   : Interrupt_ID;
+                  Static      : Boolean)
+               do
+                  Unprotected_Exchange_Handler
+                    (Old_Handler, New_Handler, Interrupt, Static);
+               end Exchange_Handler;
+
+            or
+               accept Detach_Handler
+                  (Interrupt   : Interrupt_ID;
+                   Static      : Boolean)
+               do
+                  Unprotected_Detach_Handler (Interrupt, Static);
+               end Detach_Handler;
+            or
+               accept Bind_Interrupt_To_Entry
+                 (T       : Task_Id;
+                  E       : Task_Entry_Index;
+                  Interrupt : Interrupt_ID)
+               do
+                  --  If there is a binding already (either a procedure or an
+                  --  entry), raise Program_Error (propagate it to the caller).
+
+                  if User_Handler (Interrupt).H /= null
+                    or else User_Entry (Interrupt).T /= Null_Task
+                  then
+                     Raise_Exception
+                       (Program_Error'Identity,
+                        "A binding for this interrupt is already present");
+                  end if;
+
+                  User_Entry (Interrupt) := Entry_Assoc'(T => T, E => E);
+
+                  --  Indicate the attachment of interrupt entry in the ATCB.
+                  --  This is needed so when an interrupt entry task terminates
+                  --  the binding can be cleaned. The call to unbinding must be
+                  --  make by the task before it terminates.
+
+                  T.Interrupt_Entry := True;
+
+                  --  Invoke a corresponding Server_Task if not yet created.
+                  --  Place Task_Id info in Server_ID array.
+
+                  if Server_ID (Interrupt) = Null_Task
+                    or else
+                      Ada.Task_Identification.Is_Terminated
+                        (To_Ada (Server_ID (Interrupt)))
+                  then
+                     Interrupt_Access_Hold := new Interrupt_Server_Task
+                       (Interrupt, Binary_Semaphore_Create);
+                     Server_ID (Interrupt) :=
+                       To_System (Interrupt_Access_Hold.all'Identity);
+                  end if;
+
+                  Bind_Handler (Interrupt);
+               end Bind_Interrupt_To_Entry;
+
+            or
+               accept Detach_Interrupt_Entries (T : Task_Id) do
+                  for Int in Interrupt_ID'Range loop
+                     if not Is_Reserved (Int) then
+                        if User_Entry (Int).T = T then
+                           User_Entry (Int) :=
+                             Entry_Assoc'
+                               (T => Null_Task, E => Null_Task_Entry);
+                           Unbind_Handler (Int);
+                        end if;
+                     end if;
+                  end loop;
+
+                  --  Indicate in ATCB that no interrupt entries are attached
+
+                  T.Interrupt_Entry := False;
+               end Detach_Interrupt_Entries;
+            end select;
+
+         exception
+            --  If there is a Program_Error we just want to propagate it to
+            --  the caller and do not want to stop this task.
+
+            when Program_Error =>
+               null;
+
+            when others =>
+               pragma Assert (False);
+               null;
+         end;
+      end loop;
+
+   exception
+      when Standard'Abort_Signal =>
+         --  Flush interrupt server semaphores, so they can terminate
+         Finalize_Interrupt_Servers;
+         raise;
+   end Interrupt_Manager;
+
+   ---------------------------
+   -- Interrupt_Server_Task --
+   ---------------------------
+
+   --  Server task for vectored hardware interrupt handling
+
+   task body Interrupt_Server_Task is
+      Self_Id         : constant Task_Id := Self;
+      Tmp_Handler     : Parameterless_Handler;
+      Tmp_ID          : Task_Id;
+      Tmp_Entry_Index : Task_Entry_Index;
+
+      Status : int;
+      pragma Unreferenced (Status);
+      --  ??? shouldn't we test Stat at least in a pragma Assert?
+   begin
+      System.Tasking.Utilities.Make_Independent;
+      Semaphore_ID_Map (Interrupt) := Int_Sema;
+
+      loop
+         --  Pend on semaphore that will be triggered by the
+         --  umbrella handler when the associated interrupt comes in
+
+         Status := Binary_Semaphore_Obtain (Int_Sema);
+
+         if User_Handler (Interrupt).H /= null then
+
+            --  Protected procedure handler
+
+            Tmp_Handler := User_Handler (Interrupt).H;
+            Tmp_Handler.all;
+
+         elsif User_Entry (Interrupt).T /= Null_Task then
+
+            --  Interrupt entry handler
+
+            Tmp_ID := User_Entry (Interrupt).T;
+            Tmp_Entry_Index := User_Entry (Interrupt).E;
+            System.Tasking.Rendezvous.Call_Simple
+              (Tmp_ID, Tmp_Entry_Index, System.Null_Address);
+
+         else
+            --  Semaphore has been flushed by an unbind operation in
+            --  the Interrupt_Manager. Terminate the server task.
+
+            --  Wait for the Interrupt_Manager to complete its work
+
+            POP.Write_Lock (Self_Id);
+
+            --  Delete the associated semaphore
+
+            Status := Binary_Semaphore_Delete (Int_Sema);
+
+            --  Set status for the Interrupt_Manager
+
+            Semaphore_ID_Map (Interrupt) := 0;
+            Server_ID (Interrupt) := Null_Task;
+            POP.Unlock (Self_Id);
+
+            exit;
+         end if;
+      end loop;
+   end Interrupt_Server_Task;
+
+begin
+   --  Get Interrupt_Manager's ID so that Abort_Interrupt can be sent
+
+   Interrupt_Manager_ID := To_System (Interrupt_Manager'Identity);
+end System.Interrupts;
diff -urN gcc-4.3.2-orig/gcc/ada/s-interr-vxworks.adb gcc-4.3.2/gcc/ada/s-interr-vxworks.adb
--- gcc-4.3.2-orig/gcc/ada/s-interr-vxworks.adb	2007-06-06 05:13:44.000000000 -0500
+++ gcc-4.3.2/gcc/ada/s-interr-vxworks.adb	1969-12-31 18:00:00.000000000 -0600
@@ -1,1147 +0,0 @@
-------------------------------------------------------------------------------
---                                                                          --
---                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
---                                                                          --
---                     S Y S T E M . I N T E R R U P T S                    --
---                                                                          --
---                                  B o d y                                 --
---                                                                          --
---         Copyright (C) 1992-2007, 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- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
--- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
--- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- 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,  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  unit  does not  by itself cause  the resulting  executable  to  be --
--- covered  by the  GNU  General  Public  License.  This exception does not --
--- however invalidate  any other reasons why  the executable file  might be --
--- covered by the  GNU Public License.                                      --
---                                                                          --
--- GNARL was developed by the GNARL team at Florida State University.       --
--- Extensive contributions were provided by Ada Core Technologies, Inc.     --
---                                                                          --
-------------------------------------------------------------------------------
-
---  Invariants:
-
---  All user-handleable signals are masked at all times in all tasks/threads
---  except possibly for the Interrupt_Manager task.
-
---  When a user task wants to have the effect of masking/unmasking an signal,
---  it must call Block_Interrupt/Unblock_Interrupt, which will have the effect
---  of unmasking/masking the signal in the Interrupt_Manager task. These
---  comments do not apply to vectored hardware interrupts, which may be masked
---  or unmasked using routined interfaced to the relevant VxWorks system
---  calls.
-
---  Once we associate a Signal_Server_Task with an signal, the task never goes
---  away, and we never remove the association. On the other hand, it is more
---  convenient to terminate an associated Interrupt_Server_Task for a vectored
---  hardware interrupt (since we use a binary semaphore for synchronization
---  with the umbrella handler).
-
---  There is no more than one signal per Signal_Server_Task and no more than
---  one Signal_Server_Task per signal. The same relation holds for hardware
---  interrupts and Interrupt_Server_Task's at any given time. That is, only
---  one non-terminated Interrupt_Server_Task exists for a give interrupt at
---  any time.
-
---  Within this package, the lock L is used to protect the various status
---  tables. If there is a Server_Task associated with a signal or interrupt,
---  we use the per-task lock of the Server_Task instead so that we protect the
---  status between Interrupt_Manager and Server_Task. Protection among
---  service requests are ensured via user calls to the Interrupt_Manager
---  entries.
-
---  This is the VxWorks version of this package, supporting vectored hardware
---  interrupts.
-
-with Ada.Unchecked_Conversion;
-
-with System.OS_Interface; use System.OS_Interface;
-
-with Interfaces.VxWorks;
-
-with Ada.Task_Identification;
---  used for Task_Id type
-
-with Ada.Exceptions;
---  used for Raise_Exception
-
-with System.Interrupt_Management;
---  used for Reserve
-
-with System.Task_Primitives.Operations;
---  used for Write_Lock
---           Unlock
---           Abort
---           Wakeup_Task
---           Sleep
---           Initialize_Lock
-
-with System.Storage_Elements;
---  used for To_Address
---           To_Integer
---           Integer_Address
-
-with System.Tasking.Utilities;
---  used for Make_Independent
-
-with System.Tasking.Rendezvous;
---  used for Call_Simple
-pragma Elaborate_All (System.Tasking.Rendezvous);
-
-package body System.Interrupts is
-
-   use Tasking;
-   use Ada.Exceptions;
-
-   package POP renames System.Task_Primitives.Operations;
-
-   function To_Ada is new Ada.Unchecked_Conversion
-     (System.Tasking.Task_Id, Ada.Task_Identification.Task_Id);
-
-   function To_System is new Ada.Unchecked_Conversion
-     (Ada.Task_Identification.Task_Id, Task_Id);
-
-   -----------------
-   -- Local Tasks --
-   -----------------
-
-   --  WARNING: System.Tasking.Stages performs calls to this task with
-   --  low-level constructs. Do not change this spec without synchronizing it.
-
-   task Interrupt_Manager is
-      entry Detach_Interrupt_Entries (T : Task_Id);
-
-      entry Attach_Handler
-        (New_Handler : Parameterless_Handler;
-         Interrupt   : Interrupt_ID;
-         Static      : Boolean;
-         Restoration : Boolean := False);
-
-      entry Exchange_Handler
-        (Old_Handler : out Parameterless_Handler;
-         New_Handler : Parameterless_Handler;
-         Interrupt   : Interrupt_ID;
-         Static      : Boolean);
-
-      entry Detach_Handler
-        (Interrupt : Interrupt_ID;
-         Static    : Boolean);
-
-      entry Bind_Interrupt_To_Entry
-        (T         : Task_Id;
-         E         : Task_Entry_Index;
-         Interrupt : Interrupt_ID);
-
-      pragma Interrupt_Priority (System.Interrupt_Priority'First);
-   end Interrupt_Manager;
-
-   task type Interrupt_Server_Task
-     (Interrupt : Interrupt_ID; Int_Sema : SEM_ID) is
-      --  Server task for vectored hardware interrupt handling
-      pragma Interrupt_Priority (System.Interrupt_Priority'First + 2);
-   end Interrupt_Server_Task;
-
-   type Interrupt_Task_Access is access Interrupt_Server_Task;
-
-   -------------------------------
-   -- Local Types and Variables --
-   -------------------------------
-
-   type Entry_Assoc is record
-      T : Task_Id;
-      E : Task_Entry_Index;
-   end record;
-
-   type Handler_Assoc is record
-      H      : Parameterless_Handler;
-      Static : Boolean;   --  Indicates static binding;
-   end record;
-
-   User_Handler : array (Interrupt_ID) of Handler_Assoc :=
-     (others => (null, Static => False));
-   pragma Volatile_Components (User_Handler);
-   --  Holds the protected procedure handler (if any) and its Static
-   --  information  for each interrupt or signal. A handler is static
-   --  iff it is specified through the pragma Attach_Handler.
-
-   User_Entry : array (Interrupt_ID) of Entry_Assoc :=
-     (others => (T => Null_Task, E => Null_Task_Entry));
-   pragma Volatile_Components (User_Entry);
-   --  Holds the task and entry index (if any) for each interrupt / signal
-
-   --  Type and Head, Tail of the list containing Registered Interrupt
-   --  Handlers. These definitions are used to register the handlers
-   --  specified by the pragma Interrupt_Handler.
-
-   type Registered_Handler;
-   type R_Link is access all Registered_Handler;
-
-   type Registered_Handler is record
-      H    : System.Address := System.Null_Address;
-      Next : R_Link := null;
-   end record;
-
-   Registered_Handler_Head : R_Link := null;
-   Registered_Handler_Tail : R_Link := null;
-
-   Server_ID : array (Interrupt_ID) of System.Tasking.Task_Id :=
-     (others => System.Tasking.Null_Task);
-   pragma Atomic_Components (Server_ID);
-   --  Holds the Task_Id of the Server_Task for each interrupt / signal.
-   --  Task_Id is needed to accomplish locking per interrupt base. Also
-   --  is needed to determine whether to create a new Server_Task.
-
-   Semaphore_ID_Map : array
-     (Interrupt_ID range 0 .. System.OS_Interface.Max_HW_Interrupt)
-      of SEM_ID := (others => 0);
-   --  Array of binary semaphores associated with vectored interrupts
-   --  Note that the last bound should be Max_HW_Interrupt, but this will raise
-   --  Storage_Error if Num_HW_Interrupts is null, so use an extra 4 bytes
-   --  instead.
-
-   Interrupt_Access_Hold : Interrupt_Task_Access;
-   --  Variable for allocating an Interrupt_Server_Task
-
-   Default_Handler : array (HW_Interrupt) of Interfaces.VxWorks.VOIDFUNCPTR;
-   --  Vectored interrupt handlers installed prior to program startup.
-   --  These are saved only when the umbrella handler is installed for
-   --  a given interrupt number.
-
-   -----------------------
-   -- Local Subprograms --
-   -----------------------
-
-   procedure Check_Reserved_Interrupt (Interrupt : Interrupt_ID);
-   --  Check if Id is a reserved interrupt, and if so raise Program_Error
-   --  with an appropriate message, otherwise return.
-
-   procedure Finalize_Interrupt_Servers;
-   --  Unbind the handlers for hardware interrupt server tasks at program
-   --  termination.
-
-   function Is_Registered (Handler : Parameterless_Handler) return Boolean;
-   --  See if Handler has been "pragma"ed using Interrupt_Handler.
-   --  Always consider a null handler as registered.
-
-   procedure Notify_Interrupt (Param : System.Address);
-   --  Umbrella handler for vectored interrupts (not signals)
-
-   procedure Install_Default_Action (Interrupt : HW_Interrupt);
-   --  Restore a handler that was in place prior to program execution
-
-   procedure Install_Umbrella_Handler
-     (Interrupt : HW_Interrupt;
-      Handler   : Interfaces.VxWorks.VOIDFUNCPTR);
-   --  Install the runtime umbrella handler for a vectored hardware
-   --  interrupt
-
-   procedure Unimplemented (Feature : String);
-   pragma No_Return (Unimplemented);
-   --  Used to mark a call to an unimplemented function. Raises Program_Error
-   --  with an appropriate message noting that Feature is unimplemented.
-
-   --------------------
-   -- Attach_Handler --
-   --------------------
-
-   --  Calling this procedure with New_Handler = null and Static = True
-   --  means we want to detach the current handler regardless of the
-   --  previous handler's binding status (ie. do not care if it is a
-   --  dynamic or static handler).
-
-   --  This option is needed so that during the finalization of a PO, we
-   --  can detach handlers attached through pragma Attach_Handler.
-
-   procedure Attach_Handler
-     (New_Handler : Parameterless_Handler;
-      Interrupt   : Interrupt_ID;
-      Static      : Boolean := False) is
-   begin
-      Check_Reserved_Interrupt (Interrupt);
-      Interrupt_Manager.Attach_Handler (New_Handler, Interrupt, Static);
-   end Attach_Handler;
-
-   -----------------------------
-   -- Bind_Interrupt_To_Entry --
-   -----------------------------
-
-   --  This procedure raises a Program_Error if it tries to
-   --  bind an interrupt to which an Entry or a Procedure is
-   --  already bound.
-
-   procedure Bind_Interrupt_To_Entry
-     (T       : Task_Id;
-      E       : Task_Entry_Index;
-      Int_Ref : System.Address)
-   is
-      Interrupt : constant Interrupt_ID :=
-        Interrupt_ID (Storage_Elements.To_Integer (Int_Ref));
-
-   begin
-      Check_Reserved_Interrupt (Interrupt);
-      Interrupt_Manager.Bind_Interrupt_To_Entry (T, E, Interrupt);
-   end Bind_Interrupt_To_Entry;
-
-   ---------------------
-   -- Block_Interrupt --
-   ---------------------
-
-   procedure Block_Interrupt (Interrupt : Interrupt_ID) is
-   begin
-      Unimplemented ("Block_Interrupt");
-   end Block_Interrupt;
-
-   ------------------------------
-   -- Check_Reserved_Interrupt --
-   ------------------------------
-
-   procedure Check_Reserved_Interrupt (Interrupt : Interrupt_ID) is
-   begin
-      if Is_Reserved (Interrupt) then
-         Raise_Exception
-           (Program_Error'Identity,
-            "Interrupt" & Interrupt_ID'Image (Interrupt) & " is reserved");
-      else
-         return;
-      end if;
-   end Check_Reserved_Interrupt;
-
-   ---------------------
-   -- Current_Handler --
-   ---------------------
-
-   function Current_Handler
-     (Interrupt : Interrupt_ID) return Parameterless_Handler
-   is
-   begin
-      Check_Reserved_Interrupt (Interrupt);
-
-      --  ??? Since Parameterless_Handler is not Atomic, the
-      --  current implementation is wrong. We need a new service in
-      --  Interrupt_Manager to ensure atomicity.
-
-      return User_Handler (Interrupt).H;
-   end Current_Handler;
-
-   --------------------
-   -- Detach_Handler --
-   --------------------
-
-   --  Calling this procedure with Static = True means we want to Detach the
-   --  current handler regardless of the previous handler's binding status
-   --  (i.e. do not care if it is a dynamic or static handler).
-
-   --  This option is needed so that during the finalization of a PO, we can
-   --  detach handlers attached through pragma Attach_Handler.
-
-   procedure Detach_Handler
-     (Interrupt : Interrupt_ID;
-      Static    : Boolean := False) is
-   begin
-      Check_Reserved_Interrupt (Interrupt);
-      Interrupt_Manager.Detach_Handler (Interrupt, Static);
-   end Detach_Handler;
-
-   ------------------------------
-   -- Detach_Interrupt_Entries --
-   ------------------------------
-
-   procedure Detach_Interrupt_Entries (T : Task_Id) is
-   begin
-      Interrupt_Manager.Detach_Interrupt_Entries (T);
-   end Detach_Interrupt_Entries;
-
-   ----------------------
-   -- Exchange_Handler --
-   ----------------------
-
-   --  Calling this procedure with New_Handler = null and Static = True
-   --  means we want to detach the current handler regardless of the
-   --  previous handler's binding status (ie. do not care if it is a
-   --  dynamic or static handler).
-
-   --  This option is needed so that during the finalization of a PO, we
-   --  can detach handlers attached through pragma Attach_Handler.
-
-   procedure Exchange_Handler
-     (Old_Handler : out Parameterless_Handler;
-      New_Handler : Parameterless_Handler;
-      Interrupt   : Interrupt_ID;
-      Static      : Boolean := False)
-   is
-   begin
-      Check_Reserved_Interrupt (Interrupt);
-      Interrupt_Manager.Exchange_Handler
-        (Old_Handler, New_Handler, Interrupt, Static);
-   end Exchange_Handler;
-
-   --------------
-   -- Finalize --
-   --------------
-
-   procedure Finalize (Object : in out Static_Interrupt_Protection) is
-   begin
-      --  ??? loop to be executed only when we're not doing library level
-      --  finalization, since in this case all interrupt / signal tasks are
-      --  gone.
-
-      if not Interrupt_Manager'Terminated then
-         for N in reverse Object.Previous_Handlers'Range loop
-            Interrupt_Manager.Attach_Handler
-              (New_Handler => Object.Previous_Handlers (N).Handler,
-               Interrupt   => Object.Previous_Handlers (N).Interrupt,
-               Static      => Object.Previous_Handlers (N).Static,
-               Restoration => True);
-         end loop;
-      end if;
-
-      Tasking.Protected_Objects.Entries.Finalize
-        (Tasking.Protected_Objects.Entries.Protection_Entries (Object));
-   end Finalize;
-
-   --------------------------------
-   -- Finalize_Interrupt_Servers --
-   --------------------------------
-
-   --  Restore default handlers for interrupt servers
-
-   --  This is called by the Interrupt_Manager task when it receives the abort
-   --  signal during program finalization.
-
-   procedure Finalize_Interrupt_Servers is
-      HW_Interrupts : constant Boolean := HW_Interrupt'Last >= 0;
-
-   begin
-      if HW_Interrupts then
-         for Int in HW_Interrupt loop
-            if Server_ID (Interrupt_ID (Int)) /= null
-              and then
-                not Ada.Task_Identification.Is_Terminated
-                 (To_Ada (Server_ID (Interrupt_ID (Int))))
-            then
-               Interrupt_Manager.Attach_Handler
-                 (New_Handler => null,
-                  Interrupt => Interrupt_ID (Int),
-                  Static => True,
-                  Restoration => True);
-            end if;
-         end loop;
-      end if;
-   end Finalize_Interrupt_Servers;
-
-   -------------------------------------
-   -- Has_Interrupt_Or_Attach_Handler --
-   -------------------------------------
-
-   function Has_Interrupt_Or_Attach_Handler
-     (Object : access Dynamic_Interrupt_Protection)
-      return   Boolean
-   is
-      pragma Unreferenced (Object);
-   begin
-      return True;
-   end Has_Interrupt_Or_Attach_Handler;
-
-   function Has_Interrupt_Or_Attach_Handler
-     (Object : access Static_Interrupt_Protection)
-      return   Boolean
-   is
-      pragma Unreferenced (Object);
-   begin
-      return True;
-   end Has_Interrupt_Or_Attach_Handler;
-
-   ----------------------
-   -- Ignore_Interrupt --
-   ----------------------
-
-   procedure Ignore_Interrupt (Interrupt : Interrupt_ID) is
-   begin
-      Unimplemented ("Ignore_Interrupt");
-   end Ignore_Interrupt;
-
-   ----------------------------
-   -- Install_Default_Action --
-   ----------------------------
-
-   procedure Install_Default_Action (Interrupt : HW_Interrupt) is
-   begin
-      --  Restore original interrupt handler
-
-      Interfaces.VxWorks.intVecSet
-        (Interfaces.VxWorks.INUM_TO_IVEC (Integer (Interrupt)),
-         Default_Handler (Interrupt));
-      Default_Handler (Interrupt) := null;
-   end Install_Default_Action;
-
-   ----------------------
-   -- Install_Handlers --
-   ----------------------
-
-   procedure Install_Handlers
-     (Object       : access Static_Interrupt_Protection;
-      New_Handlers : New_Handler_Array)
-   is
-   begin
-      for N in New_Handlers'Range loop
-
-         --  We need a lock around this ???
-
-         Object.Previous_Handlers (N).Interrupt := New_Handlers (N).Interrupt;
-         Object.Previous_Handlers (N).Static    := User_Handler
-           (New_Handlers (N).Interrupt).Static;
-
-         --  We call Exchange_Handler and not directly Interrupt_Manager.
-         --  Exchange_Handler so we get the Is_Reserved check.
-
-         Exchange_Handler
-           (Old_Handler => Object.Previous_Handlers (N).Handler,
-            New_Handler => New_Handlers (N).Handler,
-            Interrupt   => New_Handlers (N).Interrupt,
-            Static      => True);
-      end loop;
-   end Install_Handlers;
-
-   ------------------------------
-   -- Install_Umbrella_Handler --
-   ------------------------------
-
-   procedure Install_Umbrella_Handler
-     (Interrupt : HW_Interrupt;
-      Handler   : Interfaces.VxWorks.VOIDFUNCPTR)
-   is
-      use Interfaces.VxWorks;
-
-      Vec : constant Interrupt_Vector :=
-              INUM_TO_IVEC (Interfaces.VxWorks.int (Interrupt));
-
-      Old_Handler : constant VOIDFUNCPTR :=
-                      intVecGet
-                        (INUM_TO_IVEC (Interfaces.VxWorks.int (Interrupt)));
-
-      Stat : Interfaces.VxWorks.STATUS;
-      pragma Unreferenced (Stat);
-      --  ??? shouldn't we test Stat at least in a pragma Assert?
-
-   begin
-      --  Only install umbrella handler when no Ada handler has already been
-      --  installed. Note that the interrupt number is passed as a parameter
-      --  when an interrupt occurs, so the umbrella handler has a different
-      --  wrapper generated by intConnect for each interrupt number.
-
-      if Default_Handler (Interrupt) = null then
-         Stat :=
-           intConnect (Vec, Handler, System.Address (Interrupt));
-         Default_Handler (Interrupt) := Old_Handler;
-      end if;
-   end Install_Umbrella_Handler;
-
-   ----------------
-   -- Is_Blocked --
-   ----------------
-
-   function Is_Blocked (Interrupt : Interrupt_ID) return Boolean is
-   begin
-      Unimplemented ("Is_Blocked");
-      return False;
-   end Is_Blocked;
-
-   -----------------------
-   -- Is_Entry_Attached --
-   -----------------------
-
-   function Is_Entry_Attached (Interrupt : Interrupt_ID) return Boolean is
-   begin
-      Check_Reserved_Interrupt (Interrupt);
-      return User_Entry (Interrupt).T /= Null_Task;
-   end Is_Entry_Attached;
-
-   -------------------------
-   -- Is_Handler_Attached --
-   -------------------------
-
-   function Is_Handler_Attached (Interrupt : Interrupt_ID) return Boolean is
-   begin
-      Check_Reserved_Interrupt (Interrupt);
-      return User_Handler (Interrupt).H /= null;
-   end Is_Handler_Attached;
-
-   ----------------
-   -- Is_Ignored --
-   ----------------
-
-   function Is_Ignored (Interrupt : Interrupt_ID) return Boolean is
-   begin
-      Unimplemented ("Is_Ignored");
-      return False;
-   end Is_Ignored;
-
-   -------------------
-   -- Is_Registered --
-   -------------------
-
-   function Is_Registered (Handler : Parameterless_Handler) return Boolean is
-      type Fat_Ptr is record
-         Object_Addr  : System.Address;
-         Handler_Addr : System.Address;
-      end record;
-
-      function To_Fat_Ptr is new Ada.Unchecked_Conversion
-        (Parameterless_Handler, Fat_Ptr);
-
-      Ptr : R_Link;
-      Fat : Fat_Ptr;
-
-   begin
-      if Handler = null then
-         return True;
-      end if;
-
-      Fat := To_Fat_Ptr (Handler);
-
-      Ptr := Registered_Handler_Head;
-
-      while Ptr /= null loop
-         if Ptr.H = Fat.Handler_Addr then
-            return True;
-         end if;
-
-         Ptr := Ptr.Next;
-      end loop;
-
-      return False;
-   end Is_Registered;
-
-   -----------------
-   -- Is_Reserved --
-   -----------------
-
-   function Is_Reserved (Interrupt : Interrupt_ID) return Boolean is
-      use System.Interrupt_Management;
-   begin
-      return Reserve (System.Interrupt_Management.Interrupt_ID (Interrupt));
-   end Is_Reserved;
-
-   ----------------------
-   -- Notify_Interrupt --
-   ----------------------
-
-   --  Umbrella handler for vectored hardware interrupts (as opposed to
-   --  signals and exceptions).  As opposed to the signal implementation,
-   --  this handler is only installed in the vector table while there is
-   --  an active association of an Ada handler to the interrupt.
-
-   --  Otherwise, the handler that existed prior to program startup is
-   --  in the vector table.  This ensures that handlers installed by
-   --  the BSP are active unless explicitly replaced in the program text.
-
-   --  Each Interrupt_Server_Task has an associated binary semaphore
-   --  on which it pends once it's been started.  This routine determines
-   --  The appropriate semaphore and and issues a semGive call, waking
-   --  the server task.  When a handler is unbound,
-   --  System.Interrupts.Unbind_Handler issues a semFlush, and the
-   --  server task deletes its semaphore and terminates.
-
-   procedure Notify_Interrupt (Param : System.Address) is
-      Interrupt : constant Interrupt_ID := Interrupt_ID (Param);
-
-      Discard_Result : STATUS;
-      pragma Unreferenced (Discard_Result);
-
-   begin
-      Discard_Result := semGive (Semaphore_ID_Map (Interrupt));
-   end Notify_Interrupt;
-
-   ---------------
-   -- Reference --
-   ---------------
-
-   function Reference (Interrupt : Interrupt_ID) return System.Address is
-   begin
-      Check_Reserved_Interrupt (Interrupt);
-      return Storage_Elements.To_Address
-        (Storage_Elements.Integer_Address (Interrupt));
-   end Reference;
-
-   --------------------------------
-   -- Register_Interrupt_Handler --
-   --------------------------------
-
-   procedure Register_Interrupt_Handler (Handler_Addr : System.Address) is
-      New_Node_Ptr : R_Link;
-
-   begin
-      --  This routine registers a handler as usable for dynamic
-      --  interrupt handler association. Routines attaching and detaching
-      --  handlers dynamically should determine whether the handler is
-      --  registered. Program_Error should be raised if it is not registered.
-
-      --  Pragma Interrupt_Handler can only appear in a library
-      --  level PO definition and instantiation. Therefore, we do not need
-      --  to implement an unregister operation. Nor do we need to
-      --  protect the queue structure with a lock.
-
-      pragma Assert (Handler_Addr /= System.Null_Address);
-
-      New_Node_Ptr := new Registered_Handler;
-      New_Node_Ptr.H := Handler_Addr;
-
-      if Registered_Handler_Head = null then
-         Registered_Handler_Head := New_Node_Ptr;
-         Registered_Handler_Tail := New_Node_Ptr;
-
-      else
-         Registered_Handler_Tail.Next := New_Node_Ptr;
-         Registered_Handler_Tail := New_Node_Ptr;
-      end if;
-   end Register_Interrupt_Handler;
-
-   -----------------------
-   -- Unblock_Interrupt --
-   -----------------------
-
-   procedure Unblock_Interrupt (Interrupt : Interrupt_ID) is
-   begin
-      Unimplemented ("Unblock_Interrupt");
-   end Unblock_Interrupt;
-
-   ------------------
-   -- Unblocked_By --
-   ------------------
-
-   function Unblocked_By
-     (Interrupt : Interrupt_ID) return System.Tasking.Task_Id
-   is
-   begin
-      Unimplemented ("Unblocked_By");
-      return Null_Task;
-   end Unblocked_By;
-
-   ------------------------
-   -- Unignore_Interrupt --
-   ------------------------
-
-   procedure Unignore_Interrupt (Interrupt : Interrupt_ID) is
-   begin
-      Unimplemented ("Unignore_Interrupt");
-   end Unignore_Interrupt;
-
-   -------------------
-   -- Unimplemented --
-   -------------------
-
-   procedure Unimplemented (Feature : String) is
-   begin
-      Raise_Exception
-        (Program_Error'Identity,
-         Feature & " not implemented on VxWorks");
-   end Unimplemented;
-
-   -----------------------
-   -- Interrupt_Manager --
-   -----------------------
-
-   task body Interrupt_Manager is
-
-      --------------------
-      -- Local Routines --
-      --------------------
-
-      procedure Bind_Handler (Interrupt : Interrupt_ID);
-      --  This procedure does not do anything if a signal is blocked.
-      --  Otherwise, we have to interrupt Server_Task for status change through
-      --  a wakeup signal.
-
-      procedure Unbind_Handler (Interrupt : Interrupt_ID);
-      --  This procedure does not do anything if a signal is blocked.
-      --  Otherwise, we have to interrupt Server_Task for status change
-      --  through an abort signal.
-
-      procedure Unprotected_Exchange_Handler
-        (Old_Handler : out Parameterless_Handler;
-         New_Handler : Parameterless_Handler;
-         Interrupt   : Interrupt_ID;
-         Static      : Boolean;
-         Restoration : Boolean := False);
-
-      procedure Unprotected_Detach_Handler
-        (Interrupt : Interrupt_ID;
-         Static    : Boolean);
-
-      ------------------
-      -- Bind_Handler --
-      ------------------
-
-      procedure Bind_Handler (Interrupt : Interrupt_ID) is
-      begin
-         Install_Umbrella_Handler
-           (HW_Interrupt (Interrupt), Notify_Interrupt'Access);
-      end Bind_Handler;
-
-      --------------------
-      -- Unbind_Handler --
-      --------------------
-
-      procedure Unbind_Handler (Interrupt : Interrupt_ID) is
-         S : STATUS;
-         use type STATUS;
-
-      begin
-         --  Hardware interrupt
-
-         Install_Default_Action (HW_Interrupt (Interrupt));
-
-         --  Flush server task off semaphore, allowing it to terminate
-
-         S := semFlush (Semaphore_ID_Map (Interrupt));
-         pragma Assert (S = 0);
-      end Unbind_Handler;
-
-      --------------------------------
-      -- Unprotected_Detach_Handler --
-      --------------------------------
-
-      procedure Unprotected_Detach_Handler
-        (Interrupt : Interrupt_ID;
-         Static    : Boolean)
-      is
-         Old_Handler : Parameterless_Handler;
-      begin
-         if User_Entry (Interrupt).T /= Null_Task then
-            --  If an interrupt entry is installed raise
-            --  Program_Error. (propagate it to the caller).
-
-            Raise_Exception (Program_Error'Identity,
-              "An interrupt entry is already installed");
-         end if;
-
-         --  Note : Static = True will pass the following check. This is the
-         --  case when we want to detach a handler regardless of the static
-         --  status of the Current_Handler.
-
-         if not Static and then User_Handler (Interrupt).Static then
-
-            --  Trying to detach a static Interrupt Handler. raise
-            --  Program_Error.
-
-            Raise_Exception (Program_Error'Identity,
-              "Trying to detach a static Interrupt Handler");
-         end if;
-
-         Old_Handler := User_Handler (Interrupt).H;
-
-         --  The new handler
-
-         User_Handler (Interrupt).H := null;
-         User_Handler (Interrupt).Static := False;
-
-         if Old_Handler /= null then
-            Unbind_Handler (Interrupt);
-         end if;
-      end Unprotected_Detach_Handler;
-
-      ----------------------------------
-      -- Unprotected_Exchange_Handler --
-      ----------------------------------
-
-      procedure Unprotected_Exchange_Handler
-        (Old_Handler : out Parameterless_Handler;
-         New_Handler : Parameterless_Handler;
-         Interrupt   : Interrupt_ID;
-         Static      : Boolean;
-         Restoration : Boolean := False)
-      is
-      begin
-         if User_Entry (Interrupt).T /= Null_Task then
-
-            --  If an interrupt entry is already installed, raise
-            --  Program_Error. (propagate it to the caller).
-
-            Raise_Exception
-              (Program_Error'Identity,
-               "An interrupt is already installed");
-         end if;
-
-         --  Note : A null handler with Static = True will
-         --  pass the following check. This is the case when we want to
-         --  detach a handler regardless of the Static status
-         --  of Current_Handler.
-         --  We don't check anything if Restoration is True, since we
-         --  may be detaching a static handler to restore a dynamic one.
-
-         if not Restoration and then not Static
-           and then (User_Handler (Interrupt).Static
-
-            --  Trying to overwrite a static Interrupt Handler with a
-            --  dynamic Handler
-
-            --  The new handler is not specified as an
-            --  Interrupt Handler by a pragma.
-
-           or else not Is_Registered (New_Handler))
-         then
-            Raise_Exception
-              (Program_Error'Identity,
-               "Trying to overwrite a static Interrupt Handler with a " &
-               "dynamic Handler");
-         end if;
-
-         --  Save the old handler
-
-         Old_Handler := User_Handler (Interrupt).H;
-
-         --  The new handler
-
-         User_Handler (Interrupt).H := New_Handler;
-
-         if New_Handler = null then
-
-            --  The null handler means we are detaching the handler
-
-            User_Handler (Interrupt).Static := False;
-
-         else
-            User_Handler (Interrupt).Static := Static;
-         end if;
-
-         --  Invoke a corresponding Server_Task if not yet created.
-         --  Place Task_Id info in Server_ID array.
-
-         if New_Handler /= null
-           and then
-            (Server_ID (Interrupt) = Null_Task
-              or else
-                Ada.Task_Identification.Is_Terminated
-                  (To_Ada (Server_ID (Interrupt))))
-         then
-            Interrupt_Access_Hold :=
-              new Interrupt_Server_Task
-                (Interrupt, semBCreate (SEM_Q_FIFO, SEM_EMPTY));
-            Server_ID (Interrupt) :=
-              To_System (Interrupt_Access_Hold.all'Identity);
-         end if;
-
-         if (New_Handler = null) and then Old_Handler /= null then
-
-            --  Restore default handler
-
-            Unbind_Handler (Interrupt);
-
-         elsif Old_Handler = null then
-
-            --  Save default handler
-
-            Bind_Handler (Interrupt);
-         end if;
-      end Unprotected_Exchange_Handler;
-
-      --  Start of processing for Interrupt_Manager
-
-   begin
-      --  By making this task independent of any master, when the process
-      --  goes away, the Interrupt_Manager will terminate gracefully.
-
-      System.Tasking.Utilities.Make_Independent;
-
-      loop
-         --  A block is needed to absorb Program_Error exception
-
-         declare
-            Old_Handler : Parameterless_Handler;
-
-         begin
-            select
-               accept Attach_Handler
-                 (New_Handler : Parameterless_Handler;
-                  Interrupt   : Interrupt_ID;
-                  Static      : Boolean;
-                  Restoration : Boolean := False)
-               do
-                  Unprotected_Exchange_Handler
-                    (Old_Handler, New_Handler, Interrupt, Static, Restoration);
-               end Attach_Handler;
-
-            or
-               accept Exchange_Handler
-                 (Old_Handler : out Parameterless_Handler;
-                  New_Handler : Parameterless_Handler;
-                  Interrupt   : Interrupt_ID;
-                  Static      : Boolean)
-               do
-                  Unprotected_Exchange_Handler
-                    (Old_Handler, New_Handler, Interrupt, Static);
-               end Exchange_Handler;
-
-            or
-               accept Detach_Handler
-                  (Interrupt   : Interrupt_ID;
-                   Static      : Boolean)
-               do
-                  Unprotected_Detach_Handler (Interrupt, Static);
-               end Detach_Handler;
-            or
-               accept Bind_Interrupt_To_Entry
-                 (T       : Task_Id;
-                  E       : Task_Entry_Index;
-                  Interrupt : Interrupt_ID)
-               do
-                  --  If there is a binding already (either a procedure or an
-                  --  entry), raise Program_Error (propagate it to the caller).
-
-                  if User_Handler (Interrupt).H /= null
-                    or else User_Entry (Interrupt).T /= Null_Task
-                  then
-                     Raise_Exception
-                       (Program_Error'Identity,
-                        "A binding for this interrupt is already present");
-                  end if;
-
-                  User_Entry (Interrupt) := Entry_Assoc'(T => T, E => E);
-
-                  --  Indicate the attachment of interrupt entry in the ATCB.
-                  --  This is needed so when an interrupt entry task terminates
-                  --  the binding can be cleaned. The call to unbinding must be
-                  --  make by the task before it terminates.
-
-                  T.Interrupt_Entry := True;
-
-                  --  Invoke a corresponding Server_Task if not yet created.
-                  --  Place Task_Id info in Server_ID array.
-
-                  if Server_ID (Interrupt) = Null_Task
-                    or else
-                      Ada.Task_Identification.Is_Terminated
-                        (To_Ada (Server_ID (Interrupt)))
-                  then
-                     Interrupt_Access_Hold := new Interrupt_Server_Task
-                       (Interrupt, semBCreate (SEM_Q_FIFO, SEM_EMPTY));
-                     Server_ID (Interrupt) :=
-                       To_System (Interrupt_Access_Hold.all'Identity);
-                  end if;
-
-                  Bind_Handler (Interrupt);
-               end Bind_Interrupt_To_Entry;
-
-            or
-               accept Detach_Interrupt_Entries (T : Task_Id) do
-                  for Int in Interrupt_ID'Range loop
-                     if not Is_Reserved (Int) then
-                        if User_Entry (Int).T = T then
-                           User_Entry (Int) :=
-                             Entry_Assoc'
-                               (T => Null_Task, E => Null_Task_Entry);
-                           Unbind_Handler (Int);
-                        end if;
-                     end if;
-                  end loop;
-
-                  --  Indicate in ATCB that no interrupt entries are attached
-
-                  T.Interrupt_Entry := False;
-               end Detach_Interrupt_Entries;
-            end select;
-
-         exception
-            --  If there is a Program_Error we just want to propagate it to
-            --  the caller and do not want to stop this task.
-
-            when Program_Error =>
-               null;
-
-            when others =>
-               pragma Assert (False);
-               null;
-         end;
-      end loop;
-
-   exception
-      when Standard'Abort_Signal =>
-         --  Flush interrupt server semaphores, so they can terminate
-         Finalize_Interrupt_Servers;
-         raise;
-   end Interrupt_Manager;
-
-   ---------------------------
-   -- Interrupt_Server_Task --
-   ---------------------------
-
-   --  Server task for vectored hardware interrupt handling
-
-   task body Interrupt_Server_Task is
-      Self_Id         : constant Task_Id := Self;
-      Tmp_Handler     : Parameterless_Handler;
-      Tmp_ID          : Task_Id;
-      Tmp_Entry_Index : Task_Entry_Index;
-      S               : STATUS;
-
-      use type STATUS;
-
-   begin
-      System.Tasking.Utilities.Make_Independent;
-      Semaphore_ID_Map (Interrupt) := Int_Sema;
-
-      loop
-         --  Pend on semaphore that will be triggered by the
-         --  umbrella handler when the associated interrupt comes in
-
-         S := semTake (Int_Sema, WAIT_FOREVER);
-         pragma Assert (S = 0);
-
-         if User_Handler (Interrupt).H /= null then
-
-            --  Protected procedure handler
-
-            Tmp_Handler := User_Handler (Interrupt).H;
-            Tmp_Handler.all;
-
-         elsif User_Entry (Interrupt).T /= Null_Task then
-
-            --  Interrupt entry handler
-
-            Tmp_ID := User_Entry (Interrupt).T;
-            Tmp_Entry_Index := User_Entry (Interrupt).E;
-            System.Tasking.Rendezvous.Call_Simple
-              (Tmp_ID, Tmp_Entry_Index, System.Null_Address);
-
-         else
-            --  Semaphore has been flushed by an unbind operation in
-            --  the Interrupt_Manager. Terminate the server task.
-
-            --  Wait for the Interrupt_Manager to complete its work
-
-            POP.Write_Lock (Self_Id);
-
-            --  Delete the associated semaphore
-
-            S := semDelete (Int_Sema);
-
-            pragma Assert (S = 0);
-
-            --  Set status for the Interrupt_Manager
-
-            Semaphore_ID_Map (Interrupt) := 0;
-            Server_ID (Interrupt) := Null_Task;
-            POP.Unlock (Self_Id);
-
-            exit;
-         end if;
-      end loop;
-   end Interrupt_Server_Task;
-
-begin
-   --  Get Interrupt_Manager's ID so that Abort_Interrupt can be sent
-
-   Interrupt_Manager_ID := To_System (Interrupt_Manager'Identity);
-end System.Interrupts;
diff -urN gcc-4.3.2-orig/gcc/ada/s-osinte-rtems.ads gcc-4.3.2/gcc/ada/s-osinte-rtems.ads
--- gcc-4.3.2-orig/gcc/ada/s-osinte-rtems.ads	2008-02-13 13:04:53.000000000 -0600
+++ gcc-4.3.2/gcc/ada/s-osinte-rtems.ads	2008-09-09 13:07:24.000000000 -0500
@@ -37,15 +37,20 @@
 
 --  This is the RTEMS version of this package
 
---  These are guesses based on what I think the GNARL team will want to
---  call the rtems configurations.  We use CPU-rtems for the rtems
---  configurations.
+--
+--  RTEMS target names are of the form CPU-rtems.
+--  This implementation is designed to work on ALL RTEMS targets.
+--  The RTEMS implementation is primarily based upon the POSIX threads
+--  API but there are also bindings to GNAT/RTEMS support routines
+--  to insulate this code from C API specific details and, in some
+--  cases, obtain target architecture and BSP specific information
+--  that is unavailable at the time this package is built.
 
 --  This package encapsulates all direct interfaces to OS services
 --  that are needed by children of System.
 
 --  PLEASE DO NOT add any with-clauses to this package
---  or remove the pragma Elaborate_Body.
+--  or remove the pragma Preelaborate.
 --  It is designed to be a bottom-level (leaf) package.
 
 with Interfaces.C;
@@ -84,7 +89,13 @@
    -- Signals --
    -------------
 
-   Max_Interrupt : constant := 31;
+   Num_HW_Interrupts : constant := 256;
+
+   Max_HW_Interrupt : constant := Num_HW_Interrupts - 1;
+   type HW_Interrupt is new int range 0 .. Max_HW_Interrupt;
+
+   Max_Interrupt : constant := Max_HW_Interrupt;
+
    type Signal is new int range 0 .. Max_Interrupt;
 
    SIGXCPU     : constant := 0; --  XCPU
@@ -475,6 +486,79 @@
       destructor : destructor_pointer) return int;
    pragma Import (C, pthread_key_create, "pthread_key_create");
 
+   ------------------------------------------------------------
+   --   Binary Semaphore Wrapper to Support Interrupt Tasks  --
+   ------------------------------------------------------------
+
+   type Binary_Semaphore_Id is new rtems_id;
+
+   function Binary_Semaphore_Create return Binary_Semaphore_Id;
+   pragma Import (
+      C,
+      Binary_Semaphore_Create,
+      "__gnat_binary_semaphore_create");
+
+   function Binary_Semaphore_Delete (ID : Binary_Semaphore_Id) return int;
+   pragma Import (
+      C,
+      Binary_Semaphore_Delete,
+      "__gnat_binary_semaphore_delete");
+
+   function Binary_Semaphore_Obtain (ID : Binary_Semaphore_Id) return int;
+   pragma Import (
+      C,
+      Binary_Semaphore_Obtain,
+      "__gnat_binary_semaphore_obtain");
+
+   function Binary_Semaphore_Release (ID : Binary_Semaphore_Id) return int;
+   pragma Import (
+      C,
+      Binary_Semaphore_Release,
+      "__gnat_binary_semaphore_release");
+
+   function Binary_Semaphore_Flush (ID : Binary_Semaphore_Id) return int;
+   pragma Import (
+      C,
+      Binary_Semaphore_Flush,
+      "__gnat_binary_semaphore_flush");
+
+   ------------------------------------------------------------
+   -- Hardware Interrupt Wrappers to Support Interrupt Tasks --
+   ------------------------------------------------------------
+
+   type Interrupt_Handler is access procedure (parameter : System.Address);
+   pragma Convention (C, Interrupt_Handler);
+   type Interrupt_Vector is new System.Address;
+
+   function Interrupt_Connect
+     (Vector    : Interrupt_Vector;
+      Handler   : Interrupt_Handler;
+      Parameter : System.Address := System.Null_Address) return int;
+   pragma Import (C, Interrupt_Connect, "__gnat_interrupt_connect");
+   --  Use this to set up an user handler. The routine installs a
+   --  a user handler which is invoked after RTEMS has saved enough
+   --  context for a high-level language routine to be safely invoked.
+
+   function Interrupt_Vector_Get
+     (Vector : Interrupt_Vector) return Interrupt_Handler;
+   pragma Import (C, Interrupt_Vector_Get, "__gnat_interrupt_get");
+   --  Use this to get the existing handler for later restoral.
+
+   procedure Interrupt_Vector_Set
+     (Vector  : Interrupt_Vector;
+      Handler : Interrupt_Handler);
+   pragma Import (C, Interrupt_Vector_Set, "__gnat_interrupt_set");
+   --  Use this to restore a handler obtained using Interrupt_Vector_Get.
+
+   function Interrupt_Number_To_Vector (intNum : int) return Interrupt_Vector;
+   --  Convert a logical interrupt number to the hardware interrupt vector
+   --  number used to connect the interrupt.
+   pragma Import (
+      C,
+      Interrupt_Number_To_Vector,
+      "__gnat_interrupt_number_to_vector"
+   );
+
 private
 
    type sigset_t is new int;
@@ -507,12 +591,13 @@
       schedpolicy     : int;
       schedparam      : struct_sched_param;
       cputime_clocked_allowed : int;
-      deatchstate     : int;
+      detatchstate    : int;
    end record;
    pragma Convention (C, pthread_attr_t);
 
    type pthread_condattr_t is record
-      flags        : int;
+      is_initialized  : int;
+      process_shared  : int;
    end record;
    pragma Convention (C, pthread_condattr_t);
 
diff -urN gcc-4.3.2-orig/gcc/ada/s-osinte-vxworks.adb gcc-4.3.2/gcc/ada/s-osinte-vxworks.adb
--- gcc-4.3.2-orig/gcc/ada/s-osinte-vxworks.adb	2007-08-14 03:42:09.000000000 -0500
+++ gcc-4.3.2/gcc/ada/s-osinte-vxworks.adb	2008-09-09 13:07:24.000000000 -0500
@@ -239,4 +239,92 @@
       return int (Ticks);
    end To_Clock_Ticks;
 
+   -----------------------------
+   -- Binary_Semaphore_Create --
+   -----------------------------
+
+   function Binary_Semaphore_Create return Binary_Semaphore_Id is
+   begin
+      return semBCreate (SEM_Q_FIFO, SEM_EMPTY);
+   end Binary_Semaphore_Create;
+
+   -----------------------------
+   -- Binary_Semaphore_Delete --
+   -----------------------------
+
+   function Binary_Semaphore_Delete (ID : Binary_Semaphore_Id) return int is
+   begin
+      return semDelete (ID);
+   end Binary_Semaphore_Obtain;
+
+   -----------------------------
+   -- Binary_Semaphore_Obtain --
+   -----------------------------
+
+   function Binary_Semaphore_Obtain (ID : Binary_Semaphore_Id) return int is
+   begin
+      return semTake (ID, WAIT_FOREVER);
+   end Binary_Semaphore_Obtain;
+
+   ------------------------------
+   -- Binary_Semaphore_Release --
+   ------------------------------
+
+   function Binary_Semaphore_Release (ID : Binary_Semaphore_Id) return int is
+   begin
+      return semGive (ID);
+   end Binary_Semaphore_Release;
+
+   ----------------------------
+   -- Binary_Semaphore_Flush --
+   ----------------------------
+
+   function Binary_Semaphore_Flush (ID : Binary_Semaphore_Id) return int is
+   begin
+      return semFlush (ID);
+   end Binary_Semaphore_Flush;
+
+
+   ----------------------------
+   -- Interrupt_Connect --
+   ----------------------------
+
+   function Interrupt_Connect
+     (Vector    : Interrupt_Vector;
+      Handler   : Interrupt_Handler;
+      Parameter : System.Address := System.Null_Address) return int is
+   begin
+     return intConnect (Vector, Handler, Parameter);
+   end Interrupt_Connect;
+
+   ----------------------------
+   -- Interrupt_Vector_Get --
+   ----------------------------
+
+   function Interrupt_Vector_Get
+     (Vector : Interrupt_Vector) return Interrupt_Handler is
+   begin
+     return intVecGet (Vector);
+   end Interrupt_Get;
+
+   ----------------------------
+   -- Interrupt_Vector_Set --
+   ----------------------------
+
+   procedure Interrupt_Vector_Set
+     (Vector  : Interrupt_Vector;
+      Handler : Interrupt_Handler) is
+   begin
+      intVecSet (Interfaces.VxWorks.INUM_TO_IVEC (Vector), Handler);
+   end Interrupt_Vector_Set;
+
+   ----------------------------r --
+   -- Interrupt_Number_To_Vector --
+   ----------------------------r --
+
+   function Interrupt_Number_To_Vector (intNum : int) return Interrupt_Vector is
+   begin
+      return INUM_TO_IVEC (Interfaces.VxWorks.int (Interrupt));
+   end Interrupt_Number_To_Vector;
+
 end System.OS_Interface;
diff -urN gcc-4.3.2-orig/gcc/ada/s-osinte-vxworks.ads gcc-4.3.2/gcc/ada/s-osinte-vxworks.ads
--- gcc-4.3.2-orig/gcc/ada/s-osinte-vxworks.ads	2007-12-13 04:19:04.000000000 -0600
+++ gcc-4.3.2/gcc/ada/s-osinte-vxworks.ads	2008-09-09 13:07:24.000000000 -0500
@@ -393,6 +393,50 @@
    pragma Import (C, semFlush, "semFlush");
    --  Release all threads blocked on the semaphore
 
+   ------------------------------------------------------------
+   --   Binary Semaphore Wrapper to Support Interrupt Tasks  --
+   ------------------------------------------------------------
+
+   type Binary_Semaphore_Id is new SEM_ID;
+
+   function Binary_Semaphore_Create return Binary_Semaphore_Id;
+
+   function Binary_Semaphore_Delete (ID : Binary_Semaphore_Id) return int;
+
+   function Binary_Semaphore_Obtain (ID : Binary_Semaphore_Id) return int;
+
+   function Binary_Semaphore_Release (ID : Binary_Semaphore_Id) return int;
+
+   function Binary_Semaphore_Flush (ID : Binary_Semaphore_Id) return int;
+
+   ------------------------------------------------------------
+   -- Hardware Interrupt Wrappers to Support Interrupt Tasks --
+   ------------------------------------------------------------
+
+   type Interrupt_Handler is access procedure (parameter : System.Address);
+   type Interrupt_Vector is new System.Address;
+
+   function Interrupt_Connect
+     (Vector    : Interrupt_Vector;
+      Handler   : Interrupt_Handler;
+      Parameter : System.Address := System.Null_Address) return int;
+   --  Use this to set up an user handler. The routine installs a
+   --  a user handler which is invoked after RTEMS has saved enough
+   --  context for a high-level language routine to be safely invoked.
+
+   function Interrupt_Vector_Get
+     (Vector : Interrupt_Vector) return Interrupt_Handler;
+   --  Use this to get the existing handler for later restoral.
+
+   procedure Interrupt_Vector_Set
+     (Vector  : Interrupt_Vector;
+      Handler : Interrupt_Handler);
+   --  Use this to restore a handler obtained using Interrupt_Vector_Get.
+
+   function Interrupt_Number_To_Vector (intNum : int) return Interrupt_Vector;
+   --  Convert a logical interrupt number to the hardware interrupt vector
+   --  number used to connect the interrupt.
+
 private
    type sigset_t is new long;
 
diff -urN gcc-4.3.2-orig/gcc/ada/s-stchop-rtems.adb gcc-4.3.2/gcc/ada/s-stchop-rtems.adb
--- gcc-4.3.2-orig/gcc/ada/s-stchop-rtems.adb	1969-12-31 18:00:00.000000000 -0600
+++ gcc-4.3.2/gcc/ada/s-stchop-rtems.adb	2008-09-09 13:07:24.000000000 -0500
@@ -0,0 +1,114 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
+--                                                                          --
+--     S Y S T E M . S T A C K _ C H E C K I N G . O P E R A T I O N S      --
+--                                                                          --
+--                                  B o d y                                 --
+--                                                                          --
+--          Copyright (C) 1999-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- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- 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,  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  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.                                      --
+--                                                                          --
+-- GNARL was developed by the GNARL team at Florida State University.       --
+-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
+--                                                                          --
+------------------------------------------------------------------------------
+
+--  This is the RTEMS version of this package.
+--  This file should be kept synchronized with the general implementation
+--  provided by s-stchop.adb.
+
+pragma Restrictions (No_Elaboration_Code);
+--  We want to guarantee the absence of elaboration code because the
+--  binder does not handle references to this package.
+
+with Ada.Exceptions;
+
+with Interfaces.C; use Interfaces.C;
+
+package body System.Stack_Checking.Operations is
+
+   ----------------------------
+   -- Invalidate_Stack_Cache --
+   ----------------------------
+
+   procedure Invalidate_Stack_Cache (Any_Stack : Stack_Access) is
+      pragma Warnings (Off, Any_Stack);
+   begin
+      Cache := Null_Stack;
+   end Invalidate_Stack_Cache;
+
+   -----------------------------
+   -- Notify_Stack_Attributes --
+   -----------------------------
+
+   procedure Notify_Stack_Attributes
+     (Initial_SP : System.Address;
+      Size       : System.Storage_Elements.Storage_Offset)
+   is
+
+      --  RTEMS keeps all the information we need.
+
+      pragma Unreferenced (Size);
+      pragma Unreferenced (Initial_SP);
+
+   begin
+      null;
+   end Notify_Stack_Attributes;
+
+   -----------------
+   -- Stack_Check --
+   -----------------
+
+   function Stack_Check
+     (Stack_Address : System.Address) return Stack_Access
+   is
+      pragma Unreferenced (Stack_Address);
+
+      --  RTEMS has a routine to check this.  So use it.
+      function rtems_stack_checker_is_blown return Interfaces.C.int;
+      pragma Import (C,
+         rtems_stack_checker_is_blown, "rtems_stack_checker_is_blown");
+
+   begin
+      --  RTEMS has a routine to check this.  So use it.
+
+      if rtems_stack_checker_is_blown /= 0 then
+         Ada.Exceptions.Raise_Exception
+           (E       => Storage_Error'Identity,
+            Message => "stack overflow detected");
+      end if;
+
+      return null;
+
+   end Stack_Check;
+
+   ------------------------
+   -- Update_Stack_Cache --
+   ------------------------
+
+   procedure Update_Stack_Cache (Stack : Stack_Access) is
+   begin
+      if not Multi_Processor then
+         Cache := Stack;
+      end if;
+   end Update_Stack_Cache;
+
+end System.Stack_Checking.Operations;
