setjmp.c
Go to the documentation of this file.
1
6
/*
7
* The contents of this file are subject to the Mozilla Public License
8
* Version 1.0 (the "License"); you may not use this file except in
9
* compliance with the License. You may obtain a copy of the License at
10
* http://www.mozilla.org/MPL/
11
*
12
* Software distributed under the License is distributed on an "AS IS"
13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
14
* License for the specific language governing rights and limitations
15
* under the License.
16
*
17
* Contributor(s): Torsten Landschoff <tla@informatik.uni-kiel.de>
18
*/
19
20
#include <
setjmp.h
>
21
22
#ifdef CONF_SETJMP
23
24
int
setjmp
(
jmp_buf
env);
25
26
#ifndef DOXYGEN_SHOULD_SKIP_THIS
27
__asm__
(
"\n\
28
.text\n\
29
.align 2\n\
30
.globl _setjmp\n\
31
_setjmp:\n\
32
stc ccr,r1h ; remember flags\n\
33
mov.w #12,r2 ; move r0 'behind' jump buffer\n\
34
add r2,r0 ; for storing with pre-decrement\n\
35
\n\
36
pop r2 ; get return address\n\
37
mov.w r2,@-r0 ; store return address\n\
38
mov.w r1,@-r0 ; store flags\n\
39
mov.w r7,@-r0 ; store registers r4-r7\n\
40
mov.w r6,@-r0\n\
41
mov.w r5,@-r0\n\
42
mov.w r4,@-r0\n\
43
sub.w r0,r0 ; return value: 0\n\
44
jmp @r2 ; jump to caller\n\
45
"
);
46
#endif // DOXYGEN_SHOULD_SKIP_THIS
47
48
49
void
longjmp
(
jmp_buf
env,
int
val);
50
#ifndef DOXYGEN_SHOULD_SKIP_THIS
51
__asm__
(
"\n\
52
.text\n\
53
.align 2\n\
54
.globl _longjmp\n\
55
_longjmp:\n\
56
mov.w @r0+,r4 ; restore registers r4-r7\n\
57
mov.w @r0+,r5\n\
58
mov.w @r0+,r6\n\
59
mov.w @r0+,r7\n\
60
mov.w @r0+,r2 ; get flags\n\
61
mov.w @r0+,r0 ; get return address\n\
62
push r0 ; set up for rts\n\
63
mov.w r1,r0 ; return specified value\n\
64
ldc r2h,ccr ; restore flags\n\
65
rts ; return to caller\n\
66
"
);
67
#endif // DOXYGEN_SHOULD_SKIP_THIS
68
69
#endif // CONF_SETJMP
jmp_buf
int jmp_buf[6]
Information stored for non-local jumps.
Definition:
setjmp.h:48
setjmp.h
Non-local goto as specified in ANSI C.
__asm__
__asm__("\n\ .text\n\ .globl _atomic_inc\n\ _atomic_inc:\n\ stc ccr, r1h ; save flags\n\ orc #0x80, ccr ; disable all but NMI\n\ mov.b @r0, r1l\n\ inc r1l\n\ mov.b r1l, @r0\n\ ldc r1h, ccr ; restore flags\n\ rts\n\ ")
setjmp
int setjmp(jmp_buf env)
Save execution context for non-local goto.
longjmp
void longjmp(jmp_buf env, int val)
Non-local jump to saved machine context.
brickOS
is released under the
Mozilla Public License
.
Original code copyright 1998-2005 by the authors.
Generated for brickOS Kernel Developer by
1.8.16