__longjmp.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. #include <jmpbuf-offsets.h>
  16. ;----------------------------------------
  17. ; Name: __longjmp
  18. ; Description: Restore the current context
  19. ; as saved by a previous nr_setjmp
  20. ; Input: %o0: jmp_buf (ptr to) array to restore context from
  21. ; %o1: integer to return
  22. ; Output: %o0 = 0 the first time we're called, or
  23. ; whatever longjmp returns later
  24. ; Side Effects: uses %g0, %g1 & %g2
  25. ; CWP Depth: 0
  26. ;
  27. .align 2
  28. .global __longjmp
  29. __longjmp:
  30. ;
  31. ; The way we'll do this is by executing
  32. ; RESTORE instructions until the old
  33. ; return address matches. Then we'll
  34. ; jump to where setjmp was called from.
  35. ;
  36. ; Since we're moving the window pointer
  37. ; all over the place, we'll naturally
  38. ; only use the %g registers.
  39. ;
  40. mov %g0,%o0 ; %g0 -> jmp_buf
  41. mov %g1,%o1 ; %g1 = return value
  42. pfx jmpbuf_callersret
  43. ld %g2,[%g0] ; %g2 = old return address
  44. __longjmp_loop:
  45. cmp %g2,%i7 ; Are we there yet?
  46. skps cc_ne
  47. br __longjmp_done
  48. nop ; (delay slot)
  49. br __longjmp_loop
  50. restore ; (delay slot)
  51. ;
  52. ; One might put in a watchdog counter here, to
  53. ; prevent a runaway stack crawl... but what would that
  54. ; accomplish? What error can we throw? To whom?
  55. ;
  56. __longjmp_done:
  57. pfx jmpbuf_l0 ; Restore local register l0
  58. ld %l0,[%g0]
  59. pfx jmpbuf_l1 ; Restore local register l1
  60. ld %l1,[%g0]
  61. pfx jmpbuf_l2 ; Restore local register l2
  62. ld %l2,[%g0]
  63. pfx jmpbuf_l3 ; Restore local register l3
  64. ld %l3,[%g0]
  65. pfx jmpbuf_l4 ; Restore local register l4
  66. ld %l4,[%g0]
  67. pfx jmpbuf_l5 ; Restore local register l5
  68. ld %l5,[%g0]
  69. pfx jmpbuf_l6 ; Restore local register l6
  70. ld %l6,[%g0]
  71. pfx jmpbuf_l7 ; Restore local register l7
  72. ld %l7,[%g0]
  73. pfx jmpbuf_i0 ; Restore input register i0
  74. ld %i0,[%g0]
  75. pfx jmpbuf_i1 ; Restore input register i1
  76. ld %i1,[%g0]
  77. pfx jmpbuf_i2 ; Restore input register i2
  78. ld %i2,[%g0]
  79. pfx jmpbuf_i3 ; Restore input register i3
  80. ld %i3,[%g0]
  81. pfx jmpbuf_i4 ; Restore input register i4
  82. ld %i4,[%g0]
  83. pfx jmpbuf_i5 ; Restore input register i5
  84. ld %i5,[%g0]
  85. pfx jmpbuf_jmpret
  86. ld %o7,[%g0] ; set fake return address
  87. jmp %o7 ; and kinda return there.
  88. mov %o0,%g1 ; (delay slot) return value
  89. libc_hidden_def(__longjmp)