Message ID | 109efb43-a519-73f6-2a26-2b420090ab2b@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | annotate entry points with type and size | expand |
On Mon, 2023-07-10 at 10:51 +0200, Jan Beulich wrote: > Introduce xen/macros.h for this purpose. For now xen/lib.h simply > includes xen/macro.h, until consumers can be suitable cleaned up. > > Signed-off-by: Jan Beulich <jbeulich@suse.com> > --- > v3: New. > > --- a/xen/include/xen/lib.h > +++ b/xen/include/xen/lib.h > @@ -1,26 +1,7 @@ > #ifndef __LIB_H__ > #define __LIB_H__ > > -#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)) > - > -#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) > -#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) > - > -#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x > -#define count_args(args...) \ > - count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) > - > -/* Indirect macros required for expanded argument pasting. */ > -#define PASTE_(a, b) a ## b > -#define PASTE(a, b) PASTE_(a, b) > - > -#define __STR(...) #__VA_ARGS__ > -#define STR(...) __STR(__VA_ARGS__) > +#include <xen/macros.h> > > #ifndef __ASSEMBLY__ > > --- /dev/null > +++ b/xen/include/xen/macros.h > @@ -0,0 +1,34 @@ > +#ifndef __MACROS_H__ > +#define __MACROS_H__ > + > +#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)) > + > +#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) > +#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) > + > +#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x > +#define count_args(args...) \ > + count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) > + > +/* Indirect macros required for expanded argument pasting. */ > +#define PASTE_(a, b) a ## b > +#define PASTE(a, b) PASTE_(a, b) > + > +#define __STR(...) #__VA_ARGS__ > +#define STR(...) __STR(__VA_ARGS__) > + > +#endif /* __MACROS_H__ */ > + > +/* > + * Local variables: > + * mode: C > + * c-file-style: "BSD" > + * c-basic-offset: 4 > + * indent-tabs-mode: nil > + * End: > + */ > Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> ~ Oleksii
On 7/10/23 3:51 AM, Jan Beulich wrote: > Introduce xen/macros.h for this purpose. For now xen/lib.h simply > includes xen/macro.h, until consumers can be suitable cleaned up. > > Signed-off-by: Jan Beulich <jbeulich@suse.com> > --- > v3: New. > > --- a/xen/include/xen/lib.h > +++ b/xen/include/xen/lib.h > @@ -1,26 +1,7 @@ > #ifndef __LIB_H__ > #define __LIB_H__ > > -#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)) > - > -#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) > -#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) > - > -#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x > -#define count_args(args...) \ > - count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) > - > -/* Indirect macros required for expanded argument pasting. */ > -#define PASTE_(a, b) a ## b > -#define PASTE(a, b) PASTE_(a, b) > - > -#define __STR(...) #__VA_ARGS__ > -#define STR(...) __STR(__VA_ARGS__) > +#include <xen/macros.h> > > #ifndef __ASSEMBLY__ > > --- /dev/null > +++ b/xen/include/xen/macros.h > @@ -0,0 +1,34 @@ Should there be an SPDX header here? > +#ifndef __MACROS_H__ > +#define __MACROS_H__ > + > +#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)) > + > +#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) > +#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) > + > +#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x > +#define count_args(args...) \ > + count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) > + > +/* Indirect macros required for expanded argument pasting. */ > +#define PASTE_(a, b) a ## b > +#define PASTE(a, b) PASTE_(a, b) > + > +#define __STR(...) #__VA_ARGS__ > +#define STR(...) __STR(__VA_ARGS__) > + > +#endif /* __MACROS_H__ */ > + > +/* > + * Local variables: > + * mode: C > + * c-file-style: "BSD" > + * c-basic-offset: 4 > + * indent-tabs-mode: nil > + * End: > + */ Reviewed-by: Shawn Anastasio <sanastasio@raptorengineering.com>
On 18.07.2023 21:49, Shawn Anastasio wrote: > On 7/10/23 3:51 AM, Jan Beulich wrote: >> --- /dev/null >> +++ b/xen/include/xen/macros.h >> @@ -0,0 +1,34 @@ > > Should there be an SPDX header here? Probably, but I wouldn't know which version to use, since lib.h doesn't have one either. Not putting one there leaves things a clear or vague as they are for others without the tag (and without a full license header); putting one there would firmly state something, which then may be wrong. Therefore I think this will need sorting in (more or less) one go for all of the "license-free" source files. >> +#ifndef __MACROS_H__ >> +#define __MACROS_H__ >> + >> +#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)) >> + >> +#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) >> +#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) >> + >> +#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x >> +#define count_args(args...) \ >> + count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) >> + >> +/* Indirect macros required for expanded argument pasting. */ >> +#define PASTE_(a, b) a ## b >> +#define PASTE(a, b) PASTE_(a, b) >> + >> +#define __STR(...) #__VA_ARGS__ >> +#define STR(...) __STR(__VA_ARGS__) >> + >> +#endif /* __MACROS_H__ */ >> + >> +/* >> + * Local variables: >> + * mode: C >> + * c-file-style: "BSD" >> + * c-basic-offset: 4 >> + * indent-tabs-mode: nil >> + * End: >> + */ > > Reviewed-by: Shawn Anastasio <sanastasio@raptorengineering.com> Thanks. Jan
--- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -1,26 +1,7 @@ #ifndef __LIB_H__ #define __LIB_H__ -#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)) - -#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) -#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) - -#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x -#define count_args(args...) \ - count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) - -/* Indirect macros required for expanded argument pasting. */ -#define PASTE_(a, b) a ## b -#define PASTE(a, b) PASTE_(a, b) - -#define __STR(...) #__VA_ARGS__ -#define STR(...) __STR(__VA_ARGS__) +#include <xen/macros.h> #ifndef __ASSEMBLY__ --- /dev/null +++ b/xen/include/xen/macros.h @@ -0,0 +1,34 @@ +#ifndef __MACROS_H__ +#define __MACROS_H__ + +#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)) + +#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) +#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) + +#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x +#define count_args(args...) \ + count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) + +/* Indirect macros required for expanded argument pasting. */ +#define PASTE_(a, b) a ## b +#define PASTE(a, b) PASTE_(a, b) + +#define __STR(...) #__VA_ARGS__ +#define STR(...) __STR(__VA_ARGS__) + +#endif /* __MACROS_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */
Introduce xen/macros.h for this purpose. For now xen/lib.h simply includes xen/macro.h, until consumers can be suitable cleaned up. Signed-off-by: Jan Beulich <jbeulich@suse.com> --- v3: New.