]> 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>
Mon, 6 May 2013 20:19:35 +0000 (14:19 -0600)
commitfc8a23101826eedcc0114c7868f0f02c07734857
tree6f87026f11b21da2abb8b09e8db9cfc0e5964522
parent832049ca2903db1240782e1acab0355327ee735d
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>
(cherry picked from commit 22d12905e612de93944b4413ae3fbd278df52fe8)
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