UIQ Technology
Symbian OS Library

UIQ 3.1 SDK        UIQ developer portal

[Index] [Spacer] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class User

class User : public UserHeap;

Description

Set of static user functions.

These functions are related to a number of System component APIs.

The majority of the functions are related to either the current thread, or its heap. Examples in this category include User::Exit(), which causes the thread to terminate, and User::Alloc(), which allocates memory from the current thread's heap.

Some of these functions are equivalent to functions in the RThread or RHeap classes. In these cases, the User function is a convenient way to access the function without first having to get a handle to the current thread.

Functions are also provided to support debugging of memory leaks. These function calls can be written explicitly or can be generated using a corresponding macro - the advantage of using a macro is that the function call is only generated for debug builds.

A final category of functions, which includes User::BinarySearch() and User::QuickSort(), are just useful functions which have no other natural home.

Derivation

Members

Defined in User:
After(), AfterHighRes(), Alloc(), AllocL(), AllocLC(), AllocLen(), AllocSize(), AllocZ(), AllocZL(), Allocator(), At(), Available(), Beep(), BinarySearch(), Check(), Collate(), CommandLine(), CommandLineLength(), CompressAllHeaps(), CountAllocCells(), CountAllocCells(), CreatorHasCapability(), CreatorHasCapability(), CreatorIdentity(), CreatorSecureId(), CreatorVendorId(), Critical(), Critical(), EAllThreadsCritical, ENotCritical, EProcessCritical, EProcessPermanent, ERealtimeStateOff, ERealtimeStateOn, ERealtimeStateWarn, ESystemCritical, ESystemPermanent, ExceptionHandler(), Exit(), FastCounter(), Fold(), Fold(), Free(), FreeLogicalDevice(), FreePhysicalDevice(), FreeZ(), GetDesParameter(), GetDesParameter(), GetTIntParameter(), Heap(), IMB_Range(), Identity(), InactivityTime(), InfoPrint(), Invariant(), IsExceptionHandled(), IsRomAddress(), JustInTime(), Language(), Leave(), LeaveIfError(), LeaveIfNull(), LeaveNoMemory(), LoadLogicalDevice(), LoadPhysicalDevice(), LockPeriod(), LockedDec(), LockedInc(), LowerCase(), MachineConfiguration(), ModifyExceptionMask(), NTickCount(), Panic(), ParameterLength(), PriorityControl(), ProcessCritical(), ProcessCritical(), QueryVersionSupported(), QuickSort(), RaiseException(), ReAlloc(), ReAllocL(), RenameProcess(), RenameThread(), RequestComplete(), ResetInactivityTime(), SafeDec(), SafeInc(), SetCritical(), SetCurrencySymbol(), SetDebugMask(), SetDebugMask(), SetExceptionHandler(), SetFloatingPointMode(), SetHomeTime(), SetJustInTime(), SetMachineConfiguration(), SetPriorityControl(), SetProcessCritical(), SetTrapHandler(), SetUTCOffset(), SetUTCTime(), SetUTCTimeAndOffset(), StringLength(), StringLength(), SwitchAllocator(), SwitchHeap(), TCritical, TRealtimeState, TickCount(), TitleCase(), TrapHandler(), UTCOffset(), UpperCase(), ValidateName(), Version(), WaitForAnyRequest(), WaitForRequest(), WaitForRequest(), __DbgMarkCheck(), __DbgMarkEnd(), __DbgMarkStart(), __DbgSetAllocFail()

Inherited from UserHeap:
ChunkHeap(), EChunkHeapDuplicate, EChunkHeapSwitchTo, FixedHeap(), OffsetChunkHeap(), TChunkHeapCreateMode

See also:


Member functions


Exit()

static IMPORT_C void Exit(TInt aReason);

Description

Terminates the current thread, specifying a reason. All child threads are terminated and all resources are cleaned up.

If the current thread is the main thread in a process, the process is also terminated.

Parameters

TInt aReason

The reason code.


Panic()

