blob: ded66f2ef333f61a265cc1f3b08d95f8009222ef [file] [log] [blame]
Pierre-Clément Tosi82aaf032024-10-30 21:00:38 +00001// Copyright 2024, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Low-level CPU-specific operations.
16
Pierre-Clément Tosi043dfb72024-10-30 21:17:10 +000017#[cfg(target_arch = "aarch64")]
Pierre-Clément Tosi82aaf032024-10-30 21:00:38 +000018pub mod aarch64;
19
Pierre-Clément Tosi043dfb72024-10-30 21:17:10 +000020/// Write with well-defined compiled behavior.
21///
22/// See https://github.com/rust-lang/rust/issues/131894
23///
24/// # Safety
25///
26/// `dst` must be valid for writes.
27#[inline]
28pub unsafe fn write_volatile_u8(dst: *mut u8, src: u8) {
29 cfg_if::cfg_if! {
30 if #[cfg(target_arch = "aarch64")] {
31 // SAFETY: `dst` is valid for writes.
32 unsafe { aarch64::strb(dst, src) }
33 } else {
34 compile_error!("Unsupported target_arch")
35 }
36 }
37}