1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LSIGNAL/JMP_MARM.CIA Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,76 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <setjmp.h>
1.20 +
1.21 +//Suppressing RVCT compiler warning:
1.22 +// "Warning: #830-D: function "RHeap::operator new" has no corresponding operator delete (to be called if an exception
1.23 +// is thrown during initialization of an allocated object)
1.24 +// __declspec(dllimport) TAny* operator new(TUint aSize, TAny* aBase) throw();"
1.25 +#pragma diag_suppress 830
1.26 +
1.27 +#include <u32std.h>
1.28 +
1.29 +#pragma diag_default 830
1.30 +
1.31 +extern "C" {
1.32 +
1.33 +EXPORT_C __NAKED__ int setjmp(jmp_buf __jmpb)
1.34 + {
1.35 +#if defined( __MARM_THUMB__) && __GCC32__
1.36 + asm("stmia r0!, {r4-r7}");
1.37 + asm("mov r2, r8");
1.38 + asm("mov r3, r9");
1.39 + asm("mov r4, r10");
1.40 + asm("mov r5, r11");
1.41 + asm("mov r6, sp");
1.42 + asm("mov r7, lr");
1.43 + asm("stmia r0!, {r2-r7}");
1.44 +#else
1.45 + asm("stmia r0, {r4-r11, sp, lr} "); // Save the context */
1.46 +#endif
1.47 + asm("mov r0, #0");
1.48 + __JUMP(,lr);
1.49 + }
1.50 +
1.51 +EXPORT_C __NAKED__ void longjmp(jmp_buf __jmpb, int __retval)
1.52 + {
1.53 +#if defined( __MARM_THUMB__) && __GCC32__
1.54 + asm("mov r3, r0"); // save the jmp_buf pointer
1.55 + asm("add r3, #16"); //add on 16 to get to high registers
1.56 + asm("ldmia r3!, {r4-r7}");
1.57 + asm("mov r8,r4");
1.58 + asm("mov r9,r5");
1.59 + asm("mov r10,r6");
1.60 + asm("mov r11,r7");
1.61 + asm("ldmia r3!, {r4-r5}"); //get sp and lr
1.62 + asm("mov sp, r4");
1.63 + asm("mov lr, r5");
1.64 + asm("mov r3, r0"); //get the jmp_buf ptr again
1.65 + asm("ldmia r3!, {r4-r7}"); //and restore the lo regs
1.66 + asm("mov r0, r1"); // return(__retval)
1.67 + asm("cmp r0, #0");
1.68 + asm("bne 1f");
1.69 + asm("mov r0, #1");
1.70 + asm("1:");
1.71 +#else
1.72 + asm("ldmia r0, {r4-r11, sp, lr} "); // Restore the context
1.73 + asm("movs r0, r1"); // return(__retval == 0 ? 1 : retval)
1.74 + asm("moveq r0, #1");
1.75 +#endif
1.76 + __JUMP(,lr);
1.77 + }
1.78 +
1.79 +} // extern "C"