OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 | 500 |
501 void LinuxSemaphore::Wait() { | 501 void LinuxSemaphore::Wait() { |
502 while (true) { | 502 while (true) { |
503 int result = sem_wait(&sem_); | 503 int result = sem_wait(&sem_); |
504 if (result == 0) return; // Successfully got semaphore. | 504 if (result == 0) return; // Successfully got semaphore. |
505 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. | 505 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 | 509 |
| 510 #ifndef TIMEVAL_TO_TIMESPEC |
| 511 #define TIMEVAL_TO_TIMESPEC(tv, ts) do { \ |
| 512 (ts)->tv_sec = (tv)->tv_sec; \ |
| 513 (ts)->tv_nsec = (tv)->tv_usec * 1000; \ |
| 514 } while(false) |
| 515 #endif |
| 516 |
| 517 |
510 bool LinuxSemaphore::Wait(int timeout) { | 518 bool LinuxSemaphore::Wait(int timeout) { |
511 const long kOneSecondMicros = 1000000; // NOLINT | 519 const long kOneSecondMicros = 1000000; // NOLINT |
512 | 520 |
513 // Split timeout into second and nanosecond parts. | 521 // Split timeout into second and nanosecond parts. |
514 struct timeval delta; | 522 struct timeval delta; |
515 delta.tv_usec = timeout % kOneSecondMicros; | 523 delta.tv_usec = timeout % kOneSecondMicros; |
516 delta.tv_sec = timeout / kOneSecondMicros; | 524 delta.tv_sec = timeout / kOneSecondMicros; |
517 | 525 |
518 struct timeval current_time; | 526 struct timeval current_time; |
519 // Get the current time. | 527 // Get the current time. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 } | 675 } |
668 | 676 |
669 // This sampler is no longer the active sampler. | 677 // This sampler is no longer the active sampler. |
670 active_sampler_ = NULL; | 678 active_sampler_ = NULL; |
671 active_ = false; | 679 active_ = false; |
672 } | 680 } |
673 | 681 |
674 #endif // ENABLE_LOGGING_AND_PROFILING | 682 #endif // ENABLE_LOGGING_AND_PROFILING |
675 | 683 |
676 } } // namespace v8::internal | 684 } } // namespace v8::internal |
OLD | NEW |