summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/e1/setjmp.c
blob: 2d2edec5dda465f60746bc4450a88f56e76d7b41 (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
/*  This file is lisenced under LGPL
 *  Copyright (C) 2002-2003,    George Thanos <george.thanos@gdt.gr>
 *                              Yannis Mitsos <yannis.mitsos@gdt.gr>
 */

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

/* libc_hidden_proto(sigprocmask) */

int setjmp( jmp_buf state)
{
	__asm__ __volatile__(	"mov %0, G3\n\t"
			"mov %1, G4\n\t"
			:"=l"(state->__jmpbuf->G3),
			 "=l"(state->__jmpbuf->G4)
			:/*no input*/
			:"%G3", "%G4" );

	__asm__ __volatile__(   "setadr  %0\n\t"
			"mov %1, L1\n\t"
			"mov %2, L2\n\t"
			:"=l"(state->__jmpbuf->SavedSP),
			 "=l"(state->__jmpbuf->SavedPC),
			 "=l"(state->__jmpbuf->SavedSR)
			:/*no input*/);
	return 0;
}

int sigsetjmp( sigjmp_buf state , int savesigs)
{

	if(savesigs) {
		state->__mask_was_saved = 1;
		/* how arg in <sigprocmask> is not significant */
		sigprocmask(SIG_SETMASK, NULL, &state->__saved_mask);
	} else
		state->__mask_was_saved = 0;

	__asm__ __volatile__(	"mov %0, G3\n\t"
			"mov %1, G4\n\t"
			:"=l"(state->__jmpbuf->G3),
			 "=l"(state->__jmpbuf->G4)
			:/*no input*/
			:"%G3", "%G4" );

	__asm__ __volatile__(   "setadr  %0\n\t"
			"mov %1, L2\n\t"
			"mov %2, L3\n\t"
			:"=l"(state->__jmpbuf->SavedSP),
			 "=l"(state->__jmpbuf->SavedPC),
			 "=l"(state->__jmpbuf->SavedSR)
			:/*no input*/);
	return 0;
}