File tree 2 files changed +18
-6
lines changed 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1931,5 +1931,9 @@ fn test_wasi(target: &str) {
1931
1931
// import the same thing but have different function pointers
1932
1932
cfg. skip_fn_ptrcheck ( |f| f. starts_with ( "__wasi" ) ) ;
1933
1933
1934
+ // d_name is declared as a flexible array in WASI libc, so it
1935
+ // doesn't support sizeof.
1936
+ cfg. skip_field ( |s, field| s == "dirent" && field == "d_name" ) ;
1937
+
1934
1938
cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
1935
1939
}
Original file line number Diff line number Diff line change @@ -141,12 +141,6 @@ s! {
141
141
fds_bits: [ c_ulong; FD_SETSIZE / ULONG_SIZE ] ,
142
142
}
143
143
144
- pub struct dirent {
145
- pub d_ino: ino_t,
146
- pub d_type: c_uchar,
147
- pub d_name: [ c_char; 1024 ] ,
148
- }
149
-
150
144
pub struct lconv {
151
145
pub decimal_point: * mut c_char,
152
146
pub thousands_sep: * mut c_char,
@@ -303,6 +297,20 @@ s_no_extra_traits! {
303
297
304
298
}
305
299
300
+ // Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
301
+ // etc., since it contains a flexible array member with a dynamic size.
302
+ #[ repr( C ) ]
303
+ #[ allow( missing_copy_implementations) ]
304
+ #[ cfg_attr( feature = "extra_traits" , derive( Debug ) ) ]
305
+ pub struct dirent {
306
+ pub d_ino : ino_t ,
307
+ pub d_type : c_uchar ,
308
+ /// d_name is declared in WASI libc as a flexible array member, which
309
+ /// can't be directly expressed in Rust. As an imperfect workaround,
310
+ /// declare it as a zero-length array instead.
311
+ pub d_name : [ c_char ; 0 ] ,
312
+ }
313
+
306
314
// intentionally not public, only used for fd_set
307
315
cfg_if ! {
308
316
if #[ cfg( target_pointer_width = "32" ) ] {
You can’t perform that action at this time.
0 commit comments