If you are a newbie of C programmers in SPARC architecture (For example, working on Solaris), you should pay attention to the following tips:
(1) By default, SPARC is big-endian (For Endianness, you can refer http://en.wikipedia.org/wiki/Endianness). It means for an integer (short, int, long, etc), the MSB will be stored in the lower address, while the LSB will be stored in the higher address.
(2) SPARC requires byte-alignment. It means for a short (2 bytes long) variable, the start address of the variable must be the multiples of 2, while a int (4 bytes long) variable, the start address of the variable must be the multiples of 4. If the address can't satisfy this condition, the application will core dump, and a "Bus Error" will be reported. For this tip, you can refer Expert C Programming: Deep C Secrets (Bus Error section, page 163 ~ page 164).
For more SPARC information, you can refer:
http://en.wikipedia.org/wiki/SPARC;

本文为初学者提供了关于在SPARC架构上进行C编程的重要提示。内容涵盖SPARC架构的大端字节序特性及其对数据存储的影响,以及对字节对齐的要求,避免因不满足条件而导致的应用崩溃。
1万+

被折叠的 条评论
为什么被折叠?



