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
9#include <sysdep.h>
10#define _SETJMP_H
11#define _ASM
12#include <bits/setjmp.h>
13#include <libc-symbols.h>
14
15/**
16 * void __longjmp(__jmp_buf __env, int __val)
17 */
18ENTRY(__longjmp)
19	/* Load $ra and $csinto r40r41 */
20	lq $r40r41 = JMPBUF_RA_CS_OFFSET[$r0]
21	;;
22	/* Load $r36r37r38r39 with r12(sp) r14 r18 r19 */
23	lo $r36r37r38r39 = (JMPBUF_REGS_OFFSET)[$r0]
24	set $ra = $r40
25	;;
26	/* Load $lc, $le and $ls */
27	lo $r32r33r34r35 = JMPBUF_LC_LE_LS_OFFSET[$r0]
28	copyd $sp = $r36
29	copyd $r14 = $r37
30	set $cs = $r41
31	;;
32	/* Load r20r21r22r23 */
33	lo $r20r21r22r23 = (JMPBUF_REGS_OFFSET + QUAD_REG_SIZE)[$r0]
34	copyd $r18 = $r38
35	copyd $r19 = $r39
36	set $lc = $r32
37	;;
38	/* Load r24r25r26r27 */
39	lo $r24r25r26r27 = (JMPBUF_REGS_OFFSET + 2 * QUAD_REG_SIZE)[$r0]
40	set $le = $r33
41	;;
42	/* Load r28r29r30r31 */
43	lo $r28r29r30r31 = (JMPBUF_REGS_OFFSET + 3 * QUAD_REG_SIZE)[$r0]
44	set $ls = $r34
45	/* Copy retval */
46	copyd $r0 = $r1
47	;;
48	/* According to man, if retval is equal to 0, then we should return 1 */
49	cmoved.deqz $r0? $r0 = 1
50	ret
51	;;
52END(__longjmp)
53libc_hidden_def(__longjmp)
54