diff mbox series

[v4,3/4] include: move STR() and IS_ALIGNED()

Message ID 9a0cf101-17fa-cad2-e791-15d8d8cc5b79@suse.com (mailing list archive)
State New, archived
Headers show
Series x86: further time/APIC improvements (and more) | expand

Commit Message

Jan Beulich March 31, 2022, 9:31 a.m. UTC
lib.h is imo a better fit for them than config.h.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v4: New.
---
Originally I thought I'd also move KB() etc, but they're used in places
where yet further adjustments (adding of #include) would be necessary.

Comments

Julien Grall March 31, 2022, 10:34 a.m. UTC | #1
Hi Jan,

On 31/03/2022 10:31, Jan Beulich wrote:
> lib.h is imo a better fit for them than config.h.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,

> ---
> v4: New.
> ---
> Originally I thought I'd also move KB() etc, but they're used in places
> where yet further adjustments (adding of #include) would be necessary.
> 
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -3,6 +3,7 @@
>   /* Modified for ARM Xen by Ian Campbell */
>   
>   #include <xen/cache.h>
> +#include <xen/lib.h>
>   #include <asm/page.h>
>   #undef ENTRY
>   #undef ALIGN
> --- a/xen/arch/x86/xen.lds.S
> +++ b/xen/arch/x86/xen.lds.S
> @@ -2,6 +2,7 @@
>   /* Modified for i386/x86-64 Xen by Keir Fraser */
>   
>   #include <xen/cache.h>
> +#include <xen/lib.h>
>   #include <asm/page.h>
>   #undef ENTRY
>   #undef ALIGN
> --- a/xen/include/xen/config.h
> +++ b/xen/include/xen/config.h
> @@ -82,11 +82,6 @@
>   #define MB(_mb)     (_AC(_mb, ULL) << 20)
>   #define GB(_gb)     (_AC(_gb, ULL) << 30)
>   
> -#define IS_ALIGNED(val, align) (((val) & ((align) - 1)) == 0)
> -
> -#define __STR(...) #__VA_ARGS__
> -#define STR(...) __STR(__VA_ARGS__)
> -
>   /* allow existing code to work with Kconfig variable */
>   #define NR_CPUS CONFIG_NR_CPUS
>   
> --- a/xen/include/xen/lib.h
> +++ b/xen/include/xen/lib.h
> @@ -3,6 +3,8 @@
>   
>   #define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1))
>   
> +#define IS_ALIGNED(val, align) (!((val) & ((align) - 1)))
> +
>   #define DIV_ROUND(n, d) (((n) + (d) / 2) / (d))
>   #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
>   
> @@ -17,6 +19,9 @@
>   #define PASTE_(a, b) a ## b
>   #define PASTE(a, b) PASTE_(a, b)
>   
> +#define __STR(...) #__VA_ARGS__
> +#define STR(...) __STR(__VA_ARGS__)
> +
>   #ifndef __ASSEMBLY__
>   
>   #include <xen/inttypes.h>
>
Roger Pau Monné April 4, 2022, 1:08 p.m. UTC | #2
On Thu, Mar 31, 2022 at 11:31:02AM +0200, Jan Beulich wrote:
> lib.h is imo a better fit for them than config.h.

Looks like most of what's in config.h could move to lib.h.

> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.
diff mbox series

Patch

--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -3,6 +3,7 @@ 
 /* Modified for ARM Xen by Ian Campbell */
 
 #include <xen/cache.h>
+#include <xen/lib.h>
 #include <asm/page.h>
 #undef ENTRY
 #undef ALIGN
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -2,6 +2,7 @@ 
 /* Modified for i386/x86-64 Xen by Keir Fraser */
 
 #include <xen/cache.h>
+#include <xen/lib.h>
 #include <asm/page.h>
 #undef ENTRY
 #undef ALIGN
--- a/xen/include/xen/config.h
+++ b/xen/include/xen/config.h
@@ -82,11 +82,6 @@ 
 #define MB(_mb)     (_AC(_mb, ULL) << 20)
 #define GB(_gb)     (_AC(_gb, ULL) << 30)
 
-#define IS_ALIGNED(val, align) (((val) & ((align) - 1)) == 0)
-
-#define __STR(...) #__VA_ARGS__
-#define STR(...) __STR(__VA_ARGS__)
-
 /* allow existing code to work with Kconfig variable */
 #define NR_CPUS CONFIG_NR_CPUS
 
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -3,6 +3,8 @@ 
 
 #define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1))
 
+#define IS_ALIGNED(val, align) (!((val) & ((align) - 1)))
+
 #define DIV_ROUND(n, d) (((n) + (d) / 2) / (d))
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
 
@@ -17,6 +19,9 @@ 
 #define PASTE_(a, b) a ## b
 #define PASTE(a, b) PASTE_(a, b)
 
+#define __STR(...) #__VA_ARGS__
+#define STR(...) __STR(__VA_ARGS__)
+
 #ifndef __ASSEMBLY__
 
 #include <xen/inttypes.h>