]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Do not assume a priority value of zero is a valid priority
authorPatrick Bernardi <bernardi@adacore.com>
Wed, 3 Nov 2021 21:55:50 +0000 (17:55 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 10 Nov 2021 08:57:41 +0000 (08:57 +0000)
gcc/ada/

* libgnarl/s-taskin.adb (Initialize_ATCB): Initialize
T.Common.Current_Priority to Priority'First.
* libgnarl/s-taskin.ads (Unspecified_Priority): Redefined as -1.
* libgnat/system-rtems.ads: Start priority range from 1, as 0 is
reserved by the operating system.

gcc/ada/libgnarl/s-taskin.adb
gcc/ada/libgnarl/s-taskin.ads
gcc/ada/libgnat/system-rtems.ads

index ab50af14138f5b7ab2d6e174fb7e98f2c5796005..1e6f42da39301088919abf8f09f91e8fa7f20aba 100644 (file)
@@ -127,7 +127,7 @@ package body System.Tasking is
       end if;
       pragma Assert (T.Common.Domain /= null);
 
-      T.Common.Current_Priority         := 0;
+      T.Common.Current_Priority         := Priority'First;
       T.Common.Protected_Action_Nesting := 0;
       T.Common.Call                     := null;
       T.Common.Task_Arg                 := Task_Arg;
index cf560b569fb0a297b1e773afffecce1782c9c4c4..1751553c58c467f3479ee452ac448c1225f95838 100644 (file)
@@ -773,7 +773,10 @@ package System.Tasking is
    -- Priority info --
    -------------------
 
-   Unspecified_Priority : constant Integer := System.Priority'First - 1;
+   Unspecified_Priority : constant Integer := -1;
+   --  Indicates that a task has an unspecified priority. This is hardcoded as
+   --  -1 rather than System.Priority'First - 1 as the value needs to be used
+   --  in init.c to specify that the main task has no specified priority.
 
    Priority_Not_Boosted : constant Integer := System.Priority'First - 1;
    --  Definition of Priority actually has to come from the RTS configuration
index c083cb5fd447436b43db28dc9d606acbeff8fe91..77423d316ba4091a7e408e9861dbb87cfa6f7d2e 100644 (file)
@@ -109,15 +109,13 @@ package System is
    --             hardware priority levels.  Protected Object ceilings can
    --             override these values.
    --  245        is used by the Interrupt_Manager task
-   --  0          is reserved for the RTEMS IDLE task and really should not
-   --             be accessible from Ada but GNAT initializes
-   --             Current_Priority to 0 so it must be valid
+   --  0          is reserved for the RTEMS IDLE task
 
    Max_Priority           : constant Positive := 244;
    Max_Interrupt_Priority : constant Positive := 254;
 
-   subtype Any_Priority       is Integer      range   0 .. 254;
-   subtype Priority           is Any_Priority range   0 .. 244;
+   subtype Any_Priority       is Integer      range   1 .. 254;
+   subtype Priority           is Any_Priority range   1 .. 244;
    subtype Interrupt_Priority is Any_Priority range 245 .. 254;
 
    Default_Priority : constant Priority := 122;