sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: sl@0: //Suppressing RVCT compiler warning: sl@0: // "Warning: #830-D: function "RHeap::operator new" has no corresponding operator delete (to be called if an exception sl@0: // is thrown during initialization of an allocated object) sl@0: // __declspec(dllimport) TAny* operator new(TUint aSize, TAny* aBase) throw();" sl@0: #pragma diag_suppress 830 sl@0: sl@0: #include sl@0: sl@0: #pragma diag_default 830 sl@0: sl@0: extern "C" { sl@0: sl@0: EXPORT_C __NAKED__ int setjmp(jmp_buf __jmpb) sl@0: { sl@0: #if defined( __MARM_THUMB__) && __GCC32__ sl@0: asm("stmia r0!, {r4-r7}"); sl@0: asm("mov r2, r8"); sl@0: asm("mov r3, r9"); sl@0: asm("mov r4, r10"); sl@0: asm("mov r5, r11"); sl@0: asm("mov r6, sp"); sl@0: asm("mov r7, lr"); sl@0: asm("stmia r0!, {r2-r7}"); sl@0: #else sl@0: asm("stmia r0, {r4-r11, sp, lr} "); // Save the context */ sl@0: #endif sl@0: asm("mov r0, #0"); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: EXPORT_C __NAKED__ void longjmp(jmp_buf __jmpb, int __retval) sl@0: { sl@0: #if defined( __MARM_THUMB__) && __GCC32__ sl@0: asm("mov r3, r0"); // save the jmp_buf pointer sl@0: asm("add r3, #16"); //add on 16 to get to high registers sl@0: asm("ldmia r3!, {r4-r7}"); sl@0: asm("mov r8,r4"); sl@0: asm("mov r9,r5"); sl@0: asm("mov r10,r6"); sl@0: asm("mov r11,r7"); sl@0: asm("ldmia r3!, {r4-r5}"); //get sp and lr sl@0: asm("mov sp, r4"); sl@0: asm("mov lr, r5"); sl@0: asm("mov r3, r0"); //get the jmp_buf ptr again sl@0: asm("ldmia r3!, {r4-r7}"); //and restore the lo regs sl@0: asm("mov r0, r1"); // return(__retval) sl@0: asm("cmp r0, #0"); sl@0: asm("bne 1f"); sl@0: asm("mov r0, #1"); sl@0: asm("1:"); sl@0: #else sl@0: asm("ldmia r0, {r4-r11, sp, lr} "); // Restore the context sl@0: asm("movs r0, r1"); // return(__retval == 0 ? 1 : retval) sl@0: asm("moveq r0, #1"); sl@0: #endif sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: } // extern "C"