mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Keith Mok <ek9852@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] Fix Mac OS cross compile failed.
Date: Mon, 13 Feb 2012 17:45:51 +0800	[thread overview]
Message-ID: <CAHjoi4eS2UwNTMKHs3wnytgmLLCSnTFPA5yfBQrDbwOSuJ4YoQ@mail.gmail.com> (raw)
In-Reply-To: <20120210113344.GF3852@pengutronix.de>

Hi Sascha,

> The patch is corrupted by your mailer. I see some additional linebreaks
> and also for some other reason patch reports a malformed patch.
I copied and pasted on web gmail and sent via plain text. Please check
again this time okay or not.

>
> Please use a standard unsigned long instead.
>
Done.

>
> I *think* this should be
>
> #ifdef __BAREBOX__
> #include <asm/byteorder.h>
> #endif
Done.

>
> instead. I assume that compilation on apple fails on
>
> HOSTCC  scripts/bareboxenv
>
> right?
>
>
No, I have the bareboxenv generated and can be executed in Mac.


>
> Do we need the #ifdef __APPLE__? Something like this is a bit easier
> to read:
>
> #ifndef __BYTE_ORDER
> #ifdef __LITTLE_ENDIAN__ /* Apple defines this */
> #define __BYTE_ORDER __LITTLE_ENDIAN
> #elif defined(__BIG_ENDIAN__)
> #define __BYTE_ORDER __BIG_ENDIAN
> #endif
> #endif
>
> #ifndef __BYTE_ORDER
> #error "No byte order defined in __BYTE_ORDER"
> #endif
>

> I wonder why there's a seperate section for this config_header anyway.
> Maybe we can drop this completely?
Done.

==================================================================

Fix to avoid using GNU extension on varies areas.

Signed-off-by: Keith Mok <ek9852@gmail.com>
---
 common/Makefile       |    4 +-
 crypto/crc32.c        |   10 ++--
 include/envfs.h       |   10 ++++
 include/image.h       |    3 +-
 scripts/genenv        |    4 +-
 scripts/omap_signGP.c |  139 ++++++++++++++++++++++++-------------------------
 6 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index d1132c3..ded742b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -47,7 +47,7 @@ ifneq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH),"")
 DEFAULT_ENVIRONMENT_PATH += $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
 endif

