[SCM] strace branch, master, updated. v4.7-98-g1ba8543
Chris Metcalf
cmetcalf at tilera.com
Tue Mar 5 14:19:26 UTC 2013
On 3/5/2013 9:07 AM, Dmitry V. Levin wrote:
> On Tue, Mar 05, 2013 at 04:47:07PM +0400, Dmitry V. Levin wrote:
>> On Tue, Feb 19, 2013 at 11:02:29AM +0000, Denys Vlasenko wrote:
>> [...]
>>> commit 1ba85436def7da80971aeb902fbc6e52997a46fa
>>> Author: Denys Vlasenko <vda.linux at googlemail.com>
>>> Date: Tue Feb 19 11:28:20 2013 +0100
>>>
>>> Clean up mmap decoding
>> [...]
>>> * mem.c: Refactor mmap functions so that we have five mmap syscall
>>> handlers, each with the fixed API (not varying by arch).
>> [...]
>> mem.c b/mem.c
>>> index b67a1b6..6f22922 100644
>>> --- a/mem.c
>>> +++ b/mem.c
>>> @@ -39,8 +39,14 @@
>>> # define modify_ldt_ldt_s user_desc
>>> # endif
>>> #endif
>>> +
>>> +#include <sys/user.h> /* for PAGE_SHIFT */
>>> #if defined(SH64)
>>> -# include <asm/page.h> /* for PAGE_SHIFT */
>>> +# include <asm/page.h> /* for PAGE_SHIFT */
>>> +#endif
>>> +#if !defined(PAGE_SHIFT)
>>> +# warning Failed to get PAGE_SHIFT, assuming 12
>>> +# define PAGE_SHIFT 12
>>> #endif
>> In glibc, sys/user.h is notoriously incomplete header file containing a
>> nice comment that "The whole purpose of this file is for GDB and GDB
>> only". In particular, on most of architectures it doesn't define
>> PAGE_SHIFT, and on some architectures PAGE_SHIFT is greater that 12.
>> I think we should not rely on <sys/user.h>. The natural source of
>> PAGE_SHIFT definition seems to be <asm/page.h>; we can either include it
>> directly, or, if there is a risk of namespace collisions, fetch PAGE_SHIFT
>> during configure stage.
> It looks like <asm/page.h> is not usually installed, so another reliable
> method is needed.
You need to do it at runtime in general, since it's possible to boot some architectures and choose the page size with kernel boot arguments (or kernel build-time configure options). Just multiply by getpagesize() instead of shifting by PAGE_SHIFT.
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
More information about the Strace-devel
mailing list