Skip to content

Commit

Permalink
[Android] Fix Timer::getMilliseconds randomly returning large numbers
Browse files Browse the repository at this point in the history
Also make iOS match Android & Linux just in case.
  • Loading branch information
darksylinc committed Aug 14, 2023
1 parent edf4271 commit 2057102
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions OgreMain/src/Android/OgreTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ uint64 Timer::getMilliseconds()
{
struct timeval now;
gettimeofday( &now, NULL );
return static_cast<uint64>( now.tv_sec - start.tv_sec ) * 1000 +
static_cast<uint64>( now.tv_usec - start.tv_usec ) / 1000;
return static_cast<uint64>( now.tv_sec - start.tv_sec ) * 1000ul +
static_cast<uint64>( ( now.tv_usec - start.tv_usec ) / 1000l );
}

//--------------------------------------------------------------------------------//
uint64 Timer::getMicroseconds()
{
struct timeval now;
gettimeofday( &now, NULL );
return static_cast<uint64>( now.tv_sec - start.tv_sec ) * 1000000 +
return static_cast<uint64>( now.tv_sec - start.tv_sec ) * 1000000ul +
static_cast<uint64>( now.tv_usec - start.tv_usec );
}

Expand Down
6 changes: 3 additions & 3 deletions OgreMain/src/iOS/OgreTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ uint64 Timer::getMilliseconds()
{
struct timeval now;
gettimeofday( &now, NULL );
return static_cast<uint64>( now.tv_sec - start.tv_sec ) * 1000 +
static_cast<uint64>( ( now.tv_usec - start.tv_usec ) / 1000 );
return static_cast<uint64>( now.tv_sec - start.tv_sec ) * 1000ul +
static_cast<uint64>( ( now.tv_usec - start.tv_usec ) / 1000l );
}

//--------------------------------------------------------------------------------//
uint64 Timer::getMicroseconds()
{
struct timeval now;
gettimeofday( &now, NULL );
return static_cast<uint64>( now.tv_sec - start.tv_sec ) * 1000000 +
return static_cast<uint64>( now.tv_sec - start.tv_sec ) * 1000000ul +
static_cast<uint64>( now.tv_usec - start.tv_usec );
}

Expand Down

0 comments on commit 2057102

Please sign in to comment.