swiftlang / swift-corelibs-libdispatch

The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware
swift.org
Apache License 2.0
2.47k stars 460 forks source link

Compare with (void *)0 instead of casting to uintptr_t #769

Closed AreaZR closed 1 year ago

AreaZR commented 2 years ago

Such casts otherwise pessimize optimization

rokhinip commented 2 years ago

What is this change trying to address? This seems like a no-op.

AreaZR commented 1 year ago

It aligns with the definition of NULL better @rokhinip

rokhinip commented 1 year ago

Well firstly, _dispatch_needs_to_return_to_kernel is reading an integer value out of a TSD slot, in order to determine if we need to return to the kernel to pump events. So a comparison to NULL is not valid here - nor is (void *)0 because we're not reading pointers.

This change seems like a change for the sake of it without understanding how this code is used in the larger context. Please refer to the guidelines document on how to identify and make useful changes to the project.