Skip to contentSkip to conversation

The BUILD_BUG_ON macros moved from ubi_uboot.h to common.h

PATCH New Michael Zaidman 2 participants 8 messages Apr 1, 2010 – May 16, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 The BUILD_BUG_ON macros moved from ubi_uboot.h to common.h

The BUILD_BUG_ON macros made availible for rest of the u-boot code by moving it from ubi_uboot.h to common.h. In Linux kernel this widely used macros is defined in kernel.h file.

---
 include/common.h    |    3 +++
 include/ubi_uboot.h |    3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
include/common.h +3 -0
index a133e34..7c22e69 100644
@@ -136,6 +136,9 @@ typedef volatile unsigned char	vu_char;
 #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
 #endif /* BUG */
 
+/* Force a compilation error if condition is true */
+#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+
 typedef void (interrupt_handler_t)(void *);
 
 #include <asm/u-boot.h> /* boot information for Linux kernel */
include/ubi_uboot.h +0 -3
index 60f6a5f..20e3da5 100644
@@ -191,9 +191,6 @@ static inline long IS_ERR(const void *ptr)
 	return IS_ERR_VALUE((unsigned long)ptr);
 }
 
-/* Force a compilation error if condition is true */
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-
 /* module */
 #define THIS_MODULE		0
 #define try_module_get(...)	1
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/3 The BUILD_BUG_ON macros moved from ubi_uboot.h to common.h

Quoted 3 lines · On Thursday 01 April 2010 13:16:53 Michael Zaidman wrote:

The BUILD_BUG_ON macros made availible for rest of the u-boot code by moving it from ubi_uboot.h to common.h. In Linux kernel this widely used macros is defined in kernel.h file.

compiler.h might be a better place so that it is available to host tools too -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100402/2df3e63c/attachment.pgp

#2 lore raw

PATCH 1/3 The BUILD_BUG_ON macros moved from ubi_uboot.h to common.h

Quoted 8 lines · Mike Frysinger
Quoted 3 lines · On Thursday 01 April 2010 13:16:53 Michael Zaidman wrote:

The BUILD_BUG_ON macros made availible for rest of the u-boot code by moving it from ubi_uboot.h to common.h. In Linux kernel this widely used macros is defined in kernel.h file.

compiler.h might be a better place so that it is available to host tools too -mike

The common.h includes image.h which includes compiler.h, so technically it should works also. I have a doubt however - what about location of similar staff such as BUG, BUG_ON, debug, error, etc. Should it also be moved into compiler.h file?

#3 lore raw

PATCH 1/3 The BUILD_BUG_ON macros moved from ubi_uboot.h to common.h

Quoted 11 lines · On Friday 02 April 2010 06:56:41 Michael Zaidman wrote:
Quoted 7 lines · Mike Frysinger
Quoted 3 lines · On Thursday 01 April 2010 13:16:53 Michael Zaidman wrote:

The BUILD_BUG_ON macros made availible for rest of the u-boot code by moving it from ubi_uboot.h to common.h. In Linux kernel this widely used macros is defined in kernel.h file.

compiler.h might be a better place so that it is available to host tools too

The common.h includes image.h which includes compiler.h, so technically it should works also.

you're looking the wrong direction. host tools include compiler.h, they dont include common.h.

Quoted 2 lines

I have a doubt however - what about location of similar staff such as BUG, BUG_ON, debug, error, etc. Should it also be moved into compiler.h file?

many should not. BUG_ON requires functions that only u-boot implements and are not available in host C libraries.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100402/ee8ba090/attachment.pgp

#4 lore raw

PATCH 1/3 The BUILD_BUG_ON macros moved from ubi_uboot.h to common.h

Quoted 6 lines · Mike Frysinger
Quoted 3 lines

The common.h includes image.h which includes compiler.h, so technically it should works also.

you're looking the wrong direction. ?host tools include compiler.h, they dont include common.h.

It was clear to me. I meant the u-boot code here.

Quoted 6 lines
Quoted 3 lines

I have a doubt however - ?what about location of similar staff such as BUG, BUG_ON, debug, error, etc. Should it also be moved into compiler.h file?

many should not. ?BUG_ON requires functions that only u-boot implements and are not available in host C libraries.

So why do not place all useful staff which pass the compilation into compiler.h file?

-michael

#5 lore raw

PATCH 1/3 The BUILD_BUG_ON macros moved from ubi_uboot.h to common.h

Quoted 10 lines · On Saturday 03 April 2010 04:23:58 Michael Zaidman wrote:
Quoted 6 lines · Mike Frysinger
Quoted 3 lines

I have a doubt however - what about location of similar staff such as BUG, BUG_ON, debug, error, etc. Should it also be moved into compiler.h file?

many should not. BUG_ON requires functions that only u-boot implements and are not available in host C libraries.

So why do not place all useful staff which pass the compilation into compiler.h file?

i just told you why: only things that work with general C libraries/compilers may go into compiler.h. BUG_ON does not fall into that category. BUILD_BUG_ON does.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100403/c221c192/attachment.pgp

#6 lore raw

PATCH 1/3 The BUILD_BUG_ON macros moved from ubi_uboot.h to common.h

Quoted 9 lines · Mike Frysinger
Quoted 8 lines · On Saturday 03 April 2010 04:23:58 Michael Zaidman wrote:
Quoted 6 lines · Mike Frysinger
Quoted 3 lines

I have a doubt however - ?what about location of similar staff such as BUG, BUG_ON, debug, error, etc. Should it also be moved into compiler.h file?

many should not. ?BUG_ON requires functions that only u-boot implements and are not available in host C libraries.

Quoted 8 lines
Quoted 2 lines

So why do not place all useful staff which pass the compilation into compiler.h file?

i just told you why: only things that work with general C libraries/compilers may go into compiler.h. ?BUG_ON does not fall into that category. BUILD_BUG_ON does.
-mike

Thanks, I understood this. All I am trying to say is that the compiler.h file probably is not the best choice for such things hosting. The fact that it is the common header file _ONLY_ between u-boot and host tools code does not mean that we should fill it with all kind of things we would share between both codes. And if we see necessity to shared some useful definitions perhaps it makes sense to place them into the header file especially dedicated for this purpose. -michael