-ENV_FILES := $(shell cd $(srctree); for i in
$(DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec readlink -f
'{}' \;; done)
+ENV_FILES := $(shell for i in $(srctree)/$(DEFAULT_ENVIRONMENT_PATH);
do find $${i} -type f; done)

 endif # ifdef CONFIG_DEFAULT_ENVIRONMENT

@@ -76,7 +76,7 @@ barebox_default_env.lzo: barebox_default_env

 include/generated/barebox_default_env.h:
barebox_default_env$(barebox_default_env_comp)
 	$(Q)cat $< | $(objtree)/scripts/bin2c default_environment > $@
-	$(Q)echo "const int default_environment_uncompress_size=`stat -c%s
barebox_default_env`;" >> $@
+	$(Q)echo "const int default_environment_uncompress_size=`wc -c
barebox_default_env | awk '{print $$1}'`;" >> $@

 CLEAN_FILES += include/generated/barebox_default_env.h barebox_default_env
 CLEAN_FILES += barebox_default_env.gz barebox_default_env.bz2
diff --git a/crypto/crc32.c b/crypto/crc32.c
index 275edb4..da6c465 100644
--- a/crypto/crc32.c
+++ b/crypto/crc32.c
@@ -15,7 +15,7 @@
 #ifdef CONFIG_DYNAMIC_CRC_TABLE

 static int crc_table_empty = 1;
-static ulong crc_table[256];
+static unsigned long crc_table[256];
 static void make_crc_table(void);

 /*
@@ -44,9 +44,9 @@ static void make_crc_table(void);
 */
 static void make_crc_table(void)
 {
-  ulong c;
+  unsigned long c;
   int n, k;
-  ulong poly;            /* polynomial exclusive-or pattern */
+  unsigned long poly;            /* polynomial exclusive-or pattern */
   /* terms of polynomial defining this crc (except x^32): */
   static const char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};

@@ -57,7 +57,7 @@ static void make_crc_table(void)

   for (n = 0; n < 256; n++)
   {
-    c = (ulong)n;
+    c = (unsigned long)n;
     for (k = 0; k < 8; k++)
       c = c & 1 ? poly ^ (c >> 1) : c >> 1;
     crc_table[n] = c;
@@ -68,7 +68,7 @@ static void make_crc_table(void)
 /* ========================================================================
  * Table of CRC-32's of all single-byte values (made by make_crc_table)
  */
-static const ulong crc_table[256] = {
+static const unsigned long crc_table[256] = {
   0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
   0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
   0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
diff --git a/include/envfs.h b/include/envfs.h
index b5849d9..a622210 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -1,7 +1,9 @@
 #ifndef _ENVFS_H
 #define _ENVFS_H

+#ifdef __BAREBOX__
 #include <asm/byteorder.h>
+#endif

 #define ENVFS_MAGIC		    0x798fba79	/* some random number */
 #define ENVFS_INODE_MAGIC	0x67a8c78d
@@ -33,6 +35,14 @@ struct envfs_super {
 };

 #ifndef __BYTE_ORDER
+#ifdef __LITTLE_ENDIAN__ /* Apple defines this */
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#elif defined(__BIG_ENDIAN__)
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+#endif
+
+#ifndef __BYTE_ORDER
 #error "No byte order defined in __BYTE_ORDER"
 #endif

diff --git a/include/image.h b/include/image.h
index 35ff01b..b219b20 100644
--- a/include/image.h
+++ b/include/image.h
@@ -31,11 +31,12 @@
 #ifndef __IMAGE_H__
 #define __IMAGE_H__

-#include <linux/types.h>
 #ifdef __BAREBOX__
 #include <asm/byteorder.h>
 #include <stdio.h>
 #include <string.h>
+#else
+#include <stdint.h>
 #endif

 /*
diff --git a/scripts/genenv b/scripts/genenv
index 7b279c8..da9de61 100755
--- a/scripts/genenv
+++ b/scripts/genenv
@@ -8,13 +8,13 @@ objtree=$2
 cd $1 || exit 1
 shift 2

-tempdir=$(mktemp -d)
+tempdir=$(mktemp -d tmp.XXXXXXXXXX)

 for i in $*; do
 	cp -r $i/* $tempdir
 done

-find $tempdir -name '.svn' -o -name '*~' | xargs --no-run-if-empty rm -r
+find $tempdir -name '.svn' -o -name '*~' | xargs rm -rf

 $objtree/scripts/bareboxenv -s $tempdir $objtree/barebox_default_env

diff --git a/scripts/omap_signGP.c b/scripts/omap_signGP.c
index d20d357..46c016c 100644
--- a/scripts/omap_signGP.c
+++ b/scripts/omap_signGP.c
@@ -28,90 +28,90 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <malloc.h>
-#include <linux/types.h>
+#include <stdint.h>

 #undef CH_WITH_CHRAM
 struct chsettings {
-	__u32 section_key;
-	__u8 valid;
-	__u8 version;
-	__u16 reserved;
-	__u32 flags;
+	uint32_t section_key;
+	uint8_t valid;
+	uint8_t version;
+	uint16_t reserved;
+	uint32_t flags;
 } __attribute__ ((__packed__));

-/*    __u32  cm_clksel_core;
-    __u32  reserved1;
-    __u32  cm_autoidle_dpll_mpu;
-    __u32  cm_clksel_dpll_mpu;
-    __u32  cm_div_m2_dpll_mpu;
-    __u32  cm_autoidle_dpll_core;
-    __u32  cm_clksel_dpll_core;
-    __u32  cm_div_m2_dpll_core;
-    __u32  cm_div_m3_dpll_core;
-    __u32  cm_div_m4_dpll_core;
-    __u32  cm_div_m5_dpll_core;
-    __u32  cm_div_m6_dpll_core;
-    __u32  cm_div_m7_dpll_core;
-    __u32  cm_autoidle_dpll_per;
-    __u32  cm_clksel_dpll_per;
-    __u32  cm_div_m2_dpll_per;
-    __u32  cm_div_m3_dpll_per;
-    __u32  cm_div_m4_dpll_per;
-    __u32  cm_div_m5_dpll_per;
-    __u32  cm_div_m6_dpll_per;
-    __u32  cm_div_m7_dpll_per;
-    __u32  cm_autoidle_dpll_usb;
-    __u32  cm_clksel_dpll_usb;
-    __u32  cm_div_m2_dpll_usb;
+/*    uint32_t  cm_clksel_core;
+    uint32_t  reserved1;
+    uint32_t  cm_autoidle_dpll_mpu;
+    uint32_t  cm_clksel_dpll_mpu;
+    uint32_t  cm_div_m2_dpll_mpu;
+    uint32_t  cm_autoidle_dpll_core;
+    uint32_t  cm_clksel_dpll_core;
+    uint32_t  cm_div_m2_dpll_core;
+    uint32_t  cm_div_m3_dpll_core;
+    uint32_t  cm_div_m4_dpll_core;
+    uint32_t  cm_div_m5_dpll_core;
+    uint32_t  cm_div_m6_dpll_core;
+    uint32_t  cm_div_m7_dpll_core;
+    uint32_t  cm_autoidle_dpll_per;
+    uint32_t  cm_clksel_dpll_per;
+    uint32_t  cm_div_m2_dpll_per;
+    uint32_t  cm_div_m3_dpll_per;
+    uint32_t  cm_div_m4_dpll_per;
+    uint32_t  cm_div_m5_dpll_per;
+    uint32_t  cm_div_m6_dpll_per;
+    uint32_t  cm_div_m7_dpll_per;
+    uint32_t  cm_autoidle_dpll_usb;
+    uint32_t  cm_clksel_dpll_usb;
+    uint32_t  cm_div_m2_dpll_usb;
 }*/

 struct gp_header {
-	__u32 size;
-	__u32 load_addr;
+	uint32_t size;
+	uint32_t load_addr;
 } __attribute__ ((__packed__));

 struct ch_toc {
-	__u32 section_offset;
-	__u32 section_size;
-	__u8 unused[12];
-	__u8 section_name[12];
+	uint32_t section_offset;
+	uint32_t section_size;
+	uint8_t unused[12];
+	uint8_t section_name[12];
 } __attribute__ ((__packed__));

 struct chram {
 	/* CHRAM */
-	__u32 section_key_chr;
-	__u8 section_disable_chr;
-	__u8 pad_chr[3];
+	uint32_t section_key_chr;
+	uint8_t section_disable_chr;
+	uint8_t pad_chr[3];
 	/* EMIF1 */
-	__u32 config_emif1;
-	__u32 refresh_emif1;
-	__u32 tim1_emif1;
-	__u32 tim2_emif1;
-	__u32 tim3_emif1;
-	__u32 pwrControl_emif1;
-	__u32 phy_cntr1_emif1;
-	__u32 phy_cntr2_emif1;
-	__u8 modereg1_emif1;
-	__u8 modereg2_emif1;
-	__u8 modereg3_emif1;
-	__u8 pad_emif1;
+	uint32_t config_emif1;
+	uint32_t refresh_emif1;
+	uint32_t tim1_emif1;
+	uint32_t tim2_emif1;
+	uint32_t tim3_emif1;
+	uint32_t pwrControl_emif1;
+	uint32_t phy_cntr1_emif1;
+	uint32_t phy_cntr2_emif1;
+	uint8_t modereg1_emif1;
+	uint8_t modereg2_emif1;
+	uint8_t modereg3_emif1;
+	uint8_t pad_emif1;
 	/* EMIF2 */
-	__u32 config_emif2;
-	__u32 refresh_emif2;
-	__u32 tim1_emif2;
-	__u32 tim2_emif2;
-	__u32 tim3_emif2;
-	__u32 pwrControl_emif2;
-	__u32 phy_cntr1_emif2;
-	__u32 phy_cntr2_emif2;
-	__u8 modereg1_emif2;
-	__u8 modereg2_emif2;
-	__u8 modereg3_emif2;
-	__u8 pad_emif2;
+	uint32_t config_emif2;
+	uint32_t refresh_emif2;
+	uint32_t tim1_emif2;
+	uint32_t tim2_emif2;
+	uint32_t tim3_emif2;
+	uint32_t pwrControl_emif2;
+	uint32_t phy_cntr1_emif2;
+	uint32_t phy_cntr2_emif2;
+	uint8_t modereg1_emif2;
+	uint8_t modereg2_emif2;
+	uint8_t modereg3_emif2;
+	uint8_t pad_emif2;

-	__u32 dmm_lisa_map;
-	__u8 flags;
-	__u8 pad[3];
+	uint32_t dmm_lisa_map;
+	uint8_t flags;
+	uint8_t pad[3];
 } __attribute__ ((__packed__));


@@ -121,7 +121,7 @@ struct ch_chsettings_chram {
 	struct ch_toc toc_terminator;
 	struct chsettings section_chsettings;
 	struct chram section_chram;
-	__u8 padding1[512 -
+	uint8_t padding1[512 -
 		    (sizeof(struct ch_toc) * 3 +
 		     sizeof(struct chsettings) + sizeof(struct chram))];
 	/* struct gp_header gpheader; */
@@ -131,7 +131,7 @@ struct ch_chsettings_nochram {
 	struct ch_toc toc_chsettings;
 	struct ch_toc toc_terminator;
 	struct chsettings section_chsettings;
-	__u8 padding1[512 -
+	uint8_t padding1[512 -
 		    (sizeof(struct ch_toc) * 2 +
 		     sizeof(struct chsettings))];
 	/* struct gp_header gpheader; */
@@ -209,8 +209,7 @@ static const struct ch_chsettings_chram config_header = {
 	""
 };
 #else
-static struct ch_chsettings_nochram config_header
-	__attribute__((section(".config_header"))) = {
+static struct ch_chsettings_nochram config_header = {
 	/* CHSETTINGS TOC */
 	{(sizeof(struct ch_toc)) * 2,
 	 sizeof(struct chsettings),
-- 
1.7.7.4

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2012-02-13  9:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07 14:45 [PATCH] " Keith Mok
2012-02-10 11:33 ` Sascha Hauer
2012-02-13  9:45   ` Keith Mok [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHjoi4eS2UwNTMKHs3wnytgmLLCSnTFPA5yfBQrDbwOSuJ4YoQ@mail.gmail.com \
    --to=ek9852@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox