First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\nkern\nk_old.cpp
18 #include <e32atomics.h>
22 EXPORT_C TInt __old_LockedInc(TInt& aCount)
23 { return __e32_atomic_add_ord32(&aCount,1); }
25 EXPORT_C TInt __old_LockedDec(TInt& aCount)
26 { return __e32_atomic_add_ord32(&aCount,0xffffffff); }
28 EXPORT_C TInt __old_LockedAdd(TInt& aDest, TInt aSrc)
29 { return __e32_atomic_add_ord32(&aDest,aSrc); }
31 EXPORT_C TInt64 __old_LockedInc64(TInt64& aCount)
32 { return __e32_atomic_add_ord64(&aCount,1); }
34 EXPORT_C TInt64 __old_LockedDec64(TInt64& aCount)
35 { return __e32_atomic_add_ord64(&aCount,TUint64(TInt64(-1))); }
37 EXPORT_C TInt64 __old_LockedAdd64(TInt64& aDest, TInt64 aSrc)
38 { return __e32_atomic_add_ord64(&aDest,aSrc); }
40 EXPORT_C TUint32 __old_LockedSetClear(TUint32& aDest, TUint32 aClearMask, TUint32 aSetMask)
41 { return __e32_atomic_axo_ord32(&aDest,~(aClearMask|aSetMask),aSetMask); }
43 EXPORT_C TUint16 __old_LockedSetClear16(TUint16& aDest, TUint16 aClearMask, TUint16 aSetMask)
44 { return __e32_atomic_axo_ord16(&aDest,TUint16(~(aClearMask|aSetMask)),aSetMask); }
46 EXPORT_C TUint8 __old_LockedSetClear8(TUint8& aDest, TUint8 aClearMask, TUint8 aSetMask)
47 { return __e32_atomic_axo_ord8(&aDest,TUint8(~(aClearMask|aSetMask)),aSetMask); }
49 EXPORT_C TInt __old_SafeInc(TInt& aCount)
50 { return __e32_atomic_tas_ord32(&aCount,1,1,0); }
52 EXPORT_C TInt __old_SafeDec(TInt& aCount)
53 { return __e32_atomic_tas_ord32(&aCount,1,-1,0); }
55 EXPORT_C TInt __old_AddIfGe(TInt& aCount, TInt aLimit, TInt aInc)
56 { return __e32_atomic_tas_ord32(&aCount,aLimit,aInc,0); }
58 EXPORT_C TInt __old_AddIfLt(TInt& aCount, TInt aLimit, TInt aInc)
59 { return __e32_atomic_tas_ord32(&aCount,aLimit,0,aInc); }
61 EXPORT_C TAny* __old_SafeSwap(TAny* aNewValue, TAny*& aPtr)
62 { return __e32_atomic_swp_ord_ptr(&aPtr, aNewValue); }
64 EXPORT_C TUint8 __old_SafeSwap8(TUint8 aNewValue, TUint8& aPtr)
65 { return __e32_atomic_swp_ord8(&aPtr, aNewValue); }
67 EXPORT_C TUint16 __old_SafeSwap16(TUint16 aNewValue, TUint16& aPtr)
68 { return __e32_atomic_swp_ord16(&aPtr, aNewValue); }
70 EXPORT_C TBool __old_CompareAndSwap(TAny*& aPtr, TAny* aExpected, TAny* aNew)
71 { return __e32_atomic_cas_ord_ptr(&aPtr, &aExpected, aNew); }
73 EXPORT_C TBool __old_CompareAndSwap8(TUint8& aPtr, TUint8 aExpected, TUint8 aNew)
74 { return __e32_atomic_cas_ord8(&aPtr, (TUint8*)&aExpected, (TUint8)aNew); }
76 EXPORT_C TBool __old_CompareAndSwap16(TUint16& aPtr, TUint16 aExpected, TUint16 aNew)
77 { return __e32_atomic_cas_ord16(&aPtr, (TUint16*)&aExpected, (TUint16)aNew); }