<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 4, 2015, at 8:36 PM, Bill Abt &lt;<a href="mailto:babt@me.com" class="">babt@me.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">The fcntl() API is a variadic standard “C” library and as such not supported currently by Swift. &nbsp;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. &nbsp;There are only 3 forms of this API, all returning int. &nbsp;The first takes 2 integers and sets the 3rd to 0. &nbsp;The second takes 3 integers. &nbsp;The last and final form take 2 integers and a void pointer. &nbsp;Looking at the standard library source, it’s trivial to implement. &nbsp;It’ll take longer to write the tests than it will to write the functions. &nbsp;Once implemented, it would eliminate the need for shims for this API.</div><div class=""><br class=""></div><div class="">This seems like one of those obvious things that just haven’t been implemented yet, no?</div></div></div></blockquote><div><br class=""></div><div>Hi Bill,</div><div><br class=""></div><div>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. &nbsp;We have a system of “overlays” to provide functionality that the clang importer can’t do automatically. &nbsp;For example, the Glibc overlay is here:</div><div><a href="https://github.com/apple/swift/blob/master/stdlib/public/Glibc/Glibc.swift" class="">https://github.com/apple/swift/blob/master/stdlib/public/Glibc/Glibc.swift</a></div><div><br class=""></div><div>The darwin overlay is more filled out:</div><div><a href="https://github.com/apple/swift/blob/master/stdlib/public/SDK/Darwin/Darwin.swift" class="">https://github.com/apple/swift/blob/master/stdlib/public/SDK/Darwin/Darwin.swift</a></div><div><br class=""></div><div>It doesn’t look like it provides fcntl specifically, but it does provide open, which has the same varargs sort of implementation issues. &nbsp;Adding support for fcntl to the overlays makes sense in principle to me.</div><div><br class=""></div><div>-Chris</div></div></body></html>