Home | History | Annotate | Download | only in lib
      1 /*
      2  * arch/i386/setjmp.S
      3  *
      4  * setjmp/longjmp for the i386 architecture
      5  *
      6  *
      7  *
      8  * The jmp_buf is assumed to contain the following, in order:
      9  *	%ebx
     10  *	%esp
     11  *	%ebp
     12  *	%esi
     13  *	%edi
     14  *	<return address>
     15  */
     16 /*
     17 	.text
     18 	.align 4
     19 
     20 	.globl _setjmp
     21 	.type _setjmp, @function
     22 _setjmp:				# gcc 4.0.1 wants this as an alias?
     23 
     24 	.globl setjmp
     25 	.type setjmp, @function
     26 setjmp:
     27 #ifdef REGPARM
     28 	movl %eax,%edx
     29 #else
     30 	movl 4(%esp),%edx
     31 #endif
     32 	popl %ecx			# Return address, and adjust the stack
     33 	xorl %eax,%eax			# Return value
     34 	movl %ebx,(%edx)
     35 	movl %esp,4(%edx)		# Post-return %esp!
     36 	pushl %ecx			# Make the call/return stack happy
     37 	movl %ebp,8(%edx)
     38 	movl %esi,12(%edx)
     39 	movl %edi,16(%edx)
     40 	movl %ecx,20(%edx)		# Return address
     41 	ret
     42 
     43 	.size setjmp,.-setjmp
     44 
     45 	.text
     46 	.align 4
     47 	.globl longjmp
     48 	.type longjmp, @function
     49 longjmp:
     50 #ifdef REGPARM
     51 	xchgl %eax,%edx
     52 #else
     53 	movl 4(%esp),%edx		# jmp_ptr address
     54 	movl 8(%esp),%eax		# Return value
     55 #endif
     56 	movl (%edx),%ebx
     57 	movl 4(%edx),%esp
     58 	movl 8(%edx),%ebp
     59 	movl 12(%edx),%esi
     60 	movl 16(%edx),%edi
     61 	jmp *20(%edx)
     62 
     63 	.size longjmp,.-longjmp
     64 */
     65 #if __SIZEOF_POINTER__ == 4
     66 #include <i386/setjmp.S>
     67 #elif __SIZEOF_POINTER__ == 8
     68 #include <x86_64/setjmp.S>
     69 #else
     70 #error "Unable to build for to-be-defined architecture type"
     71 #endif
     72 
     73