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

Side by Side Diff: runtime/vm/os_thread_fuchsia.cc

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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/vm/os_thread_android.cc ('k') | runtime/vm/os_thread_linux.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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" // NOLINT 5 #include "platform/globals.h" // NOLINT
6 #if defined(TARGET_OS_FUCHSIA) 6 #if defined(TARGET_OS_FUCHSIA)
7 7
8 #include "vm/os_thread.h" 8 #include "vm/os_thread.h"
9 #include "vm/os_thread_fuchsia.h" 9 #include "vm/os_thread_fuchsia.h"
10 10
11 #include <errno.h> // NOLINT 11 #include <errno.h> // NOLINT
12 #include <magenta/syscalls.h> 12 #include <magenta/syscalls.h>
13 #include <magenta/types.h> 13 #include <magenta/types.h>
14 14
15 #include "platform/assert.h" 15 #include "platform/assert.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 #define VALIDATE_PTHREAD_RESULT(result) \ 19 #define VALIDATE_PTHREAD_RESULT(result) \
20 if (result != 0) { \ 20 if (result != 0) { \
21 FATAL1("pthread error: %d", result); \ 21 FATAL1("pthread error: %d", result); \
22 } 22 }
23 23
24 24
25 #if defined(DEBUG) 25 #if defined(DEBUG)
26 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result) 26 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result)
27 #else 27 #else
28 // NOTE: This (currently) expands to a no-op. 28 // NOTE: This (currently) expands to a no-op.
29 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0) 29 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0)
30 #endif 30 #endif
31 31
32 32
33 #ifdef DEBUG 33 #ifdef DEBUG
34 #define RETURN_ON_PTHREAD_FAILURE(result) \ 34 #define RETURN_ON_PTHREAD_FAILURE(result) \
35 if (result != 0) { \ 35 if (result != 0) { \
36 const int kBufferSize = 1024; \ 36 const int kBufferSize = 1024; \
37 char error_buf[kBufferSize]; \ 37 char error_buf[kBufferSize]; \
38 fprintf(stderr, "%s:%d: pthread error: %d\n", \ 38 fprintf(stderr, "%s:%d: pthread error: %d\n", __FILE__, __LINE__, result); \
39 __FILE__, __LINE__, result); \ 39 return result; \
40 return result; \
41 } 40 }
42 #else 41 #else
43 #define RETURN_ON_PTHREAD_FAILURE(result) \ 42 #define RETURN_ON_PTHREAD_FAILURE(result) \
44 if (result != 0) return result; 43 if (result != 0) return result;
45 #endif 44 #endif
46 45
47 46
48 static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) { 47 static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) {
49 // time in nanoseconds. 48 // time in nanoseconds.
50 mx_time_t now = mx_time_get(MX_CLOCK_MONOTONIC); 49 mx_time_t now = mx_time_get(MX_CLOCK_MONOTONIC);
51 mx_time_t target = now + (micros * kNanosecondsPerMicrosecond); 50 mx_time_t target = now + (micros * kNanosecondsPerMicrosecond);
52 int64_t secs = target / kNanosecondsPerSecond; 51 int64_t secs = target / kNanosecondsPerSecond;
53 int64_t nanos = target - (secs * kNanosecondsPerSecond); 52 int64_t nanos = target - (secs * kNanosecondsPerSecond);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 void Monitor::NotifyAll() { 421 void Monitor::NotifyAll() {
423 // When running with assertions enabled we track the owner. 422 // When running with assertions enabled we track the owner.
424 ASSERT(IsOwnedByCurrentThread()); 423 ASSERT(IsOwnedByCurrentThread());
425 int result = pthread_cond_broadcast(data_.cond()); 424 int result = pthread_cond_broadcast(data_.cond());
426 VALIDATE_PTHREAD_RESULT(result); 425 VALIDATE_PTHREAD_RESULT(result);
427 } 426 }
428 427
429 } // namespace dart 428 } // namespace dart
430 429
431 #endif // defined(TARGET_OS_FUCHSIA) 430 #endif // defined(TARGET_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « runtime/vm/os_thread_android.cc ('k') | runtime/vm/os_thread_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698