From: Mike Frysinger Date: Mon, 31 Mar 2008 12:09:32 -0400 Subject: [U-Boot-Users] [PATCH] tools/envcrc.c: use the target sizeof rather than build In-Reply-To: <1206977489.7589.473.camel@gentoo-jocke.transmode.se> References: <1206908872-2141-1-git-send-email-vapier@gentoo.org> <1206977489.7589.473.camel@gentoo-jocke.transmode.se> Message-ID: <200803311209.33668.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Monday 31 March 2008, Joakim Tjernlund wrote: > Cool script, which reminds me about something: Is it possible to > define a script that can output if the cpu is Big Endian or > Little Endian? if you can rely on grep being sane, yes. it's pretty easy. $ cat test.c short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; } short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; } int main() { _ascii (); _ebcdic (); return 0; } $ gcc -c test.c $ grep BIGenDianSyS test.o && echo BIG $ grep LiTTleEnDian test.o && echo LITTLE this shows you how to do it, so you can prob create your own version as needed -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 827 bytes Desc: This is a digitally signed message part. Url : http://lists.denx.de/pipermail/u-boot/attachments/20080331/99d23ccf/attachment.pgp