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 #include "sanitizer_stoptheworld_fuchsia.h"
21
22 namespace __sanitizer {
23
24 // The Fuchsia implementation stops the world but doesn't offer a real
25 // SuspendedThreadsList argument. This is enough for ASan's use case,
26 // and LSan does not use this API on Fuchsia.
StopTheWorld(StopTheWorldCallback callback,void * argument)27 void StopTheWorld(StopTheWorldCallback callback, void *argument) {
28 struct Params {
29 StopTheWorldCallback callback;
30 void *argument;
31 } params = {callback, argument};
32 __sanitizer_memory_snapshot(
33 nullptr, nullptr, nullptr, nullptr,
34 [](zx_status_t, void *data) {
35 auto params = reinterpret_cast<Params *>(data);
36 params->callback(SuspendedThreadsListFuchsia(), params->argument);
37 },
38 ¶ms);
39 }
40
41 } // namespace __sanitizer
42
43 #endif // SANITIZER_FUCHSIA
44