diff mbox

[v2,2/4] xen/arm: Add macro ALIGN

Message ID 1380200178-30776-3-git-send-email-julien.grall@linaro.org
State Superseded, archived
Headers show

Commit Message

Julien Grall Sept. 26, 2013, 12:56 p.m. UTC
Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/common/device_tree.c     |    2 --
 xen/include/asm-arm/config.h |    4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Ian Campbell Sept. 26, 2013, 2:30 p.m. UTC | #1
On Thu, 2013-09-26 at 13:56 +0100, Julien Grall wrote:

> diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
> index 2cea1ba..35f3b29 100644
> --- a/xen/include/asm-arm/config.h
> +++ b/xen/include/asm-arm/config.h
> @@ -186,6 +186,10 @@
>  #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
>  
>  #ifndef __ASSEMBLY__
> +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))

Seems like there ought to be a place under include/xen where this would
fit.

xen/include/xen/lib.h I reckon.

> +#endif
> +
> +#ifndef __ASSEMBLY__
>  extern unsigned long xen_phys_start;
>  extern unsigned long xenheap_phys_end;
>  extern unsigned long frametable_virt_end;
Andrew Cooper Sept. 26, 2013, 2:34 p.m. UTC | #2
On 26/09/13 15:30, Ian Campbell wrote:
> On Thu, 2013-09-26 at 13:56 +0100, Julien Grall wrote:
>
>> diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
>> index 2cea1ba..35f3b29 100644
>> --- a/xen/include/asm-arm/config.h
>> +++ b/xen/include/asm-arm/config.h
>> @@ -186,6 +186,10 @@
>>  #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
>>  
>>  #ifndef __ASSEMBLY__
>> +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
> Seems like there ought to be a place under include/xen where this would
> fit.
>
> xen/include/xen/lib.h I reckon.

Except x86 has #define ALIGN _ALIGN which will surely cause problems?

~Andrew
Ian Campbell Sept. 26, 2013, 2:38 p.m. UTC | #3
On Thu, 2013-09-26 at 15:34 +0100, Andrew Cooper wrote:
> On 26/09/13 15:30, Ian Campbell wrote:
> > On Thu, 2013-09-26 at 13:56 +0100, Julien Grall wrote:
> >
> >> diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
> >> index 2cea1ba..35f3b29 100644
> >> --- a/xen/include/asm-arm/config.h
> >> +++ b/xen/include/asm-arm/config.h
> >> @@ -186,6 +186,10 @@
> >>  #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
> >>  
> >>  #ifndef __ASSEMBLY__
> >> +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
> > Seems like there ought to be a place under include/xen where this would
> > fit.
> >
> > xen/include/xen/lib.h I reckon.
> 
> Except x86 has #define ALIGN _ALIGN which will surely cause problems?

ARM has this too (assuming you meant __ALIGN, can't find the other), but
in both cases it is only the #ifdef __ASSEMBLY__, whereas this adds a
non-asm version.

Could avoid any confusion by naming this version ROUNDUP.

xen/common/xmalloc_tlsf.c has ROUNDUP_PAGE already too BTW.

Ian.
Andrew Cooper Sept. 26, 2013, 2:41 p.m. UTC | #4
On 26/09/13 15:38, Ian Campbell wrote:
> On Thu, 2013-09-26 at 15:34 +0100, Andrew Cooper wrote:
>> On 26/09/13 15:30, Ian Campbell wrote:
>>> On Thu, 2013-09-26 at 13:56 +0100, Julien Grall wrote:
>>>
>>>> diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
>>>> index 2cea1ba..35f3b29 100644
>>>> --- a/xen/include/asm-arm/config.h
>>>> +++ b/xen/include/asm-arm/config.h
>>>> @@ -186,6 +186,10 @@
>>>>  #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
>>>>  
>>>>  #ifndef __ASSEMBLY__
>>>> +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
>>> Seems like there ought to be a place under include/xen where this would
>>> fit.
>>>
>>> xen/include/xen/lib.h I reckon.
>> Except x86 has #define ALIGN _ALIGN which will surely cause problems?
> ARM has this too (assuming you meant __ALIGN, can't find the other), but
> in both cases it is only the #ifdef __ASSEMBLY__, whereas this adds a
> non-asm version.
>
> Could avoid any confusion by naming this version ROUNDUP.
>
> xen/common/xmalloc_tlsf.c has ROUNDUP_PAGE already too BTW.
>
> Ian.
>

That seems like a sensible way forward.

~Andrew
Julien Grall Sept. 26, 2013, 3:26 p.m. UTC | #5
On 09/26/2013 03:38 PM, Ian Campbell wrote:
> On Thu, 2013-09-26 at 15:34 +0100, Andrew Cooper wrote:
>> On 26/09/13 15:30, Ian Campbell wrote:
>>> On Thu, 2013-09-26 at 13:56 +0100, Julien Grall wrote:
>>>
>>>> diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
>>>> index 2cea1ba..35f3b29 100644
>>>> --- a/xen/include/asm-arm/config.h
>>>> +++ b/xen/include/asm-arm/config.h
>>>> @@ -186,6 +186,10 @@
>>>>  #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
>>>>  
>>>>  #ifndef __ASSEMBLY__
>>>> +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
>>> Seems like there ought to be a place under include/xen where this would
>>> fit.
>>>
>>> xen/include/xen/lib.h I reckon.
>>
>> Except x86 has #define ALIGN _ALIGN which will surely cause problems?
> 
> ARM has this too (assuming you meant __ALIGN, can't find the other), but
> in both cases it is only the #ifdef __ASSEMBLY__, whereas this adds a
> non-asm version.
> 
> Could avoid any confusion by naming this version ROUNDUP.

I will rename it on the next patch series.

> xen/common/xmalloc_tlsf.c has ROUNDUP_PAGE already too BTW.
> 
> Ian.
>
diff mbox

Patch

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 9a16650..32cbb1e 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -65,8 +65,6 @@  static LIST_HEAD(aliases_lookup);
             printk(fmt, ## __VA_ARGS__);            \
     } while (0)
 
-#define ALIGN(x, a) ((x + (a) - 1) & ~((a) - 1));
-
 // #define DEBUG_DT
 
 #ifdef DEBUG_DT
diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
index 2cea1ba..35f3b29 100644
--- a/xen/include/asm-arm/config.h
+++ b/xen/include/asm-arm/config.h
@@ -186,6 +186,10 @@ 
 #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
 
 #ifndef __ASSEMBLY__
+#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
+#endif
+
+#ifndef __ASSEMBLY__
 extern unsigned long xen_phys_start;
 extern unsigned long xenheap_phys_end;
 extern unsigned long frametable_virt_end;