]> git.ipfire.org Git - thirdparty/libvirt.git/commit
threads: add one-time initialization support
authorEric Blake <eblake@redhat.com>
Wed, 20 Apr 2011 22:26:00 +0000 (16:26 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 25 Apr 2011 14:53:09 +0000 (08:53 -0600)
commit99de59900a127d893c85fbee4d8fe0323a3b81c0
treea6e6132b9e6a3bc91a29aba2caebf24872f8dd52
parent061956ccc7774c49806d56a42753f193ffe8700b
threads: add one-time initialization support

mingw lacks the counterpart to PTHREAD_MUTEX_INITIALIZER, so the
best we can do is portably expose once-only runtime initialization.

* src/util/threads.h (virOnceControlPtr): New opaque type.
(virOnceFunc): New callback type.
(virOnce): New prototype.
* src/util/threads-pthread.h (virOnceControl): Declare.
(VIR_ONCE_CONTROL_INITIALIZER): Define.
* src/util/threads-win32.h (virOnceControl)
(VIR_ONCE_CONTROL_INITIALIZER): Likewise.
* src/util/threads-pthread.c (virOnce): Implement in pthreads.
* src/util/threads-win32.c (virOnce): Implement in WIN32.
* src/libvirt_private.syms: Export it.
src/libvirt_private.syms
src/util/threads-pthread.c
src/util/threads-pthread.h
src/util/threads-win32.c
src/util/threads-win32.h
src/util/threads.h