summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-12-11 10:25:41 -0500
committerDavid Robillard <d@drobilla.net>2024-12-11 10:25:41 -0500
commitefdfc1d84ce42a177ffea92571d00908f6d8bd48 (patch)
tree51dcdc8bbfec5bfa564005578f56bfe5a9803577 /src
parent8874670463276073fe6cdb0bccd0d9a9a982b4c5 (diff)
downloadzix-efdfc1d84ce42a177ffea92571d00908f6d8bd48.tar.gz
zix-efdfc1d84ce42a177ffea92571d00908f6d8bd48.tar.bz2
zix-efdfc1d84ce42a177ffea92571d00908f6d8bd48.zip
Avoid _get_osfhandle with clang on Windows
This function crashes when called in a clang build, I'm not sure why. File locking in general isn't a realiable enough facility, and this API weirdly uses FILE* unlike anything else, adding it was probably a mistake.
Diffstat (limited to 'src')
-rw-r--r--src/win32/filesystem_win32.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/win32/filesystem_win32.c b/src/win32/filesystem_win32.c
index 24ba427..fa40cde 100644
--- a/src/win32/filesystem_win32.c
+++ b/src/win32/filesystem_win32.c
@@ -222,6 +222,12 @@ zix_dir_for_each(const char* const path,
ZixStatus
zix_file_lock(FILE* const file, const ZixFileLockMode mode)
{
+#ifdef __clang__
+ (void)file;
+ (void)mode;
+ return ZIX_STATUS_NOT_SUPPORTED;
+#else
+
HANDLE handle = (HANDLE)_get_osfhandle(fileno(file));
OVERLAPPED overlapped = {0};
@@ -231,18 +237,24 @@ zix_file_lock(FILE* const file, const ZixFileLockMode mode)
return zix_windows_status(
LockFileEx(handle, flags, 0, UINT32_MAX, UINT32_MAX, &overlapped));
+#endif
}
ZixStatus
zix_file_unlock(FILE* const file, const ZixFileLockMode mode)
{
(void)mode;
+#ifdef __clang__
+ (void)file;
+ return ZIX_STATUS_NOT_SUPPORTED;
+#else
HANDLE handle = (HANDLE)_get_osfhandle(fileno(file));
OVERLAPPED overlapped = {0};
return zix_windows_status(
UnlockFileEx(handle, 0, UINT32_MAX, UINT32_MAX, &overlapped));
+#endif
}
#if USE_GETFINALPATHNAMEBYHANDLE && USE_CREATEFILE2