Archive for October 7, 2016

Friday, October 7, 2016


Peter Steinberger measured the new os_unfair_lock against OSSpinLock, pthread_mutex, NSLock, dispatch queues, and @synchronized.

Pierre Habouzit (via David Smith):

Apple’s libplatform is now OSS too with user-land os_unfair_lock (os/lock.c) in all its strict glory.

Stephan Tolksdorf:

If you use it from Swift, you have to be careful, because it’s a struct and Swift doesn’t prevent you from copying or moving it around, which normally would be an error.

Previously: OSSpinLock Is Unsafe, Mutexes and Closure Capture in Swift.

Update (2023-01-27): David Smith:

A decade or so ago, “what lock should I use?” was a fairly complicated question on macOS/iOS.

Hopper 4 Announced

Vincent Bénony:

Starting with Hopper v4, there is no floating windows anymore: now there is this Display Mode concept, which allows you to look at the content of the file using different kind of representation.


Hopper now features a complete Swift name demangler. No more cryptic names in files written in Swift.


In order to make ASM easier to read, Hopper gives different colors to the objects in the disassembly view, according to its analysis. For instance, stack variables have a different color from numbers, or registers.


Hopper v4 analyses procedures, and collect all the methods called. He is also capable of detecting some indirect calls, like Objective-C messages.


At the moment, there is no precise ETA, but Hopper v4 will be released before the end of the year, hopefully before the end of November.

And now, the big news: Hopper v4 will be a free update for the owners of a v3 license.

This looks great. Meanwhile, there are scripts for Swift demangling.

Apple’s Lightning to Headphone Adapter

Jeff Suovanen:

There’s actually a lot going on in there. As expected, one end is a simple female 3.5 mm headphone jack, and the other end is a male Lightning connector. But what’s all that silicon around the Lightning connector end? Most of the retail space near the connector is taken up by a single mystery IC.


In past iPhones like the 6s, both DAC and ADC functions were handled internally. The analog inputs and outputs from the headphone jack (and other components) were wrangled by a single chip on the logic board, a custom Apple/Cirrus Logic IC labeled 338S00105. (In the iPhone 7 and 7 Plus, that same exact chip still exists—because even without a headphone jack, the phone still has to shake hands with the built-in loudspeakers and microphones, all of which use analog signals.)

Martin Steiger:

Various issues with the new Apple headphone adapter: (increased noise, less quality, not compatible with all headphones etc.)

Previously: Lightning to 3.5 mm Headphone Jack Adapter.

Update (2018-06-02): Jeremy Larson:

After one year, this was my third dongle that has needed to be returned, not counting the two I have lost. Two of them started having problems with distorting the audio; one just stopped working altogether.

Real World Swift Performance

Danielle Tomlinson:

Let’s talk about generics. You’re going to say, but you just showed us that protocols could be really slow, why would we want to use generics? The answer comes from what generics allow us to do.

Say we have this stack struct that is generic of a T, which is constrained by some type, which would be a protocol. What the compiler will do is replace that T with the protocol or the concrete class that you’re passing to it. Do that all of the way down the function chain and it will create specialized versions of that code that operate directly on the type.

You no longer need to go through the value witness table, or the protocol witness table, and you eradicate the existential container, which could be a really nice way to still write really fast generic code and have the really nice polymorphism that Swift gives us. That’s called static polymorphism.

Touch ID Is Only More Convenient

Alex Hern (in 2014, via Alexis Gallagher):

A speaker at the Chaos Communication Congress, an annual meeting of hackers in Germany, demonstrated his method for faking fingerprints using only a few high-definition photographs of his target, German defence minister Ursula von der Leyen.

Jan Krissler, known in hacker circles as Starbug, used commercial software called VeriFinger and several close-range photos of von der Leyen, including one gleaned from a press release issued by her own office and another he took himself from three meters away, to reverse-engineer the fingerprint.

Update (2016-10-07): See this Twitter conversation.