-
Notifications
You must be signed in to change notification settings - Fork 197
Port directory enumeration related code to WASI #836
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
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 |
---|---|---|
|
@@ -79,6 +79,29 @@ static inline _Nonnull clockid_t _platform_shims_clock_monotonic(void) { | |
static inline _Nonnull clockid_t _platform_shims_clock_realtime(void) { | ||
return CLOCK_REALTIME; | ||
} | ||
|
||
// Define dirent shims so that we can use them in Swift because wasi-libc defines | ||
// `d_name` as "flexible array member" which is not supported by ClangImporter yet. | ||
|
||
#include <dirent.h> | ||
|
||
static inline char * _Nonnull _platform_shims_dirent_d_name(struct dirent * _Nonnull entry) { | ||
return entry->d_name; | ||
} | ||
|
||
// Define getter shims for constants because wasi-libc defines them as function-like macros | ||
// which are not supported by ClangImporter yet. | ||
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. For things like this, is there any hope for us resolving this somehow beyond updating the ClangImporter (some sort of API notes or something at the toolchain layer? Not sure if that's possible today, but I'm curious what our options are since it seems like WASI requires a large amount of shims 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. Yes, we have three directions, 1. provide those definitions in WASILibc overlay module, 2. change the upstream wasi-libc headers to be compatible with ClangImporter, 3. "fix" ClangImporter to import those constants from wasi-libc headers directly. 1 is what we are doing for some frequently used constants now. Still, it's quite ad-hoc and not a scalable solution. 2 is an option worth considering to align with other platform's headers, but not sure if it's acceptable for the upstream and if they can maintain the compatibility with ClangImporter. |
||
|
||
#include <stdint.h> | ||
#include <fcntl.h> | ||
#include <dirent.h> | ||
|
||
static inline uint8_t _platform_shims_DT_DIR(void) { return DT_DIR; } | ||
static inline uint8_t _platform_shims_DT_UNKNOWN(void) { return DT_UNKNOWN; } | ||
static inline int32_t _platform_shims_O_CREAT(void) { return O_CREAT; } | ||
static inline int32_t _platform_shims_O_EXCL(void) { return O_EXCL; } | ||
static inline int32_t _platform_shims_O_TRUNC(void) { return O_TRUNC; } | ||
static inline int32_t _platform_shims_O_WRONLY(void) { return O_WRONLY; } | ||
#endif | ||
|
||
#endif /* CSHIMS_PLATFORM_SHIMS */ |
Uh oh!
There was an error while loading. Please reload this page.