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

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

Issue 1406253005: Build fixes for fnl/musl (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | runtime/vm/virtual_memory_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_LINUX) 6 #if defined(TARGET_OS_LINUX)
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/resource.h> // NOLINT 11 #include <sys/resource.h> // NOLINT
12 #include <sys/syscall.h> // NOLINT 12 #include <sys/syscall.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 16
17 namespace dart { 17 namespace dart {
18 18
19 static char* strerror_helper(int err, char* buffer, size_t bufsize) {
20 #if !defined(__GLIBC__) || \
21 ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE)
22 // Use the standard version
23 return strerror_r(err, buffer, bufsize) == 0 ?
24 buffer : const_cast<char*>("strerror_r failed");
25 #else
26 // Use the gnu specific version
27 return strerror_r(err, buffer, bufsize);
28 #endif
29 }
30
19 #define VALIDATE_PTHREAD_RESULT(result) \ 31 #define VALIDATE_PTHREAD_RESULT(result) \
20 if (result != 0) { \ 32 if (result != 0) { \
21 const int kBufferSize = 1024; \ 33 const int kBufferSize = 1024; \
22 char error_buf[kBufferSize]; \ 34 char error_buf[kBufferSize]; \
23 FATAL2("pthread error: %d (%s)", result, \ 35 FATAL2("pthread error: %d (%s)", result, \
24 strerror_r(result, error_buf, kBufferSize)); \ 36 strerror_helper(result, error_buf, kBufferSize)); \
25 } 37 }
26 38
27 39
28 #if defined(DEBUG) 40 #if defined(DEBUG)
29 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result) 41 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result)
30 #else 42 #else
31 // NOTE: This (currently) expands to a no-op. 43 // NOTE: This (currently) expands to a no-op.
32 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0) 44 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0)
33 #endif 45 #endif
34 46
35 47
36 #ifdef DEBUG 48 #ifdef DEBUG
37 #define RETURN_ON_PTHREAD_FAILURE(result) \ 49 #define RETURN_ON_PTHREAD_FAILURE(result) \
38 if (result != 0) { \ 50 if (result != 0) { \
39 const int kBufferSize = 1024; \ 51 const int kBufferSize = 1024; \
40 char error_buf[kBufferSize]; \ 52 char error_buf[kBufferSize]; \
41 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ 53 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \
42 __FILE__, __LINE__, result, \ 54 __FILE__, __LINE__, result, \
43 strerror_r(result, error_buf, kBufferSize)); \ 55 strerror_helper(result, error_buf, kBufferSize)); \
44 return result; \ 56 return result; \
45 } 57 }
46 #else 58 #else
47 #define RETURN_ON_PTHREAD_FAILURE(result) \ 59 #define RETURN_ON_PTHREAD_FAILURE(result) \
48 if (result != 0) return result; 60 if (result != 0) return result;
49 #endif 61 #endif
50 62
51 63
52 static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) { 64 static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) {
53 int64_t secs = micros / kMicrosecondsPerSecond; 65 int64_t secs = micros / kMicrosecondsPerSecond;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 376
365 void Monitor::NotifyAll() { 377 void Monitor::NotifyAll() {
366 // TODO(iposva): Do we need to track lock owners? 378 // TODO(iposva): Do we need to track lock owners?
367 int result = pthread_cond_broadcast(data_.cond()); 379 int result = pthread_cond_broadcast(data_.cond());
368 VALIDATE_PTHREAD_RESULT(result); 380 VALIDATE_PTHREAD_RESULT(result);
369 } 381 }
370 382
371 } // namespace dart 383 } // namespace dart
372 384
373 #endif // defined(TARGET_OS_LINUX) 385 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/virtual_memory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698