Issues of Porting C code targeted at ARM Cortex-A series
目录
以下内容摘录自《ARM? Cortex?-A Series Version: 4.0 Programmer’s Guide.pdf》 Issues of Porting C code targeted at ARM Cortex-A seriesEndiannessThere are two basic ways of viewing bytes in memory – little-endian and big-endian. On big-endian machines,the most significant byte of an object in memory is stored at the least significant (closest to zero) address. On little-endian machines,the most significant byte is stored at the highest address. AlignmentThe alignment of accesses is significant on ARM cores. For the Cortex-A series of processors,unaligned accesses are supported,although you must enable this by setting the U bit in the CP15:SCTL register,indicating that unaligned accesses are permitted. This means that instructions to read or write words or halfwords can access addresses that are not aligned to word or halfword boundaries. However,load and store multiple instructions ( unsigned char and signed charSimple chars are not specifically defined and it is compiler dependent whether they are signed or unsigned. It made sense at the time for the compiler to treat simple chars as unsigned,whereas on the x86 simple chars are,by default,treated as signed. One workaround for users of GCC is to use the Compiler packing of structuresCompilers are not permitted to re-order members of a structure and have to follow the alignment restrictions of the core architecture. This means that compilers might have to add unused bytes into user defined structures,for best performance and code size. Such padding is architecture specific and can therefore lead to portability problems if assumptions have been made about the location and size of this padding. Function prototypeA function prototype is a declaration that omits the function body but gives the function name,argument and return types. It effectively gives a way to specify the interface of a function separately from its definition. Incorrectly prototyped functions can behave differently between different compilers. EnumerationCompilers can allocate different numbers of bytes to enum. Care is therefore required when enumerations are used; cross-linking of code and libraries between different compilers might not be possible if enums are used. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |