| To: | hemanth.venkatesh@wipro.com |
|---|---|
| Subject: | Re: Bit operations work differently on MIPS and IA32 |
| From: | Thiemo Seufer <ths@networkno.de> |
| Date: | Thu, 20 Jul 2006 17:18:39 +0100 |
| Cc: | linux-mips@linux-mips.org |
| In-reply-to: | <2156B1E923F1A147AABDF4D9FDEAB4CB09D3D8@blr-m2-msg.wipro.com> |
| Original-recipient: | rfc822;linux-mips@linux-mips.org |
| References: | <2156B1E923F1A147AABDF4D9FDEAB4CB09D3D8@blr-m2-msg.wipro.com> |
| Sender: | linux-mips-bounce@linux-mips.org |
| User-agent: | Mutt/1.5.12-2006-07-14 |
hemanth.venkatesh@wipro.com wrote:
> Hi All,
>
>
>
> I ran the below program on an IA32 and AU1100 machine, both being little
> endian machines and got different results. Does anyone know what could
> be the cause of this behaviour. This problem is blocking us from booting
> the cramfs rootfs.
>
>
>
> #include <stdio.h>
>
> typedef unsigned int u32;
>
> main()
>
> {
>
> struct tmp{
>
> u32 namelen:6,offset:26;
>
> }tmp1;
>
> (*(int *)(&tmp1))=0x4c0;
This makes non-portable assumptions about the bitfield layout. The
results are platform-dependent (or rather ABI-dependent). Portable
code needs to avoid acessing bitfields via typecasts.
Thiemo
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Bit operations work differently on MIPS and IA32, hemanth.venkatesh |
|---|---|
| Next by Date: | [PATCH] Honour "panic_on_oops" sysctl on mips arch, Maxime Bizon |
| Previous by Thread: | Bit operations work differently on MIPS and IA32, hemanth.venkatesh |
| Next by Thread: | Re: Bit operations work differently on MIPS and IA32, Jonathan Day |
| Indexes: | [Date] [Thread] [Top] [All Lists] |