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

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

Issue 1450113003: Avoid strerror_r portability issues (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: oops namespace Created 5 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/platform/utils_macos.h ('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) 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 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "vm/os_thread.h" 8 #include "vm/os_thread.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
11 #include <sys/time.h> // NOLINT 11 #include <sys/time.h> // NOLINT
12 12
13 #include "platform/assert.h" 13 #include "platform/assert.h"
14 #include "platform/utils.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
17 #define VALIDATE_PTHREAD_RESULT(result) \ 18 #define VALIDATE_PTHREAD_RESULT(result) \
18 if (result != 0) { \ 19 if (result != 0) { \
19 const int kBufferSize = 1024; \ 20 const int kBufferSize = 1024; \
20 char error_message[kBufferSize]; \ 21 char error_message[kBufferSize]; \
21 strerror_r(result, error_message, kBufferSize); \ 22 Utils::StrError(result, error_message, kBufferSize); \
22 FATAL2("pthread error: %d (%s)", result, error_message); \ 23 FATAL2("pthread error: %d (%s)", result, error_message); \
23 } 24 }
24 25
25 26
26 #if defined(DEBUG) 27 #if defined(DEBUG)
27 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result) 28 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result)
28 #else 29 #else
29 // NOTE: This (currently) expands to a no-op. 30 // NOTE: This (currently) expands to a no-op.
30 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0) 31 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0)
31 #endif 32 #endif
32 33
33 34
34 #ifdef DEBUG 35 #ifdef DEBUG
35 #define RETURN_ON_PTHREAD_FAILURE(result) \ 36 #define RETURN_ON_PTHREAD_FAILURE(result) \
36 if (result != 0) { \ 37 if (result != 0) { \
37 const int kBufferSize = 1024; \ 38 const int kBufferSize = 1024; \
38 char error_message[kBufferSize]; \ 39 char error_message[kBufferSize]; \
39 strerror_r(result, error_message, kBufferSize); \ 40 Utils::StrError(result, error_message, kBufferSize); \
40 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ 41 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \
41 __FILE__, __LINE__, result, error_message); \ 42 __FILE__, __LINE__, result, error_message); \
42 return result; \ 43 return result; \
43 } 44 }
44 #else 45 #else
45 #define RETURN_ON_PTHREAD_FAILURE(result) \ 46 #define RETURN_ON_PTHREAD_FAILURE(result) \
46 if (result != 0) return result; 47 if (result != 0) return result;
47 #endif 48 #endif
48 49
49 50
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 void Monitor::NotifyAll() { 396 void Monitor::NotifyAll() {
396 // When running with assertions enabled we track the owner. 397 // When running with assertions enabled we track the owner.
397 ASSERT(IsOwnedByCurrentThread()); 398 ASSERT(IsOwnedByCurrentThread());
398 int result = pthread_cond_broadcast(data_.cond()); 399 int result = pthread_cond_broadcast(data_.cond());
399 VALIDATE_PTHREAD_RESULT(result); 400 VALIDATE_PTHREAD_RESULT(result);
400 } 401 }
401 402
402 } // namespace dart 403 } // namespace dart
403 404
404 #endif // defined(TARGET_OS_ANDROID) 405 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/platform/utils_macos.h ('k') | runtime/vm/os_thread_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698