Skip to content

Commit 0772a12

Browse files
authored
Support 16-bit target platforms (#2401)
Since we currently can't roll our pinned nightly toolchain, and since support for the avr target which initially caused us to notice this issue was only added on nightly recently, this commit does not add a regression test. That will be done later as part of #2400 once we are able to roll our pinned nightly toolchain. Makes progress on #2400 gherrit-pr-id: I2ce6e9e0c2ba1cbe24c8cc5686e5b9b519bbf102
1 parent 367e68b commit 0772a12

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/layout.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,19 @@ impl DstLayout {
117117
/// The alignment value must be a power of two from 1 up to
118118
/// 2<sup>29</sup>.
119119
#[cfg(not(kani))]
120+
#[cfg(not(target_pointer_width = "16"))]
120121
pub(crate) const CURRENT_MAX_ALIGN: NonZeroUsize = match NonZeroUsize::new(1 << 28) {
121122
Some(max_align) => max_align,
122123
None => const_unreachable!(),
123124
};
124125

126+
#[cfg(not(kani))]
127+
#[cfg(target_pointer_width = "16")]
128+
pub(crate) const CURRENT_MAX_ALIGN: NonZeroUsize = match NonZeroUsize::new(1 << 15) {
129+
Some(max_align) => max_align,
130+
None => const_unreachable!(),
131+
};
132+
125133
/// Constructs a `DstLayout` for a zero-sized type with `repr_align`
126134
/// alignment (or 1). If `repr_align` is provided, then it must be a power
127135
/// of two.

src/util/macro_util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl<T, U> MaxAlignsOf<T, U> {
9898
}
9999
}
100100

101+
#[cfg(__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)]
101102
const _64K: usize = 1 << 16;
102103

103104
// TODO(#29), TODO(https://github.com/rust-lang/rust/issues/69835): Remove this

0 commit comments

Comments
 (0)