Re: [swift-users] How to malloc in Swift 3

2016-09-24 Thread Gerriet M. Denkmann via swift-users

> On 23 Sep 2016, at 19:41, Quinn The Eskimo! via swift-users 
>  wrote:
> 
> 
> On 23 Sep 2016, at 11:29, Gerriet M. Denkmann via swift-users 
>  wrote:
> 
>> What about calloc then? Or use allocate and do a memset afterwards?
> 
> For trivial data types (like UInt8) this will work, but if you want to follow 
> the rules I recommend reading the following:
> 
> * UnsafeRawPointer Migration
> 
> 
> 
> * SE-0107 “UnsafeRawPointer API”
> 
> 
> 
> Spoiler: that’ll point you to `initialize(to:count:)` (-:

Thanks for the links.
By the way: I had already tried to use `initialize(to:count:)` before, but I 
used it as a replacement of allocate, which the compiler did not really like.
Since reading these documents I know that I have to use it after allocate, not 
instead of.

In dealloc I had before:
free( bitfield )
which, to my surprise, the compiler did NOT warn about (should there be a 
warning?)
I have since replace this with:
bitfield.deallocate(capacity: numberUsedInAllocate )


>   *   *   *
> 
> Also, why are you manually allocating this rather than using [UInt8]?  The 
> latter is easier, safer, and likely to have similar levels of efficiency.

I just tried this:  [UInt8] turns out to be nearly 10% slower compared to: 
UnsafeMutablePointer.allocate(capacity:).

Probably depends on the use case, whether 10% less performance is worth the 
easier and safer.
I am trying to compare Swift to ObjC classes (which use malloc), so it would 
not be a fair comparison if the Swift class has to use an UInt8 array.


Kind regards,

Gerriet.



___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Ubuntu 16.04 support?

2016-09-24 Thread Todd Fiala via swift-users
Hi Lane,

On Sat, Sep 24, 2016 at 12:52 PM, Lane Schwartz  wrote:

> Thanks.
>

Sure thing!


> I mostly was asking whether the existing 3.0 packages would remain online,
>

Ah I see.  I'll have to check on that.  We probably could keep the packages
around for the Ubuntu versions we sunset, with the caveat that they will
get stale quickly.

Thanks!

-Todd


> not whether new ones would be build. But this is helpful info.
>
> On Fri, Sep 23, 2016 at 12:02 PM, Todd Fiala  wrote:
>
>> Hi Lane,
>>
>> We’re going to be following the plan we proposed here:
>>
>> https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-
>> 20160418/001778.html
>>
>> Our intent is to continue building packages for the versions of Ubuntu
>> where we’re running official CI.
>>
>> That means the following:
>>
>> * Sunsetting the 15.10 bots now that the 16.04 bots are online.  The
>> Ubuntu 15.10 bots should go away now, and no new packages for 15.10 will be
>> built once the bots are taken offline.
>>
>> * Keep providing 14.04 and 16.04 images.  (i.e. keep providing packages
>> for the versions of Ubuntu that we cover with official CI.  In this case,
>> we are newly building packages for 16.04 given that those bots were just
>> spun up).
>>
>> * Sometime after Ubuntu 16.10 comes out, we’ll bring up the 16.10 CI and
>> packages, and sunset the 14.04 CI and packages.  At that point, when we get
>> rid of the Ubuntu 14.04 bots, we will also no longer build packages for
>> them.
>>
>> It took us a little longer than originally expected to get the 16.04 bots
>> up.  I am looking to get us to bring up the 16.10 CI on a shorter timeline
>> for the next Ubuntu cycle.
>>
>> Thanks!
>>
>> -Todd
>>
>> On Sep 22, 2016, at 10:16 AM, Lane Schwartz  wrote:
>>
>> Will the Ubuntu 14.04 package remain available?
>>
>> On Wed, Sep 21, 2016 at 3:16 PM, Todd Fiala via swift-users <
>> swift-users@swift.org> wrote:
>>
>>> Hey that’d be great.  Thanks, Mishal!
>>>
>>> -Todd
>>>
>>> On Sep 21, 2016, at 9:42 AM, Mishal Shah  wrote:
>>>
>>> I should have Ubuntu 16.04 system available on ci.swift.org by end of
>>> day.
>>>
>>> Thanks,
>>> Mishal Shah
>>>
>>> On Sep 21, 2016, at 9:25 AM, Todd Fiala  wrote:
>>>
>>> Hmm, likes get a JIRA tracking this if we don’t have one already.
>>>
>>> Mishal, what’s the current ETA on the Ubuntu 16.04 switch-over?
>>>
>>> -Todd
>>>
>>> On Sep 21, 2016, at 9:11 AM, Michael Gottesman 
>>> wrote:
>>>
>>> +CC Todd.
>>>
>>> On Sep 20, 2016, at 9:25 PM, Ron Olson via swift-users <
>>> swift-users@swift.org> wrote:
>>>
>>> Hmm, I don’t get that at all:
>>>
>>> Welcome to Swift version 3.0 (swift-3.0-RELEASE). Type :help for
>>> assistance.
>>> 1> import Foundation
>>> 2> NSURL(string:"http://swift.org;)
>>> $R0: Foundation.NSURL? = 0x00427f00 {
>>> Foundation.NSObject = {}
>>> _base = {
>>> info = 7552
>>> pad = 0
>>> }
>>> _flags = 536887337
>>> _encoding = 0
>>> _string = 0x00427bd0 -> 0x7475d720 full type metadata
>>> for Foundation.NSString + 16
>>> _baseURL = nil
>>> _extra = nil
>>> _resourceInfo = nil
>>> _range1 = {
>>> location = 0
>>> length = 4
>>> }
>>> _range2 = {
>>> location = 7
>>> length = 9
>>> }
>>>
>>> … more of the same …
>>>
>>> On 20 Sep 2016, at 22:28, Bouke Haarsma via swift-users wrote:
>>>
>>> On 2016-09-20 16:37:18 +, Lane Schwartz via swift-users said:
>>>
>>> In addition to the installation instructions per swift.org, I also
>>> needed to install "libpython2.7-dev". When starting the Swift REPL it threw
>>> the following error;
>>>
>>> ...swift/usr/bin/lldb: error while loading shared libraries:
>>> libpython2.7.so.1.0: cannot open shared object file: No such file or
>>> directory
>>>
>>> Installing that package resolved that issue. However the REPL loads, it
>>> throws errors like this:
>>>
>>> *ubuntu-1604*:*~*$ swift
>>> Welcome to Swift version 3.0 (swift-3.0-RELEASE). Type :help for
>>> assistance.
>>>   1> import Foundation
>>>   2> NSURL(string: "http://swift.org;)
>>> error: Couldn't lookup symbols:
>>>   type metadata accessor for Foundation.NSURL
>>>   Foundation.NSURL.__allocating_init (string : Swift.String) ->
>>> Swift.Optional
>>>
>>> I've downgraded to 14.04 LTS.
>>>
>>> Thanks.
>>>
>>>
>>> On Tue, Sep 20, 2016 at 11:28 AM, Ron Olson via swift-users <
>>> swift-users@swift.org> wrote:
>>> I downloaded the Ubuntu 15 release.
>>>
>>> On 20 Sep 2016, at 11:26, Lane Schwartz wrote:
>>>
>>> Thanks, Ron. Which binary release did you download? The ubuntu 15
>>> release? Or the 14 release?
>>>
>>> On Tue, Sep 20, 2016 at 11:12 AM, Ron Olson via swift-users <
>>> swift-users@swift.org> wrote:
>>> I can verify that the 3.0 Release works under 16; I downloaded it this
>>> morning and it works fine.
>>>
>>>
>>> On 20 Sep 2016, at 11:10, Lane Schwartz via swift-users wrote:
>>>
>>> I see that there are swift packages for Ubuntu 14 and 15, but not 16. Is