-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crt: Redirect access() to __mingw_access() on UCRT
__mingw_access() was introduced as the msvcrt.dll access() function reportedly returned errors when passed the X_OK constant on Vista. Users who expect to be calling access() with the X_OK constant could set the __USE_MINGW_ACCESS define to get a mingw specific reimplementation of the function. GCC has been setting this define to work around this issue (but there have been cases where the define hasn't applied on all the source where it's needed). Current versions of msvcrt.dll no longer seem to have this issue with X_OK, so the issue has somewhat been forgotten since. But UCRT's access() function shows the same behaviour of returning errors when given that constant. Always defining __USE_MINGW_ACCESS when building targeting UCRT doesn't work, as the define of access() breaks other valid cases (e.g. calls to methods named access() in C++ classes). Instead remove the access() symbol from the import libraries, and expose an UCRT specific access() that just redirects to __mingw_access(). Signed-off-by: Martin Storsjö <martin@martin.st>
- Loading branch information
Showing
4 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* This file has no copyright assigned and is placed in the Public Domain. | ||
* This file is part of the mingw-w64 runtime package. | ||
* No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
*/ | ||
|
||
#include <io.h> | ||
|
||
int __cdecl __mingw_access(const char *fname, int mode); | ||
|
||
int __cdecl access(const char *fname, int mode) | ||
{ | ||
/* On UCRT, unconditionally forward access to __mingw_access. UCRT's | ||
* access() function return an error if passed the X_OK constant, | ||
* while msvcrt.dll's access() doesn't. (It's reported that msvcrt.dll's | ||
* access() also returned errors on X_OK in the version shipped in Vista, | ||
* but in recent tests it's no longer the case.) */ | ||
return __mingw_access(fname, mode); | ||
} |