setjmp.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * This file is subject to the terms and conditions of the LGPL V2.1
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2018 Kalray Inc.
  7. */
  8. #include <sysdep.h>
  9. #define _SETJMP_H
  10. #define _ASM
  11. #include <bits/setjmp.h>
  12. #include <libc-symbols.h>
  13. /**
  14. * Simply save the user context to $r0 (jmpbuf)
  15. *
  16. * This function has the following prototype:
  17. * int __sigsetjmp (r0 = jmp_buf env, r1 = int savemask)
  18. * At the end, we call sigjmp_save
  19. * int __sigjmp_save (sigjmp_buf env, int savemask)
  20. * which will save signal mask if needed (set by setjmp/_setjmp)
  21. *
  22. * NOTE: since r0 and r1 are used by __sigjmp_save, we must not
  23. * clobber them during this function
  24. */
  25. ENTRY(__sigsetjmp)
  26. /* Save r20r21r22r23 */
  27. so (JMPBUF_REGS_OFFSET + QUAD_REG_SIZE)[$r0] = $r20r21r22r23
  28. get $r40 = $ra
  29. ;;
  30. /* Save r24r25r26r27 */
  31. so (JMPBUF_REGS_OFFSET + 2 * QUAD_REG_SIZE) [$r0] = $r24r25r26r27
  32. get $r41 = $cs
  33. ;;
  34. copyd $r36 = $sp
  35. copyd $r37 = $r14
  36. copyd $r38 = $r18
  37. copyd $r39 = $r19
  38. ;;
  39. /* Save r12(sp) r14 r18 r19 stored in $r36r37r38r39 */
  40. so (JMPBUF_REGS_OFFSET)[$r0] = $r36r37r38r39
  41. get $r32 = $lc
  42. ;;
  43. /* Save r28r29r30r31 */
  44. so (JMPBUF_REGS_OFFSET + 3 * QUAD_REG_SIZE) [$r0] = $r28r29r30r31
  45. get $r33 = $le
  46. ;;
  47. /* Save $cs and $ra */
  48. sq JMPBUF_RA_CS_OFFSET[$r0] = $r40r41
  49. get $r34 = $ls
  50. ;;
  51. /* Save $lc, $le and $ls */
  52. so JMPBUF_LC_LE_LS_OFFSET[$r0] = $r32r33r34r35
  53. goto __sigjmp_save
  54. ;;
  55. END(__sigsetjmp)
  56. libc_hidden_def(__sigsetjmp)