Skip to content

Commit c8a47d9

Browse files
authored
Merge branch 'main' into feat/qnx8
2 parents 991ccb6 + 586ccc1 commit c8a47d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+567
-111
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: ubuntu-24.04
2929
timeout-minutes: 10
3030
steps:
31-
- uses: actions/checkout@v4
31+
- uses: actions/checkout@v5
3232
- name: Setup Rust toolchain
3333
run: ./ci/install-rust.sh && rustup component add rustfmt
3434
- name: Check style
@@ -42,7 +42,7 @@ jobs:
4242
runs-on: ${{ matrix.os }}
4343
timeout-minutes: 10
4444
steps:
45-
- uses: actions/checkout@v4
45+
- uses: actions/checkout@v5
4646
- run: rustup update stable --no-self-update
4747
- uses: Swatinem/rust-cache@v2
4848
# Here we use the latest stable Rust toolchain already installed by GitHub
@@ -65,7 +65,7 @@ jobs:
6565
env:
6666
TOOLCHAIN: ${{ matrix.toolchain }}
6767
steps:
68-
- uses: actions/checkout@v4
68+
- uses: actions/checkout@v5
6969
- name: Setup Rust toolchain
7070
run: ./ci/install-rust.sh
7171

@@ -140,7 +140,7 @@ jobs:
140140
env:
141141
TARGET: ${{ matrix.target }}
142142
steps:
143-
- uses: actions/checkout@v4
143+
- uses: actions/checkout@v5
144144
- name: Setup Rust toolchain
145145
run: ./ci/install-rust.sh
146146
- uses: Swatinem/rust-cache@v2
@@ -249,7 +249,7 @@ jobs:
249249
env:
250250
TARGET: ${{ matrix.target }}
251251
steps:
252-
- uses: actions/checkout@v4
252+
- uses: actions/checkout@v5
253253
- name: Setup Rust toolchain
254254
run: ./ci/install-rust.sh
255255
- uses: Swatinem/rust-cache@v2
@@ -288,9 +288,9 @@ jobs:
288288
- x86_64-pc-solaris
289289
timeout-minutes: 25
290290
steps:
291-
- uses: actions/checkout@v4
291+
- uses: actions/checkout@v5
292292
- name: test on Solaris
293-
uses: vmactions/[email protected].4
293+
uses: vmactions/[email protected].5
294294
with:
295295
release: "11.4-gcc"
296296
usesh: true

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v5
2121
with:
2222
fetch-depth: 0
2323
- name: Install Rust (rustup)

ctest-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fn test_ctest() {
4242
// public C typedefs have to manually be specified because they are identical to normal
4343
// structs on the Rust side.
4444
.rename_union_ty(|ty| (ty == "T2Union").then_some(ty.to_string()))
45+
.alias_is_c_enum(|e| e == "enum_repr_too_small" || e == "enum_wrong_signedness")
4546
.skip_roundtrip(|_| true);
4647
ctest::generate_test(&mut t2gen, "src/t2.rs", "t2gen.rs").unwrap();
4748
}

ctest-test/src/t2.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ static void T2a(void) {}
2121

2222
#define T2C 4
2323
#define T2S "a"
24+
25+
enum enum_repr_too_small {
26+
ENUM_REPR_TOO_SMALL_A
27+
};
28+
29+
enum enum_wrong_signedness {
30+
ENUM_WRONG_SIGNEDNESS_A
31+
};

ctest-test/src/t2.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_camel_case_types)]
2+
13
use std::ffi::{c_char, c_int};
24

