[flang-commits] [PATCH] D88508: [flang][msvc] Define access flags under Windows. NFC.
Michael Kruse via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Sep 29 11:40:58 PDT 2020
Meinersbur created this revision.
Meinersbur added reviewers: isuruf, DavidTruby, sscalpone, klausler, tskeith.
Meinersbur added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Meinersbur requested review of this revision.
The flags F_OK, R_OK and W_OK are defined in unistd.h, which does not exist under the Windows platform. Windows still defines the `access` function. Its access flags are documented at https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess. For compatibility, define the flags F_OK, R_OK and W_OK using these constants.
This patch is part of the series to make flang compilable with MS Visual Studio http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88508
Files:
flang/runtime/file.cpp
Index: flang/runtime/file.cpp
===================================================================
--- flang/runtime/file.cpp
+++ flang/runtime/file.cpp
@@ -397,6 +397,15 @@
bool IsATerminal(int fd) { return ::isatty(fd); }
+#ifdef WIN32
+// Access flags are normally defined in unistd.h, which unavailable under
+// Windows. Instead, define the flags as documented at
+// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess
+#define F_OK 00
+#define R_OK 02
+#define W_OK 04
+#endif
+
bool IsExtant(const char *path) { return ::access(path, F_OK) == 0; }
bool MayRead(const char *path) { return ::access(path, R_OK) == 0; }
bool MayWrite(const char *path) { return ::access(path, W_OK) == 0; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88508.295068.patch
Type: text/x-patch
Size: 730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200929/38f0aaf5/attachment.bin>
More information about the flang-commits
mailing list