Skip to content

Commit be1b0ff

Browse files
dpkpsipa
authored andcommitted
On Mac OS X fsync does not guarantee write to disk. Use fcntl F_FULLFSYNC instead.
1 parent a02ddf9 commit be1b0ff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

port/port_posix.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,16 @@
6262
#define fflush_unlocked fflush
6363
#endif
6464

65-
#if defined(OS_MACOSX) || defined(OS_FREEBSD) ||\
65+
#if defined(OS_FREEBSD) ||\
6666
defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD)
6767
// Use fsync() on platforms without fdatasync()
6868
#define fdatasync fsync
6969
#endif
7070

71+
#if defined(OS_MACOSX)
72+
#define fdatasync(fd) fcntl(fd, F_FULLFSYNC, 0)
73+
#endif
74+
7175
#if defined(OS_ANDROID) && __ANDROID_API__ < 9
7276
// fdatasync() was only introduced in API level 9 on Android. Use fsync()
7377
// when targetting older platforms.

0 commit comments

Comments
 (0)