summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/e1/longjmp.c
blob: 9f04e7b5c592303cb4a3e56142d4d8396c6ba3d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Copyright (C) 2002-2003,    George Thanos <george.thanos@gdt.gr>
 *                             Yannis Mitsos <yannis.mitsos@gdt.gr>
 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
 *
 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 */

#include <syscall.h>
#include <setjmp.h>
#include <stdio.h>
#include <signal.h>

#define __NR_e1newSP  224
static __inline__ _syscall1(int, e1newSP, unsigned long, SavedSP )

unsigned long jmpbuf_ptr;

void longjmp(jmp_buf state, int value )
{
	if(!value)
		state->__jmpbuf->ReturnValue = 1;
	else
		state->__jmpbuf->ReturnValue = value;

	jmpbuf_ptr = (unsigned long)state;
	e1newSP(state->__jmpbuf->SavedSP);

#define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
	__asm__ __volatile__("mov L0, %0\n\t"
		     "mov L1, %1\n\t"
		     "mov L2, %2\n\t"
		     "mov G3, %3\n\t"
		     "mov G4, %4\n\t"
		     "ret PC, L1\n\t"
		     :/*no output*/
		     :"l"(_state_->__jmpbuf->ReturnValue),
		      "l"(_state_->__jmpbuf->SavedPC),
		      "l"(_state_->__jmpbuf->SavedSR),
		      "l"(_state_->__jmpbuf->G3),
		      "l"(_state_->__jmpbuf->G4)
		     :"%G3", "%G4", "%L0", "%L1" );
#undef _state_
}

libc_hidden_proto(sigprocmask)

void siglongjmp(sigjmp_buf state, int value )
{
	if( state->__mask_was_saved )
		sigprocmask(SIG_SETMASK, &state->__saved_mask, NULL);

	if(!value)
		state->__jmpbuf->ReturnValue = 1;
	else
		state->__jmpbuf->ReturnValue = value;

	jmpbuf_ptr = (unsigned long)state;
	e1newSP(state->__jmpbuf->SavedSP);


#define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
	__asm__ __volatile__("mov L0, %0\n\t"
		     "mov L1, %1\n\t"
		     "mov L2, %2\n\t"
		     "mov G3, %3\n\t"
		     "mov G4, %4\n\t"
		     "ret PC, L1\n\t"
		     :/*no output*/
		     :"l"(_state_->__jmpbuf->ReturnValue),
		      "l"(_state_->__jmpbuf->SavedPC),
		      "l"(_state_->__jmpbuf->SavedSR),
		      "l"(_state_->__jmpbuf->G3),
		      "l"(_state_->__jmpbuf->G4)
		     :"%G3", "%G4", "%L0", "%L1" );
#undef _state_
}