Message ID | 1304437058-15651-2-git-send-email-levinsasha928@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
* Sasha Levin <levinsasha928@gmail.com> wrote: > The local kernel.h may redefine macros already > defined otherwise, wrap it with #ifdef. > > Signed-off-by: Sasha Levin <levinsasha928@gmail.com> > --- > tools/kvm/include/linux/kernel.h | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/tools/kvm/include/linux/kernel.h b/tools/kvm/include/linux/kernel.h > index 8d83037..fccb624 100644 > --- a/tools/kvm/include/linux/kernel.h > +++ b/tools/kvm/include/linux/kernel.h > @@ -1,10 +1,17 @@ > #ifndef KVM__LINUX_KERNEL_H_ > #define KVM__LINUX_KERNEL_H_ > > +#ifndef DIV_ROUND_UP > #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) > +#endif > > +#ifndef ALIGN > #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) > +#endif > + > +#ifndef __ALIGN_MASK > #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) > +#endif Hm, how can duplicate definitions happen? Only one place should define them - otherwise we might end up with incompatible definitions ... Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, 2011-05-03 at 21:49 +0200, Ingo Molnar wrote: > * Sasha Levin <levinsasha928@gmail.com> wrote: > > > The local kernel.h may redefine macros already > > defined otherwise, wrap it with #ifdef. > > > > Signed-off-by: Sasha Levin <levinsasha928@gmail.com> > > --- > > tools/kvm/include/linux/kernel.h | 7 +++++++ > > 1 files changed, 7 insertions(+), 0 deletions(-) > > > > diff --git a/tools/kvm/include/linux/kernel.h b/tools/kvm/include/linux/kernel.h > > index 8d83037..fccb624 100644 > > --- a/tools/kvm/include/linux/kernel.h > > +++ b/tools/kvm/include/linux/kernel.h > > @@ -1,10 +1,17 @@ > > #ifndef KVM__LINUX_KERNEL_H_ > > #define KVM__LINUX_KERNEL_H_ > > > > +#ifndef DIV_ROUND_UP > > #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) > > +#endif > > > > +#ifndef ALIGN > > #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) > > +#endif > > + > > +#ifndef __ALIGN_MASK > > #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) > > +#endif > > Hm, how can duplicate definitions happen? Only one place should define them - > otherwise we might end up with incompatible definitions ... We has ALIGN defined in include/kvm/bios.h within our code.
* Sasha Levin <levinsasha928@gmail.com> wrote: > On Tue, 2011-05-03 at 21:49 +0200, Ingo Molnar wrote: > > * Sasha Levin <levinsasha928@gmail.com> wrote: > > > > > The local kernel.h may redefine macros already > > > defined otherwise, wrap it with #ifdef. > > > > > > Signed-off-by: Sasha Levin <levinsasha928@gmail.com> > > > --- > > > tools/kvm/include/linux/kernel.h | 7 +++++++ > > > 1 files changed, 7 insertions(+), 0 deletions(-) > > > > > > diff --git a/tools/kvm/include/linux/kernel.h b/tools/kvm/include/linux/kernel.h > > > index 8d83037..fccb624 100644 > > > --- a/tools/kvm/include/linux/kernel.h > > > +++ b/tools/kvm/include/linux/kernel.h > > > @@ -1,10 +1,17 @@ > > > #ifndef KVM__LINUX_KERNEL_H_ > > > #define KVM__LINUX_KERNEL_H_ > > > > > > +#ifndef DIV_ROUND_UP > > > #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) > > > +#endif > > > > > > +#ifndef ALIGN > > > #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) > > > +#endif > > > + > > > +#ifndef __ALIGN_MASK > > > #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) > > > +#endif > > > > Hm, how can duplicate definitions happen? Only one place should define them - > > otherwise we might end up with incompatible definitions ... > > We has ALIGN defined in include/kvm/bios.h within our code. Well, but then the right solution would be to not define it there but remove it, and use the one we get from the kernel headers? Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 05/03/2011 11:59 PM, Ingo Molnar wrote: ... >>> >>> Hm, how can duplicate definitions happen? Only one place should define them - >>> otherwise we might end up with incompatible definitions ... >> >> We has ALIGN defined in include/kvm/bios.h within our code. > > Well, but then the right solution would be to not define it there but remove > it, and use the one we get from the kernel headers? > > Thanks, > > Ingo Yeah, the right way indeed to use kernel header. The former ALIGN was introduced by me I fear when kvm tools were out of linux tree, ie quite early. Sasha mind to simply drop the former ALIGN out?
On 05/04/2011 12:10 AM, Cyrill Gorcunov wrote: > On 05/03/2011 11:59 PM, Ingo Molnar wrote: > ... >>>> >>>> Hm, how can duplicate definitions happen? Only one place should define them - >>>> otherwise we might end up with incompatible definitions ... >>> >>> We has ALIGN defined in include/kvm/bios.h within our code. >> >> Well, but then the right solution would be to not define it there but remove >> it, and use the one we get from the kernel headers? >> >> Thanks, >> >> Ingo > > Yeah, the right way indeed to use kernel header. The former ALIGN was introduced by > me I fear when kvm tools were out of linux tree, ie quite early. Sasha mind to simply > drop the former ALIGN out? > Sasha, could you please also drop this lines from bios.h #ifndef ALIGN #define ALIGN(x, a) \ (((x) + ((a) - 1)) & ~((a) - 1)) #endif /* * note we use 16 bytes alignment which makes segment based * addressing easy to compute, dont change it otherwise you * may break local variables offsets in BIOS irq routines */ #define BIOS_NEXT_IRQ_ADDR(addr, size) \ ALIGN((addr + size + 1), 16) they are rudiments.
diff --git a/tools/kvm/include/linux/kernel.h b/tools/kvm/include/linux/kernel.h index 8d83037..fccb624 100644 --- a/tools/kvm/include/linux/kernel.h +++ b/tools/kvm/include/linux/kernel.h @@ -1,10 +1,17 @@ #ifndef KVM__LINUX_KERNEL_H_ #define KVM__LINUX_KERNEL_H_ +#ifndef DIV_ROUND_UP #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#endif +#ifndef ALIGN #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) +#endif + +#ifndef __ALIGN_MASK #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) +#endif #ifndef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
The local kernel.h may redefine macros already defined otherwise, wrap it with #ifdef. Signed-off-by: Sasha Levin <levinsasha928@gmail.com> --- tools/kvm/include/linux/kernel.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)