umtx_lock and friends

Russell L. Carter rcarter at pinyon.org
Wed Jun 10 01:15:42 UTC 2015



On 06/09/15 18:03, Daniel Eischen wrote:
> On Tue, 9 Jun 2015, Daniel Eischen wrote:
>
>> On Tue, 9 Jun 2015, Russell L. Carter wrote:
>>
>>> On FreeBSD 10-stable r283752 amd64, here is the compile line:
>>>
>>> /usr/bin/cc -O -Wall tester.cpp -o tester
>>> /tmp/tester-b681b3.o: In function `main':
>>> tester.cpp:(.text+0x35): undefined reference to `_umtx_lock(umtx*)'
>>> tester.cpp:(.text+0x5c): undefined reference to `_umtx_unlock(umtx*)'
>>>
>>> Compilers don't matter, linking against libthr or libstdthreads
>>> doesn't matter.
>>
>> Is cc doing something special because it thinks it is C++?
>> I'm on 10-stable amd64 and that example (saved as tester.c)
>> works just fine.

Yep!  That made me laugh.  I generally test as c++ and I thought I
would cut this one down to just c, but that extension matters to every
c compiler I tried.

Putting the standard extern "C" { ... } guards around
#include<sys/utmp.h> cures this problem.

Thanks!
Russell

>
> Try:
>
>    /usr/bin/cc -O -Wall -x c tester.cpp -o tester
>


More information about the freebsd-hackers mailing list