File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1+ Add fdatasync support for Apple targets.
Original file line number Diff line number Diff line change @@ -1411,6 +1411,7 @@ pub fn fsync(fd: RawFd) -> Result<()> {
14111411 linux_android,
14121412 solarish,
14131413 netbsdlike,
1414+ apple_targets,
14141415 target_os = "freebsd" ,
14151416 target_os = "emscripten" ,
14161417 target_os = "fuchsia" ,
@@ -1419,7 +1420,18 @@ pub fn fsync(fd: RawFd) -> Result<()> {
14191420) ) ]
14201421#[ inline]
14211422pub fn fdatasync( fd: RawFd ) -> Result <( ) > {
1422- let res = unsafe { libc:: fdatasync( fd) } ;
1423+ cfg_if! {
1424+ // apple libc supports fdatasync too, albeit not being present in its headers
1425+ // [fdatasync](https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/vfs/vfs_syscalls.c#L7728)
1426+ if #[ cfg( apple_targets) ] {
1427+ extern "C" {
1428+ fn fdatasync( fd: libc:: c_int) -> libc:: c_int;
1429+ }
1430+ } else {
1431+ use libc:: fdatasync as fdatasync;
1432+ }
1433+ }
1434+ let res = unsafe { fdatasync( fd) } ;
14231435
14241436 Errno :: result( res) . map( drop)
14251437}
You can’t perform that action at this time.
0 commit comments