[swift-evolution] fcntl() should be added to the standard library.
clattner at apple.com
Sun Dec 6 01:11:41 CST 2015
> On Dec 4, 2015, at 8:36 PM, Bill Abt <babt at me.com> wrote:
> The fcntl() API is a variadic standard “C” library and as such not supported currently by Swift. Any visit to GitHub looking for a socket implementation will invariably find a .c or .mm file included that exposes fcntl() to Swift via a shim. There are only 3 forms of this API, all returning int. The first takes 2 integers and sets the 3rd to 0. The second takes 3 integers. The last and final form take 2 integers and a void pointer. Looking at the standard library source, it’s trivial to implement. It’ll take longer to write the tests than it will to write the functions. Once implemented, it would eliminate the need for shims for this API.
> This seems like one of those obvious things that just haven’t been implemented yet, no?
The Swift standard library doesn’t provide this sort of functionality, but I agree that it makes sense for the Darwin/Glibc modules to provide this interface. We have a system of “overlays” to provide functionality that the clang importer can’t do automatically. For example, the Glibc overlay is here:
The darwin overlay is more filled out:
It doesn’t look like it provides fcntl specifically, but it does provide open, which has the same varargs sort of implementation issues. Adding support for fcntl to the overlays makes sense in principle to me.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution