]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
5rosinte.ads: Add SIGXCPU.
authorJoel Sherrill <joel@gcc.gnu.org>
Wed, 29 Jan 2003 17:34:09 +0000 (17:34 +0000)
committerJoel Sherrill <joel@gcc.gnu.org>
Wed, 29 Jan 2003 17:34:09 +0000 (17:34 +0000)
2003-01-29 Joel Sherrill <joel@OARcorp.com>

* 5rosinte.ads: Add SIGXCPU.
* 5rtpopsp.adb: New file.
* Make-lang.in: Do not build gnatpsta and gnatpsys when cross.
* Makefile.in: Recognize more RTEMS targets and add the RTEMS
specific file 5rtpopsp.adb.
* adaint.h: Add include of <stdio.h> when target is RTEMS.  This
is likely needed for all newlib targets.
* init.c: Add RTEMS specific version of __gnat_initialize().

From-SVN: r62094

gcc/ada/5rosinte.ads
gcc/ada/5rtpopsp.adb [new file with mode: 0644]
gcc/ada/Make-lang.in
gcc/ada/Makefile.in
gcc/ada/adaint.h
gcc/ada/init.c

index 9ea4c13d7ae5e48e1117ae98d59c89340e07fb95..e22eebd81cfb68da589e074ce24a245a9910d4c7 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                   S p e c                                --
 --                                                                          --
---                             $Revision: 1.1 $
+--                             $Revision: 1.1.16.1 $
 --                                                                          --
 --          Copyright (C) 1997-2001 Free Software Foundation, Inc.          --
 --                                                                          --
@@ -107,6 +107,7 @@ package System.OS_Interface is
    SIGTERM     : constant := 15; --  software termination signal from kill
    SIGUSR1     : constant := 16; --  user defined signal 1
    SIGUSR2     : constant := 17; --  user defined signal 2
+   SIGXCPU     : constant := 0; --  XCPU
 
    SIGADAABORT : constant := SIGABRT;
 
