[U-Boot-Users] [PATCH] tools/envcrc.c: use the target sizeof rather than build

Mike Frysinger vapier at gentoo.org
Mon Mar 31 18:09:32 CEST 2008


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 


More information about the U-Boot mailing list