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

Side by Side Diff: runtime/vm/os_thread_android.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.cc ('k') | runtime/vm/os_thread_fuchsia.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" // NOLINT 5 #include "platform/globals.h" // NOLINT
6 6
7 7
8 #if defined(TARGET_OS_ANDROID) 8 #if defined(TARGET_OS_ANDROID)
9 9
10 #include "vm/os_thread.h" 10 #include "vm/os_thread.h"
11 11
12 #include <errno.h> // NOLINT 12 #include <errno.h> // NOLINT
13 #include <sys/time.h> // NOLINT 13 #include <sys/time.h> // NOLINT
14 14
15 #include "platform/assert.h" 15 #include "platform/assert.h"
16 #include "platform/signal_blocker.h" 16 #include "platform/signal_blocker.h"
17 #include "platform/utils.h" 17 #include "platform/utils.h"
18 18
19 #include "vm/profiler.h" 19 #include "vm/profiler.h"
20 20
21 namespace dart { 21 namespace dart {
22 22
23 #define VALIDATE_PTHREAD_RESULT(result) \ 23 #define VALIDATE_PTHREAD_RESULT(result) \
24 if (result != 0) { \ 24 if (result != 0) { \
25 const int kBufferSize = 1024; \ 25 const int kBufferSize = 1024; \
26 char error_message[kBufferSize]; \ 26 char error_message[kBufferSize]; \
27 NOT_IN_PRODUCT(Profiler::DumpStackTrace(true /* native_stack_trace */)); \ 27 NOT_IN_PRODUCT(Profiler::DumpStackTrace(true /* native_stack_trace */)); \
28 Utils::StrError(result, error_message, kBufferSize); \ 28 Utils::StrError(result, error_message, kBufferSize); \
29 FATAL2("pthread error: %d (%s)", result, error_message); \ 29 FATAL2("pthread error: %d (%s)", result, error_message); \
30 } 30 }
31 31
32 32
33 #if defined(DEBUG) 33 #if defined(DEBUG)
34 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result) 34 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result)
35 #else 35 #else
36 // NOTE: This (currently) expands to a no-op. 36 // NOTE: This (currently) expands to a no-op.
37 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0) 37 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0)
38 #endif 38 #endif
39 39
40 40
41 #ifdef DEBUG 41 #ifdef DEBUG
42 #define RETURN_ON_PTHREAD_FAILURE(result) \ 42 #define RETURN_ON_PTHREAD_FAILURE(result) \
43 if (result != 0) { \ 43 if (result != 0) { \
44 const int kBufferSize = 1024; \ 44 const int kBufferSize = 1024; \
45 char error_message[kBufferSize]; \ 45 char error_message[kBufferSize]; \
46 Utils::StrError(result, error_message, kBufferSize); \ 46 Utils::StrError(result, error_message, kBufferSize); \
47 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ 47 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", __FILE__, __LINE__, \
48 __FILE__, __LINE__, result, error_message); \ 48 result, error_message); \
49 return result; \ 49 return result; \
50 } 50 }
51 #else 51 #else
52 #define RETURN_ON_PTHREAD_FAILURE(result) \ 52 #define RETURN_ON_PTHREAD_FAILURE(result) \
53 if (result != 0) return result; 53 if (result != 0) return result;
54 #endif 54 #endif
55 55
56 56
57 static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) { 57 static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) {
58 struct timeval tv; 58 struct timeval tv;
59 int64_t secs = micros / kMicrosecondsPerSecond; 59 int64_t secs = micros / kMicrosecondsPerSecond;
60 int64_t remaining_micros = (micros - (secs * kMicrosecondsPerSecond)); 60 int64_t remaining_micros = (micros - (secs * kMicrosecondsPerSecond));
61 int result = gettimeofday(&tv, NULL); 61 int result = gettimeofday(&tv, NULL);
62 ASSERT(result == 0); 62 ASSERT(result == 0);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 void Monitor::NotifyAll() { 446 void Monitor::NotifyAll() {
447 // When running with assertions enabled we track the owner. 447 // When running with assertions enabled we track the owner.
448 ASSERT(IsOwnedByCurrentThread()); 448 ASSERT(IsOwnedByCurrentThread());
449 int result = pthread_cond_broadcast(data_.cond()); 449 int result = pthread_cond_broadcast(data_.cond());
450 VALIDATE_PTHREAD_RESULT(result); 450 VALIDATE_PTHREAD_RESULT(result);
451 } 451 }
452 452
453 } // namespace dart 453 } // namespace dart
454 454
455 #endif // defined(TARGET_OS_ANDROID) 455 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/vm/os_thread.cc ('k') | runtime/vm/os_thread_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698