ARM的汇编语言与x86完全不同,需要重写,涉及使用嵌入汇编的代码,都需要针对ARM进行配套修改。
需要重新实现汇编代码段。
示例:
static inline long atomic64_add_and_return(long i, atomic64_t *v) { long i = i; asm_volatile_( "lock ; " "xaddq %0, %1;" :"=r"(i) :"m"(v->counter), "0"(i)); return i + __i; } static inline void prefetch(void *x) { asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x)); }
static __inline__ long atomic64_add_and_return(long i, atomic64_t *v) { return __sync_add_and_fetch(&((v)->counter), i); } #define prefetch(_x) __builtin_prefetch(_x) 以__sync_add_and_fetch为例,编译后其反汇编对应代码如下所示: <__sync_add_and_fetch >: ldxr x2, [x0] add x2, x2, x1 stlxr w3, x2, [x0]