Subject: Re: Struct alignment on netwinder

From: Russell King <[email-masked]>
Date: Wed, 2 Sep 1998 21:03:54 +0100 (BST)

Andrew E. Mileski writes:
> > As you've observed, code that relies on this is just plain wrong and needs to
> > be fixed.  You may be able to work around it by adding
> > __attribute__ (( __packed__ )) to the structure definitions.
> 
> As Philip said, the code is just plain wrong :P
> 
> I had to hack RPM because it does I/O with structs.
> I didn't bother using the packed attribute, as that
> isn't portable either.
> 
> The solution is to always read and write unsigned
> chars, and then if you are really thorough, don't
> assume bit order either.

I was talking to Eric Troan (RedHat bod), and he will not accept
any patches for lib/cpio.c - his opinion is that because everything
else works, we ought to fall in line.

He will not accept patches to rpm to change this because he wants the
code to be readable, not functional.  Sounds like he's too concerned
about 'the readability of code' rather than the functionality of it.

If you ask me, I think this is totally the wrong attitude.

He also mentioned that he is not considering even attempting to do
an ARM distribution because of the lack of market for such a port.

I'm afraid that my opinions are changing, favouring maybe some other
distribution like Debian now.
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [email-masked]      --- ---
  | | | |   http://www.arm.uk.linux.org/~rmk/aboutme.html    /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Shaleh <[email-masked]>
Date: Wed, 02 Sep 1998 17:53:25 -0400

> > chars, and then if you are really thorough, don't

How do you deal w/ functions that expect signed variables?  Passing an
unsigned char into something that expects an int or char gives me
warnings in gcc et. al.

-- 
=====
Linux, because I'd like to *get there* today
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Paul Koning <[email-masked]>
Date: Wed, 2 Sep 1998 18:05:31 -0400

>>>>> "Russell" == Russell King <[email-masked]> writes:

 Russell> Andrew E. Mileski writes:
 >> > As you've observed, code that relies on this is just plain wrong
 >> and needs to > be fixed.  You may be able to work around it by
 >> adding > __attribute__ (( __packed__ )) to the structure
 >> definitions.
 >> 
 >> I had to hack RPM because it does I/O with structs.  I didn't
 >> bother using the packed attribute, as that isn't portable either.
 >> 
 >> The solution is to always read and write unsigned chars, and then
 >> if you are really thorough, don't assume bit order either.

 Russell> I was talking to Eric Troan (RedHat bod), and he will not
 Russell> accept any patches for lib/cpio.c - his opinion is that
 Russell> because everything else works, we ought to fall in line.

Wow.  Is he the person in charge of that file?  I thought cpio is a
standard file utility.  Or is this cpio-compatible library code?

Anyway, with an attitude like that, who needs enemies?

 Russell> He will not accept patches to rpm to change this because he
 Russell> wants the code to be readable, not functional.  Sounds like
 Russell> he's too concerned about 'the readability of code' rather
 Russell> than the functionality of it.

Oh.  So he doesn't care if it is broken, he just wants it to look
pretty?

 Russell> I'm afraid that my opinions are changing, favouring maybe
 Russell> some other distribution like Debian now.

I'll say.  It sounds like Red Hat should be avoided for any purpose,
if this is what they think is the right way to build software.

	paul

---

From: Russell King <[email-masked]>
Date: Wed, 2 Sep 1998 23:32:40 +0100 (BST)

> standard file utility.  Or is this cpio-compatible library code?

It's supposed to be cpio-compatible, but cpio is a little more portable
than that implementation.

> if this is what they think is the right way to build software.

Indeed.  And to think that I was just last month arguing to keep ARM
RedHat on the linux-arm mailing list. ;(
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [email-masked]      --- ---
  | | | |   http://www.arm.uk.linux.org/~rmk/aboutme.html    /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Ian Jeffray <[email-masked]>
Date: Wed, 02 Sep 1998 23:40:18 +0100

Hi all,

I'm building 2.0.35 on "arch-old" and I've some problems.
First off, tty.h had to be hacked quite a lot to get things to
compile... even the latest version of the headers doesnt seem to
define things correctly and has #ifdef __arm__ where it doesnt want
to be. :-(   That aside, I get to building scsi.c where it gives me
an  "#error You lose".  Why?  Because my PAGE_SHIFT is 15, therefore
PAGE_SIZE is 32k... scsi.c gives that error if PAGE_SIZE/512 is
greater than 32, which it is (64). Now I'm confused... this looks
exactly the same as for 2.0.31 which I built perfectly OK...
can someone tell me what's going on here, and how I might validly
frig scsi.c to work for machines with 32K PAGE_SIZE ?
(I dont want to just suck-and-see as I value my scsi disc ;)

Best regards,

Ian

-- 
Ian Jeffray // [email-masked] // http://www.eh.org/~ian/
Tel: 0131 337 9923 // 0131 623 4462 // 0378 392 963
Paradise : http://www.paradise.force9.co.uk/
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Alan Cox <[email-masked]>
Date: Wed, 2 Sep 1998 23:51:08 +0100 (BST)

> standard file utility.  Or is this cpio-compatible library code?

Its cpio compatible library code.

> Anyway, with an attitude like that, who needs enemies?

Erik's a nice guy. If you got as much work to do as he did you'd be
as abrupt in email. 

Alan

---

From: Alan Cox <[email-masked]>
Date: Wed, 2 Sep 1998 23:51:41 +0100 (BST)

> unsigned char into something that expects an int or char gives me

Thats what casting was invented for

---

From: Alan Cox <[email-masked]>
Date: Wed, 2 Sep 1998 23:57:09 +0100 (BST)

> else works, we ought to fall in line.

It needs maintaining. If you want to fix it you probably want

	lib/cpio-annoyinghardware.c

> an ARM distribution because of the lack of market for such a port.

Is that a suprise. The Acorn market is microscopic and the only other
possible market is the Netwinder folks, providing the survive.

> distribution like Debian now.

The Debian folk are cool and don't have any commercial pressures (or market
to cause them). 
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Alan Cox <[email-masked]>
Date: Thu, 3 Sep 1998 00:19:21 +0100 (BST)

> RedHat on the linux-arm mailing list. ;(

Erik isnt dumb. Before everyone gets down to calling each other nazis
and things let me go beat on Erik and find out what the actual issues
are. Even if the arm code is messy I can think of plenty of solutions

(for one RPM has %ifarch unlike dpkg src)

Maybe it needs to have

	arch_write_struct()/arch_read_struct()

code to keep it clean.

Alan

---

From: Todd Graham Lewis <[email-masked]>
Date: Wed, 2 Sep 1998 19:44:28 -0400 (EDT)

> else works, we ought to fall in line.

Did he post this in public?  If so, do you have a reference to it
somewhere?  I'd love to add an "Eric Troan writes buggy code!" section
to my home page...

--
Todd Graham Lewis            32°49'N,83°36'W          (800) 719-4664, x2804
******Linux******         MindSpring Enterprises      [email-masked]

---

From: "Andrew E. Mileski" <[email-masked]>
Date: Wed, 02 Sep 1998 23:21:10 -0400

> > As Philip said, the code is just plain wrong :P

Russell, you misquoted :(  Philip wrote "> > >" and
I wrote "> >".

Please be more careful.

--
Andrew E. Mileski
Software Developer
Corel Computer Corp.

---

From: "Andrew E. Mileski" <[email-masked]>
Date: Wed, 02 Sep 1998 23:27:45 -0400

> unsigned char into something that expects an int or char gives me

You convert signed to unsigned BEFORE a write, and
convert unsigned to signed AFTER a read.  Notice I
stated "convert" not cast!  The idea is to ensure
all bits get read/written.

---

From: Eduard Pfarr <[email-masked]>
Date: Thu, 3 Sep 1998 10:48:27 +0200 (BST)

In <URL:news:local.Armlinux> on Thu 03 Sep, Alan Cox wrote:

[..]
> possible market is the Netwinder folks, providing the survive.

Good day,

I'm new to (Arm-) Linux. I've decided to go for it because I've been under
the impression that Linux is CPU independant as far as possible. I've liked
that interview with Linus in a recent (German) computer magazine (»c't«)
where he stated proudly that Linux supported the most number of different
platforms. ARM, and StrongARM computers in particular, are such platforms.
I suppose it's not nice what RedHat are doing - according to Russel King's
posts. Am I wrong?

One last word: I've started to become inspired by the unconventional and
friendly »spirit« of the Linux world. Not that $$$-pressure like in the M$
world (where I come from). So far. I've subscribed to this list just a few
weeks ago and with regret I see this not-nice discussion here.
  If Linux is intented to overcome the M$ thingy one day, one should rather
cooperate in the Linux »market«. A propos: Does anybody successfully run
that impressive KDE on his Arm-Linux? (Peter T. maybe? <g>)

 Cheers,
 Eduard.

-- 
W3-Seite des Monats: http://www.javalobby.org

---

From: Paul Koning <[email-masked]>
Date: Thu, 3 Sep 1998 09:28:45 -0400

>>>>> "Alan" == Alan Cox <[email-masked]> writes:

 Alan> ... let me go beat on Erik and find out what the
 Alan> actual issues are. Even if the arm code is messy I can think of
 Alan> plenty of solutions

 Alan> (for one RPM has %ifarch unlike dpkg src)

 Alan> Maybe it needs to have

 Alan> arch_write_struct()/arch_read_struct()

 Alan> code to keep it clean.

FWIW, this is *not* an ARM specific issue.  There are other platforms
(i960 comes to mind) where struct alignment is different from the
popular assumption.  I used to argue about this being a bug until
someone beat me over the head with a C standard, which says clearly
that structs can be aligned to *bigger* boundaries than the sizes of
their constituents (but not smaller).  It's just that only a small
number of platforms actually do this, so it's easy to get lulled into
believing that it isn't so.

Of course, this bad assumption lives in many other places -- isn't
there an ethernet-header struct somewhere that is used all over?  Same 
issue...

	paul