]> git.ipfire.org Git - thirdparty/libvirt.git/commit
build: avoid non-portable cast of pthread_t
authorEric Blake <eblake@redhat.com>
Thu, 2 May 2013 20:23:02 +0000 (14:23 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 3 May 2013 12:30:22 +0000 (06:30 -0600)
commit22d12905e612de93944b4413ae3fbd278df52fe8
tree3e618d0f11f448eb2f49ccd94d6ee033c9c1b3c2
parent9eafa251164e2bbaeefce5be025958c8b789bf7a
build: avoid non-portable cast of pthread_t

POSIX says pthread_t is opaque.  We can't guarantee if it is scaler
or a pointer, nor what size it is; and BSD differs from Linux.
We've also had reports of gcc complaining on attempts to cast it,
if we use a cast to the wrong type (for example, pointers have to be
cast to void* or intptr_t before being narrowed; while casting a
function return of scalar pthread_t to void* triggers a different
warning).

Give up on casts, and use unions to get at decent bits instead.  And
rather than futz around with figuring which 32 bits of a potentially
64-bit pointer are most likely to be unique, convert the rest of
the code base to use 64-bit values when using a debug id.

Based on a report by Guido Günther against kFreeBSD, but with a
fix that doesn't regress commit 4d970fd29 for FreeBSD.

* src/util/virthreadpthread.c (virThreadSelfID, virThreadID): Use
union to get at a decent bit representation of thread_t bits.
* src/util/virthread.h (virThreadSelfID, virThreadID): Alter
signature.
* src/util/virthreadwin32.c (virThreadSelfID, virThreadID):
Likewise.
* src/qemu/qemu_domain.h (qemuDomainJobObj): Alter type of owner.
* src/qemu/qemu_domain.c (qemuDomainObjTransferJob)
(qemuDomainObjSetJobPhase, qemuDomainObjReleaseAsyncJob)
(qemuDomainObjBeginNestedJob, qemuDomainObjBeginJobInternal): Fix
clients.
* src/util/virlog.c (virLogFormatString): Likewise.
* src/util/vireventpoll.c (virEventPollInterruptLocked):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/util/vireventpoll.c
src/util/virlog.c
src/util/virthread.h
src/util/virthreadpthread.c
src/util/virthreadwin32.c