rust-lang / libc

Raw bindings to platform APIs for Rust
https://docs.rs/libc
Apache License 2.0
2.1k stars 1.04k forks source link

ctest: change API of when to skip #4122

Open tgross35 opened 2 days ago

tgross35 commented 2 days ago

Currently our config looks a bit like this:

    cfg.skip_field(move |struct_, field| {
        (struct_ == "siginfo_t" && field == "_pad") ||
        (musl && struct_ == "glob_t" && field == "gl_flags") ||
        // ...
    });

A problem is that we have no validation that e.g. _pad actually exists in siginfo_t. It would be better to have something like the following:

cfg.skip_field(&[
    // format: `(struct, field, extra_condition)`
    ("siginfo_t", "_pad", true),
    ("glob_t", "gl_flags", musl),
])

This would skip if any any of the entries match struct and field, and the condition for that row is true. However, it could also warn if any of those items are never used meaning the struct or field don't exist.

tgross35 commented 1 day ago

For the ctest rewrite it would also be nice to be able to specify volatile_item with an annotation rather than in the build script.