| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; | 313 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; |
| 314 *secs = usage.ru_utime.tv_sec; | 314 *secs = usage.ru_utime.tv_sec; |
| 315 *usecs = usage.ru_utime.tv_usec; | 315 *usecs = usage.ru_utime.tv_usec; |
| 316 return 0; | 316 return 0; |
| 317 } | 317 } |
| 318 | 318 |
| 319 | 319 |
| 320 double OS::TimeCurrentMillis() { | 320 double OS::TimeCurrentMillis() { |
| 321 struct timeval tv; | 321 struct timeval tv; |
| 322 if (gettimeofday(&tv, NULL) < 0) return 0.0; | 322 if (gettimeofday(&tv, NULL) < 0) return 0.0; |
| 323 return (static_cast<double>(tv.tv_sec) * 1000) + | 323 volatile double result = |
| 324 (static_cast<double>(tv.tv_usec) / 1000); | 324 (static_cast<double>(tv.tv_sec) * 1000) + |
| 325 (static_cast<double>(tv.tv_usec) / 1000); |
| 326 return result; |
| 325 } | 327 } |
| 326 | 328 |
| 327 | 329 |
| 328 int64_t OS::Ticks() { | 330 int64_t OS::Ticks() { |
| 329 // gettimeofday has microsecond resolution. | 331 // gettimeofday has microsecond resolution. |
| 330 struct timeval tv; | 332 struct timeval tv; |
| 331 if (gettimeofday(&tv, NULL) < 0) | 333 if (gettimeofday(&tv, NULL) < 0) |
| 332 return 0; | 334 return 0; |
| 333 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; | 335 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; |
| 334 } | 336 } |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 return ntohl(value); | 992 return ntohl(value); |
| 991 } | 993 } |
| 992 | 994 |
| 993 | 995 |
| 994 Socket* OS::CreateSocket() { | 996 Socket* OS::CreateSocket() { |
| 995 return new POSIXSocket(); | 997 return new POSIXSocket(); |
| 996 } | 998 } |
| 997 | 999 |
| 998 | 1000 |
| 999 } } // namespace v8::internal | 1001 } } // namespace v8::internal |
| OLD | NEW |