Skip to contentSkip to conversation

add u-boot/types to simplify HOST support

PATCH New Jean-Christophe PLAGNIOL-VILLARD 2 participants 4 messages Aug 16, 2008 – Aug 17, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add u-boot/types to simplify HOST support

add fix MacOS HOST support

---
 include/elf.h          |   15 +------------
 include/environment.h  |    6 +----
 include/image.h        |    1 +
 include/libfdt_env.h   |    3 +-
 include/u-boot/md5.h   |    2 +-
 include/u-boot/types.h |   53 ++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 58 insertions(+), 22 deletions(-)
 create mode 100644 include/u-boot/types.h
include/elf.h +1 -14
index a9839df..88d76bd 100644
@@ -33,20 +33,7 @@
 #ifndef _ELF_H
 #define _ELF_H
 
-#if defined(__BEOS__)	 || \
-    defined(__NetBSD__)  || \
-    defined(__FreeBSD__) || \
-    defined(__sun__)	 || \
-    defined(__APPLE__)
-#include <inttypes.h>
-#elif defined(__linux__) && defined(USE_HOSTCC)
-#include <stdint.h>
-#elif defined(__WIN32__)
-#include <unistd.h>
-typedef	 unsigned char	 uint8_t;
-typedef	 unsigned short  uint16_t;
-typedef	 unsigned int	 uint32_t;
-#endif
+#include <u-boot/types.h>
 
 /*
  *  This version doesn't work for 64-bit ABIs - Erik.
include/environment.h +1 -5
index 481ea73..d9d75cb 100644
@@ -84,11 +84,7 @@
 # endif
 #endif /* CFG_ENV_IS_IN_NAND */
 
-#ifdef USE_HOSTCC
-# include <stdint.h>
-#else
-# include <linux/types.h>
-#endif
+#include <u-boot/types.h>
 
 #ifdef CFG_REDUNDAND_ENVIRONMENT
 # define ENV_HEADER_SIZE	(sizeof(uint32_t) + 1)
include/image.h +1 -0
index 4b9c582..0f1a5f4 100644
@@ -35,6 +35,7 @@
 
 #include <asm/byteorder.h>
 #include <command.h>
+#include <u-boot/types.h>
 
 #ifndef USE_HOSTCC
 #include <lmb.h>
include/libfdt_env.h +1 -2
index a7fd2f8..d5b1c12 100644
@@ -21,12 +21,11 @@
 #ifndef _LIBFDT_ENV_H
 #define _LIBFDT_ENV_H
 
+#include <u-boot/types.h>
 #ifdef USE_HOSTCC
-#include <stdint.h>
 #include <string.h>
 #else
 #include <linux/string.h>
-#include <linux/types.h>
 #endif /* USE_HOSTCC */
 
 #include <stddef.h>
include/u-boot/md5.h +1 -1
index 8b44a7f..0e3f3bc 100644
@@ -6,7 +6,7 @@
 #ifndef _MD5_H
 #define _MD5_H
 
