x86: Use inline assembler instead of global register variable to get sp
LTO in gcc 4.6/47. has trouble with global register variables. They were used to read the stack pointer. Use a simple inline assembler statement with a mov instead. This also helps LLVM/clang, which does not support global register variables. [ hpa: Ideally this should become a builtin in both gcc and clang. ] v2: More general asm constraint. Fix description (Jan Beulich) Signed-off-by: Andi Kleen <ak@linux.intel.com> Link: http://lkml.kernel.org/r/1382458079-24450-6-git-send-email-andi@firstfloor.org Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
		
					parent
					
						
							
								a2e7f0e3a4
							
						
					
				
			
			
				commit
				
					
						dff38e3e93
					
				
			
		
					 1 changed files with 5 additions and 3 deletions
				
			
		|  | @ -163,9 +163,11 @@ struct thread_info { | ||||||
|  */ |  */ | ||||||
| #ifndef __ASSEMBLY__ | #ifndef __ASSEMBLY__ | ||||||
| 
 | 
 | ||||||
| 
 | #define current_stack_pointer ({		\ | ||||||
| /* how to get the current stack pointer from C */ | 	unsigned long sp;			\ | ||||||
| register unsigned long current_stack_pointer asm("esp") __used; | 	asm("mov %%esp,%0" : "=g" (sp));	\ | ||||||
|  | 	sp;					\ | ||||||
|  | }) | ||||||
| 
 | 
 | ||||||
| /* how to get the thread information struct from C */ | /* how to get the thread information struct from C */ | ||||||
| static inline struct thread_info *current_thread_info(void) | static inline struct thread_info *current_thread_info(void) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andi Kleen
				Andi Kleen