kernel/eka/nkern/nk_old.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2008-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 the License "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 // e32\nkern\nk_old.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32atomics.h>
       
    19 
       
    20 extern "C" {
       
    21 
       
    22 EXPORT_C TInt __old_LockedInc(TInt& aCount)
       
    23 	{ return __e32_atomic_add_ord32(&aCount,1); }
       
    24 
       
    25 EXPORT_C TInt __old_LockedDec(TInt& aCount)
       
    26 	{ return __e32_atomic_add_ord32(&aCount,0xffffffff); }
       
    27 
       
    28 EXPORT_C TInt __old_LockedAdd(TInt& aDest, TInt aSrc)
       
    29 	{ return __e32_atomic_add_ord32(&aDest,aSrc); }
       
    30 
       
    31 EXPORT_C TInt64 __old_LockedInc64(TInt64& aCount)
       
    32 	{ return __e32_atomic_add_ord64(&aCount,1); }
       
    33 
       
    34 EXPORT_C TInt64 __old_LockedDec64(TInt64& aCount)
       
    35 	{ return __e32_atomic_add_ord64(&aCount,TUint64(TInt64(-1))); }
       
    36 
       
    37 EXPORT_C TInt64 __old_LockedAdd64(TInt64& aDest, TInt64 aSrc)
       
    38 	{ return __e32_atomic_add_ord64(&aDest,aSrc); }
       
    39 
       
    40 EXPORT_C TUint32 __old_LockedSetClear(TUint32& aDest, TUint32 aClearMask, TUint32 aSetMask)
       
    41 	{ return __e32_atomic_axo_ord32(&aDest,~(aClearMask|aSetMask),aSetMask); }
       
    42 
       
    43 EXPORT_C TUint16 __old_LockedSetClear16(TUint16& aDest, TUint16 aClearMask, TUint16 aSetMask)
       
    44 	{ return __e32_atomic_axo_ord16(&aDest,TUint16(~(aClearMask|aSetMask)),aSetMask); }
       
    45 
       
    46 EXPORT_C TUint8 __old_LockedSetClear8(TUint8& aDest, TUint8 aClearMask, TUint8 aSetMask)
       
    47 	{ return __e32_atomic_axo_ord8(&aDest,TUint8(~(aClearMask|aSetMask)),aSetMask); }
       
    48 
       
    49 EXPORT_C TInt __old_SafeInc(TInt& aCount)
       
    50 	{ return __e32_atomic_tas_ord32(&aCount,1,1,0); }
       
    51 
       
    52 EXPORT_C TInt __old_SafeDec(TInt& aCount)
       
    53 	{ return __e32_atomic_tas_ord32(&aCount,1,-1,0); }
       
    54 
       
    55 EXPORT_C TInt __old_AddIfGe(TInt& aCount, TInt aLimit, TInt aInc)
       
    56 	{ return __e32_atomic_tas_ord32(&aCount,aLimit,aInc,0); }
       
    57 
       
    58 EXPORT_C TInt __old_AddIfLt(TInt& aCount, TInt aLimit, TInt aInc)
       
    59 	{ return __e32_atomic_tas_ord32(&aCount,aLimit,0,aInc); }
       
    60 
       
    61 EXPORT_C TAny* __old_SafeSwap(TAny* aNewValue, TAny*& aPtr)
       
    62 	{ return __e32_atomic_swp_ord_ptr(&aPtr, aNewValue); }
       
    63 
       
    64 EXPORT_C TUint8 __old_SafeSwap8(TUint8 aNewValue, TUint8& aPtr)
       
    65 	{ return __e32_atomic_swp_ord8(&aPtr, aNewValue); }
       
    66 
       
    67 EXPORT_C TUint16 __old_SafeSwap16(TUint16 aNewValue, TUint16& aPtr)
       
    68 	{ return __e32_atomic_swp_ord16(&aPtr, aNewValue); }
       
    69 
       
    70 EXPORT_C TBool __old_CompareAndSwap(TAny*& aPtr, TAny* aExpected, TAny* aNew)
       
    71 	{ return __e32_atomic_cas_ord_ptr(&aPtr, &aExpected, aNew); }
       
    72 
       
    73 EXPORT_C TBool __old_CompareAndSwap8(TUint8& aPtr, TUint8 aExpected, TUint8 aNew)
       
    74 	{ return __e32_atomic_cas_ord8(&aPtr, (TUint8*)&aExpected, (TUint8)aNew); }
       
    75 
       
    76 EXPORT_C TBool __old_CompareAndSwap16(TUint16& aPtr, TUint16 aExpected, TUint16 aNew)
       
    77 	{ return __e32_atomic_cas_ord16(&aPtr, (TUint16*)&aExpected, (TUint16)aNew); }
       
    78 
       
    79 }