| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PLATFORM_GLOBALS_H_ | 5 #ifndef PLATFORM_GLOBALS_H_ |
| 6 #define PLATFORM_GLOBALS_H_ | 6 #define PLATFORM_GLOBALS_H_ |
| 7 | 7 |
| 8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to | 8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to |
| 9 // enable platform independent printf format specifiers. | 9 // enable platform independent printf format specifiers. |
| 10 #ifndef __STDC_FORMAT_MACROS | 10 #ifndef __STDC_FORMAT_MACROS |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 const int kMillisecondsPerSecond = 1000; | 318 const int kMillisecondsPerSecond = 1000; |
| 319 const int kMicrosecondsPerMillisecond = 1000; | 319 const int kMicrosecondsPerMillisecond = 1000; |
| 320 const int kMicrosecondsPerSecond = (kMicrosecondsPerMillisecond * | 320 const int kMicrosecondsPerSecond = (kMicrosecondsPerMillisecond * |
| 321 kMillisecondsPerSecond); | 321 kMillisecondsPerSecond); |
| 322 const int kNanosecondsPerMicrosecond = 1000; | 322 const int kNanosecondsPerMicrosecond = 1000; |
| 323 const int kNanosecondsPerMillisecond = (kNanosecondsPerMicrosecond * | 323 const int kNanosecondsPerMillisecond = (kNanosecondsPerMicrosecond * |
| 324 kMicrosecondsPerMillisecond); | 324 kMicrosecondsPerMillisecond); |
| 325 const int kNanosecondsPerSecond = (kNanosecondsPerMicrosecond * | 325 const int kNanosecondsPerSecond = (kNanosecondsPerMicrosecond * |
| 326 kMicrosecondsPerSecond); | 326 kMicrosecondsPerSecond); |
| 327 | 327 |
| 328 // Helpers to round micro second times to human understandable values. | 328 // Helpers to scale micro second times to human understandable values. |
| 329 inline double RoundMicrosecondsToSeconds(int64_t micros) { | 329 inline double MicrosecondsToSeconds(int64_t micros) { |
| 330 const int k1M = 1000000; // Converting us to secs. | 330 return static_cast<double>(micros) / kMicrosecondsPerSecond; |
| 331 return static_cast<double>(micros + (k1M >> 1)) / k1M; | |
| 332 } | 331 } |
| 333 inline double RoundMicrosecondsToMilliseconds(int64_t micros) { | 332 inline double MicrosecondsToMilliseconds(int64_t micros) { |
| 334 const int k1K = 1000; // Conversting us to ms. | 333 return static_cast<double>(micros) / kMicrosecondsPerMillisecond; |
| 335 return static_cast<double>(micros + (k1K >> 1)) / k1K; | |
| 336 } | 334 } |
| 337 | 335 |
| 338 // A macro to disallow the copy constructor and operator= functions. | 336 // A macro to disallow the copy constructor and operator= functions. |
| 339 // This should be used in the private: declarations for a class. | 337 // This should be used in the private: declarations for a class. |
| 340 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | 338 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 341 private: \ | 339 private: \ |
| 342 TypeName(const TypeName&); \ | 340 TypeName(const TypeName&); \ |
| 343 void operator=(const TypeName&) | 341 void operator=(const TypeName&) |
| 344 | 342 |
| 345 | 343 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods | 498 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods |
| 501 // have an implicit 'this' argument, the arguments of such methods | 499 // have an implicit 'this' argument, the arguments of such methods |
| 502 // should be counted from two, not one." | 500 // should be counted from two, not one." |
| 503 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ | 501 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ |
| 504 __attribute__((__format__(__printf__, string_index, first_to_check))) | 502 __attribute__((__format__(__printf__, string_index, first_to_check))) |
| 505 #else | 503 #else |
| 506 #define PRINTF_ATTRIBUTE(string_index, first_to_check) | 504 #define PRINTF_ATTRIBUTE(string_index, first_to_check) |
| 507 #endif | 505 #endif |
| 508 | 506 |
| 509 #endif // PLATFORM_GLOBALS_H_ | 507 #endif // PLATFORM_GLOBALS_H_ |
| OLD | NEW |