Skip to content

Commit

Permalink
[PATCH] i386: use C code for current_thread_info()
Browse files Browse the repository at this point in the history
Using C code for current_thread_info() lets the compiler optimize it.
With gcc 4.0.2, kernel is smaller:

    text           data     bss     dec     hex filename
 3645212         555556  312024 4512792  44dc18 2.6.17-rc6-nb-post/vmlinux
 3647276         555556  312024 4514856  44e428 2.6.17-rc6-nb/vmlinux
 -------
   -2064

Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Chuck Ebbert authored and Linus Torvalds committed Jun 28, 2006
1 parent 4b89aff commit c723e08
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions include/asm-i386/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,15 @@ struct thread_info {
#define init_stack (init_thread_union.stack)


/* how to get the current stack pointer from C */
register unsigned long current_stack_pointer asm("esp") __attribute_used__;

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
__asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~(THREAD_SIZE - 1)));
return ti;
return (struct thread_info *)(current_stack_pointer & ~(THREAD_SIZE - 1));
}

/* how to get the current stack pointer from C */
register unsigned long current_stack_pointer asm("esp") __attribute_used__;

/* thread information allocation */
#ifdef CONFIG_DEBUG_STACK_USAGE
#define alloc_thread_info(tsk) \
Expand Down

0 comments on commit c723e08

Please sign in to comment.