From owner-freebsd-hackers Mon Nov 20 7:40:50 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.gmx.net (pop.gmx.net [194.221.183.20]) by hub.freebsd.org (Postfix) with SMTP id D34BA37B479 for ; Mon, 20 Nov 2000 07:40:47 -0800 (PST) Received: (qmail 3660 invoked by uid 0); 20 Nov 2000 15:40:45 -0000 Received: from p3ee21477.dip.t-dialin.net (HELO forge.local) (62.226.20.119) by mail.gmx.net (mail05) with SMTP; 20 Nov 2000 15:40:45 -0000 Received: from thomas by forge.local with local (Exim 3.12 #1 (Debian)) id 13xt38-0000QR-00 for ; Mon, 20 Nov 2000 16:40:06 +0100 Date: Mon, 20 Nov 2000 16:40:06 +0100 To: freebsd-hackers@freebsd.org Subject: Re: Byte order? Message-ID: <20001120164006.A1624@crow.dom2ip.de> Mail-Followup-To: tmoestl@gmx.net, freebsd-hackers@freebsd.org References: <00112017175200.47740@pro.lookanswer.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <00112017175200.47740@pro.lookanswer.com>; from havoc@lookanswer.com on Mon, Nov 20, 2000 at 05:17:00PM +0200 From: Thomas Moestl Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I know, that x86 is big endian architecture > but simple programm like this: > > #include > #include > main () { > /* Are we little or big endian? From Harbison&Steele. */ > union > { > long l; > char c[sizeof (long)]; > } u; > u.l = 1; > printf ("Little endian? %s\n", (u.c[sizeof (long) - 1] == 1) ? "yes" : "no"); > #if BYTE_ORDER == BIG_ENDIAN > printf("Big endian\n"); > #elif BYTE_ORDER == LITTLE_ENDIAN > printf("Little endian\n"); > #else > printf("Unknown\n"); > #endif > } > > Give me a strange result: > Little endian? no > Little endian This program gets it wrong. When the last byte of a long is set after the long was set to 1, we have a big endian architecture (the "little" end is at the 4th byte, so the "big end" is at the 1st byte). > On my FreeBSD 4.2-BETA BYTE_ORDER = LITTLE_ENDIAN! > I`m very confused and some programms detect my machine as Little Endian, by > example freetds. The x86 architecture _is_ little endian. - Thomas To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message