File tree Expand file tree Collapse file tree 2 files changed +6
-21
lines changed
Expand file tree Collapse file tree 2 files changed +6
-21
lines changed Original file line number Diff line number Diff line change @@ -299,24 +299,9 @@ fn bar() -> Foo { .. } // Will be emitted as `struct foo bar();`
299299
300300### Volatile annotation
301301
302- cbindgen will emit the C volatile type qualifier for types and variables that have the ` volatile=true ` annotation.
302+ cbindgen will emit the C volatile type qualifier for transparent 1-field structs that have the ` volatile ` annotation.
303303
304- There is no equivalent in rust. You should use ` read_volatile ` and ` write_volatile ` to get C-like behavior.
305-
306- ``` rust
307- /// cbindgen:volatile=true
308- type volatile_type_t = u32 ;
309-
310- #[repr(C )]
311- struct S {
312- /// cbindgen:volatile=true
313- volatile_variable : u32 ,
314- }
315-
316- /// cbindgen:volatile=true
317- #[no_mangle]
318- static mut volatile_global_variable : u32 = 0 ;
319- ```
304+ Example usage can be found in ` tests/rust/volatile.rs ` .
320305
321306### Struct Annotations
322307
Original file line number Diff line number Diff line change 1- //! This test uses the `cbindgen: volatile=true ` annotation to generate volatile types and variables .
1+ //! This test uses the `volatile` annotation on a wrapper to generate volatile types.
22
33use std:: ffi:: c_int;
44use std:: mem:: ManuallyDrop ;
@@ -8,7 +8,7 @@ use std::ptr::null_mut;
88use std:: ptr:: NonNull ;
99use std:: cell:: Cell ;
1010
11- /// cbindgen:volatile=true
11+ /// cbindgen:volatile
1212#[ repr( transparent) ]
1313pub struct V < T > ( T ) ;
1414impl < T > V < T > {
@@ -45,8 +45,8 @@ pub type c_vci = V<Cell<c_int>>;
4545
4646pub type c_vfn = V < Option < extern "C" fn ( ) > > ;
4747
48- // TODO not FFI-safe
49- //pub type c_va2 = [V< c_int> ; 2];
48+ // TODO cannot mangle array
49+ //pub type c_va2 = V<[ c_int; 2]> ;
5050
5151#[ repr( C ) ]
5252pub struct S {
You can’t perform that action at this time.
0 commit comments