OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / e1 / longjmp.c
1 /*  This file is lisenced under LGPL
2  *  Copyright (C) 2002-2003,    George Thanos <george.thanos@gdt.gr>
3  *                              Yannis Mitsos <yannis.mitsos@gdt.gr>
4  */
5
6 #include <syscall.h>
7 #include <setjmp.h>
8 #include <stdio.h>
9 #include <signal.h>
10
11 #define __NR_e1newSP  224
12 static inline _syscall1(int, e1newSP, unsigned long, SavedSP )
13
14 unsigned long jmpbuf_ptr;
15
16 void longjmp(jmp_buf state, int value )
17 {
18         if(!value)
19                 state->__jmpbuf->ReturnValue = 1;
20         else
21                 state->__jmpbuf->ReturnValue = value;
22
23         jmpbuf_ptr = (unsigned long)state; 
24         e1newSP(state->__jmpbuf->SavedSP);
25
26 #define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
27         asm volatile("mov L0, %0\n\t"
28                      "mov L1, %1\n\t"
29                      "mov L2, %2\n\t"
30                      "mov G3, %3\n\t"
31                      "mov G4, %4\n\t"
32                      "ret PC, L1\n\t"
33                      :/*no output*/
34                      :"l"(_state_->__jmpbuf->ReturnValue),
35                       "l"(_state_->__jmpbuf->SavedPC),
36                       "l"(_state_->__jmpbuf->SavedSR),
37                       "l"(_state_->__jmpbuf->G3),
38                       "l"(_state_->__jmpbuf->G4)
39                      :"%G3", "%G4", "%L0", "%L1" );
40 #undef _state_
41 }
42
43 libc_hidden_proto(sigprocmask)
44
45 void siglongjmp(sigjmp_buf state, int value )
46 {
47         if( state->__mask_was_saved )
48                 sigprocmask(SIG_SETMASK, &state->__saved_mask, NULL);
49
50         if(!value)
51                 state->__jmpbuf->ReturnValue = 1;
52         else
53                 state->__jmpbuf->ReturnValue = value;
54
55         jmpbuf_ptr = (unsigned long)state; 
56         e1newSP(state->__jmpbuf->SavedSP);
57         
58
59 #define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
60         asm volatile("mov L0, %0\n\t"
61                      "mov L1, %1\n\t"
62                      "mov L2, %2\n\t"
63                      "mov G3, %3\n\t"
64                      "mov G4, %4\n\t"
65                      "ret PC, L1\n\t"
66                      :/*no output*/
67                      :"l"(_state_->__jmpbuf->ReturnValue),
68                       "l"(_state_->__jmpbuf->SavedPC),
69                       "l"(_state_->__jmpbuf->SavedSR),
70                       "l"(_state_->__jmpbuf->G3),
71                       "l"(_state_->__jmpbuf->G4)
72                      :"%G3", "%G4", "%L0", "%L1" );
73 #undef _state_
74 }