static IMPORT_C void Panic(const TDesC &aCategory, TInt aReason);

Description

Panics the current thread, specifying a category name and panic number.

Keep the length of the category name small; a length of 16 is ideal.

Parameters

const TDesC &aCategory

A reference to the descriptor containing the text that defines the category for this panic.

TInt aReason

The panic number.


Leave()

static IMPORT_C void Leave(TInt aReason);

Description

Leaves the currently executing function, unwinds the call stack, and returns from the most recently entered trap harness.

Parameters

TInt aReason

The value returned from the most recent call to TRAP or TRAPD. This is known as the reason code and, typically, it gives the reason for the environment or user error causing this leave to occur.

See also:


LeaveNoMemory()

static IMPORT_C void LeaveNoMemory();

Description

Leaves with the specific reason code KErrNoMemory.

See also:


LeaveIfError()

static IMPORT_C TInt LeaveIfError(TInt aReason);

Description

Leaves or returns with a specified reason code.

If the reason code is negative the function leaves, and the reason code is returned through the trap harness.

If the reason code is zero or positive, the function simply returns with the reason value.

Parameters

TInt aReason

The reason code.

Return value

TInt

If the function returns, the reason code which is either zero or positive.


LeaveIfNull()

static IMPORT_C TAny *LeaveIfNull(TAny *aPtr);

Description

Leaves with the reason code KErrNoMemory, if the specified pointer is NULL.

If the pointer is not NULL, the function simply returns with the value of the pointer.

Parameters

TAny *aPtr

The pointer to be tested.

Return value

TAny *

If the function returns, the value of aPtr.


SetTrapHandler()

static IMPORT_C TTrapHandler *SetTrapHandler(TTrapHandler *aHandler);

Description

Sets the current thread's trap handler and returns a pointer to any pre-existing trap handler.

Pass a NULL pointer to this function to clear the trap handler.

The trap handler works with the TRAP mechanism to handle the effects of a leave.

Note that TTrapHandler is an abstract base class; a trap handler must be implemented as a derived class.

Parameters

TTrapHandler *aHandler

A pointer to the trap handler which is to be installed as the current thread's trap handler.

Return value

TTrapHandler *

A pointer to the current thread's pre-existing trap handler, if any. NULL, if no pre-existing trap handler is set.

See also:


TrapHandler()

static IMPORT_C TTrapHandler *TrapHandler();

Description

Gets a pointer to the current thread's trap handler.

Note that TTrapHandler is an abstract base class; a trap handler must be implemented as a derived class.

Return value

TTrapHandler *

A pointer to the current thread's trap handler, if any. NULL, if no pre-existing trap handler is set.


InfoPrint()

static IMPORT_C TInt InfoPrint(const TDesC &aDes);

Description

Invokes the notifier server to display a text message on the screen for a short time.

Parameters

const TDesC &aDes

A reference to the descriptor containing the text to be sent to the notifier server.

Return value

TInt

KErrNone if successful, otherwise one of the system-wide error codes.

See also:


RequestComplete()

static IMPORT_C void RequestComplete(TRequestStatus *&aStatus, TInt aReason);

Description

Signals the current thread that the asynchronous request associated with the specified request status object is complete.

This function is used to complete an asynchronous request originating in the same thread as the code that is currently executing. If a request originates in another thread, then executing code must use RThread::RequestComplete() to signal the completion of that request.

The request is completed with the completion code passed in aReason. This value is copied into the request status, pointed to by aStatus, before signalling the current thread's request semaphore.

The meaning of the completion code passed in aReason is a matter of convention to be decided between the service requester and the service provider.

Parameters

TRequestStatus *&aStatus

A reference to a pointer to the request status object. This is a pointer into the current thread's address space. On return, the pointer to the request status is set to NULL. Note that setting the pointer to NULL is a convenience, not all servers need it, and is done before the function returns.

TInt aReason

The completion code of this request.

See also:


WaitForAnyRequest()

