linux kernel에서 이해하기 어려운 자료 선언이 있네요...
글쓴이: parkys1 / 작성시간: 금, 2007/07/13 - 3:28오전
이해하지 못할 선언은 바로 current_stack_pointer 값 입니다.
선언은 다음과 같습니다.
/* how to get the current stack pointer from C */ register unsigned long current_stack_pointer asm("esp") __attribute_used__;
위 선언에서 current_stack_pointer는 변수로 선언되었고, stack pointer값을 가지고
있습니다. 즉, 동적으로 변하는 stack pointer값을 계속 가지고 있지요..
사용하는 곳은 다음과 같습니다..
/* how to get the thread information struct from C */ static inline struct thread_info *current_thread_info(void) { return (struct thread_info *)(current_stack_pointer & ~(THREAD_SIZE - 1)); }
많이 보셨을법한 함수죠... 여기선 current_stack_pointer변수를 그냥 값으로 이용합니다.
어떻게 저런 선언이 가능한거죠?!
댓글 달기