28 #include "runtime/os.hpp"
29
30 #ifdef SUPPORTS_CLOCK_MONOTONIC
31
32 // Exported clock functionality
33
34 inline bool os::Posix::supports_monotonic_clock() {
35 return _clock_gettime != NULL;
36 }
37
38 inline int os::Posix::clock_gettime(clockid_t clock_id, struct timespec *tp) {
39 return _clock_gettime != NULL ? _clock_gettime(clock_id, tp) : -1;
40 }
41
42 inline int os::Posix::clock_getres(clockid_t clock_id, struct timespec *tp) {
43 return _clock_getres != NULL ? _clock_getres(clock_id, tp) : -1;
44 }
45
46 #endif // SUPPORTS_CLOCK_MONOTONIC
47
48 #ifndef SOLARIS
49
50 // Platform Mutex/Monitor implementation
51
52 inline void os::PlatformMutex::lock() {
53 int status = pthread_mutex_lock(mutex());
54 assert_status(status == 0, status, "mutex_lock");
55 }
56
57 inline void os::PlatformMutex::unlock() {
58 int status = pthread_mutex_unlock(mutex());
59 assert_status(status == 0, status, "mutex_unlock");
60 }
61
62 inline bool os::PlatformMutex::try_lock() {
63 int status = pthread_mutex_trylock(mutex());
64 assert_status(status == 0 || status == EBUSY, status, "mutex_trylock");
65 return status == 0;
66 }
67
68 inline void os::PlatformMonitor::notify() {
69 int status = pthread_cond_signal(cond());
70 assert_status(status == 0, status, "cond_signal");
71 }
72
73 inline void os::PlatformMonitor::notify_all() {
74 int status = pthread_cond_broadcast(cond());
75 assert_status(status == 0, status, "cond_broadcast");
76 }
77
78 #endif // !SOLARIS
79
80 #endif // OS_POSIX_OS_POSIX_INLINE_HPP
|
28 #include "runtime/os.hpp"
29
30 #ifdef SUPPORTS_CLOCK_MONOTONIC
31
32 // Exported clock functionality
33
34 inline bool os::Posix::supports_monotonic_clock() {
35 return _clock_gettime != NULL;
36 }
37
38 inline int os::Posix::clock_gettime(clockid_t clock_id, struct timespec *tp) {
39 return _clock_gettime != NULL ? _clock_gettime(clock_id, tp) : -1;
40 }
41
42 inline int os::Posix::clock_getres(clockid_t clock_id, struct timespec *tp) {
43 return _clock_getres != NULL ? _clock_getres(clock_id, tp) : -1;
44 }
45
46 #endif // SUPPORTS_CLOCK_MONOTONIC
47
48 // Platform Mutex/Monitor implementation
49
50 inline void os::PlatformMutex::lock() {
51 int status = pthread_mutex_lock(mutex());
52 assert_status(status == 0, status, "mutex_lock");
53 }
54
55 inline void os::PlatformMutex::unlock() {
56 int status = pthread_mutex_unlock(mutex());
57 assert_status(status == 0, status, "mutex_unlock");
58 }
59
60 inline bool os::PlatformMutex::try_lock() {
61 int status = pthread_mutex_trylock(mutex());
62 assert_status(status == 0 || status == EBUSY, status, "mutex_trylock");
63 return status == 0;
64 }
65
66 inline void os::PlatformMonitor::notify() {
67 int status = pthread_cond_signal(cond());
68 assert_status(status == 0, status, "cond_signal");
69 }
70
71 inline void os::PlatformMonitor::notify_all() {
72 int status = pthread_cond_broadcast(cond());
73 assert_status(status == 0, status, "cond_broadcast");
74 }
75
76 #endif // OS_POSIX_OS_POSIX_INLINE_HPP
|