[PATCH] exports.h: add required definitions from common.h
Chris Packham
judge.packham at gmail.com
Wed Jan 16 05:36:05 CET 2013
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/exports.h | 15 +++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
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/exports.h b/include/exports.h
index 63aa4b2..65b25a1 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -3,6 +3,21 @@
#ifndef __ASSEMBLY__
+#ifndef __COMMON_H_
+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 /* ifndef __COMMON_H__ */
+
/* These are declarations of exported functions available in C code */
unsigned long get_version(void);
int getc(void);
--=20
1.7.10.2.dirty
On Wed, Jan 16, 2013 at 5:23 PM, Chris Packham <judge.packham at gmail.com>wro=
te:
> Hi,
>
> I've just run into something porting an existing out of tree board to
> u-boot 2012.10 but I think it points to a generic issue for standalone
> applications.
>
> Consider the following change
>
> diff --git a/examples/standalone/hello_world.c
> b/examples/standalone/hello_world.c
> index 067c390..d2e6a77 100644
> --- a/examples/standalone/hello_world.c
> +++ b/examples/standalone/hello_world.c
> @@ -24,7 +24,7 @@
> #include <common.h>
> #include <exports.h>
>
> -int hello_world (int argc, char * const argv[])
> +int net_init (int argc, char * const argv[])
> {
> int i;
>
> Because I'm not linking with the u-boot object file, I should be able to
> use any function name I like in my application as long as it isn't one of
> the functions in exports.h (at least in theory). Unfortunately I end up
> with the following compiler error
>
> hello_world.c:27: error: conflicting types for =E2=80=98net_init=E2=80=
=99
> uboot/include/net.h:489: error: previous declaration of =E2=80=98net_in=
it=E2=80=99 was
> here
> make[1]: *** [hello_world.o] Error 1
>
> If I replace #include <common.h> in my app with the first hunk of include=
s
> from the top of common.h then I can compile just fine.
>
> I was wondering if it made sense to people to have standalone application=
s
> define something like __STANDALONE__ either via CPPFLAGS or in the source
> itself and use the presence of that to exclude the majority of common.h
> when used in standalone applications. Or alternatively move the required
> bits to exports.h.
>
> Thanks,
> Chris
>
>
--e89a8ff1c58499a81b04d3607e6f--
More information about the U-Boot
mailing list