刚开始编写jinix时,bitops.h使用的linux-2.4.18代码(简单修改),
贴部分代码:
/**
* __set_bit - Set a bit in memory
* @nr: the bit to set
* @addr: the address to start counting from
*
* Unlike set_bit(), this function is non-atomic and may be reordered.
* If it's called on the same region of memory simultaneously, the effect
* may be that only one operation succeeds.
*/
static __inline__ void __set_bit(int nr, volatile void * addr)
{
__asm__(
"btsl %1,%0"
:"=m" (ADDR)
:"Ir" (nr));
}
最近定位jinix其中一个bug,发现这个函数并没有起作用,和手上2.6.24内核比较一下,
它的定义如下:
static __inline__ void __set_bit(int nr, volatile void * addr)
{
__asm__(
"btsl %1,%0"
:"+m" (ADDR)
:"Ir" (nr));
}
也就是ADDR内存属性由‘=m’只写改成了‘+m’可读可写,
上面的代码在gcc-3.4.6+binutils-2.18 执行都正常,
换了gcc-4.4.4+binutils-2.20.1就挂了。
the fuck source code!!
阅读(1280) | 评论(1) | 转发(0) |