Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Thiemo Seufer <ths@networkno.de>
To: hemanth.venkatesh@wipro.com
Cc: linux-mips@linux-mips.org
Subject: Re: Bit operations work differently on MIPS and IA32
Date: Thu, 20 Jul 2006 17:18:39 +0100	[thread overview]
Message-ID: <20060720161839.GE4350@networkno.de> (raw)
In-Reply-To: <2156B1E923F1A147AABDF4D9FDEAB4CB09D3D8@blr-m2-msg.wipro.com>

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

  parent reply	other threads:[~2006-07-20 16:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-20 16:02 Bit operations work differently on MIPS and IA32 hemanth.venkatesh
2006-07-20 16:02 ` hemanth.venkatesh
2006-07-20 16:18 ` Thiemo Seufer [this message]
2006-07-20 17:45 ` Jonathan Day
2006-07-21  6:51   ` hemanth.venkatesh
2006-07-21  6:51     ` hemanth.venkatesh

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=20060720161839.GE4350@networkno.de \
    --to=ths@networkno.de \
    --cc=hemanth.venkatesh@wipro.com \
    --cc=linux-mips@linux-mips.org \
    /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