Skip to content

Conversation

@he32
Copy link
Contributor

@he32 he32 commented Dec 29, 2025

Description

This change fixes these test failures from cd libc-test; cargo test:

bad `if_msghdr` size: rust: 148 != c 152
bad `if_msghdr` align: rust: 4 != c 8
size of `struct if_msghdr` is 152 in C and 148 in Rust

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

he32 added 9 commits December 19, 2025 17:07
At least the rust compiler 1.92.0 cross-builds for this target
with this version of the file.
...and let each machine definition implement their own of the latter,
instead of c_uchar which is inconsistent with the C implementation.

This allows us to fix the errors from

    $ cd libc-test; cargo test
    ...
    bad `pthread_spin_t` size: rust: 1 != c 4
    bad `pthread_spin_t` align: rust: 1 != c 4
    bad `__cpu_simple_lock_nv_t` signed: rust: 1 != c 0
    size of `pthread_spin_t` is 4 in C and 1 in Rust
 * Use the same type names as used by the native libc, to allow
   more self-tests to succeed
 * Eliminate use of s! and s_no_extra_traits!
 * Move type definitions up before their use
 * Remove un-needed imports, uncovered by libc's "cargo test"
 * Hardwire _ALIGNBYTES to what't it's in C instead of a dynamic
   erroneous define.  THis now makes all the libc self-tests succeed.
…orms:

(verified on NetBSD/i386 10.0).  This fixes

    bad `if_msghdr` size: rust: 148 != c 152
    bad `if_msghdr` align: rust: 4 != c 8
and
    size of `struct if_msghdr` is 152 in C and 148 in Rust

by adding an alignment restriction (and also doing "repr(C)"
for good measure).

Ref. https://nxr.netbsd.org/xref/src/sys/net/if.h#790 for
the original C definition of if_msghdr.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants