setjmp.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* setjmp for i386.
  2. Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #define _ASM
  17. #define _SETJMP_H
  18. #include <bits/setjmp.h>
  19. .globl __sigsetjmp;
  20. .type __sigsetjmp,@function
  21. .align 4; \
  22. __sigsetjmp:
  23. movl 4(%esp), %eax /* User's jmp_buf in %eax. */
  24. /* Save registers. */
  25. movl %ebx, (JB_BX*4)(%eax)
  26. movl %esi, (JB_SI*4)(%eax)
  27. movl %edi, (JB_DI*4)(%eax)
  28. movl %ebp, (JB_BP*4)(%eax)
  29. leal 4(%esp), %ecx /* Save SP as it will be after we return. */
  30. movl %ecx, (JB_SP*4)(%eax)
  31. movl 0(%esp), %ecx /* Save PC we are returning to now. */
  32. movl %ecx, (JB_PC*4)(%eax)
  33. pushl 0x8(%esp) /* save mask */
  34. pushl 0x8(%esp) /* jump buf */
  35. /* Make a tail call to __sigjmp_save; it takes the same args. */
  36. #if defined(PIC)
  37. /* We cannot use the PLT, because it requires that %ebx be set, but
  38. we can't save and restore our caller's value. Instead, we do an
  39. indirect jump through the GOT, using for the temporary register
  40. %ecx, which is call-clobbered. */
  41. call Lhere
  42. Lhere:
  43. popl %ecx
  44. addl $_GLOBAL_OFFSET_TABLE_+[.-Lhere], %ecx
  45. movl (__sigjmp_save)(%ecx), %ecx
  46. call *%ecx
  47. #else
  48. call __sigjmp_save
  49. #endif
  50. add $8, %esp
  51. ret
  52. .size __sigsetjmp,.-__sigsetjmp;
  53. .globl _setjmp;
  54. .type _setjmp,@function
  55. .align 4; \
  56. _setjmp:
  57. pushl $0 /* Push zero argument. */
  58. pushl 0x8(%esp) /* Push jmp_buf. */
  59. call __sigsetjmp
  60. add $8, %esp
  61. ret
  62. .size _setjmp,.-_setjmp;