static IMPORT_C void WaitForAnyRequest();

Description

Waits for any asynchronous request to complete.

The current thread waits on its request semaphore.

The function completes, and control returns to the caller when the current thread's request semaphore is signalled by any of the service providers which handle these asynchronous requests.

The request status of all outstanding asynchronous requests must be examined to determine which request is complete.

See also:


WaitForRequest()

static IMPORT_C void WaitForRequest(TRequestStatus &aStatus);

Description

Waits for a specific asynchronous request to complete.

The current thread waits on its request semaphore.

The function completes and control returns to the caller when the current thread's request semaphore is signalled by the service provider handling the request associated with aStatus. Before signalling, the service provider sets an appropriate value in aStatus, other than KRequestPending.

Note that if other asynchronous requests complete before the one associated with aStatus, the request semaphore is adjusted so that knowledge of their completion is not lost. In this a case, a subsequent call to User::WaitForAnyRequest() or User::WaitForRequest() will complete and return immediately.

Parameters

TRequestStatus &aStatus

A reference to the request status object associated with the specific asynchronous request.

See also:


WaitForRequest()

static IMPORT_C void WaitForRequest(TRequestStatus &aStatus1, TRequestStatus &aStatus2);

Description

Waits for either of two specific asynchronous requests to complete.

The current thread waits on its request semaphore.

The function completes and control returns to the caller when the current thread's request semaphore is signalled by either the service provider handling the request associated with aStatus1 or the service provider handling the request associated with aStatus2. Before signalling, the completing service provider sets an appropriate value in the status object, other than KRequestPending.

Note that if other asynchronous requests complete before the ones associated with aStatus1 and aStatus2, the request semaphore is adjusted so that knowledge of their completion is not lost. In this a case, a subsequent call to User::WaitForAnyRequest() or User::WaitForRequest() will complete and return immediately.

Parameters

TRequestStatus &aStatus1

A reference to the request status object associated with the first specific asynchronous request.

TRequestStatus &aStatus2

A reference to the request status object associated with the second specific asynchronous request.

See also:


AllocLen()

static IMPORT_C TInt AllocLen(const TAny *aCell);

Description

Gets the length of the specified allocated heap cell.

The cell is assumed to be in the current thread's heap.

Parameters

const TAny *aCell

A pointer to the allocated cell whose length is to be fetched.

Return value

TInt

The length of the allocated cell.


Alloc()

static IMPORT_C TAny *Alloc(TInt aSize);

Description

Allocates a cell of specified size from the current thread's heap.

If there is insufficient memory available on the heap from which to allocate a cell of the required size, the function returns NULL.

The resulting size of the allocated cell may be rounded up to a value greater than aSize, but is guaranteed to be not less than aSize.

Parameters

TInt aSize

The size of the cell to be allocated from the current thread's heap.

Return value

TAny *

A pointer to the allocated cell. NULL, if there is insufficient memory available.

Panic codes

USER

47, if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.


AllocL()

static IMPORT_C TAny *AllocL(TInt aSize);

Description

Allocates a cell of specified size from the current thread's heap, and leaves if there is insufficient memory in the heap.

The resulting size of the allocated cell may be rounded up to a value greater than aSize, but is guaranteed to be not less than aSize.

Parameters

TInt aSize

The size of the cell to be allocated from the current thread's heap.

Return value

TAny *

A pointer to the allocated cell.

Panic codes

USER

47, if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.


AllocLC()

static IMPORT_C TAny *AllocLC(TInt aSize);

Description

Allocates a cell of specified size from the current thread's default heap, and, if successful, places a pointer to the cell onto the cleanup stack.

The function leaves if there is insufficient memory in the heap.

The resulting size of the allocated cell may be rounded up to a value greater than aSize, but is guaranteed to be not less than aSize.

Parameters

TInt aSize

The size of the cell to be allocated from the current thread's default heap.

Return value

TAny *

A pointer to the allocated cell.

Panic codes

USER

47, if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.


AllocZ()

