]> git.ipfire.org Git - thirdparty/gcc.git/blob - libsanitizer/sanitizer_common/sanitizer_stoptheworld_fuchsia.cpp
Libsanitizer: merge from master.
[thirdparty/gcc.git] / libsanitizer / sanitizer_common / sanitizer_stoptheworld_fuchsia.cpp
1 //===-- sanitizer_stoptheworld_fuchsia.cpp -------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===---------------------------------------------------------------------===//
8 //
9 // See sanitizer_stoptheworld.h for details.
10 //
11 //===---------------------------------------------------------------------===//
12
13 #include "sanitizer_platform.h"
14
15 #if SANITIZER_FUCHSIA
16
17 #include <zircon/sanitizer.h>
18
19 #include "sanitizer_stoptheworld.h"
20
21 namespace __sanitizer {
22
23 // The Fuchsia implementation stops the world but doesn't offer a real
24 // SuspendedThreadsList argument. This is enough for ASan's use case,
25 // and LSan does not use this API on Fuchsia.
26 void StopTheWorld(StopTheWorldCallback callback, void *argument) {
27 struct Params {
28 StopTheWorldCallback callback;
29 void *argument;
30 } params = {callback, argument};
31 __sanitizer_memory_snapshot(
32 nullptr, nullptr, nullptr, nullptr,
33 [](zx_status_t, void *data) {
34 auto params = reinterpret_cast<Params *>(data);
35 params->callback({}, params->argument);
36 },
37 &params);
38 }
39
40 } // namespace __sanitizer
41
42 #endif // SANITIZER_FUCHSIA