-
Notifications
You must be signed in to change notification settings - Fork 5
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
Drop Foundation dependency #92
Conversation
16d9b39
to
c10f94a
Compare
Co-authored-by: Kabir Oberai <[email protected]>
c10f94a
to
396a16e
Compare
import ucrt | ||
#else | ||
#error("Unsupported Platform") | ||
#endif |
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.
How come we need to use libc here? Seems like the only use site is open(..., O_DIRECTORY)
— can we not use SystemPackage.FileDescriptor.OpenOptions.directory
instead?
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.
I wanted to keep using memchr
because llvm recognizes the lib call and optimizes it.
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.
I see, what do you think about making a memchr
shim in SystemExtras? Might be nice to isolate the C library stuff to that one spot. We can do the same for O_DIRECTORY
, which seems like it might need to be re-declared by us on Windows (other platforms define .directory
in SystemPackage).
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.
Yes, importing it through a C shim could be an option. Actually memchr
is not a syscall and SystemExtras
will be upstreamed to swift-system later, so SystemExtras
might not be an appropriate place.
Once we upgrade the minimum supported Swift version to 6.0, we can import it via @_extern(c)
without C module, but it's not feasible right now.
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.
Ah interesting, I would've assumed that UnsafeRawBufferPointer.firstIndex(of:)
could be optimized to memchr
under the hood but it looks like that isn't being done yet. It's being tracked via swiftlang/swift#63200.
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.
Yeah, it's unfortunate situation now 🥲
No description provided.