public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data)
@ 2011-01-03 15:47 Loïc Minier
  2011-01-03 16:35 ` Mike Frysinger
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Loïc Minier @ 2011-01-03 15:47 UTC (permalink / raw)
  To: u-boot

The eNET (x86) build fails with "invalid application of 'sizeof' to
incomplete type 'struct global_data'" because x86 doesn't define
struct global_data.  Change sizeof(struct global_data) to sizeof(gd_t)
which is always available.

Cc: Graeme Russ <graeme.russ@gmail.com>
Signed-off-by: Lo?c Minier <loic.minier@linaro.org>
---
 lib/asm-offsets.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c
index 2209561..6a4084e 100644
--- a/lib/asm-offsets.c
+++ b/lib/asm-offsets.c
@@ -23,7 +23,7 @@ int main(void)
 {
 	/* Round up to make sure size gives nice stack alignment */
 	DEFINE(GENERATED_GBL_DATA_SIZE,
-		(sizeof(struct global_data)+15) & ~15);
+		(sizeof(gd_t)+15) & ~15);
 
 	return 0;
 }
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data)
  2011-01-03 15:47 [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data) Loïc Minier
@ 2011-01-03 16:35 ` Mike Frysinger
  2011-01-03 17:00   ` Loïc Minier
  2011-01-03 16:51 ` Wolfgang Denk
  2011-01-03 17:00 ` [U-Boot] [PATCH 2/2] i386: Define struct global_data as on other arches Loïc Minier
  2 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2011-01-03 16:35 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 3, 2011 at 10:47 AM, Lo?c Minier wrote:
> The eNET (x86) build fails with "invalid application of 'sizeof' to
> incomplete type 'struct global_data'" because x86 doesn't define
> struct global_data. ?Change sizeof(struct global_data) to sizeof(gd_t)
> which is always available.

why not change x86's global_data.h to define the struct ?  all other
arches define 'struct global_data'.
-mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data)
  2011-01-03 15:47 [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data) Loïc Minier
  2011-01-03 16:35 ` Mike Frysinger
@ 2011-01-03 16:51 ` Wolfgang Denk
  2011-01-03 17:03   ` Loïc Minier
  2011-01-03 17:00 ` [U-Boot] [PATCH 2/2] i386: Define struct global_data as on other arches Loïc Minier
  2 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Denk @ 2011-01-03 16:51 UTC (permalink / raw)
  To: u-boot

Dear =?UTF-8?q?Lo=C3=AFc=20Minier?=,

In message <1294069652-9114-1-git-send-email-loic.minier@linaro.org> you wrote:
> The eNET (x86) build fails with "invalid application of 'sizeof' to
> incomplete type 'struct global_data'" because x86 doesn't define
> struct global_data.  Change sizeof(struct global_data) to sizeof(gd_t)
> which is always available.

Um... I do not like this change; the resulting code is harder to read.

Can you please change the struct declaration isntead, like this:

diff --git a/arch/i386/include/asm/global_data.h b/arch/i386/include/asm/global_data.h
index e3f8a25..e9000c3 100644
--- a/arch/i386/include/asm/global_data.h
+++ b/arch/i386/include/asm/global_data.h
@@ -35,7 +35,7 @@
 
 #ifndef __ASSEMBLY__
 
-typedef	struct {
+typedef	struct global_data {
 	bd_t		*bd;
 	unsigned long	flags;
 	unsigned long	baudrate;

Best regards,

Wolfgang Denk

-- 
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
"Athens  built  the  Acropolis.  Corinth  was  a   commercial   city,
interested  in  purely  materialistic things. Today we admire Athens,
visit it, preserve the old temples, yet we hardly ever  set  foot  in
Corinth."              - Dr. Harold Urey, Nobel Laureate in chemistry

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 2/2] i386: Define struct global_data as on other arches
  2011-01-03 15:47 [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data) Loïc Minier
  2011-01-03 16:35 ` Mike Frysinger
  2011-01-03 16:51 ` Wolfgang Denk
@ 2011-01-03 17:00 ` Loïc Minier
  2 siblings, 0 replies; 6+ messages in thread
From: Loïc Minier @ 2011-01-03 17:00 UTC (permalink / raw)
  To: u-boot

The eNET (x86) build was failing to build with "invalid application of
'sizeof' to incomplete type 'struct global_data'" because x86 didn't
define struct global_data.  lib/asm-offsets.c was changed to use
sizeof(gd_t) as gd_t is more commonly used outside of
arch/*/include/asm/global_data.h, but it is still useful to define
struct global_data in arch/i386/include/asm/global_data.h for
consistency.

Signed-off-by: Lo?c Minier <loic.minier@linaro.org>
Cc: Graeme Russ <graeme.russ@gmail.com>
---
 arch/i386/include/asm/global_data.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/i386/include/asm/global_data.h b/arch/i386/include/asm/global_data.h
index e3f8a25..6b7e101 100644
--- a/arch/i386/include/asm/global_data.h
+++ b/arch/i386/include/asm/global_data.h
@@ -35,7 +35,7 @@
 
 #ifndef __ASSEMBLY__
 
-typedef	struct {
+typedef	struct	global_data {
 	bd_t		*bd;
 	unsigned long	flags;
 	unsigned long	baudrate;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data)
  2011-01-03 16:35 ` Mike Frysinger
@ 2011-01-03 17:00   ` Loïc Minier
  0 siblings, 0 replies; 6+ messages in thread
From: Loïc Minier @ 2011-01-03 17:00 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 03, 2011, Mike Frysinger wrote:
> why not change x86's global_data.h to define the struct ?  all other
> arches define 'struct global_data'.

 We could implement both fixes; there are two reasons I preferred
 sending this fix instead of the one you mention:
 * gd_t is used across the tree, while struct global_data is only used
   in arch/*/include/asm/global_data.h headers
 * the global_data.h header suggested that sizeof(gd_t) was an
   acceptable construct in a comment:
   GENERATED_GBL_DATA_SIZE > sizeof(gd_t)

 I'll send an additional patch to also add struct global_data to
 arch/i386/include/asm/global_data.h.

-- 
Lo?c Minier

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data)
  2011-01-03 16:51 ` Wolfgang Denk
@ 2011-01-03 17:03   ` Loïc Minier
  0 siblings, 0 replies; 6+ messages in thread
From: Loïc Minier @ 2011-01-03 17:03 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 03, 2011, Wolfgang Denk wrote:
> Um... I do not like this change; the resulting code is harder to read.

 I don't mind either way; I had asked
 <20101220111358.GA28532@bee.dooz.org> which one was the preferred
 approach, but didn't get comments on this particular point; see
 <20110103170050.GB10571@bee.dooz.org> for the rationale for picking
 this option rather than the other one.

 I've sent a second patch to also define struct global_data; feel free
 to cherry pick any of the two patches or both

   Thanks!
-- 
Lo?c Minier

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-03 17:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-03 15:47 [U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data) Loïc Minier
2011-01-03 16:35 ` Mike Frysinger
2011-01-03 17:00   ` Loïc Minier
2011-01-03 16:51 ` Wolfgang Denk
2011-01-03 17:03   ` Loïc Minier
2011-01-03 17:00 ` [U-Boot] [PATCH 2/2] i386: Define struct global_data as on other arches Loïc Minier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox