OS X doesn't implement pthread barriers, using a simple atomic flag instead.
Details
Diff Detail
Event Timeline
test/functionalities/watchpoint/hello_watchlocation/main.cpp | ||
---|---|---|
107 | it was useful. |
Looks good. I haven't tested it yet, but you can commit it if you have.
I'll check it a bit later.
Someone else already posted a fix for this that used pthread_condition_t and pthread_mutex_t, so don't commit this.
lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp | ||
---|---|---|
58 ↗ | (On Diff #20832) | std::condition_variable? |
65 ↗ | (On Diff #20832) | I understand this isn't your code, but RAND_MAX is not guaranteed to be > 32768. On Windows, it isn't. std::random would be better here. |
93–95 ↗ | (On Diff #20832) | Since we're already bringing in std::atomic, how about std::thread while we're at it? That would make this testcase compile on Windows. |
@Greg, the author of the other fix and I have sort of decided among
ourselves to abandon his fix and use this instead.
@zach, would it be better if I just rewrote this entire test with C++11
instead of C? Should that be a general rule for all tests in the future?
I like your fix better. The C++ way will spin one CPU while waiting for a global to change. I much prefer this solution the other thread will park itself instead of spin locking.
I meant to say I like the other fix that uses pthread_condion_t and pthread_mutex_t since it won't spin like this fix will. Please use the other one.
Just to be clear, are you saying you don't want C++11 at all? Or that you just want a condition variable instead of a spinlock? Because if you just want a condition variable, then we should go with the C++11 and std::condition_variable as I suggested, since the test will work on platforms that don't have pthreads.
It's not a general rule for *all* tests, but I think it should be a general rule for all tests that aren't specifically testing a property of the debugger that requires only C code. So I think it should be a general rule for *almost* all tests, but there may occasionally be valid reasons to test strict C.
As I commented in the other fix for this bug, we should move to using the correct C++11 primitives to abstract us from the host system. pthread_ types and functions obviously don't do this.
I strongly feel we should use std::condition_variable and std::mutex and anything else the C++11 libraries can do for us.
it was useful.