diff --git a/gcc/ada/5rtpopsp.adb b/gcc/ada/5rtpopsp.adb
new file mode 100644 (file)
index 0000000..a1f1597
--- /dev/null
@@ -0,0 +1,266 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS               --
+--                                                                          --
+--    S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S .   --
+--                              S P E C I F I C                             --
+--                                                                          --
+--                                  B o d y                                 --
+--                                                                          --
+--                             $Revision: 1.7 $
+--                                                                          --
+--            Copyright (C) 1991-1999, Florida State University             --
+--                                                                          --
+-- 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,  59 Temple Place - Suite 330,  Boston, --
+-- MA 02111-1307, 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. It is --
+-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
+-- State University (http://www.gnat.com).                                  --
+--                                                                          --
+------------------------------------------------------------------------------
+
+--  This is a POSIX version of this package where foreign threads are
+--  recognized.
+--  Currently, DEC Unix, SCO UnixWare 7 and RTEMS use this version.
+
+with System.Soft_Links;
+--  used to initialize TSD for a C thread, in function Self
+
+separate (System.Task_Primitives.Operations)
+package body Specific is
+
+   ------------------
+   --  Local Data  --
+   ------------------
+
+   --  The followings are logically constants, but need to be initialized
+   --  at run time.
+
+   --  The following gives the Ada run-time direct access to a variable
+   --  context switched by RTEMS at the lowest level.
+
+   RTEMS_Ada_Self : System.Address;
+   pragma Import (C, RTEMS_Ada_Self, "rtems_ada_self");
+
+   --  The following are used to allow the Self function to
+   --  automatically generate ATCB's for C threads that happen to call
+   --  Ada procedure, which in turn happen to call the Ada runtime system.
+
+   type Fake_ATCB;
+   type Fake_ATCB_Ptr is access Fake_ATCB;
+   type Fake_ATCB is record
+      Stack_Base : Interfaces.C.unsigned := 0;
+      --  A value of zero indicates the node is not in use.
+      Next : Fake_ATCB_Ptr;
+      Real_ATCB : aliased Ada_Task_Control_Block (0);
+   end record;
+
+   Fake_ATCB_List : Fake_ATCB_Ptr;
+   --  A linear linked list.
+   --  The list is protected by All_Tasks_L;
+   --  Nodes are added to this list from the front.
+   --  Once a node is added to this list, it is never removed.
+
+   Fake_Task_Elaborated : aliased Boolean := True;
+   --  Used to identified fake tasks (i.e., non-Ada Threads).
+
+   Next_Fake_ATCB : Fake_ATCB_Ptr;
+   --  Used to allocate one Fake_ATCB in advance. See comment in New_Fake_ATCB
+
+   -----------------------
+   -- Local Subprograms --
+   -----------------------
+
+   ---------------------------------
+   --  Support for New_Fake_ATCB  --
+   ---------------------------------
+
+   function New_Fake_ATCB return Task_ID;
+   --  Allocate and Initialize a new ATCB. This code can safely be called from
+   --  a foreign thread, as it doesn't access implicitely or explicitely
+   --  "self" before having initialized the new ATCB.
+
+   -------------------
+   -- New_Fake_ATCB --
+   -------------------
+
+   function New_Fake_ATCB return Task_ID is
+      Self_ID   : Task_ID;
+      P, Q      : Fake_ATCB_Ptr;
+      Succeeded : Boolean;
+
+   begin
+      --  This section is ticklish.
+      --  We dare not call anything that might require an ATCB, until
+      --  we have the new ATCB in place.
+
+      Write_Lock (All_Tasks_L'Access);
+      Q := null;
+      P := Fake_ATCB_List;
+
+      while P /= null loop
+         if P.Stack_Base = 0 then
+            Q := P;
+         end if;
+
+         P := P.Next;
+      end loop;
+
+      if Q = null then
+
+         --  Create a new ATCB with zero entries.
+
+         Self_ID := Next_Fake_ATCB.Real_ATCB'Access;
+         Next_Fake_ATCB.Stack_Base := 1;
+         Next_Fake_ATCB.Next := Fake_ATCB_List;
+         Fake_ATCB_List := Next_Fake_ATCB;
+         Next_Fake_ATCB := null;
+
+      else
+         --  Reuse an existing fake ATCB.
+
+         Self_ID := Q.Real_ATCB'Access;
+         Q.Stack_Base := 1;
+      end if;
+
+      --  Record this as the Task_ID for the current thread.
+
+      Self_ID.Common.LL.Thread := pthread_self;
+
+      RTEMS_Ada_Self := To_Address (Self_ID);
+
+      --  Do the standard initializations
+
+      System.Tasking.Initialize_ATCB
+        (Self_ID, null, Null_Address, Null_Task, Fake_Task_Elaborated'Access,
+         System.Priority'First, Task_Info.Unspecified_Task_Info, 0, Self_ID,
+         Succeeded);
+      pragma Assert (Succeeded);
+
+      --  Finally, it is safe to use an allocator in this thread.
+
+      if Next_Fake_ATCB = null then
+         Next_Fake_ATCB := new Fake_ATCB;
+      end if;
+
+      Self_ID.Common.State := Runnable;
+      Self_ID.Awake_Count := 1;
+
+      --  Since this is not an ordinary Ada task, we will start out undeferred
+
+      Self_ID.Deferral_Level := 0;
+
+      System.Soft_Links.Create_TSD (Self_ID.Common.Compiler_Data);
+
+      --  ????
+      --  The following call is commented out to avoid dependence on
+      --  the System.Tasking.Initialization package.
+      --  It seems that if we want Ada.Task_Attributes to work correctly
+      --  for C threads we will need to raise the visibility of this soft
+      --  link to System.Soft_Links.
+      --  We are putting that off until this new functionality is otherwise
+      --  stable.
+      --  System.Tasking.Initialization.Initialize_Attributes_Link.all (T);
+
+      for J in Known_Tasks'Range loop
+         if Known_Tasks (J) = null then
+            Known_Tasks (J) := Self_ID;
+            Self_ID.Known_Tasks_Index := J;
+            exit;
+         end if;
+      end loop;
+
+      --  Must not unlock until Next_ATCB is again allocated.
+
+      Unlock (All_Tasks_L'Access);
+      return Self_ID;
+   end New_Fake_ATCB;
+
+   ----------------
+   -- Initialize --
+   ----------------
+
+   procedure Initialize (Environment_Task : Task_ID) is
+
+   begin
+      RTEMS_Ada_Self := To_Address (Environment_Task);
+
+      --  Create a free ATCB for use on the Fake_ATCB_List.
+
+      Next_Fake_ATCB := new Fake_ATCB;
+   end Initialize;
+
+   ---------
+   -- Set --
+   ---------
+
+   procedure Set (Self_Id : Task_ID) is
+
+   begin
+      RTEMS_Ada_Self := To_Address (Self_Id);
+   end Set;
+
+   ----------
+   -- Self --
+   ----------
+
+   --  To make Ada tasks and C threads interoperate better, we have
+   --  added some functionality to Self.  Suppose a C main program
+   --  (with threads) calls an Ada procedure and the Ada procedure
+   --  calls the tasking runtime system.  Eventually, a call will be
+   --  made to self.  Since the call is not coming from an Ada task,
+   --  there will be no corresponding ATCB.
+
+   --  (The entire Ada run-time system may not have been elaborated,
+   --  either, but that is a different problem, that we will need to
+   --  solve another way.)
+
+   --  What we do in Self is to catch references that do not come
+   --  from recognized Ada tasks, and create an ATCB for the calling
+   --  thread.
+
+   --  The new ATCB will be "detached" from the normal Ada task
+   --  master hierarchy, much like the existing implicitly created
+   --  signal-server tasks.
+
+   --  We will also use such points to poll for disappearance of the
+   --  threads associated with any implicit ATCBs that we created
+   --  earlier, and take the opportunity to recover them.
+
+   --  A nasty problem here is the limitations of the compilation
+   --  order dependency, and in particular the GNARL/GNULLI layering.
+   --  To initialize an ATCB we need to assume System.Tasking has
+   --  been elaborated.
+
+   function Self return Task_ID is
+      Result : System.Address;
+
+   begin
+      Result := RTEMS_Ada_Self;
+
+      --  If the key value is Null, then it is a non-Ada task.
+
+      if Result = System.Null_Address then
+         return New_Fake_ATCB;
+      end if;
+
+      return To_Task_ID (Result);
+   end Self;
+
+end Specific;
index 37b53240e3aab18de5d6fb8f0a6bcdabf405a803..c4d82fdd758d7c2f422835c782d8cb9f751bf39e 100644 (file)
@@ -153,7 +153,7 @@ cross-gnattools: force
           gnatbl$(exeext) gnatchop$(exeext) gnatcmd$(exeext) \
           gnatkr$(exeext) gnatlink$(exeext) \
           gnatls$(exeext) gnatmake$(exeext) \
-          gnatprep$(exeext) gnatpsta$(exeext) gnatpsys$(exeext) \
+          gnatprep$(exeext) \
           gnatxref$(exeext) gnatfind$(exeext) $(EXTRA_GNATTOOLS)
 
 # use target-gcc
index a3df9baff92c121b07773d8be68e82bad322f8af..2e13903f7c70e43bce922af9b34a5dbfd7d88264 100644 (file)
@@ -1403,7 +1403,7 @@ ifeq ($(strip $(filter-out lynxos,$(osys))),)
   endif
 endif
 
-ifeq ($(strip $(filter-out rtems,$(osys))),)
+ifeq ($(strip $(filter-out rtems rtemself rtemsaout rtemscoff,$(osys))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<4rintnam.ads \
   s-inmaop.adb<7sinmaop.adb \
@@ -1414,7 +1414,7 @@ ifeq ($(strip $(filter-out rtems,$(osys))),)
   s-parame.adb<5rparame.adb \
   s-taprop.adb<7staprop.adb \
   s-taspri.ads<7staspri.ads \
-  s-tpopsp.adb<5atpopsp.adb
+  s-tpopsp.adb<5rtpopsp.adb
 endif
 
 ifeq ($(strip $(filter-out go32 msdos,$(osys))),)
@@ -2181,7 +2181,7 @@ gnatlib: ../stamp-gnatlib1 ../stamp-gnatlib2
 #      ../xgcc -B../ -dD -E ../tconfig.h $(INCLUDES) > rts/tconfig.h
        $(MAKE) -C rts CC="../../xgcc -B../../" \
                INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
-                CFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -DIN_RTS" \
+                CFLAGS="$(GNATLIBCFLAGS) $(LIBGCC2_CFLAGS) -DIN_RTS" \
                ADA_CFLAGS="$(GNATLIBCFLAGS)" \
                srcdir=$(fsrcdir) \
                -f ../Makefile $(LIBGNAT_OBJS)
@@ -2279,14 +2279,14 @@ ravenppclib:
 gnatlib-shared-default:
        $(MAKE) $(FLAGS_TO_PASS) \
              GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \
+            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(LIBGCC2_CFLAGS)" \
             THREAD_KIND="$(THREAD_KIND)" \
              gnatlib
        $(RM) rts/libgnat$(soext) rts/libgnarl$(soext)
-       cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
+       cd rts; ../../xgcc -B../../ -shared $(LIBGCC2_CFLAGS) \
                -o libgnat-$(LIBRARY_VERSION)$(soext) $(SO_OPTS)libgnat-$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) $(MISCLIB) -lm
-       cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
+       cd rts; ../../xgcc -B../../ -shared $(LIBGCC2_CFLAGS) \
                -o libgnarl-$(LIBRARY_VERSION)$(soext) $(SO_OPTS)libgnarl-$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_TASKING_OBJS) $(THREADSLIB)
        cd rts; $(LN) libgnat-$(LIBRARY_VERSION)$(soext) libgnat$(soext)
index a38a7f32ff683c0efc752f00f6ccb58e03c9771e..cbc20b2f29eefe55f7f9528d9d3389285648d515 100644 (file)
@@ -4,7 +4,7 @@
  *                                                                          *
  *                               A D A I N T                                *
  *                                                                          *
- *                            $Revision: 1.5 $
+ *                            $Revision: 1.5.2.1 $
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
  *                                                                          *
  ****************************************************************************/
 
+#if defined(__rtems__)
+#include <stdio.h>
+#endif
+
 #include <dirent.h>
 
 extern void   __gnat_to_gm_time                           PARAMS ((int *, int *,
index f0f13051c1d037a74496f799eb10dc2583e228af..4edebdf745fc7695b8ebd272db46f7b853fe5442 100644 (file)
@@ -4,7 +4,7 @@
  *                                                                          *
  *                                 I N I T                                  *
  *                                                                          *
- *                            $Revision: 1.8 $
+ *                            $Revision: 1.8.10.1 $
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
@@ -1640,6 +1640,22 @@ __gnat_initialize ()
 #endif
 }
 
+/***************************************/
+/* __gnat_initialize (RTEMS version) */
+/***************************************/
+
+#elif defined(__rtems__)
+
+extern void __gnat_install_handler ();
+
+/* For RTEMS, each bsp will provide a custom __gnat_install_handler (). */
+
+void
+__gnat_initialize ()
+{
+   __gnat_install_handler ();
+}
+
 #else
 
 /* For all other versions of GNAT, the initialize routine and handler