Changeset 402 for trunk/src/core/time.cc


Ignore:
Timestamp:
06/13/15 21:51:27 (10 years ago)
Author:
epyon
Message:
  • cleanups of clang warnings (gotta love them all)
  • only nv-core for now (this will take a while for the whole source)
  • mainly C++ casts instead of C-style casts, but also a few bugs fixed!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/time.cc

    r401 r402  
    8585nv::uint32 nv::get_cpu_ms()
    8686{
    87         return (uint32)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000.0 ) ) ;
     87        return static_cast<uint32>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000.0f ) ) ;
    8888}
    8989
    9090nv::uint64 nv::get_cpu_us()
    9191{
    92         return (uint64)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000000.0 ) ) ;
     92        return static_cast<uint64>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000000.0f ) ) ;
    9393}
    9494
     
    9999        QueryPerformanceCounter(&now);
    100100        LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart;
    101         return (uint32) (1000.0 * result / (double) zero_timer.frequency.QuadPart);
     101        return static_cast<uint32>(1000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) );
    102102#else
    103103        struct timeval now;
    104104        gettimeofday(&now, NULL);
    105         return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 );
     105        return static_cast<uint32>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 );
    106106#endif
    107107}
     
    113113        QueryPerformanceCounter(&now);
    114114        LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart;
    115         return (uint64) (1000000.0 * result / (double) zero_timer.frequency.QuadPart);
     115        return static_cast<uint64>(1000000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) );
    116116#else
    117117        struct timeval now;
    118118        gettimeofday(&now, NULL);
    119         return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) );
     119        return static_cast<uint64>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) );
    120120#endif
    121121}
Note: See TracChangeset for help on using the changeset viewer.