| Flutter macOS Embedder |

availability_version_check.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <dispatch/dispatch.h>
6 #include <dlfcn.h>
7 #include <cstdint>
8
9 #include "flutter/fml/logging.h"
10
11 // See context in https://github.com/flutter/flutter/issues/132130 and
12 // https://github.com/flutter/engine/pull/44711.
13
14 // TODO(zanderso): Remove this after Clang 18 rolls into Xcode.
15 // https://github.com/flutter/flutter/issues/133203
16
17 namespace {
18
19 typedef uint32_t dyld_platform_t;
20
21 typedef struct {
22 dyld_platform_t platform;
23 uint32_t version;
24 } dyld_build_version_t;
25
26 typedef bool (*AvailabilityVersionCheckFn)(uint32_t count,
27 dyld_build_version_t versions[]);
28
29 AvailabilityVersionCheckFn AvailabilityVersionCheck;
30
31 dispatch_once_t DispatchOnceCounter;
32
33 void InitializeAvailabilityCheck(void* unused) {
34 if (AvailabilityVersionCheck) {
35 return;
36 }
37 AvailabilityVersionCheck = reinterpret_cast<AvailabilityVersionCheckFn>(
38 dlsym(RTLD_DEFAULT, "_availability_version_check"));
39 FML_CHECK(AvailabilityVersionCheck);
40 }
41
42 extern "C" bool _availability_version_check(uint32_t count,
43 dyld_build_version_t versions[]) {
44 dispatch_once_f(&DispatchOnceCounter, NULL, InitializeAvailabilityCheck);
45 return AvailabilityVersionCheck(count, versions);
46 }
47
48 } // namespace