[U-Boot] [PATCH 1/2] common: introduce a genutils.h file

Heiko Schocher
2010-12-13T09:26:33Z

as discussed in thread
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/76654

and as a result of this discussion Michael Zaidman
proposed to create a genutils.h, see:

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/78692

So, introduce this genutils.h, as BUILD_BUG_ON is also
needed in sensor support.

Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Michael Zaidman <michael.zaidman@gmail.com>
---
maybe I should include genutils.h in common.h ?

include/genutils.h | 30 ++++++++++++++++++++++++++++++
include/ubi_uboot.h | 4 +---
2 files changed, 31 insertions(+), 3 deletions(-)
create mode 100644 include/genutils.h

diff --git a/include/genutils.h b/include/genutils.h
new file mode 100644
index 0000000..102f048
--- /dev/null
+++ b/include/genutils.h
@@ -0,0 +1,30 @@
+/*
+ * (C) Copyright 2010
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __GENUTILS_H_
+#define __GENUTILS_H_ 1
+
+/* Force a compilation error if condition is true */
+#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+
+#endif /* __GENUTILS_H_ */
diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index d2c90a6..ad15c8e 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -16,6 +16,7 @@

#include <common.h>
#include <compiler.h>
+#include <genutils.h>
#include <malloc.h>
#include <div64.h>
#include <linux/crc32.h>
@@ -191,9 +192,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
--
1.7.2.3