[RFC/PATCH] common.h: move definitions needed by standalone

Chris Packham judge.packham at gmail.com
Wed Jan 16 05:36:05 CET 2013


programs

Standalone applications need to include export.h which in turn needs
some of the basic types defined by including common.h. Unfortunately
common.h also has declarations for functions not available to standalone
applications. For example if a standalone application defined it's own
networking stack it could only defined "int net_init(void)" because this
is the declaration in net.h which is included in common.h.

To avoid symbol namespace conflicts between standalone applications and
u-boot code add the definitions required in exports.h so standalone
applications do not have to include common.h.
---
 examples/standalone/hello_world.c |    1 -
 include/common.h                  |   13 +----------
 include/exports.h                 |    2 ++
 include/stddef.h                  |   43
+++++++++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 13 deletions(-)
 create mode 100644 include/stddef.h

diff --git a/examples/standalone/hello_world.c
b/examples/standalone/hello_world.c
index 067c390..91a2deb 100644
--- a/examples/standalone/hello_world.c
+++ b/examples/standalone/hello_world.c
@@ -21,7 +21,6 @@
  * MA 02111-1307 USA
  */

-#include <common.h>
 #include <exports.h>

 int hello_world (int argc, char * const argv[])
diff --git a/include/common.h b/include/common.h
index a7fb05e..dca33b8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -29,18 +29,7 @@

 #ifndef __ASSEMBLY__        /* put C only stuff in this section */

-typedef unsigned char        uchar;
-typedef volatile unsigned long    vu_long;
-typedef volatile unsigned short vu_short;
-typedef volatile unsigned char    vu_char;
-
-#include <config.h>
-#include <asm-offsets.h>
-#include <linux/bitops.h>
-#include <linux/types.h>
-#include <linux/string.h>
-#include <asm/ptrace.h>
-#include <stdarg.h>
+#include <stddef.h>
 #if defined(CONFIG_PCI) && (defined(CONFIG_4xx) && !defined(CONFIG_AP1000)=
)
 #include <pci.h>
 #endif
diff --git a/include/exports.h b/include/exports.h
index 63aa4b2..d874235 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -3,6 +3,8 @@

 #ifndef __ASSEMBLY__

+#include <stddef.h>
+
 /* These are declarations of exported functions available in C code */
 unsigned long get_version(void);
 int  getc(void);
diff --git a/include/stddef.h b/include/stddef.h
new file mode 100644
index 0000000..7fea85a
--- /dev/null
+++ b/include/stddef.h
@@ -0,0 +1,43 @@
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd 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 __STDDEF_H__
+#define __STDDEF_H__
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned char           uchar;
+typedef volatile unsigned long  vu_long;
+typedef volatile unsigned short vu_short;
+typedef volatile unsigned char  vu_char;
+
+#include <config.h>
+#include <asm-offsets.h>
+#include <linux/bitops.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <asm/ptrace.h>
+#include <stdarg.h>
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __STDDEF_H__ */
--=20
1.7.10.2.dirty

--e89a8ff1c170157ade04d36d59a4--


More information about the U-Boot mailing list