1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/klib/dbase.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,163 @@
1.4 +// Copyright (c) 1994-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 the License "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 +// e32\klib\dbase.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <kernel/kern_priv.h>
1.22 +
1.23 +/** Deletes the specified DBase derived object.
1.24 +
1.25 +@param aPtr Pointer to the DBase derived object to be deleted.
1.26 +
1.27 +@pre Calling thread must be in a critical section.
1.28 +@pre Interrupts must be enabled.
1.29 +@pre Kernel must be unlocked.
1.30 +@pre No fast mutex can be held.
1.31 +@pre Call in a thread context.
1.32 +@pre Can be used in a device driver.
1.33 +*/
1.34 +EXPORT_C void DBase::Delete(DBase* aPtr)
1.35 + {
1.36 + CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::Delete");
1.37 + delete aPtr;
1.38 + }
1.39 +
1.40 +
1.41 +/** Allocates the object from the kernel heap and then initialises its contents
1.42 + to binary zeros.
1.43 +
1.44 +@param aSize The size of the derived class. This parameter is specified
1.45 + implicitly by C++ in all circumstances in which a derived class
1.46 + is allocated.
1.47 +
1.48 +@return An untyped pointer to the allocated object.
1.49 +
1.50 +@pre Calling thread must be in a critical section.
1.51 +@pre Interrupts must be enabled.
1.52 +@pre Kernel must be unlocked.
1.53 +@pre No fast mutex can be held.
1.54 +@pre Call in a thread context.
1.55 +@pre Can be used in a device driver.
1.56 +*/
1.57 +EXPORT_C TAny* DBase::operator new(TUint aSize) __NO_THROW
1.58 + {
1.59 + CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::operator new(TUint aSize)");
1.60 + return Kern::AllocZ(aSize);
1.61 + }
1.62 +
1.63 +
1.64 +/** Allocates the object from the kernel heap with additional memory and then
1.65 + initialises its contents to binary zeros.
1.66 +
1.67 +@param aSize The size of the derived class. This parameter is specified
1.68 + implicitly by C++ in all circumstances in which a derived class
1.69 + is allocated.
1.70 +
1.71 +@param anExtraSize Indicates additional size beyond the end of the base class.
1.72 +
1.73 +@return An untyped pointer to the allocated object.
1.74 +
1.75 +@pre Calling thread must be in a critical section.
1.76 +@pre Interrupts must be enabled.
1.77 +@pre Kernel must be unlocked.
1.78 +@pre No fast mutex can be held.
1.79 +@pre Call in a thread context.
1.80 +@pre Can be used in a device driver.
1.81 +*/
1.82 +EXPORT_C TAny* DBase::operator new(TUint aSize, TUint anExtraSize) __NO_THROW
1.83 + {
1.84 + CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::operator new(TUint aSize, TUint anExtraSize)");
1.85 + aSize+=anExtraSize;
1.86 + return Kern::AllocZ(aSize);
1.87 + }
1.88 +
1.89 +_LIT(KLitKernLib,"KernLib");
1.90 +void KL::Panic(KL::TKernLibPanic aPanic)
1.91 + {
1.92 + Kern::PanicCurrentThread(KLitKernLib,aPanic);
1.93 + }
1.94 +
1.95 +
1.96 +/** Default constructor for version type
1.97 + Sets version to 0.0.0
1.98 + */
1.99 +EXPORT_C TVersion::TVersion()
1.100 + : iMajor(0),iMinor(0),iBuild(0)
1.101 + {}
1.102 +
1.103 +
1.104 +/**
1.105 +Compares two versions and returns true if the test version is less than the
1.106 +current version.
1.107 +
1.108 +Version information is encapsulated by a TVersion type object and consists of
1.109 +a major version number, a minor version number and a build number.
1.110 +
1.111 +The function returns true if one of the following conditions is true:
1.112 +
1.113 +1. the test major version is strictly less than the current major version
1.114 +
1.115 +2. the test major version is equal to the current major version and the test
1.116 + minor version is less than or equal to the current minor version.
1.117 +
1.118 +If neither condition is true, the function returns false.
1.119 +
1.120 +@param aCurrent A reference to the current version against which aRequested
1.121 + is compared.
1.122 +@param aRequested A reference to the test version to be compared
1.123 + against aCurrent.
1.124 +
1.125 +@return True, if one or both conditions are true. False otherwise.
1.126 +*/
1.127 +EXPORT_C TBool Kern::QueryVersionSupported(const TVersion &aCurrent,const TVersion &aRequested)
1.128 + {
1.129 +
1.130 + if (aRequested.iMajor<aCurrent.iMajor || (aRequested.iMajor==aCurrent.iMajor && aRequested.iMinor<=aCurrent.iMinor))
1.131 + return(ETrue);
1.132 + return(EFalse);
1.133 + }
1.134 +
1.135 +
1.136 +/** Constructor for version type.
1.137 +
1.138 + @param aMajor The major version number (0-127).
1.139 + @param aMajor The minor version number (0-127).
1.140 + @param aMajor The build number (0-32767).
1.141 + */
1.142 +EXPORT_C TVersion::TVersion(TInt aMajor,TInt aMinor,TInt aBuild)
1.143 + : iMajor((TInt8)aMajor), iMinor((TInt8)aMinor), iBuild((TInt16)aBuild)
1.144 + {}
1.145 +
1.146 +
1.147 +/** Converts a version type to a text string.
1.148 +
1.149 + The string is of the form X.YY(Z)
1.150 + where X is major version number, Y is minor and Z is build number.
1.151 +
1.152 + @return The string in a TBuf class.
1.153 + */
1.154 +EXPORT_C TVersionName TVersion::Name() const
1.155 + {
1.156 +
1.157 + TVersionName v;
1.158 + v.AppendNum(iMajor);
1.159 + v.Append(TChar('.'));
1.160 + v.AppendNumFixedWidth(iMinor,EDecimal,2);
1.161 + v.Append(TChar('('));
1.162 + v.AppendNum(iBuild);
1.163 + v.Append(TChar(')'));
1.164 + return v;
1.165 + }
1.166 +