From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Thierry Subject: [PATCH kvmtool 03/16] brlock: fix build with KVM_BRLOCK_DEBUG Date: Thu, 7 Mar 2019 08:36:04 +0000 Message-ID: <1551947777-13044-4-git-send-email-julien.thierry@arm.com> References: <1551947777-13044-1-git-send-email-julien.thierry@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Andre.Przywara@arm.com, Sami.Mujawar@arm.com, will.deacon@arm.com, kvm@vger.kernel.org To: kvmarm@lists.cs.columbia.edu Return-path: In-Reply-To: <1551947777-13044-1-git-send-email-julien.thierry@arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org Build breaks when using KVM_BRLOCK_DEBUG because the header was seamingly conceived to be included in a single .c file... Fix this by moving the definition of the read/write lock into the kvm struct. Signed-off-by: Julien Thierry --- include/kvm/brlock.h | 10 ++++------ include/kvm/kvm.h | 4 ++++ kvm.c | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/kvm/brlock.h b/include/kvm/brlock.h index 29f72e0..1862210 100644 --- a/include/kvm/brlock.h +++ b/include/kvm/brlock.h @@ -21,13 +21,11 @@ #include "kvm/rwsem.h" -DECLARE_RWSEM(brlock_sem); +#define br_read_lock(kvm) down_read(&(kvm)->brlock_sem); +#define br_read_unlock(kvm) up_read(&(kvm)->brlock_sem); -#define br_read_lock(kvm) down_read(&brlock_sem); -#define br_read_unlock(kvm) up_read(&brlock_sem); - -#define br_write_lock(kvm) down_write(&brlock_sem); -#define br_write_unlock(kvm) up_write(&brlock_sem); +#define br_write_lock(kvm) down_write(&(kvm)->brlock_sem); +#define br_write_unlock(kvm) up_write(&(kvm)->brlock_sem); #else diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index 1edacfd..7a73818 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -81,6 +81,10 @@ struct kvm { int nr_disks; int vm_state; + +#ifdef KVM_BRLOCK_DEBUG + pthread_rwlock_t brlock_sem; +#endif }; void kvm__set_dir(const char *fmt, ...); diff --git a/kvm.c b/kvm.c index d5249a0..57c4ff9 100644 --- a/kvm.c +++ b/kvm.c @@ -160,6 +160,10 @@ struct kvm *kvm__new(void) kvm->sys_fd = -1; kvm->vm_fd = -1; +#ifdef KVM_BRLOCK_DEBUG + kvm->brlock_sem = (pthread_rwlock_t) PTHREAD_RWLOCK_INITIALIZER; +#endif + return kvm; } -- 1.9.1