diff options
author | Roger Pau Monne <roger.pau@entel.upc.edu> | 2012-01-27 17:48:14 +0000 |
---|---|---|
committer | Roger Pau Monne <roger.pau@entel.upc.edu> | 2012-01-27 17:48:14 +0000 |
commit | ade17521489197781e655b78f2e0d30eff5b4ab6 (patch) | |
tree | 501f80551af4e5c17cc22992c1778a7f24c56154 /tools/libxl/libxl_internal.c | |
parent | 34710f4a96bf73d9ef12528bffc560cf8e980ddd (diff) | |
download | xen-ade17521489197781e655b78f2e0d30eff5b4ab6.tar.gz xen-ade17521489197781e655b78f2e0d30eff5b4ab6.tar.bz2 xen-ade17521489197781e655b78f2e0d30eff5b4ab6.zip |
libxl: fix mutex initialization
The macro PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP is not defined on
NetBSD, so define mutex attributes manually.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_internal.c')
-rw-r--r-- | tools/libxl/libxl_internal.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index 49b0dabea7..12c32dce09 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -296,6 +296,33 @@ _hidden int libxl__compare_macs(libxl_mac *a, libxl_mac *b) return 0; } +_hidden int libxl__init_recursive_mutex(libxl_ctx *ctx, pthread_mutex_t *lock) +{ + pthread_mutexattr_t attr; + int rc = 0; + + if (pthread_mutexattr_init(&attr) != 0) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + "Failed to init mutex attributes\n"); + return ERROR_FAIL; + } + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + "Failed to set mutex attributes\n"); + rc = ERROR_FAIL; + goto out; + } + if (pthread_mutex_init(lock, &attr) != 0) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + "Failed to init mutex\n"); + rc = ERROR_FAIL; + goto out; + } +out: + pthread_mutexattr_destroy(&attr); + return rc; +} + libxl_device_model_version libxl__device_model_version_running(libxl__gc *gc, uint32_t domid) { |