__longjmp.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If not,
  13. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. Boston, MA 02111-1307, USA. */
  15. #define _ASM
  16. #define _SETJMP_H
  17. #include <bits/setjmp.h>
  18. ;----------------------------------------
  19. ; Name: __longjmp
  20. ; Description: Restore the current context
  21. ; as saved by a previous nr_setjmp
  22. ; Input: %o0: jmp_buf (ptr to) array to restore context from
  23. ; %o1: integer to return
  24. ; Output: %o0 = 0 the first time we're called, or
  25. ; whatever longjmp returns later
  26. ; Side Effects: uses %g0, %g1 & %g2
  27. ; CWP Depth: 0
  28. ;
  29. .align 2
  30. .global __longjmp
  31. __longjmp:
  32. ;
  33. ; The way we'll do this is by executing
  34. ; RESTORE instructions until the old
  35. ; return address matches. Then we'll
  36. ; jump to where setjmp was called from.
  37. ;
  38. ; Since we're moving the window pointer
  39. ; all over the place, we'll naturally
  40. ; only use the %g registers.
  41. ;
  42. mov %g0,%o0 ; %g0 -> jmp_buf
  43. mov %g1,%o1 ; %g1 = return value
  44. pfx jmpbuf_callersret
  45. ld %g2,[%g0] ; %g2 = old return address
  46. __longjmp_loop:
  47. cmp %g2,%i7 ; Are we there yet?
  48. skps cc_ne
  49. br __longjmp_done
  50. nop ; (delay slot)
  51. br __longjmp_loop
  52. restore ; (delay slot)
  53. ;
  54. ; One might put in a watchdog counter here, to
  55. ; prevent a runaway stack crawl... but what would that
  56. ; accomplish? What error can we throw? To whom?
  57. ;
  58. __longjmp_done:
  59. pfx jmpbuf_l0 ; Restore local register l0
  60. ld %l0,[%g0]
  61. pfx jmpbuf_l1 ; Restore local register l1
  62. ld %l1,[%g0]
  63. pfx jmpbuf_l2 ; Restore local register l2
  64. ld %l2,[%g0]
  65. pfx jmpbuf_l3 ; Restore local register l3
  66. ld %l3,[%g0]
  67. pfx jmpbuf_l4 ; Restore local register l4
  68. ld %l4,[%g0]
  69. pfx jmpbuf_l5 ; Restore local register l5
  70. ld %l5,[%g0]
  71. pfx jmpbuf_l6 ; Restore local register l6
  72. ld %l6,[%g0]
  73. pfx jmpbuf_l7 ; Restore local register l7
  74. ld %l7,[%g0]
  75. pfx jmpbuf_i0 ; Restore input register i0
  76. ld %i0,[%g0]
  77. pfx jmpbuf_i1 ; Restore input register i1
  78. ld %i1,[%g0]
  79. pfx jmpbuf_i2 ; Restore input register i2
  80. ld %i2,[%g0]
  81. pfx jmpbuf_i3 ; Restore input register i3
  82. ld %i3,[%g0]
  83. pfx jmpbuf_i4 ; Restore input register i4
  84. ld %i4,[%g0]
  85. pfx jmpbuf_i5 ; Restore input register i5
  86. ld %i5,[%g0]
  87. pfx jmpbuf_jmpret
  88. ld %o7,[%g0] ; set fake return address
  89. jmp %o7 ; and kinda return there.
  90. mov %o0,%g1 ; (delay slot) return value