lkml.org 
[lkml]   [2014]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 06/28] nios2: Memory management
On Tue, Apr 22, 2014 at 12:35:22PM -0300, Ezequiel Garcia wrote:
> On Apr 22, Tobias Klauser wrote:
> > On 2014-04-22 at 16:24:43 +0200, Ezequiel Garcia <ezequiel.garcia@free-electrons.com> wrote:
> > > Hi Ley Foon,
> > >
> > > On Apr 18, Ley Foon Tan wrote:
> > > > +/*
> > > > + * PAGE_SHIFT determines the page size
> > > > + */
> > > > +#define PAGE_SHIFT 12
> > > > +#define PAGE_SIZE 4096
> > > > +#define PAGE_MASK (~(PAGE_SIZE - 1))
> > > > +
> > >
> > > How about something like this:
> > >
> > > /* PAGE_SHIFT determines the page size */
> > > #define PAGE_SHIFT 12
> > > #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
> > > #define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
> > >
> > > Otherwise, the PAGE_SIZE macro above produces some warnings, IIRC.
> >
> > AFAIR old nios2 GCC versions (the 4.1 version from Windriver, IIRC)
> > would complain about something like the above, that's the reason I added
> > an explicit value for PAGE_SIZE back then.
> >
>
> Other than being "pretty" the above fix is to remove a mismatch type
> warning. You can get rid of the warning in different ways:
>
> ifdef __ASSEMBLY__
> define PAGE_SIZE 4096
> else
> define PAGE_SIZE 4096UL
> endif

The usual way to do this is as follows:
#include <linux/const.h>

#define PAGE_SHIFT 12
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))

_AC(1, UL) expands to 1 for assembler and 1UL for C code.

This is also what was suggested above.

Please follow this scheme for nios2 too.

Sam


\
 
 \ /
  Last update: 2014-04-22 18:41    [W:0.135 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site