diff options
Diffstat (limited to 'gcc/ada/s-finmas.adb')
-rw-r--r-- | gcc/ada/s-finmas.adb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/gcc/ada/s-finmas.adb b/gcc/ada/s-finmas.adb index a08bb08a494..c663988f43a 100644 --- a/gcc/ada/s-finmas.adb +++ b/gcc/ada/s-finmas.adb @@ -463,22 +463,36 @@ package body System.Finalization_Masters is Fin_Addr_Ptr : Finalize_Address_Ptr) is begin - Master.Finalize_Address := Fin_Addr_Ptr; + -- TSS primitive Finalize_Address is set at the point of allocation, + -- either through Allocate_Any_Controlled or through this routine. + -- Since multiple tasks can allocate on the same finalization master, + -- access to this attribute must be protected. + + Lock_Task.all; + + if Master.Finalize_Address = null then + Master.Finalize_Address := Fin_Addr_Ptr; + end if; + + Unlock_Task.all; end Set_Finalize_Address; - -------------------------- - -- Set_Finalize_Address -- - -------------------------- + ---------------------------------------- + -- Set_Heterogeneous_Finalize_Address -- + ---------------------------------------- - procedure Set_Finalize_Address + procedure Set_Heterogeneous_Finalize_Address (Obj : System.Address; Fin_Addr_Ptr : Finalize_Address_Ptr) is begin + -- Protected access is required in this case because + -- Finalize_Address_Table is a global data structure. + Lock_Task.all; Finalize_Address_Table.Set (Obj, Fin_Addr_Ptr); Unlock_Task.all; - end Set_Finalize_Address; + end Set_Heterogeneous_Finalize_Address; -------------------------- -- Set_Is_Heterogeneous -- |