[cfe-commits] patch: libcxxabi cxa_*_virtual and cxa_guard_* methods

John McCall rjmccall at apple.com
Sun May 22 13:45:44 PDT 2011


On May 22, 2011, at 12:23 PM, Howard Hinnant wrote:

> On May 20, 2011, at 2:11 AM, Nick Lewycky wrote:
> 
>> I've started dipping my toes in the libcxxabi project by implementing a few simple methods. Patch attached, please review!
>> 
>> This isn't heavily tested, I'm mostly just trying to make sure I have the style down. Please let me know if we should be using different file names (hard to follow a pattern where there isn't one), of if the private methods in cxa_guard actually belong in an anonymous namespace, etc.
>> 
>> Nick
>> 
>> <libcxxabi-virtual-and-guard.patch>
> 
> I disagree with John that your implementation doesn't support the recursive calls for *different* static objects.  I believe it does.  And I like that your design allows for parallel initialization of different static objects.

Oh, yes, sorry, I did misread the code as using a global lock instead of a variable-specific lock.  In retrospect, I'm not sure how. :)

> What I'm nervous about though is the use of the spin lock.  An arbitrary amount of time can go by while one thread is initializing and the other thread is spinning, waiting for that initialization to complete.

Yeah;  while there are times and places for spin locks, I don't think this is one, and this is actually a very naive spin lock.

That said, while I shouldn't be concerned about using pthread_mutex_t, I know that certain platforms have particularly terrible implementations. :)

John.



More information about the cfe-commits mailing list