Skip to content

Commit fbf791b

Browse files
committed
explain the types used in the open64 call
1 parent 04689e2 commit fbf791b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libstd/sys/unix/fs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,10 @@ impl File {
703703
| opts.get_access_mode()?
704704
| opts.get_creation_mode()?
705705
| (opts.custom_flags as c_int & !libc::O_ACCMODE);
706+
// The third argument of `open64` is documented to have type `mode_t`. On
707+
// some platforms (like macOS, where `open64` is actually `open`), `mode_t` is `u16`.
708+
// However, since this is a variadic function, C integer promotion rules mean that on
709+
// the ABI level, this still gets passed as `c_int` (aka `u32` on Unix platforms).
706710
let fd = cvt_r(|| unsafe { open64(path.as_ptr(), flags, opts.mode as c_int) })?;
707711
let fd = FileDesc::new(fd);
708712

0 commit comments

Comments
 (0)