On 04/20/2011 04:43 PM, Eric Blake wrote:
> 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.
> +++ b/src/util/threads-win32.h
> @@ -1,7 +1,7 @@
>  /*
>   * threads-win32.h basic thread synchronization primitives
>   *
> - * Copyright (C) 2009 Red Hat, Inc.
> + * Copyright (C) 2009, 2011 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> @@ -41,3 +41,12 @@ struct virThread {
>  struct virThreadLocal {
>      DWORD key;
>  };
> +
> +struct virOnceControl {
> +    INIT_ONCE once;
> +};

Self-NAK - not all versions of Windows support INIT_ONCE yet,
http://msdn.microsoft.com/en-us/library/ms684122%28v=vs.85%29.aspx
states that applications must use InterlockedIncrement to set up their
own critical sections instead.

The idea is still doable, it just requires more work on the WIN32 side
of things.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to