os/kernelhwsrv/kernel/eka/nkern/nk_old.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\nkern\nk_old.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32atomics.h>
sl@0
    19
sl@0
    20
extern "C" {
sl@0
    21
sl@0
    22
EXPORT_C TInt __old_LockedInc(TInt& aCount)
sl@0
    23
	{ return __e32_atomic_add_ord32(&aCount,1); }
sl@0
    24
sl@0
    25
EXPORT_C TInt __old_LockedDec(TInt& aCount)
sl@0
    26
	{ return __e32_atomic_add_ord32(&aCount,0xffffffff); }
sl@0
    27
sl@0
    28
EXPORT_C TInt __old_LockedAdd(TInt& aDest, TInt aSrc)
sl@0
    29
	{ return __e32_atomic_add_ord32(&aDest,aSrc); }
sl@0
    30
sl@0
    31
EXPORT_C TInt64 __old_LockedInc64(TInt64& aCount)
sl@0
    32
	{ return __e32_atomic_add_ord64(&aCount,1); }
sl@0
    33
sl@0
    34
EXPORT_C TInt64 __old_LockedDec64(TInt64& aCount)
sl@0
    35
	{ return __e32_atomic_add_ord64(&aCount,TUint64(TInt64(-1))); }
sl@0
    36
sl@0
    37
EXPORT_C TInt64 __old_LockedAdd64(TInt64& aDest, TInt64 aSrc)
sl@0
    38
	{ return __e32_atomic_add_ord64(&aDest,aSrc); }
sl@0
    39
sl@0
    40
EXPORT_C TUint32 __old_LockedSetClear(TUint32& aDest, TUint32 aClearMask, TUint32 aSetMask)
sl@0
    41
	{ return __e32_atomic_axo_ord32(&aDest,~(aClearMask|aSetMask),aSetMask); }
sl@0
    42
sl@0
    43
EXPORT_C TUint16 __old_LockedSetClear16(TUint16& aDest, TUint16 aClearMask, TUint16 aSetMask)
sl@0
    44
	{ return __e32_atomic_axo_ord16(&aDest,TUint16(~(aClearMask|aSetMask)),aSetMask); }
sl@0
    45
sl@0
    46
EXPORT_C TUint8 __old_LockedSetClear8(TUint8& aDest, TUint8 aClearMask, TUint8 aSetMask)
sl@0
    47
	{ return __e32_atomic_axo_ord8(&aDest,TUint8(~(aClearMask|aSetMask)),aSetMask); }
sl@0
    48
sl@0
    49
EXPORT_C TInt __old_SafeInc(TInt& aCount)
sl@0
    50
	{ return __e32_atomic_tas_ord32(&aCount,1,1,0); }
sl@0
    51
sl@0
    52
EXPORT_C TInt __old_SafeDec(TInt& aCount)
sl@0
    53
	{ return __e32_atomic_tas_ord32(&aCount,1,-1,0); }
sl@0
    54
sl@0
    55
EXPORT_C TInt __old_AddIfGe(TInt& aCount, TInt aLimit, TInt aInc)
sl@0
    56
	{ return __e32_atomic_tas_ord32(&aCount,aLimit,aInc,0); }
sl@0
    57
sl@0
    58
EXPORT_C TInt __old_AddIfLt(TInt& aCount, TInt aLimit, TInt aInc)
sl@0
    59
	{ return __e32_atomic_tas_ord32(&aCount,aLimit,0,aInc); }
sl@0
    60
sl@0
    61
EXPORT_C TAny* __old_SafeSwap(TAny* aNewValue, TAny*& aPtr)
sl@0
    62
	{ return __e32_atomic_swp_ord_ptr(&aPtr, aNewValue); }
sl@0
    63
sl@0
    64
EXPORT_C TUint8 __old_SafeSwap8(TUint8 aNewValue, TUint8& aPtr)
sl@0
    65
	{ return __e32_atomic_swp_ord8(&aPtr, aNewValue); }
sl@0
    66
sl@0
    67
EXPORT_C TUint16 __old_SafeSwap16(TUint16 aNewValue, TUint16& aPtr)
sl@0
    68
	{ return __e32_atomic_swp_ord16(&aPtr, aNewValue); }
sl@0
    69
sl@0
    70
EXPORT_C TBool __old_CompareAndSwap(TAny*& aPtr, TAny* aExpected, TAny* aNew)
sl@0
    71
	{ return __e32_atomic_cas_ord_ptr(&aPtr, &aExpected, aNew); }
sl@0
    72
sl@0
    73
EXPORT_C TBool __old_CompareAndSwap8(TUint8& aPtr, TUint8 aExpected, TUint8 aNew)
sl@0
    74
	{ return __e32_atomic_cas_ord8(&aPtr, (TUint8*)&aExpected, (TUint8)aNew); }
sl@0
    75
sl@0
    76
EXPORT_C TBool __old_CompareAndSwap16(TUint16& aPtr, TUint16 aExpected, TUint16 aNew)
sl@0
    77
	{ return __e32_atomic_cas_ord16(&aPtr, (TUint16*)&aExpected, (TUint16)aNew); }
sl@0
    78
sl@0
    79
}