Re: MinGW patch

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

 



"Richard W.M. Jones" <rjones@xxxxxxxxxx> wrote:
> I got about 95% of the way towards compiling on MinGW using the MinGW
> cross-compiler from http://mirzam.it.vu.nl/mingw/.  Attached are some
> fairly non-controversial patches which fix some of the problems I
> found.  Build notes follow below.
...
> Index: src/hash.c
> ===================================================================
> RCS file: /data/cvs/libvirt/src/hash.c,v
> retrieving revision 1.36
> diff -u -r1.36 hash.c
> --- src/hash.c	10 Apr 2008 16:53:29 -0000	1.36
> +++ src/hash.c	17 Apr 2008 18:55:16 -0000
> @@ -25,7 +25,10 @@
>  #include <libxml/threads.h>
>  #include "internal.h"
>  #include "hash.h"
> +
> +#if HAVE_PTHREAD_H
>  #include <pthread.h>
> +#endif

Hi Rich,

Looks good.
You might want to define-away the pthread_* functions instead.
With definitions something like this (untested) you can remove
all of those in-function #if directives.

#if HAVE_PTHREAD_H
# include <pthread.h>
#else
# define pthread_mutex_init(a, b) /* empty */
# define pthread_mutex_lock(a) /* empty */
# define pthread_mutex_unlock(a) /* empty */
# define pthread_mutex_destroy(a) /* empty */
#endif

>
>  #define MAX_HASH_LEN 8
>
> @@ -713,7 +716,9 @@
>      if (ret->storageVols == NULL)
>          goto failed;
>
> +#if HAVE_LIBPTHREAD
>      pthread_mutex_init(&ret->lock, NULL);
> +#endif
>
>      ret->refs = 1;
>      return(ret);
> @@ -729,7 +734,9 @@
>          if (ret->storageVols != NULL)
>              virHashFree(ret->storageVols, (virHashDeallocator) virStorageVolFreeName);
>
> +#if HAVE_LIBPTHREAD
>          pthread_mutex_destroy(&ret->lock);
> +#endif
>          free(ret);
>      }
>      return(NULL);
> @@ -762,8 +769,10 @@
>
>      free(conn->name);
>
> +#if HAVE_LIBPTHREAD
>      pthread_mutex_unlock(&conn->lock);
>      pthread_mutex_destroy(&conn->lock);
> +#endif
>      free(conn);
>  }
>
> @@ -784,7 +793,9 @@
>          virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
>          return(-1);
>      }
> +#if HAVE_LIBPTHREAD
>      pthread_mutex_lock(&conn->lock);
> +#endif
>      DEBUG("unref connection %p %s %d", conn, conn->name, conn->refs);
>      conn->refs--;
>      refs = conn->refs;
> @@ -793,7 +804,9 @@
>          /* Already unlocked mutex */
>          return (0);
>      }
> +#if HAVE_LIBPTHREAD
>      pthread_mutex_unlock(&conn->lock);
> +#endif
>      return (refs);
>  }
>
> @@ -818,7 +831,9 @@
>          virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
>          return(NULL);
>      }
> +#if HAVE_LIBPTHREAD
>      pthread_mutex_lock(&conn->lock);
> +#endif
>
>      /* TODO search by UUID first as they are better differenciators */
>
> @@ -849,11 +864,15 @@
>          conn->refs++;
>      }
>      ret->refs++;
> +#if HAVE_LIBPTHREAD
>      pthread_mutex_unlock(&conn->lock);
> +#endif
>      return(ret);
>
>   error:
> +#if HAVE_LIBPTHREAD
>      pthread_mutex_unlock(&conn->lock);
> +#endif
...

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]