This patch cleans the way getpagesize() is imported and removes an inconsistency wrt the underlying C routine. No change in functionality.
Tested on x86_64-pc-linux-gnu, committed on trunk 2015-10-26 Arnaud Charlet <char...@adacore.com> * s-osinte-hpux.ads, s-osinte-aix.ads, s-osinte-solaris-posix.ads, s-osinte-darwin.ads, s-osinte-android.ads, s-osinte-freebsd.ads, s-taprop-posix.adb (Get_Page_Size): C function returns an int. Adjust callers accordingly.
Index: s-osinte-hpux.ads =================================================================== --- s-osinte-hpux.ads (revision 229313) +++ s-osinte-hpux.ads (working copy) @@ -7,7 +7,7 @@ -- S p e c -- -- -- -- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1995-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -301,8 +301,7 @@ -- Returns the stack base of the specified thread. Only call this function -- when Stack_Base_Available is True. - function Get_Page_Size return size_t; - function Get_Page_Size return Address; + function Get_Page_Size return int; pragma Import (C, Get_Page_Size, "getpagesize"); -- Returns the size of a page Index: s-osinte-aix.ads =================================================================== --- s-osinte-aix.ads (revision 229313) +++ s-osinte-aix.ads (working copy) @@ -7,7 +7,7 @@ -- S p e c -- -- -- -- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1995-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -319,8 +319,7 @@ -- Returns the stack base of the specified thread. Only call this function -- when Stack_Base_Available is True. - function Get_Page_Size return size_t; - function Get_Page_Size return Address; + function Get_Page_Size return int; pragma Import (C, Get_Page_Size, "getpagesize"); -- Returns the size of a page Index: s-osinte-solaris-posix.ads =================================================================== --- s-osinte-solaris-posix.ads (revision 229313) +++ s-osinte-solaris-posix.ads (working copy) @@ -7,7 +7,7 @@ -- S p e c -- -- -- -- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1995-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -300,8 +300,7 @@ -- Returns the stack base of the specified thread. Only call this function -- when Stack_Base_Available is True. - function Get_Page_Size return size_t; - function Get_Page_Size return Address; + function Get_Page_Size return int; pragma Import (C, Get_Page_Size, "getpagesize"); -- Returns the size of a page Index: s-osinte-darwin.ads =================================================================== --- s-osinte-darwin.ads (revision 229313) +++ s-osinte-darwin.ads (working copy) @@ -7,7 +7,7 @@ -- S p e c -- -- -- -- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1995-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -299,8 +299,7 @@ -- returns the stack base of the specified thread. Only call this function -- when Stack_Base_Available is True. - function Get_Page_Size return size_t; - function Get_Page_Size return System.Address; + function Get_Page_Size return int; pragma Import (C, Get_Page_Size, "getpagesize"); -- Returns the size of a page Index: s-osinte-android.ads =================================================================== --- s-osinte-android.ads (revision 229313) +++ s-osinte-android.ads (working copy) @@ -317,8 +317,7 @@ return Address is (Null_Address); -- This is a dummy procedure to share some GNULLI files - function Get_Page_Size return size_t; - function Get_Page_Size return Address; + function Get_Page_Size return int; pragma Import (C, Get_Page_Size, "_getpagesize"); -- Returns the size of a page Index: s-osinte-freebsd.ads =================================================================== --- s-osinte-freebsd.ads (revision 229313) +++ s-osinte-freebsd.ads (working copy) @@ -7,7 +7,7 @@ -- S p e c -- -- -- -- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1995-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -332,8 +332,7 @@ -- returns the stack base of the specified thread. Only call this function -- when Stack_Base_Available is True. - function Get_Page_Size return size_t; - function Get_Page_Size return Address; + function Get_Page_Size return int; pragma Import (C, Get_Page_Size, "getpagesize"); -- Returns the size of a page Index: s-taprop-posix.adb =================================================================== --- s-taprop-posix.adb (revision 229313) +++ s-taprop-posix.adb (working copy) @@ -315,21 +315,20 @@ procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is Stack_Base : constant Address := Get_Stack_Base (T.Common.LL.Thread); - Guard_Page_Address : Address; + Page_Size : Address; + Res : Interfaces.C.int; - Res : Interfaces.C.int; - begin if Stack_Base_Available then -- Compute the guard page address - Guard_Page_Address := - Stack_Base - (Stack_Base mod Get_Page_Size) + Get_Page_Size; - + Page_Size := Address (Get_Page_Size); Res := - mprotect (Guard_Page_Address, Get_Page_Size, - prot => (if On then PROT_ON else PROT_OFF)); + mprotect + (Stack_Base - (Stack_Base mod Page_Size) + Page_Size, + size_t (Page_Size), + prot => (if On then PROT_ON else PROT_OFF)); pragma Assert (Res = 0); end if; end Stack_Guard; @@ -978,7 +977,8 @@ is Attributes : aliased pthread_attr_t; Adjusted_Stack_Size : Interfaces.C.size_t; - Page_Size : constant Interfaces.C.size_t := Get_Page_Size; + Page_Size : constant Interfaces.C.size_t := + Interfaces.C.size_t (Get_Page_Size); Result : Interfaces.C.int; function Thread_Body_Access is new