[gcc r15-1144] ada: Fix usage of SetThreadIdealProcessor

Marc Poulhi?s dkm@gcc.gnu.org
Mon Jun 10 09:08:10 GMT 2024


https://gcc.gnu.org/g:aec9d8c9f5d673ff745f7b0560966e98b1404a53

commit r15-1144-gaec9d8c9f5d673ff745f7b0560966e98b1404a53
Author: Ronan Desplanques <desplanques@adacore.com>
Date:   Mon Apr 15 18:07:49 2024 +0200

    ada: Fix usage of SetThreadIdealProcessor
    
    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.

Diff:
---
 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


More information about the Gcc-cvs mailing list