Skip to content

Commit 604b73b

Browse files
pvdrzqsdrqs
authored andcommitted
use #[feature(core_ffi_c)] when available
1 parent a78b0f3 commit 604b73b

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

src/codegen/helpers.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,19 @@ pub mod ast_ty {
166166
#prefix::#ident
167167
}
168168
}
169-
None => quote! {
170-
::std::os::raw::#ident
171-
},
169+
None => {
170+
if ctx.options().use_core &&
171+
ctx.options().rust_features().core_ffi_c
172+
{
173+
quote! {
174+
::core::ffi::#ident
175+
}
176+
} else {
177+
quote! {
178+
::std::os::raw::#ident
179+
}
180+
}
181+
}
172182
}
173183
}
174184

src/features.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ macro_rules! rust_target_base {
130130
/// Nightly rust
131131
/// * `thiscall` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/42202))
132132
/// * `vectorcall` calling convention (no tracking issue)
133+
/// * `core_ffi_c` ([Tracking issue](https://github.com/rust-lang/rust/issues/94501))
133134
=> Nightly => nightly;
134135
);
135136
}
@@ -236,6 +237,7 @@ rust_feature_def!(
236237
Nightly {
237238
=> thiscall_abi;
238239
=> vectorcall_abi;
240+
=> core_ffi_c;
239241
}
240242
);
241243

tests/expectations/tests/core_ffi_c.rs

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/headers/core_ffi_c.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// bindgen-flags: --rust-target nightly --use-core --no-convert-floats
2+
typedef char c_char;
3+
typedef double c_double;
4+
typedef float c_float;
5+
typedef int c_int;
6+
typedef long c_long;
7+
typedef long long c_longlong;
8+
typedef signed char c_schar;
9+
typedef short c_short;
10+
typedef unsigned char c_uchar;
11+
typedef unsigned int c_uint;
12+
typedef unsigned long c_ulong;
13+
typedef unsigned long long c_ulonglong;
14+
typedef unsigned short c_ushort;

0 commit comments

Comments
 (0)