Skip to content

Commit 544317d

Browse files
authored
Merge pull request #31 from hermit-os/i128-align8
fix(x86_64): explicitly decrease alignment of i128 to 8
2 parents d7a6340 + 6c77bd1 commit 544317d

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hermit-entry"
3-
version = "0.9.9"
3+
version = "0.9.10"
44
authors = ["Martin Kröning <mkroening@posteo.net>"]
55
edition = "2021"
66
description = "Hermit's loading and entry API."

src/boot_info/kernel.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ impl From<RawPlatformInfo> for PlatformInfo {
6666
has_pci,
6767
num_cpus,
6868
cpu_freq,
69-
boot_time: OffsetDateTime::from_unix_timestamp_nanos(boot_time).unwrap(),
69+
boot_time: OffsetDateTime::from_unix_timestamp_nanos(i128::from_ne_bytes(
70+
boot_time.0,
71+
))
72+
.unwrap(),
7073
},
7174
RawPlatformInfo::LinuxBootParams {
7275
command_line_data,

src/boot_info/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl From<PlatformInfo> for RawPlatformInfo {
5454
has_pci,
5555
num_cpus,
5656
cpu_freq,
57-
boot_time: boot_time.unix_timestamp_nanos(),
57+
boot_time: boot_time.unix_timestamp_nanos().to_ne_bytes().into(),
5858
},
5959
PlatformInfo::LinuxBootParams {
6060
command_line,

src/boot_info/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ struct RawLoadInfo {
158158
tls_info: TlsInfo,
159159
}
160160

161+
#[derive(Clone, Copy, Debug)]
162+
#[cfg_attr(target_arch = "x86_64", repr(C, align(8)))]
163+
#[cfg_attr(not(target_arch = "x86_64"), repr(transparent))]
164+
struct Align8<T>(pub T);
165+
166+
impl<T> From<T> for Align8<T> {
167+
fn from(value: T) -> Self {
168+
Self(value)
169+
}
170+
}
171+
161172
#[cfg_attr(not(all(feature = "loader", feature = "kernel")), allow(dead_code))]
162173
#[derive(Clone, Copy, Debug)]
163174
#[repr(C)]
@@ -174,7 +185,7 @@ enum RawPlatformInfo {
174185
has_pci: bool,
175186
num_cpus: NonZeroU64,
176187
cpu_freq: Option<NonZeroU32>,
177-
boot_time: i128,
188+
boot_time: Align8<[u8; 16]>,
178189
},
179190
LinuxBootParams {
180191
command_line_data: *const u8,

0 commit comments

Comments
 (0)