aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/file.h
diff options
context:
space:
mode:
authorAttilio Rao <attilio@FreeBSD.org>2008-05-25 14:57:43 +0000
committerAttilio Rao <attilio@FreeBSD.org>2008-05-25 14:57:43 +0000
commit258f4727f17d184968106445cf521025a6a2f5fb (patch)
treeefe0ea20cbccbb0a37624368357258c8142915a2 /sys/sys/file.h
parent0e72a03405be056f3142fb1838e11aef5c6898f6 (diff)
downloadsrc-258f4727f17d184968106445cf521025a6a2f5fb.tar.gz
src-258f4727f17d184968106445cf521025a6a2f5fb.zip
Notes
Diffstat (limited to 'sys/sys/file.h')
-rw-r--r--sys/sys/file.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/sys/file.h b/sys/sys/file.h
index e3fdd6027bcb..3b054404d6ac 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -39,6 +39,7 @@
#include <sys/unistd.h>
#else
#include <sys/queue.h>
+#include <sys/refcount.h>
#include <sys/_lock.h>
#include <sys/_mutex.h>
@@ -116,7 +117,7 @@ struct file {
short f_type; /* descriptor type */
short f_vnread_flags; /* (f) Sleep lock for f_offset */
volatile u_int f_flag; /* see fcntl.h */
- volatile int f_count; /* reference count */
+ volatile u_int f_count; /* reference count */
/*
* DTYPE_VNODE specific fields.
*/
@@ -196,9 +197,10 @@ int fgetvp_write(struct thread *td, int fd, struct vnode **vpp);
int fgetsock(struct thread *td, int fd, struct socket **spp, u_int *fflagp);
void fputsock(struct socket *sp);
-#define fhold(fp) atomic_add_int(&(fp)->f_count, 1)
+#define fhold(fp) \
+ (refcount_acquire(&(fp)->f_count))
#define fdrop(fp, td) \
- (atomic_fetchadd_int(&(fp)->f_count, -1) <= 1 ? _fdrop((fp), (td)) : 0)
+ (refcount_release(&(fp)->f_count) ? _fdrop((fp), (td)) : 0)
static __inline fo_rdwr_t fo_read;
static __inline fo_rdwr_t fo_write;