[Ada] Do not assume a priority value of zero is a valid priority

Pierre-Marie de Rodat derodat@adacore.com
Wed Nov 10 08:58:41 GMT 2021


While a priority value of zero is typically valid on most systems, there
are some targets where zero may be reserved for OS purposes (for
example: RTEMS where zero is reserved for use by the idle thread and
should not be used by applications). This patch removes one occurrence
in GNARL where a Priority object was initialized to zero instead of
Priority'First, and adjusts the Priority type on RTEMS to prevent the
use of priority level zero. By contrast,
System.Tasking.Unspecified_Priority is hardcoded as -1 since it is used
in init.c, which does not have access to the Priority type.

Tested on x86_64-pc-linux-gnu, committed on trunk

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 2405 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211110/afaf1e84/attachment.bin>


More information about the Gcc-patches mailing list