Changeset 121 for trunk/src/time.cc
- Timestamp:
- 06/15/13 17:47:57 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/time.cc
r34 r121 42 42 static timer_impl zero_timer; 43 43 44 volatilenv::uint64 nv::get_ticks()44 nv::uint64 nv::get_ticks() 45 45 { 46 46 #if NV_COMPILER == NV_MSVC 47 47 return __rdtsc(); 48 #el if NV_COMPILER == NV_GNUC49 register long long ticks asm("eax") ;48 #else 49 register long long ticks asm("eax") = 0; 50 50 asm volatile (".byte 15, 49" : : : "eax", "edx"); 51 return ticks; 52 #else 53 return 0; // unsupported 51 return static_cast<nv::uint64>( ticks ); 54 52 #endif 55 53 } … … 59 57 #if NV_COMPILER == NV_MSVC 60 58 Sleep( ms ); 61 #el if NV_COMPILER == NV_GNUC59 #else 62 60 usleep( ms * 1000 ); 63 #else64 61 #endif 65 62 } … … 85 82 struct timeval now; 86 83 gettimeofday(&now, NULL); 87 return ( now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000;84 return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 ); 88 85 #endif 89 86 } … … 99 96 struct timeval now; 100 97 gettimeofday(&now, NULL); 101 return ( now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec);98 return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) ); 102 99 #endif 103 100 }
Note: See TracChangeset
for help on using the changeset viewer.