[llvm-commits] [patch] Fix some tests when --disable-threads is used

Duncan Sands baldrick at free.fr
Thu Mar 3 08:37:56 PST 2011


On 03/03/11 17:31, Dimitry Andric wrote:
> On 2011-03-03 16:19, Duncan Sands wrote:
> ...
>>> This is because the tests attempt to acquire a mutex, and expect it to
>>> fail, but all mutex functions simply return true when --disable-threads
>>> is used.
>>
>> why not change the mutexes to return false, i.e. success?
>
> Yes, that seems to be a better idea; if mutexes are unimplemented,
> failure is really the only option. :) The test suite survives now.

It's not failure, it is success!  I think this should be thought about as
follows: --disable-threads means that you are working in a single threaded
environment.  Thus if you try to acquire a mutex you always get it and so
on (of course this is not strictly true: if you try to acquire a mutex
twice in a row then it would fail, but I want to ignore this for the sake
of discussion).  So as an optimization you can remove the actual mutexes and
just return "success" everywhere, or whatever would have been returned in
the multi-threaded case if there were in fact no other threads.

Ciao, Duncan.



More information about the llvm-commits mailing list