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<()> {
1411
1411
linux_android,
1412
1412
solarish,
1413
1413
netbsdlike,
1414
+ apple_targets,
1414
1415
target_os = "freebsd" ,
1415
1416
target_os = "emscripten" ,
1416
1417
target_os = "fuchsia" ,
@@ -1419,7 +1420,18 @@ pub fn fsync(fd: RawFd) -> Result<()> {
1419
1420
) ) ]
1420
1421
#[ inline]
1421
1422
pub 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) } ;
1423
1435
1424
1436
Errno :: result( res) . map( drop)
1425
1437
}
You can’t perform that action at this time.
0 commit comments