]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix usage of SetThreadIdealProcessor
authorRonan Desplanques <desplanques@adacore.com>
Mon, 15 Apr 2024 16:07:49 +0000 (18:07 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 10 Jun 2024 09:03:59 +0000 (11:03 +0200)
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.

gcc/ada/libgnarl/s-taprop__mingw.adb

index 3a124ba78d0943d974c82884fb9ab8374e6ba09f..38e281cb72169ae12c007c428fda35d48a558fa0 100644 (file)
@@ -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