分类: LINUX
2011-04-10 14:13:49
ARM7,ARM9,PC都是32位CPU: char为1 Byte, short为2 Byte, int和long都为4 Byte, long long为8 Byte
源码
[guowenxue@localhost QCTool]$ cat test.c
#include
int main(void)
{
printf("unsigned long long: %d\n", sizeof(unsigned long long));
printf("unsigned long: %d\n", sizeof(unsigned long));
printf("unsigned int: %d\n", sizeof(unsigned int));
printf("unsigned short: %d\n", sizeof(unsigned short));
printf("unsigned char: %d\n", sizeof(unsigned char));
return 0;
}
编译
[guowenxue@localhost QCTool]$ arm-elf-gcc test.c -Wl,-elf2flt -o test_ARM7
[guowenxue@localhost QCTool]$ arm-linux-gcc test.c -o test_ARM9
[guowenxue@localhost QCTool]$ gcc test.c -o test_I386
W90P710(ARM7):
root:/tmp> ./test_ARM7
unsigned long long: 8
unsigned long: 4
unsigned int: 4
unsigned short: 2
unsigned char: 1
root:/tmp> uname -a
Linux (none) 2.4.20-uc0 #5722 Mon Mar 14 16:13:08 CST 2011 armv3l unknown
root:/tmp> cat /proc/cpuinfo
Processor : Winbond W90P710 rev 1 (v3l)
BogoMIPS : 39.83
Hardware : W90P710
Revision : 0000
Serial : 0000000000000000
AT91SAM9260(ARM9)
/tmp >: ./test_ARM9
unsigned long long: 8
unsigned long: 4
unsigned int: 4
unsigned short: 2
unsigned char: 1
/tmp >: uname -a
Linux netaccess 2.6.22.1 #5481 Wed Feb 23 13:45:32 CST 2011 armv5tejl unknown
/tmp >: cat /proc/cpu
/proc/cpu/ /proc/cpuinfo
/tmp >: cat /proc/cpu
/proc/cpu/ /proc/cpuinfo
/tmp >: cat /proc/cpuinfo
Processor : ARM926EJ-S rev 5 (v5l)
BogoMIPS : 99.12
Features : swp half fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part : 0x926
CPU revision : 5
Cache type : write-back
Cache clean : cp15 c7 ops
Cache lockdown : format C
Cache format : Harvard
I size : 8192
I assoc : 4
I line length : 32
I sets : 64
D size : 8192
D assoc : 4
D line length : 32
D sets : 64
Hardware : Atmel AT91SAM9260-EK
Revision : 0000
Serial : 0000000000000000
PC(I386上)
[guowenxue@localhost QCTool]$ ./test_I386
unsigned long long: 8
unsigned long: 4
unsigned int: 4
unsigned short: 2
unsigned char: 1
[guowenxue@localhost QCTool]$ uname -a
Linux localhost.localdomain 2.6.9-42.ELsmp #1 SMP Sat Aug 12 09:39:11 CDT 2006 i686 i686 i386 GNU/Linux
[guowenxue@localhost QCTool]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
stepping : 13
cpu MHz : 2000.006
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm pni monitor ds_cpl est tm2 xtpr