OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #ifndef SRC_SHARED_PLATFORM_POSIX_H_ | 5 #ifndef SRC_SHARED_PLATFORM_POSIX_H_ |
6 #define SRC_SHARED_PLATFORM_POSIX_H_ | 6 #define SRC_SHARED_PLATFORM_POSIX_H_ |
7 | 7 |
8 #ifndef SRC_SHARED_PLATFORM_H_ | 8 #ifndef SRC_SHARED_PLATFORM_H_ |
9 #error Do not include platform_posix.h directly; use platform.h instead. | 9 #error Do not include platform_posix.h directly; use platform.h instead. |
10 #endif | 10 #endif |
11 | 11 |
12 #if defined(FLETCH_TARGET_OS_POSIX) | 12 #if defined(DARTINO_TARGET_OS_POSIX) |
13 | 13 |
14 #include <errno.h> | 14 #include <errno.h> |
15 #include <pthread.h> | 15 #include <pthread.h> |
16 | 16 |
17 #include "src/shared/globals.h" | 17 #include "src/shared/globals.h" |
18 | 18 |
19 #ifndef MAXPATHLEN | 19 #ifndef MAXPATHLEN |
20 #define MAXPATHLEN PATH_MAX | 20 #define MAXPATHLEN PATH_MAX |
21 #endif | 21 #endif |
22 | 22 |
23 namespace fletch { | 23 namespace dartino { |
24 | 24 |
25 // Forward declare [Platform::GetMicroseconds]. | 25 // Forward declare [Platform::GetMicroseconds]. |
26 namespace Platform { | 26 namespace Platform { |
27 uint64 GetMicroseconds(); | 27 uint64 GetMicroseconds(); |
28 } // namespace Platform | 28 } // namespace Platform |
29 | 29 |
30 class MutexImpl { | 30 class MutexImpl { |
31 public: | 31 public: |
32 MutexImpl() { pthread_mutex_init(&mutex_, NULL); } | 32 MutexImpl() { pthread_mutex_init(&mutex_, NULL); } |
33 ~MutexImpl() { pthread_mutex_destroy(&mutex_); } | 33 ~MutexImpl() { pthread_mutex_destroy(&mutex_); } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 int Notify() { return pthread_cond_signal(&cond_); } | 72 int Notify() { return pthread_cond_signal(&cond_); } |
73 int NotifyAll() { return pthread_cond_broadcast(&cond_); } | 73 int NotifyAll() { return pthread_cond_broadcast(&cond_); } |
74 | 74 |
75 private: | 75 private: |
76 pthread_mutex_t mutex_; // Pthread mutex for POSIX platforms. | 76 pthread_mutex_t mutex_; // Pthread mutex for POSIX platforms. |
77 pthread_cond_t cond_; // Pthread condition for POSIX platforms. | 77 pthread_cond_t cond_; // Pthread condition for POSIX platforms. |
78 }; | 78 }; |
79 | 79 |
80 } // namespace fletch | 80 } // namespace dartino |
81 | 81 |
82 #endif // defined(FLETCH_TARGET_OS_POSIX) | 82 #endif // defined(DARTINO_TARGET_OS_POSIX) |
83 | 83 |
84 #endif // SRC_SHARED_PLATFORM_POSIX_H_ | 84 #endif // SRC_SHARED_PLATFORM_POSIX_H_ |
OLD | NEW |