-
Notifications
You must be signed in to change notification settings - Fork 128
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
FoundationEssentials: perform explicit conversion of mode_t
#522
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,10 @@ | |
#include <libkern/OSThermalNotification.h> | ||
#endif | ||
|
||
#if defined(_WIN32) | ||
typedef int mode_t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It means fewer code path divergences. Having a large number of |
||
#endif | ||
|
||
INTERNAL char * _Nullable * _Nullable _platform_shims_get_environ(); | ||
|
||
INTERNAL void _platform_shims_lock_environ(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my reference, could you elaborate a bit more on why these casts are all necessary? What type is
S_IFREG
on Windows? Does it use some other integer type, or does it useint
? If so I think I'd expect that declaring atypealias mode_t = Int
(or the appropriate integer type) would eliminate the need for these casts becauseS_IFREG
would be considered the same type wasfileType
here. Or is there a detail I might be missing here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no
mode_t
on Windows, there is an alias that I have created which isint
. However, the type system often sees the values asUInt16
which would then be incompatible withint
. The explicit casting avoids the mismatched types on the various sides.