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

Re: [libvirt] [PATCHv2 1/2] build: avoid pthreads-win32 on mingw



On Wed, Jun 09, 2010 at 02:49:35PM -0600, Eric Blake wrote:
> * src/util/threads.c (includes) [WIN32]: On mingw, favor native
> threading over pthreads-win32 library.
> * src/util/thread.h [WIN32] Likewise.
> Suggested by Daniel P. Berrange.
> ---
> 
> Changes from v1: new patch:
> 
> On 06/03/2010 08:02 AM, Daniel P. Berrange wrote:
> >>> So, is the libvirt patch worth installing, while we wait for the
> >>> eventual fix of dependencies to not force mingw32-pthreads on 64-bit users?
> >> 
> >> How about changing configure.ac so that it defaults to looking for win32
> >> threads on Win32, rather than trying pthreads
> >That would also be a useful patch, but seems like it would be
> >insufficient on its own.  In other words, there are two issues here -
> >dealing with a broken <pthread.h> if it gets pulled in (which, for
> >example, it WILL be pulled in by gnulib if it exists since it defines
> >struct timespec, even if we don't use it for anything pthread-related),
> >and the issue of whether we should favor pthread or win32 threading.
> 
> It turns out to not be a configure.ac issue at all.  I tested that
> patch 1/2, in isolation, solves the struct timespec issue that I
> was seeing on mingw by not pulling in pthreads-win32 code, but does
> not solve remaining mingw issues.  And patch 2/2, in isolation,
> compiles clean but doesn't avoid pthreads-win32.
> 
> So, okay to push both patches?
> 
>  src/util/threads-win32.c |    2 +-
>  src/util/threads.c       |   12 ++++++------
>  src/util/threads.h       |   10 ++++------
>  3 files changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/src/util/threads-win32.c b/src/util/threads-win32.c
> index e478560..fe1fcd0 100644
> --- a/src/util/threads-win32.c
> +++ b/src/util/threads-win32.c
> @@ -1,7 +1,7 @@
>  /*
>   * threads-win32.c: basic thread synchronization primitives
>   *
> - * Copyright (C) 2009 Red Hat, Inc.
> + * Copyright (C) 2009-2010 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
> diff --git a/src/util/threads.c b/src/util/threads.c
> index 8c0a91a..4ebce56 100644
> --- a/src/util/threads.c
> +++ b/src/util/threads.c
> @@ -23,12 +23,12 @@
> 
>  #include "threads.h"
> 
> -#ifdef HAVE_PTHREAD_MUTEXATTR_INIT
> +/* On mingw, we prefer native threading over the sometimes-broken
> + * pthreads-win32 library wrapper.  */
> +#ifdef WIN32
> +# include "threads-win32.c"
> +#elif defined HAVE_PTHREAD_MUTEXATTR_INIT
>  # include "threads-pthread.c"
>  #else
> -# ifdef WIN32
> -#  include "threads-win32.c"
> -# else
> -#  error "Either pthreads or Win32 threads are required"
> -# endif
> +# error "Either pthreads or Win32 threads are required"
>  #endif
> diff --git a/src/util/threads.h b/src/util/threads.h
> index 8b2be8d..db54ea0 100644
> --- a/src/util/threads.h
> +++ b/src/util/threads.h
> @@ -61,14 +61,12 @@ int virThreadLocalInit(virThreadLocalPtr l,
>  void *virThreadLocalGet(virThreadLocalPtr l);
>  void virThreadLocalSet(virThreadLocalPtr l, void*);
> 
> -# ifdef HAVE_PTHREAD_MUTEXATTR_INIT
> +# ifdef WIN32
> +#  include "threads-win32.h"
> +# elif defined HAVE_PTHREAD_MUTEXATTR_INIT
>  #  include "threads-pthread.h"
>  # else
> -#  ifdef WIN32
> -#   include "threads-win32.h"
> -#  else
> -#   error "Either pthreads or Win32 threads are required"
> -#  endif
> +#  error "Either pthreads or Win32 threads are required"
>  # endif
> 
>  #endif
> -- 

ACK


Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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