static IMPORT_C TAny *AllocZ(TInt aSize);

Description

Allocates a cell of specified size from the current thread's default heap, and clears it to binary zeroes.

If there is insufficient memory available on the heap from which to allocate a cell of the required size, the function returns NULL.

The resulting size of the allocated cell may be rounded up to a value greater than aSize, but is guaranteed to be not less than aSize.

Parameters

TInt aSize

The size of the cell to be allocated from the current thread's default heap.

Return value

TAny *

A pointer to the allocated cell. NULL, if there is insufficient memory available.

Panic codes

USER

47, if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.


AllocZL()

static IMPORT_C TAny *AllocZL(TInt aSize);

Description

Allocates a cell of specified size from the current thread's default heap, clears it to binary zeroes, and leaves if there is insufficient memory in the heap.

The resulting size of the allocated cell may be rounded up to a value greater than aSize, but is guaranteed to be not less than aSize.

Parameters

TInt aSize

The size of the cell to be allocated from the current thread's heap.

Return value

TAny *

A pointer to the allocated cell.

Panic codes

USER

47, if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.


AllocSize()

static IMPORT_C TInt AllocSize(TInt &aTotalAllocSize);

Description

Gets the total number of cells allocated on the current thread's default heap, and the total space allocated to them.

Parameters

TInt &aTotalAllocSize

On return, contains the total space allocated to the cells.

Return value

TInt

The number of cells currently allocated on the current thread's heap.


Available()

static IMPORT_C TInt Available(TInt &aBiggestBlock);

Description

Gets the total free space currently available on the current thread's default heap, and the space available in the largest free block.

The space available represents the total space which can be allocated.

Note that compressing the heap may reduce the total free space available and the space available in the largest free block.

Parameters

TInt &aBiggestBlock

On return, contains the space available in the largest free block on the current thread's default heap.

Return value

TInt

The total free space currently available on the current thread's heap.


CountAllocCells()

static IMPORT_C TInt CountAllocCells();

Description

Gets the total number of cells allocated on the current thread's default heap.

Return value

TInt

The number of cells allocated on the current thread's default user heap.


CountAllocCells()

static IMPORT_C TInt CountAllocCells(TInt &aFreeCount);

Description

Gets the the total number of cells allocated, and the number of free cells, on the current thread's default heap.

Parameters

TInt &aFreeCount

On return, contains the number of free cells on the current thread's default heap.

Return value

TInt

The number of cells allocated on the current thread's default heap.


Free()

static IMPORT_C void Free(TAny *aCell);

Description

Frees the specified cell and returns it to the current thread's default heap.

Parameters

TAny *aCell

A pointer to a valid cell to be freed. If NULL this function call will be ignored.

Panic codes

USER

42, if aCell is not NULL and does not point to a valid cell.


FreeZ()

static IMPORT_C void FreeZ(TAny *&aCell);

Description

Frees the specified cell, returns it to the current thread's default heap, and resets the pointer to NULL.

Parameters

TAny *&aCell

A reference to a pointer to a valid cell to be freed. If NULL this function call will be ignored.

Panic codes

USER

42, if aCell is not NULL and does not point to a valid cell.


Allocator()

static IMPORT_C RAllocator &Allocator();

Description

Gets the current thread's default current heap.

Return value

RAllocator &

The current heap.


Heap()

static inline RHeap &Heap();

Description

Gets a reference to the handle to the current thread's heap.

Return value

RHeap &

A reference to the handle to the current thread's heap.


ReAlloc()

static IMPORT_C TAny *ReAlloc(TAny *aCell, TInt aSize, TInt aMode=0);

Description

Increases or decreases the size of an existing cell in the current thread's heap.

If the cell is being decreased in size, then it is guaranteed not to move, and the function returns the pointer originally passed in aCell. Note that the length of the cell will be the same if the difference between the old size and the new size is smaller than the minimum cell size.

If the cell is being increased in size, i.e. aSize is bigger than its current size, then the function tries to grow the cell in place. If successful, then the function returns the pointer originally passed in aCell. If unsuccessful, then:

  1. if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then the function returns NULL.

  2. if the cell can be moved, i.e. aMode does not have the ENeverMove bit set, then the function tries to allocate a new replacement cell, and, if successful, returns a pointer to the new cell; if unsuccessful, it returns NULL.

Note that in debug mode, the function returns NULL if the cell cannot be grown in place, regardless of whether the ENeverMove bit is set.

If the reallocated cell is at a different location from the original cell, then the content of the original cell is copied to the reallocated cell.

If the supplied pointer, aCell is NULL, then the function attempts to allocate a new cell, but only if the cell can be moved, i.e. aMode does not have the ENeverMove bit set.

Note the following general points:

Parameters

TAny *aCell

A pointer to the cell to be reallocated. This may be NULL.

TInt aSize

The new size of the cell. This may be bigger or smaller than the size of the original cell. The value can also be zero, but this is interpreted as a request for a cell of minimum size; the net effect is the same as if the caller had explicitly requested a cell of minimum size. Note that the minimum size of a heap cell is device dependent.

TInt aMode

Flags controlling the reallocation. The only bit which has any effect on this function is that defined by the enumeration ENeverMove of the enum RAllocator::TReAllocMode. If this is set, then any successful reallocation guarantees not to have changed the start address of the cell. By default, this parameter is zero.

Return value

TAny *

A pointer to the reallocated cell. This may be the same as the original pointer supplied through aCell. NULL if there is insufficient memory to reallocate the cell, or to grow it in place.

Panic codes

USER

42, if aCell is not NULL, and does not point to a valid cell.

USER

47, if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling ReAlloc(someptr,-1) raises this panic.

See also:


ReAllocL()

static IMPORT_C TAny *ReAllocL(TAny *aCell, TInt aSize, TInt aMode=0);

Description

Increases or decreases the size of an existing cell, and leaves if there is insufficient memory in the current thread's default heap.

If the cell is being decreased in size, then it is guaranteed not to move, and the function returns the pointer originally passed in aCell. Note that the length of the cell will be the same if the difference between the old size and the new size is smaller than the minimum cell size.

If the cell is being increased in size, i.e. aSize is bigger than its current size, then the function tries to grow the cell in place. If successful, then the function returns the pointer originally passed in aCell. If unsuccessful, then:

  1. if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then the function leaves.

  2. if the cell can be moved, i.e. aMode does not have the ENeverMove bit set, then the function tries to allocate a new replacement cell, and, if successful, returns a pointer to the new cell; if unsuccessful, it leaves.

Note that in debug mode, the function leaves if the cell cannot be grown in place, regardless of whether the ENeverMove bit is set.

If the reallocated cell is at a different location from the original cell, then the content of the original cell is copied to the reallocated cell.

If the supplied pointer, aCell is NULL, then the function attempts to allocate a new cell, but only if the cell can be moved, i.e. aMode does not have the ENeverMove bit set.

Note the following general points:

Parameters

TAny *aCell

A pointer to the cell to be reallocated. This may be NULL.

TInt aSize

The new size of the cell. This may be bigger or smaller than the size of the original cell. The value can also be zero, but this is interpreted as a request for a cell of minimum size; the net effect is the same as if the caller had explicitly requested a cell of minimum size. Note that the minimum size of a heap cell is device dependent.

TInt aMode

Flags controlling the reallocation. The only bit which has any effect on this function is that defined by the enumeration ENeverMove of the enum RAllocator::TReAllocMode. If this is set, then any successful reallocation guarantees not to have changed the start address of the cell. By default, this parameter is zero.

Return value

TAny *

A pointer to the reallocated cell. This may be the same as the original pointer supplied through aCell.

Panic codes

USER

42, if aCell is not NULL, and does not point to a valid cell.

USER

47, if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling ReAlloc(someptr,-1) raises this panic.

See also:


SwitchAllocator()

static IMPORT_C RAllocator *SwitchAllocator(RAllocator *aAllocator);

Description

Changes the current thread's heap.

Parameters

RAllocator *aAllocator

A pointer to the new heap handle.

Return value

RAllocator *

A pointer to the old heap handle.


SwitchHeap()

static inline RHeap *SwitchHeap(RAllocator *aHeap);

Description

Changes the current thread's heap.

Parameters

RAllocator *aHeap

A pointer to the new heap handle.

Return value

RHeap *

A pointer to the old heap handle.


CompressAllHeaps()

Interface status: deprecatedThis method is no longer supported, and calling it has no effect.

static IMPORT_C TInt CompressAllHeaps();

Description

Compresses all the chunks containing heaps.

Return value

TInt

KErrNone


After()

static IMPORT_C void After(TTimeIntervalMicroSeconds32 aInterval);

Description

Suspends the current thread until a specified time interval has expired.

Parameters

TTimeIntervalMicroSeconds32 aInterval

The time interval for which the current thread is to be suspended, in microseconds.

Panic codes

USER

86, if the time interval is negative.


At()

static IMPORT_C TInt At(const TTime &aTime);

Description

Suspends the current thread until the specified absolute time.

If the machine is off at that time, the machine will be turned on again.

KErrNone - suspension of the current thread completed normally at the requested time.

KErrAbort - suspension of the current thread was aborted because the system time changed.

KErrUnderflow - the requested completion time is in the past.

KErrOverFlow - the requested completion time is too far in the future.

Parameters

const TTime &aTime

The absolute time until which the current thread is to be suspended.

Return value

TInt

On completion, contains the status of the request to suspend the current thread:


AfterHighRes()

static IMPORT_C void AfterHighRes(TTimeIntervalMicroSeconds32 aInterval);

Description

Suspends the current thread until a specified time interval has expired to a resolution of 1ms .

Parameters

TTimeIntervalMicroSeconds32 aInterval

The time interval for which the current thread is to be suspended, in microseconds.

Panic codes

USER

86, if the time interval is negative.


SetHomeTime()

Interface status: deprecatedSet the time using User::SetUTCTime if the UTC time is known; otherwise, use the timezone server to set the time.
Capability: WriteDeviceData

static IMPORT_C TInt SetHomeTime(const TTime &aTime);

Description

Sets the home time to a specified time value.

Parameters

const TTime &aTime

A reference to a time representation object containing the time value.

Return value

TInt

KErrNone if successful or one of the system-wide error codes.


SetUTCTime()

Capability: WriteDeviceData

static IMPORT_C TInt SetUTCTime(const TTime &aUTCTime);

Description

Sets the UTC time to a specified time value.

Parameters

const TTime &aUTCTime

Return value

TInt

KErrNone if successful or one of the system-wide error codes.


UTCOffset()

static IMPORT_C TTimeIntervalSeconds UTCOffset();

Description

Gets the UTC offset - the difference between UTC and the current local time due to any time zones and daylight savings time that may be in effect. A positive offset indicates a time ahead of UTC, a negative offset indicates a time behind UTC.

Return value

TTimeIntervalSeconds

The UTC offset, in seconds.


SetUTCOffset()

Capability: WriteDeviceData

static IMPORT_C void SetUTCOffset(TTimeIntervalSeconds aOffset);

Description

Sets the UTC offset to the given number of seconds. This should include both time zone differences and the effect of any applicable daylight savings time. A positive offset indicates a time ahead of UTC, a negative offset indicates a time behind UTC.

Parameters

TTimeIntervalSeconds aOffset

The UTC offset, in seconds.


SetUTCTimeAndOffset()

Capability: WriteDeviceData

static IMPORT_C TInt SetUTCTimeAndOffset(const TTime &aUTCTime, TTimeIntervalSeconds aOffset);

Description

Sets the UTC time and UTC offset to the specified values, atomically. This is equivalent to calling both SetUTCTime and SetUTCOffset, but without the possibility of an incorrect time being observed between the two calls. If the operation is not successful, an error code will be returned and both the time and offset will be left unchanged.