-#include <linux/types.h>
+#include <u-boot/types.h>
 
 struct MD5Context {
 	__u32 buf[4];
include/u-boot/types.h new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
1.5.6.3
#1 lore raw

PATCH 1/1 add u-boot/types to simplify HOST support

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 12 lines · In message <[email protected]> you wrote:

add fix MacOS HOST support

---
 include/elf.h          |   15 +------------
 include/environment.h  |    6 +----
 include/image.h        |    1 +
 include/libfdt_env.h   |    3 +-
 include/u-boot/md5.h   |    2 +-
 include/u-boot/types.h |   53 ++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 58 insertions(+), 22 deletions(-)
 create mode 100644 include/u-boot/types.h

...

Quoted 49 lines
include/u-boot/types.h new file +43 -0
new file mode 100644
index 0000000..e4afa98
@@ -0,0 +1,53 @@
+/*
+ * (C) Copyright 2008 Jean-Christophe PLAGNIOL-VILLARD
+ *  <[email protected]>
+ *
+ * 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 __U_BOOT_TYPES_H__
+#define __U_BOOT_TYPES_H__
+
+#ifndef USE_HOSTCC
+#include <linux/types.h>
+#else
+
+#if defined(__BEOS__)	 || \
+    defined(__NetBSD__)  || \
+    defined(__FreeBSD__) || \
+    defined(__sun__)	 || \
+    defined(__APPLE__)
+#include <inttypes.h>
+/* sysv */
+typedef unsigned char	unchar;
+typedef unsigned short	ushort;
+typedef unsigned int	uint;
+typedef unsigned long	ulong;
+
+#elif defined(__linux__)

include/u-boot/types.h line 53

Quoted 10 lines
include/u-boot/types.h new file +10 -0
+#include <stdint.h>
+#elif defined(__WIN32__)
+#include <unistd.h>
+typedef	 unsigned char	 uint8_t;
+typedef	 unsigned short  uint16_t;
+typedef	 unsigned int	 uint32_t;
+#endif
+#endif /* USE_HOSTCC */
+
+#endif /* __U_BOOT_TYPES_H__ */

My initial reaction was "what a good idea", bt after looking at the resulting code I find that it bocmes even less readable. With this patch applied, I lost the last bit of track I had which define was coming where from.

For example, include/environment.h used to have this code:

-#ifdef USE_HOSTCC
-# include <stdint.h>
-#else
-# include <linux/types.h>
-#endif

So it would include <linux/types.h> for <stdint.h> for native builds.

With your change, we have added complexity of selecting from <inttypes.h> or <stdint.h> or <unistd.h> or nothing.

Are you absolutely sure that this is 100% equivalent and working?

I have to admit that I don't like this change.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Who is the oldest inhabitant of this village?"
"We haven't got one; we had one, but he died three weeks ago."
#2 lore raw

PATCH 1/1 add u-boot/types to simplify HOST support

Quoted 17 lines

include/u-boot/types.h line 53

Quoted 3 lines
include/u-boot/types.h new file +3 -0
+
+
+#endif /* __U_BOOT_TYPES_H__ */

My initial reaction was "what a good idea", bt after looking at the resulting code I find that it bocmes even less readable. With this patch applied, I lost the last bit of track I had which define was coming where from.

For example, include/environment.h used to have this code:

include/environment.h +0 -5
-#ifdef USE_HOSTCC
-# include <stdint.h>
-#else
-# include <linux/types.h>
-#endif
Quoted 4 lines

So it would include <linux/types.h> for <stdint.h> for native builds.

With your change, we have added complexity of selecting from <inttypes.h> or <stdint.h> or <unistd.h> or nothing.

we can modify it as

#ifdef USE_HOSTCC
#include <linux/types.h>
#else

#if defined(__BEOS__)	 || \
    defined(__NetBSD__)  || \
    defined(__FreeBSD__) || \
    defined(__sun__)	 || \
    defined(__APPLE__)

#include <inttypes.h>
/* sysv */
typedef unsigned char unchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;

#elif defined(__WIN32__)
#include <unistd.h>
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#else /* __linux__ & default */
#include <stdint.h>
#endif
#endif /* USE_HOSTCC */

Quoted 3 lines

Are you absolutely sure that this is 100% equivalent and working?

I've test it on MacOs and Linux.

Best Regards,
J.

#3 lore raw

PATCH 1/1 add u-boot/types to simplify HOST support

Dear Jean-Christophe,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 5 lines

So it would include <linux/types.h> for <stdint.h> for native builds.

With your change, we have added complexity of selecting from <inttypes.h> or <stdint.h> or <unistd.h> or nothing.

we can modify it as

Of course we can modify it - but that doesn't make it less cluttered.

Quoted 3 lines
Quoted 1 line

Are you absolutely sure that this is 100% equivalent and working?

I've test it on MacOs and Linux.

That's just two systems out of N...

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Documentation is the castor oil of programming.
Managers know it must be good because the programmers hate it so much.