|
发表于 2002-10-12 12:46:37
|
显示全部楼层
asm,c用gcc,c++用g++。。
如果用汇编的话,可以直接在函数中嵌入。举例一段内核代码如下:
extern inline void up(struct semaphore * sem)
{
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->_magic);
#endif
_asm__volatile_(
"# atomic up operation \n \t"
LOCK "incl (%0) \n \t"
"jle 2f\n"
"1:\n"
".section .text.lock,\"ax \"\n"
"2:\tcall_up_wakeup\n\t"
"jmp 1b\b"
".previous"
:/* no outputs */
:"c" (sem)
:"memory");
} |
|