Re: [PATCH] virthreadpthread: don't try to cast pthread_t to void*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/02/2013 06:05 AM, Guido Günther wrote:
> This fixes the build on kFreeBSD that otherwise fails with:
> 
> util/virthreadpthread.c: In function 'virThreadSelfID':
> util/virthreadpthread.c:222:27: error: cast from function call of type 'pthread_t' to non-matching type 'void *' [-Werror=bad-function-cast]
> ---
> I'm unsure why we'd need the cast to (void*) first.

EVERYTHING should be castable to void*.  That's lame that your compiler
is refusing to cast pthread_t.

I'm thinking that the solution will require writing a union, assign to
the pthread_t member of the union, and read out the int member, as the
only way we're going to shut up compilers.  We KNOW that casting
pthread_t isn't portable; but all we really want is a few bits that are
hopefully likely enough to be unique to make the use of virThreadSelfID
useful in debug messages.  We aren't relying on the conversion being a
1:1 mapping nor on trying to reverse the mapping.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]