os/kernelhwsrv/kernel/eka/klib/dbase.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1994-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\klib\dbase.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <kernel/kern_priv.h>
sl@0
    19
sl@0
    20
/**	Deletes the specified DBase derived object.
sl@0
    21
sl@0
    22
@param aPtr Pointer to the DBase derived object to be deleted.
sl@0
    23
sl@0
    24
@pre Calling thread must be in a critical section.
sl@0
    25
@pre Interrupts must be enabled.
sl@0
    26
@pre Kernel must be unlocked.
sl@0
    27
@pre No fast mutex can be held.
sl@0
    28
@pre Call in a thread context.
sl@0
    29
@pre Can be used in a device driver.
sl@0
    30
*/
sl@0
    31
EXPORT_C void DBase::Delete(DBase* aPtr)
sl@0
    32
	{
sl@0
    33
	CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::Delete");	
sl@0
    34
	delete aPtr;
sl@0
    35
	}
sl@0
    36
sl@0
    37
sl@0
    38
/**	Allocates the object from the kernel heap and then initialises its contents
sl@0
    39
	to binary zeros.
sl@0
    40
sl@0
    41
@param aSize The size of the derived class. This parameter is specified
sl@0
    42
             implicitly by C++ in all circumstances in which a derived class
sl@0
    43
             is allocated.
sl@0
    44
sl@0
    45
@return An untyped pointer to the allocated object.
sl@0
    46
sl@0
    47
@pre Calling thread must be in a critical section.
sl@0
    48
@pre Interrupts must be enabled.
sl@0
    49
@pre Kernel must be unlocked.
sl@0
    50
@pre No fast mutex can be held.
sl@0
    51
@pre Call in a thread context.
sl@0
    52
@pre Can be used in a device driver.
sl@0
    53
*/
sl@0
    54
EXPORT_C TAny* DBase::operator new(TUint aSize) __NO_THROW
sl@0
    55
	{
sl@0
    56
	CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::operator new(TUint aSize)");	
sl@0
    57
	return Kern::AllocZ(aSize);
sl@0
    58
	}
sl@0
    59
sl@0
    60
sl@0
    61
/**	Allocates the object from the kernel heap with additional memory and then
sl@0
    62
	initialises its contents to binary zeros.
sl@0
    63
sl@0
    64
@param  aSize The size of the derived class. This parameter is specified
sl@0
    65
              implicitly by C++ in all circumstances in which a derived class
sl@0
    66
              is allocated.
sl@0
    67
              
sl@0
    68
@param  anExtraSize Indicates additional size beyond the end of the base class.
sl@0
    69
sl@0
    70
@return An untyped pointer to the allocated object.
sl@0
    71
sl@0
    72
@pre Calling thread must be in a critical section.
sl@0
    73
@pre Interrupts must be enabled.
sl@0
    74
@pre Kernel must be unlocked.
sl@0
    75
@pre No fast mutex can be held.
sl@0
    76
@pre Call in a thread context.
sl@0
    77
@pre Can be used in a device driver.
sl@0
    78
*/
sl@0
    79
EXPORT_C TAny* DBase::operator new(TUint aSize, TUint anExtraSize) __NO_THROW
sl@0
    80
	{
sl@0
    81
	CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::operator new(TUint aSize, TUint anExtraSize)");	
sl@0
    82
	aSize+=anExtraSize;
sl@0
    83
	return Kern::AllocZ(aSize);
sl@0
    84
	}
sl@0
    85
sl@0
    86
_LIT(KLitKernLib,"KernLib");
sl@0
    87
void KL::Panic(KL::TKernLibPanic aPanic)
sl@0
    88
	{
sl@0
    89
	Kern::PanicCurrentThread(KLitKernLib,aPanic);
sl@0
    90
	}
sl@0
    91
sl@0
    92
sl@0
    93
/** Default constructor for version type
sl@0
    94
	Sets version to 0.0.0
sl@0
    95
 */
sl@0
    96
EXPORT_C TVersion::TVersion()
sl@0
    97
	: iMajor(0),iMinor(0),iBuild(0)
sl@0
    98
	{}
sl@0
    99
sl@0
   100
sl@0
   101
/**
sl@0
   102
Compares two versions and returns true if the test version is less than the
sl@0
   103
current version.
sl@0
   104
sl@0
   105
Version information is encapsulated by a TVersion type object and consists of
sl@0
   106
a major version number, a minor version number and a build number.
sl@0
   107
sl@0
   108
The function returns true if one of the following conditions is true:
sl@0
   109
sl@0
   110
1. the test major version is strictly less than the current major version
sl@0
   111
sl@0
   112
2. the test major version is equal to the current major version and the test
sl@0
   113
   minor version is less than or equal to the current minor version.
sl@0
   114
sl@0
   115
If neither condition is true, the function returns false.
sl@0
   116
sl@0
   117
@param aCurrent   A reference to the current version against which aRequested
sl@0
   118
                  is compared.
sl@0
   119
@param aRequested A reference to the test version to be compared
sl@0
   120
                  against aCurrent.
sl@0
   121
sl@0
   122
@return True, if one or both conditions are true. False otherwise.
sl@0
   123
*/
sl@0
   124
EXPORT_C TBool Kern::QueryVersionSupported(const TVersion &aCurrent,const TVersion &aRequested)
sl@0
   125
	{
sl@0
   126
sl@0
   127
	if (aRequested.iMajor<aCurrent.iMajor || (aRequested.iMajor==aCurrent.iMajor && aRequested.iMinor<=aCurrent.iMinor))
sl@0
   128
		return(ETrue);
sl@0
   129
	return(EFalse);
sl@0
   130
	}
sl@0
   131
sl@0
   132
sl@0
   133
/** Constructor for version type.
sl@0
   134
sl@0
   135
	@param	aMajor	The major version number (0-127).
sl@0
   136
	@param	aMajor	The minor version number (0-127).
sl@0
   137
	@param	aMajor	The build number (0-32767).
sl@0
   138
 */
sl@0
   139
EXPORT_C TVersion::TVersion(TInt aMajor,TInt aMinor,TInt aBuild)
sl@0
   140
	: iMajor((TInt8)aMajor), iMinor((TInt8)aMinor), iBuild((TInt16)aBuild)
sl@0
   141
	{}
sl@0
   142
sl@0
   143
sl@0
   144
/** Converts a version type to a text string.
sl@0
   145
sl@0
   146
	The string is of the form X.YY(Z)
sl@0
   147
	where X is major version number, Y is minor and Z is build number.
sl@0
   148
sl@0
   149
	@return The string in a TBuf class.
sl@0
   150
 */
sl@0
   151
EXPORT_C TVersionName TVersion::Name() const
sl@0
   152
	{
sl@0
   153
sl@0
   154
	TVersionName v;
sl@0
   155
	v.AppendNum(iMajor);
sl@0
   156
	v.Append(TChar('.'));
sl@0
   157
	v.AppendNumFixedWidth(iMinor,EDecimal,2);
sl@0
   158
	v.Append(TChar('('));
sl@0
   159
	v.AppendNum(iBuild);
sl@0
   160
	v.Append(TChar(')'));
sl@0
   161
	return v;
sl@0
   162
	}
sl@0
   163