35
pub type T2Foo = u32;
@@ -34,3 +36,15 @@ i! {
3436
extern "C" {
3537
pub fn T2a();
3638
}
39+
40+
#[cfg(target_env = "msvc")]
41+
pub type enum_repr_too_small = i16;
42+
#[cfg(not(target_env = "msvc"))]
43+
pub type enum_repr_too_small = u16;
44+
pub const ENUM_REPR_TOO_SMALL_A: enum_repr_too_small = 0;
45+
46+
#[cfg(target_env = "msvc")]
47+
pub type enum_wrong_signedness = u32;
48+
#[cfg(not(target_env = "msvc"))]
49+
pub type enum_wrong_signedness = i32;
50+
pub const ENUM_WRONG_SIGNEDNESS_A: enum_wrong_signedness = 0;

ctest-test/tests/all.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ fn t2() {
5858
"bad T2Union size",
5959
"bad field type b of T2Union",
6060
"bad field offset b of T2Union",
61+
"bad enum_wrong_signedness signed",
62+
"bad enum_repr_too_small size",
63+
"bad enum_repr_too_small align",
6164
];
6265
let mut errors = errors.iter().cloned().collect::<HashSet<_>>();
6366

ctest/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ edition = "2024"
55
rust-version = "1.88"
66
license = "MIT OR Apache-2.0"
77
repository = "https://github.com/rust-lang/libc"
8-
publish = false
8+
publish = true
99

1010
[dependencies]
1111
askama = "0.14.0"
1212
cc = "1.2.29"
13-
proc-macro2 = { version = "1.0.95", features = ["span-locations"] }
13+
proc-macro2 = { version = "1.0.101", features = ["span-locations"] }
1414
quote = "1.0.40"
1515
syn = { version = "2.0.104", features = ["full", "visit", "extra-traits"] }
1616
thiserror = "2.0.12"

ctest/README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ APIs in Rust match the APIs defined in C.
1010

1111
## MSRV (Minimum Supported Rust Version)
1212

13-
The MSRV is 1.63.0 because of the transitive dependencies.
13+
The MSRV is 1.88.0 because of the transitive dependencies.
1414
Note that MSRV may be changed anytime by dependencies.
1515

1616
## Example
@@ -34,7 +34,7 @@ mylib-sys = { path = "../mylib-sys" }
3434
libc = "0.2"
3535

3636
[build-dependencies]
37-
ctest = "0.4"
37+
ctest = "0.5.0-beta.0"
3838
```
3939

4040
Next, add a build script to `systest/build.rs`:
@@ -52,7 +52,7 @@ fn main() {
5252

5353
// Generate the tests, passing the path to the `*-sys` library as well as
5454
// the module to generate.
55-
cfg.generate("../mylib-sys/lib.rs", "all.rs");
55+
ctest::generate_test(&mut cfg, "../mylib-sys/lib.rs", "all.rs");
5656
}
5757
```
5858

@@ -72,10 +72,10 @@ directory, and everything should be kicked into action!
7272

7373
## How it works
7474

75-
This library will parse the `*-sys` crate to learn about all extern fn
76-
definitions within. It will then generate a test suite to ensure that all
77-
function function signatures, constant values, struct layout/alignment, type
78-
size/alignment, etc, all match their C equivalent.
75+
This library will parse the `*-sys` crate to learn about all definitions within.
76+
It will then generate a test suite to ensure that all function signatures,
77+
constant values, struct layout/alignment, type size/alignment, etc,
78+
all match their C equivalent.
7979

8080
The generated tests come in two forms. One is a Rust file which contains the
8181
`main` function (hence the `include!` above), and another is a C file which is
@@ -101,6 +101,14 @@ This project is licensed under either of
101101

102102
at your option.
103103

104+
## Modifying test templates
105+
If you modify the test templates for either Rust or C in any way, then before
106+
contributing you must run the following command to update the pre-generated test
107+
files we check against:
108+
```rust
109+
$ LIBC_BLESS=1 cargo test
110+
```
111+
104112
## Contribution
105113

106114
Unless you explicitly state otherwise, any contribution intentionally submitted

ctest/src/ast/constant.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pub struct Const {
66
pub(crate) public: bool,
77
pub(crate) ident: BoxStr,
88
pub(crate) ty: syn::Type,
9-
#[expect(unused)]
10-
pub(crate) expr: syn::Expr,
119
}
1210

1311
impl Const {

ctest/src/ast/mod.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,3 @@ impl fmt::Display for Abi {
4848
}
4949
}
5050
}
51-
52-
/// Things that can appear directly inside of a module or scope.
53-
///
54-
/// This is not an exhaustive list and only contains variants directly useful
55-
/// for our purposes.
56-
#[derive(Debug, Clone)]
57-
#[expect(unused)]
58-
pub(crate) enum Item {
59-
/// Represents a constant defined in Rust.
60-
Const(Const),
61-
/// Represents a function defined in Rust.
62-
Fn(Box<Fn>),
63-
/// Represents a static variable defined in Rust.
64-
Static(Static),
65-
/// Represents a type alias defined in Rust.
66-
Type(Type),
67-
/// Represents a struct defined in Rust.
68-
Struct(Struct),
69-
/// Represents a union defined in Rust.
70-
Union(Union),
71-
}

0 commit comments

Comments
 (0)