__longjmp.S 3.1 KB

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