[cfe-dev] [PATCH] Make libcxx compile on x86_64 Linux w/ g++ 4.4.3

Jeffrey Yasskin jyasskin at google.com
Wed Jun 2 08:39:23 PDT 2010


When I was fixing these problems (sorry for missing the move case), I
used "0" instead of either NULL or nullptr. That's not guaranteed to
work either, and I didn't check glibc to see if it's actually the
not-a-thread value, but it at least made things compile.

Howard, is there a reason you're using pthread_t and literal no-thread
values everywhere instead of using thread::id? Using thread::id
everywhere would reduce the number of places that need porting.

On Wed, Jun 2, 2010 at 8:23 AM, Howard Hinnant <hhinnant at apple.com> wrote:
> Thanks Matt.  What is pthread_t on your system?  And are you sure that assigning NULL to it is putting it into a state that means "not a thread"?
>
> -Howard
>
> On Jun 2, 2010, at 3:35 AM, Matt Johnson wrote:
>
>> Hi,
>> Just thought I'd contribute a small patch that helped libcxx compile on
>> my machine using g++ 4.4.3 with -std=c++0x. Without it I got the
>> following message:
>>
>> + g++ -std=c++0x -c -g -Os -fPIC -nostdinc++ -I../include
>> ../src/condition_variable.cpp
>> In file included from ../src/condition_variable.cpp:11:
>> ../include/thread: In member function ‘std::__1::thread&
>> std::__1::thread::operator=(std::__1::thread&&)’:
>> ../include/thread:268: error: no match for ‘operator!=’ in
>> ‘((std::__1::thread*)this)->std::__1::thread::__t_ !=
>> std::__1::__get_nullptr_t()’
>> ../include/system_error:569: note: candidates are: bool
>> std::__1::operator!=(const std::__1::error_condition&, const
>> std::__1::error_condition&)
>> ../include/system_error:565: note: bool std::__1::operator!=(const
>> std::__1::error_condition&, const std::__1::error_code&)
>> ../include/system_error:561: note: bool std::__1::operator!=(const
>> std::__1::error_code&, const std::__1::error_condition&)
>> ../include/system_error:557: note: bool std::__1::operator!=(const
>> std::__1::error_code&, const std::__1::error_code&)
>> ../include/cstddef:73: note: bool
>> std::__1::operator!=(std::__1::nullptr_t, std::__1::nullptr_t)
>> ../include/thread:271: error: cannot convert ‘std::__1::nullptr_t’ to
>> ‘pthread_t’ in assignment
>>
>> This happens because nullptr is not convertible or comparable to
>> integral types (except bool), only pointers and pointer-to-members
>> (http://en.wikipedia.org/wiki/C%2B%2B0x#Null_pointer_constant), so you
>> can't use it to check or set __t, at least not directly. There's
>> probably a better way to do it than this, just thought I'd bring the
>> matter to your attention. For what it's worth, I haven't hacked the test
>> script to run on my machine yet so I haven't tested it, but it does
>> compile with minimal #warnings about exception_ptr not being implemented.
>>
>> mrj10 at mjlap:~/llvm/libcxx/include$ svn diff thread
>> Index: thread
>> ===================================================================
>> --- thread (revision 105315)
>> +++ thread (working copy)
>> @@ -265,10 +265,12 @@
>> thread&
>> thread::operator=(thread&& __t)
>> {
>> - if (__t_ != nullptr)
>> + //if (__t_ != nullptr)
>> + if (__t_ != NULL)
>> terminate();
>> __t_ = __t.__t_;
>> - __t.__t_ = nullptr;
>> + //__t.__t_ = nullptr;
>> + __t.__t_ = NULL;
>> return *this;
>> }
>>
>> Thanks,
>> Matt
>>
>> --
>> Matt Johnson
>> Graduate Student
>> University of Illinois at Urbana-Champaign, Dept. of ECE
>> Coordinated Science Lab, Rm. 213
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list