[PATCH] Fix RWMutex to be thread-safe when pthread_rwlock is not available

Mark Seaborn mseaborn at chromium.org
Wed Feb 26 17:55:59 PST 2014


On 26 February 2014 17:30, Chandler Carruth <chandlerc at gmail.com> wrote:

>
>   It's not trivial, but I'm moderately familiar with how to implement a
> reasonable RW mutex on top of a mutex. Would you prefer that? I'm happy to
> contribute such an implementation.


Thanks -- I'm familiar with how to do that too, and I might add a
pthread_rwlock implementation to nacl-newlib's libpthread at some point.
 It seems like overkill to add a rwlock implementation to LLVM, though,
because it would currently only get used under NaCl, and only for a very
small number of uses in LLVM.

I just didn't want to leave lib/Support/Unix/RWMutex.cpp as a
silently-unsafe fallback code path, because that could cause nasty
surprises for other people in the future.  Another option here would just
be to have writer_acquire() call report_fatal_error(), but it seemed better
to add a simple but non-optimal implementation that works. :-)

Cheers,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140226/a3671fb0/attachment.html>


More information about the llvm-commits mailing list