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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 while (true) { | 713 while (true) { |
714 int result = sem_trywait(&sem_); | 714 int result = sem_trywait(&sem_); |
715 if (result == 0) return true; // Successfully got semaphore. | 715 if (result == 0) return true; // Successfully got semaphore. |
716 if (!to) return false; // Timeout. | 716 if (!to) return false; // Timeout. |
717 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. | 717 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. |
718 usleep(ts.tv_nsec / 1000); | 718 usleep(ts.tv_nsec / 1000); |
719 to--; | 719 to--; |
720 } | 720 } |
721 } | 721 } |
722 | 722 |
| 723 |
723 Semaphore* OS::CreateSemaphore(int count) { | 724 Semaphore* OS::CreateSemaphore(int count) { |
724 return new OpenBSDSemaphore(count); | 725 return new OpenBSDSemaphore(count); |
725 } | 726 } |
726 | 727 |
727 | 728 |
728 void OS::SetUp() { | 729 void OS::SetUp() { |
729 // Seed the random number generator. We preserve microsecond resolution. | 730 // Seed the random number generator. We preserve microsecond resolution. |
730 uint64_t seed = Ticks() ^ (getpid() << 16); | 731 uint64_t seed = Ticks() ^ (getpid() << 16); |
731 srandom(static_cast<unsigned int>(seed)); | 732 srandom(static_cast<unsigned int>(seed)); |
732 limit_mutex = CreateMutex(); | 733 limit_mutex = CreateMutex(); |
733 } | 734 } |
734 | 735 |
735 | 736 |
736 void OS::TearDown() { | 737 void OS::TearDown() { |
737 delete limit_mutex; | 738 delete limit_mutex; |
738 } | 739 } |
739 | 740 |
740 | 741 |
741 } } // namespace v8::internal | 742 } } // namespace v8::internal |
OLD | NEW |