sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <setjmp.h>
|
sl@0
|
17 |
|
sl@0
|
18 |
//Suppressing RVCT compiler warning:
|
sl@0
|
19 |
// "Warning: #830-D: function "RHeap::operator new" has no corresponding operator delete (to be called if an exception
|
sl@0
|
20 |
// is thrown during initialization of an allocated object)
|
sl@0
|
21 |
// __declspec(dllimport) TAny* operator new(TUint aSize, TAny* aBase) throw();"
|
sl@0
|
22 |
#pragma diag_suppress 830
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <u32std.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
#pragma diag_default 830
|
sl@0
|
27 |
|
sl@0
|
28 |
extern "C" {
|
sl@0
|
29 |
|
sl@0
|
30 |
EXPORT_C __NAKED__ int setjmp(jmp_buf __jmpb)
|
sl@0
|
31 |
{
|
sl@0
|
32 |
#if defined( __MARM_THUMB__) && __GCC32__
|
sl@0
|
33 |
asm("stmia r0!, {r4-r7}");
|
sl@0
|
34 |
asm("mov r2, r8");
|
sl@0
|
35 |
asm("mov r3, r9");
|
sl@0
|
36 |
asm("mov r4, r10");
|
sl@0
|
37 |
asm("mov r5, r11");
|
sl@0
|
38 |
asm("mov r6, sp");
|
sl@0
|
39 |
asm("mov r7, lr");
|
sl@0
|
40 |
asm("stmia r0!, {r2-r7}");
|
sl@0
|
41 |
#else
|
sl@0
|
42 |
asm("stmia r0, {r4-r11, sp, lr} "); // Save the context */
|
sl@0
|
43 |
#endif
|
sl@0
|
44 |
asm("mov r0, #0");
|
sl@0
|
45 |
__JUMP(,lr);
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
EXPORT_C __NAKED__ void longjmp(jmp_buf __jmpb, int __retval)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
#if defined( __MARM_THUMB__) && __GCC32__
|
sl@0
|
51 |
asm("mov r3, r0"); // save the jmp_buf pointer
|
sl@0
|
52 |
asm("add r3, #16"); //add on 16 to get to high registers
|
sl@0
|
53 |
asm("ldmia r3!, {r4-r7}");
|
sl@0
|
54 |
asm("mov r8,r4");
|
sl@0
|
55 |
asm("mov r9,r5");
|
sl@0
|
56 |
asm("mov r10,r6");
|
sl@0
|
57 |
asm("mov r11,r7");
|
sl@0
|
58 |
asm("ldmia r3!, {r4-r5}"); //get sp and lr
|
sl@0
|
59 |
asm("mov sp, r4");
|
sl@0
|
60 |
asm("mov lr, r5");
|
sl@0
|
61 |
asm("mov r3, r0"); //get the jmp_buf ptr again
|
sl@0
|
62 |
asm("ldmia r3!, {r4-r7}"); //and restore the lo regs
|
sl@0
|
63 |
asm("mov r0, r1"); // return(__retval)
|
sl@0
|
64 |
asm("cmp r0, #0");
|
sl@0
|
65 |
asm("bne 1f");
|
sl@0
|
66 |
asm("mov r0, #1");
|
sl@0
|
67 |
asm("1:");
|
sl@0
|
68 |
#else
|
sl@0
|
69 |
asm("ldmia r0, {r4-r11, sp, lr} "); // Restore the context
|
sl@0
|
70 |
asm("movs r0, r1"); // return(__retval == 0 ? 1 : retval)
|
sl@0
|
71 |
asm("moveq r0, #1");
|
sl@0
|
72 |
#endif
|
sl@0
|
73 |
__JUMP(,lr);
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
} // extern "C"
|