[libcxx-commits] [PATCH] D64298: Make ~mutex and ~condition_variable trivial with Apple pthreads
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 25 13:25:59 PDT 2019
ldionne requested changes to this revision.
ldionne added a comment.
This revision now requires changes to proceed.
Ok, so I spoke to our OS folks and here's what I got.
First of all, we're looking at the wrong sources. The sources we're looking at are about 17 years old (!!!). The most up-to-date public sources for `pthread_cond_destroy` are https://opensource.apple.com/source/libpthread/libpthread-330.220.2/src/pthread_cond.c.auto.html
Second, it seems like both `pthread_cond_destroy` and `pthread_mutex_destroy` can result in the kernel releasing resources it holds internally, so those can't be omitted. It's also the case that synchronization objects must be destroyed (i.e. call `pthread_xxx_destroy`) before the same address in the process can be used to hold another synchronization object. So, in other words, it seems unsafe to omit these calls. This is unfortunate because of the optimizations this would have enabled, however correctness is clearly more important than performance.
Furthermore, I would strongly encourage being careful with these changes on other platforms. Not because I personally care about such platforms, but I do think that such a tricky optimization should be vetted by folks working on those synchronization primitives from the OS side before anything is done.
I'll be updating the comment to explain that on Apple platforms, `pthread_xxx_destroy` is NOT a nop, to avoid future confusion.
Repository:
rCXX libc++
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64298/new/
https://reviews.llvm.org/D64298
More information about the libcxx-commits
mailing list