From b0500d628632d99011253a69008fc28399c272d0 Mon Sep 17 00:00:00 2001 From: pk Date: Sun, 16 May 2004 17:48:18 +0000 Subject: [PATCH] Provide a version of FILE_UNUSE() for cases where we already hold the file's lock. --- sys/sys/file.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/sys/file.h b/sys/sys/file.h index 72054897045f..7fe79b1e1c43 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -1,4 +1,4 @@ -/* $NetBSD: file.h,v 1.49 2004/04/25 16:42:43 simonb Exp $ */ +/* $NetBSD: file.h,v 1.50 2004/05/16 17:48:18 pk Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -123,9 +123,10 @@ do { \ simple_unlock(&(fp)->f_slock); \ } while (/* CONSTCOND */ 0) -#define FILE_UNUSE(fp, p) \ +#define FILE_UNUSE_WLOCK(fp, p, havelock) \ do { \ - simple_lock(&(fp)->f_slock); \ + if (!(havelock)) \ + simple_lock(&(fp)->f_slock); \ if ((fp)->f_iflags & FIF_WANTCLOSE) { \ simple_unlock(&(fp)->f_slock); \ /* Will drop usecount */ \ @@ -137,6 +138,8 @@ do { \ } \ simple_unlock(&(fp)->f_slock); \ } while (/* CONSTCOND */ 0) +#define FILE_UNUSE(fp, p) FILE_UNUSE_WLOCK(fp, p, 0) +#define FILE_UNUSE_HAVELOCK(fp, p) FILE_UNUSE_WLOCK(fp, p, 1) /* * Flags for fo_read and fo_write.