Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: runtime/bin/thread_macos.cc

Issue 1800863002: Cleanup in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/thread_linux.cc ('k') | runtime/bin/thread_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart 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 file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/thread_macos.h"
9 10
10 #include <sys/errno.h> // NOLINT 11 #include <mach/mach_host.h> // NOLINT
11 #include <sys/types.h> // NOLINT
12 #include <sys/sysctl.h> // NOLINT
13 #include <mach/mach_init.h> // NOLINT 12 #include <mach/mach_init.h> // NOLINT
14 #include <mach/mach_host.h> // NOLINT
15 #include <mach/mach_port.h> // NOLINT 13 #include <mach/mach_port.h> // NOLINT
16 #include <mach/mach_traps.h> // NOLINT 14 #include <mach/mach_traps.h> // NOLINT
17 #include <mach/task_info.h> // NOLINT 15 #include <mach/task_info.h> // NOLINT
16 #include <mach/thread_act.h> // NOLINT
18 #include <mach/thread_info.h> // NOLINT 17 #include <mach/thread_info.h> // NOLINT
19 #include <mach/thread_act.h> // NOLINT 18 #include <sys/errno.h> // NOLINT
19 #include <sys/sysctl.h> // NOLINT
20 #include <sys/types.h> // NOLINT
20 21
21 #include "platform/assert.h" 22 #include "platform/assert.h"
22 #include "platform/utils.h" 23 #include "platform/utils.h"
23 24
24 namespace dart { 25 namespace dart {
25 namespace bin { 26 namespace bin {
26 27
27 #define VALIDATE_PTHREAD_RESULT(result) \ 28 #define VALIDATE_PTHREAD_RESULT(result) \
28 if (result != 0) { \ 29 if (result != 0) { \
29 const int kBufferSize = 1024; \ 30 const int kBufferSize = 1024; \
30 char error_message[kBufferSize]; \ 31 char error_message[kBufferSize]; \
31 Utils::StrError(result, error_message, kBufferSize); \ 32 Utils::StrError(result, error_message, kBufferSize); \
32 FATAL2("pthread error: %d (%s)", result, error_message); \ 33 FATAL2("pthread error: %d (%s)", result, error_message); \
33 } 34 }
34 35
35 36
36 #ifdef DEBUG 37 #ifdef DEBUG
37 #define RETURN_ON_PTHREAD_FAILURE(result) \ 38 #define RETURN_ON_PTHREAD_FAILURE(result) \
38 if (result != 0) { \ 39 if (result != 0) { \
39 const int kBufferSize = 1024; \ 40 const int kBufferSize = 1024; \
40 char error_message[kBufferSize]; \ 41 char error_message[kBufferSize]; \
41 Utils::StrError(result, error_message, kBufferSize); \ 42 Utils::StrError(result, error_message, kBufferSize); \
42 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ 43 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \
43 __FILE__, __LINE__, result, error_message); \ 44 __FILE__, __LINE__, result, error_message); \
44 return result; \ 45 return result; \
45 } 46 }
46 #else 47 #else
47 #define RETURN_ON_PTHREAD_FAILURE(result) \ 48 #define RETURN_ON_PTHREAD_FAILURE(result) \
48 if (result != 0) return result; 49 if (result != 0) { \
50 return result; \
51 }
49 #endif 52 #endif
50 53
51 54
52 class ThreadStartData { 55 class ThreadStartData {
53 public: 56 public:
54 ThreadStartData(Thread::ThreadStartFunction function, 57 ThreadStartData(Thread::ThreadStartFunction function,
55 uword parameter) 58 uword parameter)
56 : function_(function), parameter_(parameter) {} 59 : function_(function), parameter_(parameter) {}
57 60
58 Thread::ThreadStartFunction function() const { return function_; } 61 Thread::ThreadStartFunction function() const { return function_; }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 153 }
151 154
152 155
153 intptr_t Thread::ThreadIdToIntPtr(ThreadId id) { 156 intptr_t Thread::ThreadIdToIntPtr(ThreadId id) {
154 ASSERT(sizeof(id) == sizeof(intptr_t)); 157 ASSERT(sizeof(id) == sizeof(intptr_t));
155 return reinterpret_cast<intptr_t>(id); 158 return reinterpret_cast<intptr_t>(id);
156 } 159 }
157 160
158 161
159 bool Thread::Compare(ThreadId a, ThreadId b) { 162 bool Thread::Compare(ThreadId a, ThreadId b) {
160 return pthread_equal(a, b) != 0; 163 return (pthread_equal(a, b) != 0);
161 } 164 }
162 165
163 166
164 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) { 167 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) {
165 ASSERT(thread_id == GetCurrentThreadId()); 168 ASSERT(thread_id == GetCurrentThreadId());
166 ASSERT(cpu_usage != NULL); 169 ASSERT(cpu_usage != NULL);
167 // TODO(johnmccutchan): Enable this after fixing issue with macos directory 170 // TODO(johnmccutchan): Enable this after fixing issue with macos directory
168 // watcher. 171 // watcher.
169 const bool get_cpu_usage = false; 172 const bool get_cpu_usage = false;
170 if (get_cpu_usage) { 173 if (get_cpu_usage) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 void Monitor::NotifyAll() { 338 void Monitor::NotifyAll() {
336 // TODO(iposva): Do we need to track lock owners? 339 // TODO(iposva): Do we need to track lock owners?
337 int result = pthread_cond_broadcast(data_.cond()); 340 int result = pthread_cond_broadcast(data_.cond());
338 VALIDATE_PTHREAD_RESULT(result); 341 VALIDATE_PTHREAD_RESULT(result);
339 } 342 }
340 343
341 } // namespace bin 344 } // namespace bin
342 } // namespace dart 345 } // namespace dart
343 346
344 #endif // defined(TARGET_OS_MACOS) 347 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/thread_linux.cc ('k') | runtime/bin/thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698