1 // Copyright 2018 The Fuchsia 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 #pragma once
6 
7 #include <zircon/compiler.h>
8 
9 __BEGIN_CDECLS;
10 
11 // Returns true if the byte at the given address can be read or written.
12 //
13 // These functions are designed for testing purposes. They are very heavyweight since they spin up a
14 // thread to attempt the memory access.
15 //
16 // If there is a failure creating a thread, the return value will be false.
17 //
18 // The write probe is implemented as a non-atomic read/write of the same value. If the address could
19 // be modified by a different thread, or if it falls in the region of the stack used by the
20 // implementation of probe_for_write itself (since the probe is asynchronous), the non-atomic
21 // read/write can corrupt the data.
22 bool probe_for_read(const void* addr);
23 bool probe_for_write(void* addr);
24 
25 __END_CDECLS;
26