[llvm-commits] CVS: llvm/lib/System/Mutex.cpp

Chris Lattner sabre at nondot.org
Tue Jul 12 23:39:24 PDT 2005


On Tue, 12 Jul 2005, Reid Spencer wrote:
> It makes sure that you get a process-wide rather than system-wide mutex.
> Linux is okay but some operating systems default the mutex to system
> wide which is unneeded for LLVM and *way* more expensive.  This call
> just makes sure that we get a process-wide exception. We could probably
> make it only be called on those systems that need it, but we're nit
> picking nanoseconds here .. its a 2 line function that gets called, just
> sets a value in a structure.

Hrm, that is strange, are you sure that some systems default to system 
wide?  That seems like it would violate the pthreads spec.

I'm not trying to nitpick nanoseconds, just trying to make the code more 
portable :)

-Chris

>> What does this call do?  Is it even needed?
>>
>> -Chris
>>
>> On Tue, 12 Jul 2005, Reid Spencer wrote:
>>
>>>
>>>
>>> Changes in directory llvm/lib/System:
>>>
>>> Mutex.cpp updated: 1.2 -> 1.3
>>> ---
>>> Log message:
>>>
>>> Don't call pthread_mutexattr_setpshared on FreeBSD because its implementation
>>> of pthreads is missing that call (despite it violating the spec).
>>>
>>>
>>> ---
>>> Diffs of the changes:  (+2 -0)
>>>
>>> Mutex.cpp |    2 ++
>>> 1 files changed, 2 insertions(+)
>>>
>>>
>>> Index: llvm/lib/System/Mutex.cpp
>>> diff -u llvm/lib/System/Mutex.cpp:1.2 llvm/lib/System/Mutex.cpp:1.3
>>> --- llvm/lib/System/Mutex.cpp:1.2	Tue Jul 12 21:15:17 2005
>>> +++ llvm/lib/System/Mutex.cpp	Tue Jul 12 22:02:06 2005
>>> @@ -62,8 +62,10 @@
>>>     errorcode = pthread_mutexattr_settype(&attr, kind);
>>>     assert(errorcode == 0);
>>>
>>> +#ifndef __FreeBSD__
>>>     // Make it a process local mutex
>>>     errorcode = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE);
>>> +#endif
>>>
>>>     // Initialize the mutex
>>>     errorcode = pthread_mutex_init(mutex, &attr);
>>>
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://mail.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>
>> -Chris
>>
>

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/




More information about the llvm-commits mailing list