EXPORT_C int symbian_get_cpu_time(long* sec, long* usec) { // The RThread().GetCpuTime() does not seem to work? // (it always returns KErrNotSupported) // TTimeIntervalMicroSeconds ti; // TInt err = me.GetCpuTime(ti); dTHX; TInt periodus; /* tick period in microseconds */ if (HAL::Get(HALData::ESystemTickPeriod, periodus) != KErrNone) return -1; TUint tick = User::TickCount(); if (PL_timesbase.tms_utime == 0) { PL_timesbase.tms_utime = tick; PL_clocktick = PERL_SYMBIAN_CLK_TCK; } tick -= PL_timesbase.tms_utime; TInt64 tickus = TInt64(tick) * TInt64(periodus); TInt64 tmps = tickus / 1000000; #ifdef __SERIES60_3X__ if (sec) *sec = I64LOW(tmps); if (usec) *usec = I64LOW(tickus) - I64LOW(tmps) * 1000000; #else if (sec) *sec = tmps.Low(); if (usec) *usec = tickus.Low() - tmps.Low() * 1000000; #endif //__SERIES60_3X__ return 0; }
TInt TFileOps::Open(TChar aDrvCh, TInt aNum) /// Open the file for testing, give error if there is not enough space for it. /// @param aDrvCh Drive letter. /// @param aNum File number suffix. { TVolumeInfo vol; TInt drv; TInt r = TheFs.CharToDrive(aDrvCh, drv); if (r != KErrNone) TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), (TUint)aDrvCh, r); r = TheFs.Volume(vol, drv); if (r != KErrNone) TTest::Fail(HERE, _L("Volume(%c:) returned %d"), (TUint)aDrvCh, r); iMax = I64LOW(vol.iFree / MAKE_TINT64(0,KBufLen)) / 2 - 1; if (iMax < 10) TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"), I64LOW(vol.iFree/1024)); Reset(); iName.Format(_L("%c:\\TEST_%d"), (TUint)aDrvCh, aNum); r = iF.Replace(TheFs, iName, EFileStreamText | EFileWrite); if (r == KErrNone) iOpen = ETrue; return r; }
void CRKWindow::WinKeyL(const TKeyEvent &aKey,const TTime &aTime) { if (aKey.iCode==EKeyEscape) { CActiveScheduler::Stop(); iTest->iAbort=ETrue; } #if defined(LOGGING) TLogMessageText logMessageText; _LIT(KKey,"CRKWindow::WinKeyL Code=%d (%c) State=%d RepeatCount=%d"); logMessageText.Format(KKey,aKey.iScanCode,aKey.iScanCode,iState,iRepCount); iTest->LOG_MESSAGE(logMessageText); #endif if (aKey.iCode==32) { switch(iState) { case EStateWaitingForKeyCode: SetState(EStateWaitingForFirstRepeat); iPrevTime=aTime; break; case EStateWaitingForFirstRepeat: iRepCount=1; iInitialGap = I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64()); SetState(EStateWaitingForNthRepeat); break; case EStateWaitingForNthRepeat: if (iRepCount==5) SetState(EStateWaitingForKeyUp); else { TTimeIntervalMicroSeconds32 gap(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); #if defined(LOGGING) TLogMessageText logMessageText; _LIT(KRepeatGap,"Repeat after %d"); logMessageText.AppendFormat(KRepeatGap,gap.Int()); iTest->LOG_MESSAGE(logMessageText); TheClient->Flush(); #endif if (gap<iMinGap) iMinGap=gap; if (gap>iMaxGap) iMaxGap=gap; iTotalGap=iTotalGap.Int()+gap.Int(); // Horrible way to do a += iRepCount++; SetState(EStateWaitingForNthRepeat); } case EStateWaitingForKeyUp: // Do nothing here break; default: //iTest->Test(EFalse); iTest->TestBase()->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); CActiveScheduler::Stop(); } iPrevTime=aTime; } }
void CLogClearLogClientOp::InitiateRequestToServerL() { const TInt64 dateVal(iDate.Int64()); #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM TIpcArgs args(&iData, I64LOW(dateVal), I64HIGH(dateVal), iSimId); #else TIpcArgs args(&iData, I64LOW(dateVal), I64HIGH(dateVal)); #endif iSession.Send(ELogOperationInitiate, args, iStatus); }
/** Reading data @param aPos position to read @param aLength number of bytes to read @param aTrg targer buffer @return KErrNone or KErrOverflow in case of an error */ TInt CTestProxyDrive::Read(TInt64 aPos, TInt aLength, TDes8& aTrg) { __FNLOG ("CTestProxyDrive::Read"); // TInt64 is not supported by Copy() ASSERT (I64HIGH(aPos) == 0); if(!aLength) { return KErrNone; } if( (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos)) && (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos) + static_cast<TUint>(aLength)) ) { return KErrOverflow; } aTrg.Copy(&iMediaBuf[I64LOW(aPos)], aLength); return KErrNone; }
/** Writing data @param aPos position to write @param aSrc source buffer @return KErrNone or KErrOverflow in case of an error */ TInt CTestProxyDrive::Write (TInt64 aPos, const TDesC8& aSrc) { __FNLOG ("CTestProxyDrive::Write"); // TInt64 is not supported by Copy() ASSERT(0 == I64HIGH(aPos)); if (!aSrc.Length()) { return KErrNone; } if ( (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos)) && (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos) + static_cast<TUint>(aSrc.Length())) ) { return KErrOverflow; } TPtr8 ptr (&iMediaBuf[I64LOW(aPos)], aSrc.Length(), aSrc.Length()); ptr.Copy(aSrc); return KErrNone; }
TInt DMediaDriverNVMemory::Read() { __DEBUG_PRINT(">DMediaDriverNVMemory::Read() pos: %lx, size: %lx", iPos, iTotalLength); // Set our sector offset TUint32 transactionSectorOffset = (TUint32)(iPos / KDiskSectorSize); TUint32 transactionLength = 0; TUint32 transactionDirection = NVMEM_TRANSACTION_READ; // Do we have an operation longer than our shared memory? if( iSplitted > 0 ) { transactionLength = KNVMemTransferBufferSize; } else { // Do the whole operation in one go since we have enough room in our memory transactionLength = I64LOW(iTotalLength); // Read the "broken" tail sector if( iTail ) { transactionLength += iTail; iAlignmentOverhead += iTail; } } // Read the "broken" head sector if( iHead > 0 ) { transactionLength += iHead; iAlignmentOverhead += iHead; } // We should be ok to continue ContinueTransaction( transactionSectorOffset, transactionLength/KDiskSectorSize, transactionDirection ); __DEBUG_PRINT("<DMediaDriverNVMemory::Read()"); return KErrNone; }
void CTestDevVideoPlayClock::MmcspuoTick(const TTimeIntervalMicroSeconds& aTime) { iPeriodicUtilityIteration++; TUint currentTime = I64LOW(aTime.Int64()); TUint predictedTime = iPeriodicUtilityIteration * KTestClock2Seconds; if (!TimeComparison(currentTime, predictedTime, KTestClockBigDeviationMS)) { ERR_PRINTF3(_L("Error - Periodic Utility time comparison failed: Got %u; Expected %u"), currentTime, predictedTime); iPeriodicUtilityTestVerdict = EFail; iPeriodicUtility->Stop(); CActiveScheduler::Stop(); } else { INFO_PRINTF3(_L("Periodic Utility time comparison passed: Got %u; Expected %u"), currentTime, predictedTime); } if (iPeriodicUtilityIteration >= 5) { iPeriodicUtility->Stop(); CActiveScheduler::Stop(); } }
TBool CMMFSwCodecUtility::RampAudio(CMMFDataBuffer* aBuffer) { TInt i=0; TInt length = aBuffer->Data().Length()>>1; TInt16* sample = REINTERPRET_CAST(TInt16*,&aBuffer->Data()[0]); TInt64 theResult(0); while ((i < length) && (iRampIncr < iRampSamples)) { theResult = sample[i]; theResult *= iRampIncr; theResult /= iRampSamples; sample[i] = STATIC_CAST(TInt16, I64LOW(theResult) ); if ((iChannels == 1) || (!iSkip)) { iRampIncr++; } iSkip = !iSkip; i++; } if (iRampIncr < iRampSamples) return ETrue; else return EFalse; }
static void TestMkDir() { test.Next(_L("Benchmark MkDir")); ClearSessionDirectory(); TTime startTime; TTime endTime; TTimeIntervalMicroSeconds timeTaken(0); startTime.HomeTime(); const TInt KNumDirEntries = 100; for (TInt n=0; n<KNumDirEntries; n++) { TFileName dirName = _L("\\F32-TST\\DIR_"); dirName.AppendNum(n); dirName.Append(_L("\\")); TInt r = TheFs.MkDir(dirName); test_KErrNone(r); } endTime.HomeTime(); timeTaken=endTime.MicroSecondsFrom(startTime); TInt timeTakenInMs = I64LOW(timeTaken.Int64() / 1000); test.Printf(_L("Time taken to create %d entries = %d ms\n"), KNumDirEntries, timeTakenInMs); }
void ExternalizeInt64L(const TInt64& aInt, RWriteStream& aStream) { TInt32 low = I64LOW( aInt ); TInt32 high = I64HIGH( aInt ); aStream.WriteInt32L(low); aStream.WriteInt32L(high); }
// ----------------------------------------------------------------------------- void CPresenceCacheBuddyInfo::ExternalizeL( RWriteStream& aStream ) const { aStream.WriteInt32L( iAvailability ); ExternalizeFieldL( BuddyId(), aStream ); // externalize expiry time TUint32 time_high = I64HIGH( iExpiryTime ); TUint32 time_low = I64LOW( iExpiryTime ); aStream.WriteUint32L(time_high); aStream.WriteUint32L(time_low); TInt count = iIds.Count(); aStream.WriteInt32L( count ); for ( TInt i=0; i < count; i++ ) { if ( iIds[i] ) { TPtrC key = iIds[i]->Des(); TPtrC8 value = iValues[i] ? iValues[i]->Des() : TPtrC8(); ExternalizeFieldL( key, aStream ); ExternalizeFieldL( value, aStream ); } else { // nothing to insert, special case if replacement has been failed earlier } } }
//Creates enough number of large data files to fill the available disk space. //It will change FilesCount global variable's value. static void CreateLargeFileL() { TInt fileNo = 0; const TInt KLargeFileSize = 1000000000; TInt64 diskSpace = FreeDiskSpaceL(); RDebug::Print(_L("CreateLargeFileL: free space before = %ld\n"), diskSpace); TBuf<KMaxFileName> filePath; const TInt64 KMinDiskSpace = 200; //Reserve almost all disk space, except a small amount - 200 bytes. while(diskSpace > KMinDiskSpace) { AssembleLargeFileName(KLargeFileName, fileNo++, filePath); TInt fileSize = KLargeFileSize; if(diskSpace < (TInt64)KLargeFileSize) { TInt64 lastFileSize = diskSpace - KMinDiskSpace; fileSize = I64LOW(lastFileSize); } DoCreateLargeFileL(filePath, fileSize); diskSpace = FreeDiskSpaceL(); RDebug::Print(_L("----CreateLargeFileL, step %d, free space = %ld\n"), fileNo, diskSpace); } diskSpace = FreeDiskSpaceL(); RDebug::Print(_L("CreateLargeFileL: free space after = %ld\n"), diskSpace); }
TUint32 ticks_to_us(TUint32 aTicks, TUint32 aF) { TUint64 x = TUint64(aTicks) * TUint64(1000000); TUint64 f64 = aF; x += (f64>>1); x /= f64; return I64LOW(x); }
LOCAL_C TInt32 GetSpeed(TInt aOps, TInt64 aDtime) /// Calculate and return the throughput from the umber of blocks transferred /// and the elapsed time. { TInt64 dsize = MAKE_TINT64(0, aOps) * MAKE_TINT64(0, KBufLen) * MAKE_TINT64(0, KSecond); TInt32 speed = I64LOW((dsize + aDtime/2) / aDtime); return speed; }
void CMMFSwCodecUtility::ConfigAudioRamper(TInt64 aRampTime, TInt aSampleRate, TInt aChannels) { iRampSamples = I64LOW(((TInt64(aSampleRate) * aRampTime) /1000000 )); // Add this iRampSamplesLeft = iRampSamples; iChannels = aChannels; iRampIncr = 0; iSkip = ETrue; }
LOCAL_C TInt GetSpeed(TStats& aStats) /// Calculate and return the data throughput from the statistics, rounded. { gDataLock.Wait(); TInt speed = I64LOW((aStats.iSize + aStats.iTime/2) / aStats.iTime); gDataLock.Signal(); return speed; }
void CSuspendTest::CreateL() { // // Create the eraser thread // iEraser = new(ELeave) CEraser; iEraser->CreateL(); // // Load the device drivers // TInt r; #ifndef SKIP_PDD_LOAD test.Printf( _L("Loading %S\n"), &KLfsDriverName ); r = User::LoadPhysicalDevice( KLfsDriverName ); test( KErrNone == r || KErrAlreadyExists == r ); #endif #ifdef UNMOUNT_DRIVE RFs fs; test( KErrNone == fs.Connect() ); test( KErrNone == fs.SetSessionPath( _L("Z:\\") ) ); TFullName name; fs.FileSystemName( name, KLffsLogicalDriveNumber ); if( name.Length() > 0 ) { test.Printf( _L("Unmounting drive") ); test( KErrNone == fs.DismountFileSystem( _L("Lffs"), KLffsLogicalDriveNumber) ); User::After( 2000000 ); test.Printf( _L("Drive unmounted") ); } fs.Close(); #endif // // Open a TBusLogicalDevice to it // test.Printf( _L("Opening media channel\n") ); TBool changedFlag = EFalse; r = iDrive.Connect( KDriveNumber, changedFlag ); User::LeaveIfError( r ); iDriveOpened = ETrue; // // Get size of Flash drive, block size, block count // TLocalDriveCapsV2Buf info; iDrive.Caps(info); iFlashSize = I64LOW(info().iSize); iBlockSize = info().iEraseBlockSize; iBlockCount = iFlashSize / iBlockSize; test.Printf( _L("Flash size is 0x%x bytes\n"), iFlashSize ); test.Printf( _L("Block size is 0x%x bytes\n"), iBlockSize ); test.Printf( _L("Block count is %d\n"), iBlockCount ); test.Printf( _L("CreateL complete\n") ); }
TInt CTestCrashDataSource::SetSimRegValues( const TUint32 aThreadId, RRegisterList & aRegisterList ) { RDebug::Print( _L("CTestCrashDataSource::SetSimRegValues()\n") ); if( aRegisterList.Count() > 0 ) { TUint8 val8 = (TUint8)(KRegValue8 + aThreadId); TUint16 val16 = (TUint16)(KRegValue16 + aThreadId); TUint32 val32 = (TUint32)(KRegValue32 + aThreadId); TUint64 val64 = (TUint64)(MAKE_TUINT64(0xFEDCBA98u,0x76543210u) + aThreadId); for( TInt i = 0; i < aRegisterList.Count(); i ++ ) { TRegisterData & reg = aRegisterList[i]; switch ( reg.iSize ) { case 0: reg.iValue8 = val8 + i; RDebug::Printf( " Setting reg[%d] iValue8=0x%X\n", i, reg.iValue8 ); break; case 1: reg.iValue16 = val16+ i; RDebug::Printf( " Setting reg[%d] iValue16=0x%X\n", i, reg.iValue16 ); break; case 2: reg.iValue32 = val32+ i; RDebug::Printf( " Setting reg[%d] iValue32=0x%X\n", i, reg.iValue32 ); break; case 3: reg.iValue64 = val64+ i; RDebug::Printf( " Setting reg[%d]=0x%X%X\n", i, I64HIGH(reg.iValue64), I64LOW(reg.iValue64) ); break; } //reg.iAvailable = i%8 ? ETrue : EFalse; /* if ( 0 == ((i+1) % 8) ) { RDebug::Printf( " setting reg[%d] as not available\n", i ); reg.iAvailable = EFalse; } */ } return KErrNone; } return KErrBadHandle; }
jlong Os::java_time_millis() { TTime NineteenSeventy(_L("19700000:000000.000000")); TTime now; now.UniversalTime(); TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(NineteenSeventy); TInt64 time = interval.Int64() / 1000; return ((jlong)I64HIGH(time) << 32) | (jlong)I64LOW(time); }
/** c'tor */ CTestProxyDrive::CTestProxyDrive() : CProxyDrive (NULL) { // default settings iCaps.iSize = KMaxBufSize * 2; iCaps.iSectorSizeInBytes = 512; iCaps.iNumberOfSectors = I64LOW(iCaps.iSize / iCaps.iSectorSizeInBytes); iCaps.iNumPagesPerBlock = 1; }
// ----------------------------------------------------------------------------- // TAccPolGenericIDAccessor::SetHWDeviceID // Set hardware model ID for Generic ID. // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C void TAccPolGenericIDAccessor::SetHWDeviceID( TAccPolGenericID& aGenericID, const TUint64 aHWDeviceID ) { COM_TRACE_2( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetHWDeviceIDL() H:0x%x, L:0x%x", I64HIGH( aHWDeviceID ), I64LOW( aHWDeviceID ) ); aGenericID.iStaticAttributes.iHWDeviceID = aHWDeviceID; COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetHWDeviceIDL() - return void" ); }
void CWordTest::BenchmarkL() { TTime start, end; start.HomeTime(); const int n = 100; for (int i = 0; i < n; i++) iTextView->FormatTextL(); end.HomeTime(); int ms = (I64LOW(end.Int64()) - I64LOW(start.Int64())) / 1000; TBuf<128> message; #ifdef _DEBUG _LIT(build,"debug"); #else _LIT(build,"release"); #endif message.Format(_L("form%d %S: reformatting %d times took %d milliseconds"), iTextView->Layout()->MajorVersion(),&build,n,ms); User::InfoPrint(message); }
// ----------------------------------------------------------------------------- // TAccPolGenericIDAccessor::SetDeviceAddress // Set device address for Generic ID. // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C void TAccPolGenericIDAccessor::SetDeviceAddress( TAccPolGenericID& aGenericID, const TUint64 aDeviceAddress ) { COM_TRACE_2( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetDeviceAddressL() H:0x%x, L:0x%x", I64HIGH( aDeviceAddress ), I64LOW( aDeviceAddress ) ); aGenericID.iStaticAttributes.iDeviceAddress = aDeviceAddress; COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetDeviceAddressL() - return void" ); }
void CTestDevVideoPlayClock::RunThread() { TTimeIntervalMicroSeconds currentTime(0); while(!iShutdownSubthread) { currentTime = iClockSource->Time(); TUint timeUint = I64LOW(currentTime.Int64()); } }
// --------------------------------------------------------------------------- // CTransactionIDGenerator::CTransactionIDGenerator // --------------------------------------------------------------------------- // CTransactionIDGenerator::CTransactionIDGenerator() { TUint ticks = User::TickCount(); TTime now; now.UniversalTime(); TInt64 us = now.Int64(); iSeed = static_cast<TInt64>( ticks ) + us; iCounter = I64LOW( us ) - ticks; }
EXPORT_C void TE64Addr::SetAddr(const TInt64& aAddr) { #ifdef I64HIGH u.iAddr32[0] = I64HIGH(aAddr); u.iAddr32[1] = I64LOW(aAddr); #else u.iAddr32[0] = aAddr.High(); u.iAddr32[1] = aAddr.Low(); #endif }
void CRKWindow::WinKeyL(const TKeyEvent &aKey,const TTime &aTime) { if (aKey.iCode==EKeyEscape) { CActiveScheduler::Stop(); iTest->iAbort=ETrue; } if (aKey.iCode==32) { switch(iState) { case EStateWaitingForKeyCode: SetState(EStateWaitingForFirstRepeat); iPrevTime=aTime; break; case EStateWaitingForFirstRepeat: iRepCount=1; iInitialGap = I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64()); SetState(EStateWaitingForNthRepeat); break; case EStateWaitingForNthRepeat: if (iRepCount==5) SetState(EStateWaitingForKeyUp); else { TTimeIntervalMicroSeconds32 gap(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); if (gap<iMinGap) iMinGap=gap; if (gap>iMaxGap) iMaxGap=gap; iTotalGap=iTotalGap.Int()+gap.Int(); // Horrible way to do a += iRepCount++; SetState(EStateWaitingForNthRepeat); } case EStateWaitingForKeyUp: // Do nothing here break; default: iTest->TestL(EFalse); } iPrevTime=aTime; } }
TStsTransactionId CStsServer::CreateTransactionID() { TTime currentTime; TStsTransactionId transactionID; do { currentTime.UniversalTime(); transactionID = I64LOW(currentTime.Int64()); } while(IsExistingTransaction(transactionID)); return transactionID; }
void CBkmrkProperties::TransSaveL() { SetModified (); TUint32 indexBase = IndexBase(); TUint32 timeLo = I64LOW(iLastModified.Int64()); TUint32 timeHi = I64HIGH(iLastModified.Int64()); iRepository->Set(indexBase + KBkmrkLastModifiedLoIndex, static_cast<TInt>(timeLo)); iRepository->Set(indexBase + KBkmrkLastModifiedHiIndex, static_cast<TInt>(timeHi)); iRepository->Set(indexBase + KCmnDescriptionIndex, Description()); iRepository->Set(indexBase + KCmnIconIndex, static_cast<TInt>(iIconId)); iCustomProperties->TransSaveL(); }