Skip to content

Commit 156ef76

Browse files
pangzhencommit-bot@chromium.org
authored andcommitted
[vm, timeline] Fix compilation failed below macOS 10.14
signpost.h exists in macOS 10.14 or above, so compilation failed below macOS 10.14 Change-Id: I97c4d6652f8330d3fc150186e41067c80c3b56f2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151101 Commit-Queue: Vyacheslav Egorov <[email protected]> Reviewed-by: Vyacheslav Egorov <[email protected]>
1 parent 6021f0a commit 156ef76

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

runtime/vm/timeline.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ static TimelineEventRecorder* CreateTimelineRecorder() {
117117
#if defined(HOST_OS_LINUX) || defined(HOST_OS_ANDROID)
118118
return new TimelineEventSystraceRecorder();
119119
#elif defined(HOST_OS_MACOS)
120-
if (__builtin_available(iOS 12.0, macOS 10.14, *)) {
121-
return new TimelineEventMacosRecorder();
122-
}
120+
return new TimelineEventMacosRecorder();
123121
#elif defined(HOST_OS_FUCHSIA)
124122
return new TimelineEventFuchsiaRecorder();
125123
#else
@@ -767,10 +765,8 @@ TimelineStream::TimelineStream(const char* name,
767765
enabled_(static_cast<uintptr_t>(enabled))
768766
#endif
769767
{
770-
#if defined(HOST_OS_MACOS)
771-
if (__builtin_available(iOS 12.0, macOS 10.14, *)) {
772-
macos_log_ = os_log_create("Dart", name);
773-
}
768+
#if defined(HOST_OS_SUPPORTS_SIGNPOST)
769+
macos_log_ = os_log_create("Dart", name);
774770
#endif
775771
}
776772

runtime/vm/timeline.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@
2020
#include <lib/trace-engine/instrumentation.h>
2121
#elif defined(HOST_OS_MACOS)
2222
#include <os/availability.h>
23+
#if defined(__MAC_10_14) || defined (__IPHONE_12_0)
24+
#define HOST_OS_SUPPORTS_SIGNPOST 1
25+
#endif
26+
//signpost.h exists in macOS 10.14, iOS 12 or above
27+
#if defined(HOST_OS_SUPPORTS_SIGNPOST)
2328
#include <os/signpost.h>
2429
#endif
30+
#endif
2531

2632
namespace dart {
2733

@@ -94,7 +100,7 @@ class TimelineStream {
94100

95101
#if defined(HOST_OS_FUCHSIA)
96102
trace_site_t* trace_site() { return &trace_site_; }
97-
#elif defined(HOST_OS_MACOS)
103+
#elif defined(HOST_OS_SUPPORTS_SIGNPOST)
98104
os_log_t macos_log() { return macos_log_; }
99105
#endif
100106

@@ -108,7 +114,7 @@ class TimelineStream {
108114

109115
#if defined(HOST_OS_FUCHSIA)
110116
trace_site_t trace_site_ = {};
111-
#elif defined(HOST_OS_MACOS)
117+
#elif defined(HOST_OS_SUPPORTS_SIGNPOST)
112118
os_log_t macos_log_ = {};
113119
#endif
114120
};

runtime/vm/timeline_macos.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
#include "vm/globals.h"
66
#if defined(HOST_OS_MACOS) && defined(SUPPORT_TIMELINE)
77

8-
#include <os/signpost.h>
98

109
#include "vm/log.h"
1110
#include "vm/timeline.h"
1211

12+
#if defined(HOST_OS_SUPPORTS_SIGNPOST)
13+
#include <os/signpost.h>
14+
#endif
15+
1316
namespace dart {
1417

1518
// Only available on iOS 12.0, macOS 10.14 or above
@@ -23,6 +26,7 @@ void TimelineEventMacosRecorder::OnEvent(TimelineEvent* event) {
2326
return;
2427
}
2528

29+
#if defined(HOST_OS_SUPPORTS_SIGNPOST)
2630
os_log_t log = event->stream_->macos_log();
2731
if (!os_signpost_enabled(log)) {
2832
return;
@@ -75,6 +79,7 @@ void TimelineEventMacosRecorder::OnEvent(TimelineEvent* event) {
7579
default:
7680
break;
7781
}
82+
#endif // defined(HOST_OS_SUPPORTS_SIGNPOST)
7883
}
7984

8085
} // namespace dart

0 commit comments

Comments
 (0)