From: "Jan Beulich" Subject: [PATCH] add BUILD_BUG_ON() Date: Thu, 27 Apr 2006 16:21:18 +0200 Message-ID: <4450EF7E.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE1C4F84E.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartE1C4F84E.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline .. and a few users. Signed-off-by: Jan Beulich --=__PartE1C4F84E.0__= Content-Type: text/plain; name="xen-BUILD_BUG_ON.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen-BUILD_BUG_ON.patch" --- 2006-04-21/xen/arch/x86/setup.c.0 2006-04-21 16:51:17.000000000 +0200 +++ 2006-04-21/xen/arch/x86/setup.c 2006-04-27 09:49:07.000000000 +0200 @@ -391,17 +391,17 @@ void __init __start_xen(multiboot_info_t total_pages = nr_pages; /* Sanity check for unwanted bloat of dom0_op structure. */ - BUG_ON(sizeof(((struct dom0_op *)0)->u) != - sizeof(((struct dom0_op *)0)->u.pad)); + BUILD_BUG_ON(sizeof(((struct dom0_op *)0)->u) != + sizeof(((struct dom0_op *)0)->u.pad)); - BUG_ON(sizeof(start_info_t) > PAGE_SIZE); - BUG_ON(sizeof(shared_info_t) > PAGE_SIZE); - BUG_ON(sizeof(vcpu_info_t) != 64); + BUILD_BUG_ON(sizeof(start_info_t) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(vcpu_info_t) != 64); /* __foo are defined in public headers. Check they match internal defs. */ - BUG_ON(__HYPERVISOR_VIRT_START != HYPERVISOR_VIRT_START); + BUILD_BUG_ON(__HYPERVISOR_VIRT_START != HYPERVISOR_VIRT_START); #ifdef HYPERVISOR_VIRT_END - BUG_ON(__HYPERVISOR_VIRT_END != HYPERVISOR_VIRT_END); + BUILD_BUG_ON(__HYPERVISOR_VIRT_END != HYPERVISOR_VIRT_END); #endif init_frametable(); --- 2006-04-21/xen/include/xen/lib.h.0 2006-04-06 17:50:27.000000000 +0200 +++ 2006-04-21/xen/include/xen/lib.h 2006-04-27 09:24:50.000000000 +0200 @@ -16,6 +16,9 @@ #define BUG_ON(_p) do { if (_p) BUG(); } while ( 0 ) +/* Force a compilation error if condition is true */ +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) + #ifndef NDEBUG #define ASSERT(_p) { if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s\n", #_p , __LINE__, __FILE__); BUG(); } } #else --=__PartE1C4F84E.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartE1C4F84E.0__=--