Parameters

const TTime &aUTCTime

TTimeIntervalSeconds aOffset

The UTC offset, in seconds.

Return value

TInt

KErrNone if successful or one of the system-wide error codes.


SetCurrencySymbol()

Capability: WriteDeviceData

static IMPORT_C TInt SetCurrencySymbol(const TDesC &aSymbol);

Description

Sets the system wide currency symbol.

On successful return from this function, a call to the Set() member function of a TCurrencySymbol object fetches the new currency symbol.

Parameters

const TDesC &aSymbol

A reference to the descriptor containing the currency symbol to be set.

Return value

TInt

KErrNone if successful, otherwise one of the other system wide error codes.

Panic codes

USER

119, if the length of aSymbol is greater than KMaxCurrencySymbol.

See also:


SetFloatingPointMode()

static IMPORT_C TInt SetFloatingPointMode(TFloatingPointMode aMode, TFloatingPointRoundingMode aRoundingMode=EFpRoundToNearest);

Description

Sets the hardware floating point mode for the current thread. This does not affect software floating point calculations. The rounding mode can also be set. New threads created by this thread will inherit the mode, thus to set the mode for a whole process, call this method before you create any new threads.

Parameters

TFloatingPointMode aMode

The floating point calculation mode to use.

TFloatingPointRoundingMode aRoundingMode

The floating point rounding mode to use, defaults to nearest.

Return value

TInt

KErrNone if successful, KErrNotSupported if the hardware does not support the chosen mode, or there is no floating point hardware present.

See also:


TickCount()

static IMPORT_C TUint TickCount();

Description

Gets the current tick count.

The period between ticks is usually 1/64 second, but may be hardware dependent.

Return value

TUint

The machine dependent tick count.


NTickCount()

static IMPORT_C TUint32 NTickCount();

Description

Gets the nanokernel tick count.

This is the current value of the machine's millisecond tick counter.

On the emulator the resolution defaults to 5 milliseconds; however you can change it to N milliseconds when you launch the emulator from the command line by specifying -Dtimerresolution=N as a parameter to epoc.exe, for example:

epoc.exe -Dtimerresolution=3

On most hardware the resolution is about 1 millisecond.

You can get the nanokernel tick period in microseconds by calling into the Hardware Abstraction Layer:

TInt nanokernel_tick_period;
HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period);

Return value

TUint32

The nanokernel tick count.


LockPeriod()

static IMPORT_C TTimerLockSpec LockPeriod();

Description

Returns which of the periods the clock is currently in.

Return value

TTimerLockSpec

The fraction of a second at which the timer completes.


InactivityTime()

static IMPORT_C TTimeIntervalSeconds InactivityTime();

Description

Gets the time since the last user activity.

Return value

TTimeIntervalSeconds

The time interval.


ResetInactivityTime()

static IMPORT_C void ResetInactivityTime();

Description

Resets all user inactivity timers.


FastCounter()

static IMPORT_C TUint32 FastCounter();

Description

Gets the fast counter.

This is the current value of the machine's high resolution timer. If a high resolution timer is not available, it uses the millisecond timer instead.

The freqency of this counter can be determined by reading the HAL attribute EFastCounterFrequency.

Return value

TUint32

The fast counter value.


LockedInc()

static IMPORT_C TInt LockedInc(TInt &aValue);

Description

Increments a TInt value by 1 when the current thread is locked to prevent re-entrancy.

The increment to aValue is done while the current thread is locked; i.e. no other thread is permitted to run until the sequence of instructions which increment aValue have completed. Hence the function gives controlled access to a TInt variable which may be in a memory location accessible to more than one thread.

As an example of its use, the function is used in the implementation of critical sections.

Parameters

TInt &aValue

A reference to an integer whose value is to be incremented. On return contains the incremented value.

Return value

TInt

The value of aValue before it is incremented.

See also:


LockedDec()

static IMPORT_C TInt LockedDec(TInt &aValue);

Description

Decrements a TInt value by 1 when the current thread is locked to prevent re-entrancy.

The decrement from aValue is done while the current thread is locked; i.e. no other thread is permitted to run until the sequence of instructions which decrement aValue have completed. Hence the function gives controlled access to a TInt variable which may be in a memory location accessible to more than one thread.

As an example of its use, the function is used in the implementation of critical sections.

Parameters

TInt &aValue

A reference to TInt whose value is to be decremented. On return contains the decremented value.

Return value

TInt

The value of aValue before it is decremented.

See also:


SafeInc()

static IMPORT_C TInt SafeInc(TInt &aValue);

Description

Atomically increments the specified value by 1, if the value is > 0.

Parameters

TInt &aValue

The value to be incremented; on return the incremented value.

Return value

TInt

The original value of aValue


SafeDec()

static IMPORT_C TInt SafeDec(TInt &aValue);

Description

Atomically decrements the specified value by 1, if the value is > 0.

Parameters

TInt &aValue

The value to be decremented; on return the decremented value.

Return value

TInt

The original value of aValue


Beep()

static IMPORT_C TInt Beep(TInt aFrequency, TTimeIntervalMicroSeconds32 aDuration);

Description

Makes a beep tone with a specified frequency and duration.

This function should not be used. It exists to maintain compatibility with older versions of Symban OS.

Parameters

TInt aFrequency

TTimeIntervalMicroSeconds32 aDuration

Return value

TInt


IsRomAddress()

static IMPORT_C TInt IsRomAddress(TBool &aBool, TAny *aPtr);

Description

Tests whether the specified address is in the ROM.

Parameters

TBool &aBool

True, if the address at aPtr is within the ROM; false, otherwise.

TAny *aPtr

The address to be tested.

Return value

TInt

Always KErrNone.


BinarySearch()

static IMPORT_C TInt BinarySearch(TInt aCount, const TKey &aKey, TInt &aPos);

Description

Performs a binary search for an array element containing a specified key.

It can be used on any kind of array where elements can be identified by key. It is used by the standard Symbian OS arrays having CArrayFix, CArrayVar or CArrayPak in their class hierarchy in the implementation of the various functions for inserting, deleting and finding elements by key. The function can be used by other arrays.

The function returns a zero value if the search is successful and a non-zero value otherwise.

If the search is successful, the function puts the position (i.e. the index) of the element into aPos. If the search is unsuccessful, then the function puts into aPos the position of the first element in the array whose key is greater than the search key.

If the array is empty, i.e. aCount is zero, then the search is unsuccessful and aPos is not defined.

Parameters

TInt aCount

The number of elements in the array.

const TKey &aKey

A reference to a suitably initialised TKey derived object. In particular, the object will have been initialised with a pointer to a sample element containing the search key.

TInt &aPos

If the element is found, the reference is set to the position of that element within the array. The position is relative to zero, (i.e. the first element in the array is at position 0). If the element is not found and the array is not empty, then the reference is set to the position of the first element in the array with a key which is greater than the search key. If the element is not found and the array is empty, then the reference is undefined.

Return value

TInt

Zero, if the element with the specified key is found. Non-zero, if the element with the specified key is not found.

Panic codes

USER

97, if aCount is negative.


QuickSort()

static IMPORT_C TInt QuickSort(TInt aCount, const TKey &aKey, const TSwap &aSwap);

Description

Quick sorts array elements.

It is used by the standard Symbian OS arrays having CArrayFixBase, CArrayVarBase or CArrayPakBase in their class hierarchy in the implementation of their sort functions. The function can be used by other arrays.

The function returns KErrNone if the operation is successful otherwise it returns KErrGeneral.

Parameters

TInt aCount

The number of elements in the array.

const TKey &aKey

A reference to a suitably initialised TKey derived object.

const TSwap &aSwap

A reference to a suitably initialised TSwap derived object.

Return value