Re: [swift-users] Still having trouble with C interop (passing buffers)

2017-04-25 Thread Rick Mann via swift-users
Yup, that seems to be it. I would have thought that init(capacity:) should work, too (it could defer allocation until, say, the call withUnsafeMutableBytes()), and just not zero the contents (the init(count:) call zeroes the contents). > On Apr 25, 2017, at 15:20 , Philippe Hausler wrote: > >

Re: [swift-users] Still having trouble with C interop (passing buffers)

2017-04-25 Thread Philippe Hausler via swift-users
> On Apr 25, 2017, at 2:57 PM, Rick Mann via swift-users > wrote: > > I'm trying to pass a Data of allocated size to a C function for it to fill in: > > > lib_example_call(_ params: UnsafePointer!, _ data: > UnsafeMutableRawPointer!) > > ... > { >self.dataBuffer = Data(capacity: BufferS

[swift-users] Still having trouble with C interop (passing buffers)

2017-04-25 Thread Rick Mann via swift-users
I'm trying to pass a Data of allocated size to a C function for it to fill in: lib_example_call(_ params: UnsafePointer!, _ data: UnsafeMutableRawPointer!) ... { self.dataBuffer = Data(capacity: BufferSizeConstant) var params = lib_call_params_t(); params.data_capacity = BufferSize

Re: [swift-users] Performance in Trunk builds vs 3.1.1

2017-04-25 Thread Slava Pestov via swift-users
Can you share the code for your benchmark? Slava > On Apr 25, 2017, at 6:34 AM, Proyb P via swift-users > wrote: > > I have testing the performance between trunk builds downloaded from Swift > website (April 22 and 24) and 3.1.1 > > Fibonacci (N: 50) benchmark: > Trunk (22 Apr): 1m13s > Trun

Re: [swift-users] Atomics and Memory Fences in Swift

2017-04-25 Thread Shawn Erickson via swift-users
On Mon, Dec 5, 2016 at 9:28 AM Joe Groff via swift-users < swift-users@swift.org> wrote: > > On Dec 4, 2016, at 4:53 PM, Andrew Trick via swift-users < > swift-users@swift.org> wrote: > > > On Nov 30, 2016, at 5:40 AM, Anders Ha via swift-users < > swift-users@swift.org> wrote: > > Hi guys > > I h

[swift-users] Performance in Trunk builds vs 3.1.1

2017-04-25 Thread Proyb P via swift-users
I have testing the performance between trunk builds downloaded from Swift website (April 22 and 24) and 3.1.1 Fibonacci (N: 50) benchmark: Trunk (22 Apr): 1m13s Trunk (24 Apr): 1m16s 3.1.1: 1m7s I assume there are overhead in trunk build? There is a big regression. ___

Re: [swift-users] Data fix for Linux

2017-04-25 Thread Tim Hawkins via swift-users
Do you know if that will include a backend for grandcentral to support epoll instead of kqueue/kevent? The later is not supported on many linux distros. I wish swift supported fedora directly instead of all the hacks i have to do to get it to work. On Tue, Apr 25, 2017, 00:21 Proyb P via swift-us

Re: [swift-users] Atomics and Memory Fences in Swift

2017-04-25 Thread Anders Ha via swift-users
What about `withUnsafeMutablePointer` on a stored object property, marked with `final`? e.g. `withUnsafeMutablePointer(to: &object.lock, os_unfair_lock_lock)`. The generated object code with `-Owmo` shows that it is optimised to an address calculation immediately followed by a call to `os_unfair

Re: [swift-users] withUnsafeMutableBytes is killing me

2017-04-25 Thread Ole Begemann via swift-users
On 25.04.2017 12:24, Rick Mann via swift-users wrote: Not the ResultType, you mean, but the input type, right? Yes, sorry, I meant ContentType. Yeah, I finally figured that out, although it doesn't explain another situation I'm experiencing that I didn't include in the post. However, that d

Re: [swift-users] withUnsafeMutableBytes is killing me

2017-04-25 Thread Rick Mann via swift-users
Not the ResultType, you mean, but the input type, right? Yeah, I finally figured that out, although it doesn't explain another situation I'm experiencing that I didn't include in the post. However, that doesn't explain why it can't infer it in the last example. > On Apr 25, 2017, at 02:58 , Ole

Re: [swift-users] withUnsafeMutableBytes is killing me

2017-04-25 Thread Ole Begemann via swift-users
The withUnsafeMutableBytes method has two generic parameters, ResultType and ContentType: |mutating func withUnsafeMutableBytes(_ body: (UnsafeMutablePointer ) throws -> ResultType) rethrows -> ResultType| In your examples, the type checker can't infer the type of ResultType. You'll have

[swift-users] withUnsafeMutableBytes is killing me

2017-04-25 Thread Rick Mann via swift-users
The following playground reproduces an issue I'm having, in that the code won't compile depending on the content of the closure. In fact, an empty closure is fine, but when I try to call certain things, it's not. I figure it has something to do with the type inference for inPointer, but I can't