有人能解释一下这段代码吗?它来自于这里,是从Linux内核中获取的。
/*
* how to get the thread information struct from C
*/
static inline struct thread_info *current_thread_info(void) __attribute_const__;
static inline struct thread_info *current_thread_info(void)
{
register unsigned long sp asm ("sp");
return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
}
问题:
__attribute_const__
是什么?register unsigned long sp asm ("sp");
这是做什么的?- 为什么
(struct thread_info *)(sp & ~(THREAD_SIZE - 1));
会返回指向结构体的指针?