chiark / gitweb /
[PATCH] added klibc version 0.82 (cvs tree) to the udev tree.
[elogind.git] / klibc / klibc / arch / sparc64 / setjmp.S
1 !
2 ! setjmp.S
3 !
4 ! Basic setjmp/longjmp
5 !
6 ! This code was based on the equivalent code in NetBSD
7 !
8
9 !
10 ! The jmp_buf contains the following entries:
11 !   sp
12 !   fp
13 !   pc
14 !
15         .text
16         .align  4
17         .global setjmp
18         .type   setjmp, @function
19 setjmp:
20         stx     %sp,[%o0+0]     ! Callers stack pointer
21         stx     %o7,[%o0+8]     ! Return pc
22         stx     %fp,[%o0+16]    ! Frame pointer
23         retl                    ! Return
24          clr    %o0             !  ...0
25
26         .size   setjmp,.-setjmp
27
28
29         .globl  longjmp
30         .type   longjmp, @function      
31 longjmp:
32         mov     %o1, %g4        ! save return value
33         mov     %o0, %g1        ! save target
34         ldx     [%g1+16],%g5    ! get callers frame
35 1:
36         cmp     %fp, %g5        ! compare against desired frame
37         bl,a    1b              ! if below...
38          restore                ! pop frame and loop
39         be,a    2f              ! if there...
40          ldx    [%g1+0],%o2     ! fetch return %sp
41
42 .Lbotch:
43         unimp   0               ! ... error ...
44         
45 2:
46         cmp     %o2, %sp        ! %sp must not decrease
47         bl      .Lbotch
48          nop
49         mov     %o2, %sp        ! it is OK, put it in place
50
51         ldx     [%g1+8],%o3     ! fetch %pc
52         jmp     %o3 + 8         ! if sucess...
53          mov    %g4,%o0         !   return %g4
54
55         .size   longjmp,.-longjmp