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