Skip to content

Commit c529f7c

Browse files
committed
Add portable argument for mkdir
1 parent 9c455c6 commit c529f7c

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

rules/stat/ir_unsafe.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
}
9696
},
9797
{
98-
"text": ")"
98+
"text": " as ::libc::mode_t)"
9999
}
100100
],
101101
"params": {
@@ -104,7 +104,7 @@
104104
"is_unsafe_pointer": true
105105
},
106106
"a1": {
107-
"type": "u32"
107+
"type": "::libc::mode_t"
108108
}
109109
},
110110
"return_type": {

rules/stat/tgt_unsafe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ unsafe fn f2(a0: i32, a1: *mut ::libc::stat) -> i32 {
99
libc::fstat(a0, a1)
1010
}
1111

12-
unsafe fn f3(a0: *const u8, a1: u32) -> i32 {
13-
libc::mkdir(a0 as *const i8, a1)
12+
unsafe fn f3(a0: *const u8, a1: ::libc::mode_t) -> i32 {
13+
libc::mkdir(a0 as *const i8, a1 as ::libc::mode_t)
1414
}

tests/unit/out/unsafe/sys_stat.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,14 @@ pub unsafe fn test_fstat_1() {
131131
pub unsafe fn test_mkdir_2() {
132132
let mut path: *const u8 = (b"/tmp/cpp2rust_mkdir_test_dir\0".as_ptr().cast_mut()).cast_const();
133133
libc::rmdir(path as *const i8);
134-
assert!(((((libc::mkdir(path as *const i8, 493_u32)) == (0)) as i32) != 0));
134+
assert!(((((libc::mkdir(path as *const i8, 493_u32 as ::libc::mode_t)) == (0)) as i32) != 0));
135135
let mut st: stat = std::mem::zeroed::<stat>();
136136
assert!(((((libc::stat(path as *const i8, (&mut st as *mut stat))) == (0)) as i32) != 0));
137137
assert!((((((st.st_mode) & (61440_u32)) == ((16384) as u32)) as i32) != 0));
138138
(*libcc2rs::cpp2rust_errno()) = 0;
139-
assert!(((((libc::mkdir(path as *const i8, 493_u32)) == (-1_i32)) as i32) != 0));
139+
assert!(
140+
((((libc::mkdir(path as *const i8, 493_u32 as ::libc::mode_t)) == (-1_i32)) as i32) != 0)
141+
);
140142
assert!(((((*libcc2rs::cpp2rust_errno()) == (17)) as i32) != 0));
141143
assert!(((((libc::rmdir(path as *const i8)) == (0)) as i32) != 0));
142144
(*libcc2rs::cpp2rust_errno()) = 0;

0 commit comments

Comments
 (0)