From: Ronan Desplanques <[email protected]>
This patches fixes the way the run-time library checks the return
value of SetThreadIdealProcessor.
gcc/ada/
* libgnarl/s-taprop__mingw.adb (Set_Task_Affinity): Fix usage
of SetThreadIdealProcessor.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/libgnarl/s-taprop__mingw.adb | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/libgnarl/s-taprop__mingw.adb
b/gcc/ada/libgnarl/s-taprop__mingw.adb
index 3a124ba78d0..38e281cb721 100644
--- a/gcc/ada/libgnarl/s-taprop__mingw.adb
+++ b/gcc/ada/libgnarl/s-taprop__mingw.adb
@@ -1308,7 +1308,13 @@ package body System.Task_Primitives.Operations is
Result :=
SetThreadIdealProcessor
(T.Common.LL.Thread, ProcessorId (T.Common.Base_CPU) - 1);
- pragma Assert (Result = 1);
+
+ -- The documentation for SetThreadIdealProcessor states:
+ --
+ -- If the function fails, the return value is (DWORD) - 1.
+ --
+ -- That should map to DWORD'Last in Ada.
+ pragma Assert (Result /= DWORD'Last);
-- Task_Info
@@ -1317,7 +1323,10 @@ package body System.Task_Primitives.Operations is
Result :=
SetThreadIdealProcessor
(T.Common.LL.Thread, T.Common.Task_Info.CPU);
- pragma Assert (Result = 1);
+
+ -- See the comment above about the return value of
+ -- SetThreadIdealProcessor.
+ pragma Assert (Result /= DWORD'Last);
end if;
-- Dispatching domains
--
2.45.1