OSDN Git Service

2010-12-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-taprop-vms.adb
index 01a77d6..582f88b 100644 (file)
@@ -408,15 +408,12 @@ package body System.Task_Primitives.Operations is
       Result : Interfaces.C.int;
 
    begin
-      if Single_Lock then
-         Result :=
-           pthread_cond_wait
-             (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access);
-      else
-         Result :=
-           pthread_cond_wait
-             (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
-      end if;
+      Result :=
+        pthread_cond_wait
+          (cond  => Self_ID.Common.LL.CV'Access,
+           mutex => (if Single_Lock
+                     then Single_RTS_Lock'Access
+                     else Self_ID.Common.LL.L'Access));
 
       --  EINTR is not considered a failure
 
@@ -540,19 +537,13 @@ package body System.Task_Primitives.Operations is
                   exit;
                end if;
 
-               if Single_Lock then
-                  Result :=
-                    pthread_cond_wait
-                      (Self_ID.Common.LL.CV'Access,
-                       Single_RTS_Lock'Access);
-                  pragma Assert (Result = 0);
-               else
-                  Result :=
-                    pthread_cond_wait
-                      (Self_ID.Common.LL.CV'Access,
-                       Self_ID.Common.LL.L'Access);
-                  pragma Assert (Result = 0);
-               end if;
+               Result :=
+                 pthread_cond_wait
+                   (cond  => Self_ID.Common.LL.CV'Access,
+                    mutex => (if Single_Lock
+                              then Single_RTS_Lock'Access
+                              else Self_ID.Common.LL.L'Access));
+               pragma Assert (Result = 0);
 
                Yielded := True;
 
@@ -1104,7 +1095,16 @@ package body System.Task_Primitives.Operations is
             S.State := False;
          else
             S.Waiting := True;
-            Result := pthread_cond_wait (S.CV'Access, S.L'Access);
+
+            loop
+               --  Loop in case pthread_cond_wait returns earlier than expected
+               --  (e.g. in case of EINTR caused by a signal).
+
+               Result := pthread_cond_wait (S.CV'Access, S.L'Access);
+               pragma Assert (Result = 0 or else Result = EINTR);
+
+               exit when not S.Waiting;
+            end loop;
          end if;
 
          Result := pthread_mutex_unlock (S.L'Access);