From ae580a798abde37d35ca8cf2a9779dab446b56ca Mon Sep 17 00:00:00 2001 From: Markus Hosch Date: Wed, 14 Jan 2026 16:15:44 +0100 Subject: [PATCH] Add a definition of max_align_t to nto The definition of this type is a bit tricky for nto for multiple reasons: * The C definition is different from the C++ definition in some versions of the QNX SDK. * It uses long double, which does not exist inside libc. * The definition on C uses alignment modifiers per field, which aren't supported in Rust. However, since they just reuse the field type, they're actually redundant so that we can safely skip them. --- src/unix/nto/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 2b8117866b83..dd2281a02c18 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -795,6 +795,23 @@ s_no_extra_traits! { pub __owner: c_uint, pub __spare: c_uint, } + + // There is no canonical definition of c_longdouble in Rust. For both AArch64 and x86_64, + // however, the size and alignment properties are that of the gcc __int128 which corresponds (at + // least on rustc 1.78+ with LLVM 18, see + // https://blog.rust-lang.org/2024/03/30/i128-layout-update/) to i128. Use this instead until we + // get native f128 support. + // + // The definition was taken from the definition of the _Maxalignt struct in the QNX SDK. + // However, on QNX7, there is a different definition of std::max_align_t (the C++ version of + // this type). In practice, this doesn't make a difference for the _alignment_ properties of the + // type - however, it changes the size, so using in in any other form than the zero-sized array + // form would be bogus and it would potentially change the size of the data type. On QNX8, this + // got fixed and both C and C++ are using the same definition. + pub struct max_align_t { + _ll: crate::c_longlong, + _ld: i128, + } } pub const _SYSNAME_SIZE: usize = 256 + 1;