[Ada] Round up stack size
Arnaud Charlet
charlet@adacore.com
Mon Aug 17 12:12:00 GMT 2009
Some OSes required an aligned stack size.
Tested on x86_64-darwin, committed on trunk
2009-08-17 Tristan Gingold <gingold@adacore.com>
* s-taprop-posix.adb: Round up the stack size to avoid failure on
Darwin.
-------------- next part --------------
Index: s-taprop-posix.adb
===================================================================
--- s-taprop-posix.adb (revision 150823)
+++ s-taprop-posix.adb (working copy)
@@ -926,6 +926,7 @@ package body System.Task_Primitives.Oper
is
Attributes : aliased pthread_attr_t;
Adjusted_Stack_Size : Interfaces.C.size_t;
+ Page_Size : constant Interfaces.C.size_t := Get_Page_Size;
Result : Interfaces.C.int;
function Thread_Body_Access is new
@@ -946,9 +947,15 @@ package body System.Task_Primitives.Oper
-- to be sure the effective stack size is greater than what
-- has been asked.
- Adjusted_Stack_Size := Adjusted_Stack_Size + 2 * Get_Page_Size;
+ Adjusted_Stack_Size := Adjusted_Stack_Size + 2 * Page_Size;
end if;
+ -- Round stack size as this is required by some OSes (Darwin)
+
+ Adjusted_Stack_Size := Adjusted_Stack_Size + Page_Size - 1;
+ Adjusted_Stack_Size :=
+ Adjusted_Stack_Size - Adjusted_Stack_Size mod Page_Size;
+
Result := pthread_attr_init (Attributes'Access);
pragma Assert (Result = 0 or else Result = ENOMEM);
More information about the Gcc-patches
mailing list