public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Couple of comment tweaks to latest change
@ 2024-05-13  8:36 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2024-05-13  8:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

From: Eric Botcazou <ebotcazou@adacore.com>

This replaces a few remaining references to "master" by "collection" and
makes a couple of additional tweaks in comments.

gcc/ada/

	* libgnat/s-finpri.adb (Finalize): Replace "master" by "collection"
	in comments and add a comment about the form of the loop.
	* libgnat/s-stposu.adb (Allocate_Any_Controlled): Tweak comment.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/s-finpri.adb | 20 ++++++++++++--------
 gcc/ada/libgnat/s-stposu.adb |  9 ++++-----
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb
index 2abc9f49403..731c913b2e7 100644
--- a/gcc/ada/libgnat/s-finpri.adb
+++ b/gcc/ada/libgnat/s-finpri.adb
@@ -174,18 +174,16 @@ package body System.Finalization_Primitives is
       if Collection.Finalization_Started then
          Unlock_Task.all;
 
-         --  Double finalization may occur during the handling of stand alone
-         --  libraries or the finalization of a pool with subpools. Due to the
-         --  potential aliasing of masters in these two cases, do not process
-         --  the same master twice.
+         --  Double finalization may occur during the handling of stand-alone
+         --  libraries or the finalization of a pool with subpools.
 
          return;
       end if;
 
-      --  Lock the master to prevent any allocations while the objects are
-      --  being finalized. The master remains locked because either the master
-      --  is explicitly deallocated or the associated access type is about to
-      --  go out of scope.
+      --  Lock the collection to prevent any allocation while the objects are
+      --  being finalized. The collection remains locked because either it is
+      --  explicitly deallocated or the associated access type is about to go
+      --  out of scope.
 
       --  Synchronization:
       --    Read  - allocation, finalization
@@ -193,6 +191,12 @@ package body System.Finalization_Primitives is
 
       Collection.Finalization_Started := True;
 
+      --  Note that we cannot walk the list while finalizing its elements
+      --  because the finalization of one may call Unchecked_Deallocation
+      --  on another and, therefore, detach it from anywhere on the list.
+      --  Instead, we empty the list by repeatedly finalizing the first
+      --  element (after the dummy head) and detaching it from the list.
+
       while not Is_Empty_List (Collection.Head'Unchecked_Access) loop
          Curr_Ptr := Collection.Head.Next;
 
diff --git a/gcc/ada/libgnat/s-stposu.adb b/gcc/ada/libgnat/s-stposu.adb
index ebbd3e4d72a..8d232fa0d61 100644
--- a/gcc/ada/libgnat/s-stposu.adb
+++ b/gcc/ada/libgnat/s-stposu.adb
@@ -196,17 +196,16 @@ package body System.Storage_Pools.Subpools is
       --  object or a record with controlled components.
 
       if Is_Controlled then
-
-         --  Synchronization:
-         --    Read  - allocation, finalization
-         --    Write - finalization
-
          Lock_Taken := True;
          Lock_Task.all;
 
          --  Do not allow the allocation of controlled objects while the
          --  associated collection is being finalized.
 
+         --  Synchronization:
+         --    Read  - allocation, finalization
+         --    Write - finalization
+
          if Finalization_Started (Collection.all) then
             raise Program_Error with "allocation after finalization started";
          end if;
-- 
2.43.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-13  8:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-13  8:36 [COMMITTED] ada: Couple of comment tweaks to latest change Marc Poulhiès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).