Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 21627 - macOS: std.stdio.File.sync does not guarantee to be… #7789

Merged
merged 1 commit into from Mar 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion std/stdio.d
Expand Up @@ -58,18 +58,22 @@ else version (CRuntime_UClibc)
else version (OSX)
{
version = GENERIC_IO;
version = Darwin;
}
else version (iOS)
{
version = GENERIC_IO;
version = Darwin;
}
else version (TVOS)
{
version = GENERIC_IO;
version = Darwin;
}
else version (WatchOS)
{
version = GENERIC_IO;
version = Darwin;
}
else version (FreeBSD)
{
Expand Down Expand Up @@ -982,7 +986,9 @@ Call $(LREF flush) before calling this function to flush the C `FILE` buffers fi

This function calls
$(HTTP msdn.microsoft.com/en-us/library/windows/desktop/aa364439%28v=vs.85%29.aspx,
`FlushFileBuffers`) on Windows and
`FlushFileBuffers`) on Windows,
$(HTTP developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link does not exist

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it works now. I must have had a connection issue.

`F_FULLFSYNC fcntl`) on Darwin and
$(HTTP pubs.opengroup.org/onlinepubs/7908799/xsh/fsync.html,
`fsync`) on POSIX for the file handle.

Expand All @@ -999,6 +1005,12 @@ Throws: `Exception` if the file is not opened or if the OS call fails.
import core.sys.windows.winbase : FlushFileBuffers;
wenforce(FlushFileBuffers(windowsHandle), "FlushFileBuffers failed");
}
else version (Darwin)
{
import core.sys.darwin.fcntl : fcntl, F_FULLFSYNC;
CyberShadow marked this conversation as resolved.
Show resolved Hide resolved
import std.exception : errnoEnforce;
errnoEnforce(fcntl(fileno, F_FULLFSYNC, 0) != -1, "fcntl failed");
}
else
{
import core.sys.posix.unistd : fsync;
Expand Down