Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Aug 2002 12:11:39 -0700 
From:      "Balaji, Pavan" <pavan.balaji@intel.com>
To:        "'Matthew Seaman'" <m.seaman@infracaninophile.co.uk>, "Balaji, Pavan" <pavan.balaji@intel.com>
Cc:        "'freebsd-questions@freebsd.org'" <freebsd-questions@FreeBSD.ORG>
Subject:   RE: GCC versions!!!
Message-ID:  <3D386AED1B47D411A94300508B11F18704AD699A@fmsmsx116.fm.intel.com>

next in thread | raw e-mail | index | archive | help

That was my guess. But, now how do I set it right, if I'm working on
transferring data between two such machines?


Pavan Balaji,
Intel Corporation
Email: pavan.balaji@intel.com

    "Only the Paranoid Survive"  --  Andy Grove


> -----Original Message-----
> From: Matthew Seaman [mailto:m.seaman@infracaninophile.co.uk]
> Sent: Monday, August 05, 2002 3:09 AM
> To: Balaji, Pavan
> Cc: 'freebsd-questions@freebsd.org'
> Subject: Re: GCC versions!!!
> 
> 
> On Sun, Aug 04, 2002 at 07:09:16PM -0700, Balaji, Pavan wrote:
> > 
> > I ran this program on FreeBSD (GCC version 2.95.3) and the 
> output for this
> > program was
> > 1  256  65536  0
> > 
> > I reran it on Linux (GCC version 3.0.something) and the output was:
> > 16777216  65536  1  0  (as expected).
> > 
> > After a little poking around, I could figure out that the 
> memory for the
> > structure was allocated in a way that for every word 
> boundary, the bytes
> > allocation is in the reverse order. For example, if I have 
> 4 characters in a
> > structure a, b, c and d, the memory for d is allocated 
> first, then c, then b
> > and finally a.
> > 
> > Is this something to do with gcc or with freebsd? Any ideas?
> 
> I get exactly the same output with the standard gcc-2.95.4 and with
> gcc-3.1.1 from ports:
> 
>     happy-idiot-talk:/tmp:% cc -v
>     Using builtin specs.
>     gcc version 2.95.4 20020320 [FreeBSD]
>     happy-idiot-talk:/tmp:% cc -o foo-2.95.4 foo.c 
>     [...]
>     happy-idiot-talk:/tmp:% ./foo-2.95.4 
>     1  256  65536  0  
>     
>     happy-idiot-talk:/tmp:% gcc31 -v
>     [...]
>     gcc version 3.1.1 [FreeBSD]
>     happy-idiot-talk:/tmp:% gcc31 -o foo-3.1.1 foo.c 
>     [...]
>     happy-idiot-talk:/tmp:% ./foo-3.1.1 
>     1  256  65536  0  
> 
> I doubt there's a difference at this level between gcc on Linux or
> FreeBSD: this sort of alignment/endianness issue is mostly a function
> of the CPU the code is running on.  At a guess, your second result was
> obtained on a Sparc or PowerPC[*] or similar CPU, which is the
> other-endian from an x86 class CPU: I never can rememder which one is
> 'big-endian' and which one is 'little-endian' though.
> 
> 	Matthew
> 
> [*] PowerPC can work 'either-endian' but I thing most Unix OS's select
> this way.
> 
> -- 
> Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
>                                                       Savill Way
> Tel: +44 1628 476614                                  Marlow
> Fax: +44 0870 0522645                                 Bucks., 
> SL7 1TH UK
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
> 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D386AED1B47D411A94300508B11F18704AD699A>