mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-22 15:47:37 +00:00
Switch the rest of the refcount(9) functions to bool return type.
There are some explicit comparisions of refcount_release(9) result with 0/1, which are fine. Reviewed by: markj, mjg Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21014
This commit is contained in:
parent
d4828bcfc7
commit
13ff4eb1fa
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=350204
@ -26,7 +26,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 20, 2009
|
||||
.Dd July 21, 2019
|
||||
.Dt REFCOUNT 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -42,7 +42,7 @@
|
||||
.Fn refcount_init "volatile u_int *count" "u_int value"
|
||||
.Ft void
|
||||
.Fn refcount_acquire "volatile u_int *count"
|
||||
.Ft int
|
||||
.Ft bool
|
||||
.Fn refcount_release "volatile u_int *count"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
@ -73,9 +73,9 @@ protection for acquiring a new reference.
|
||||
The
|
||||
.Fn refcount_release
|
||||
function is used to release an existing reference.
|
||||
The function returns a non-zero value if the reference being released was
|
||||
The function returns true if the reference being released was
|
||||
the last reference;
|
||||
otherwise, it returns zero.
|
||||
otherwise, it returns false.
|
||||
.Pp
|
||||
Note that these routines do not provide any inter-CPU synchronization,
|
||||
data protection,
|
||||
@ -89,7 +89,7 @@ is released.
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Nm refcount_release
|
||||
function returns non-zero when releasing the last reference and zero when
|
||||
function returns true when releasing the last reference and false when
|
||||
releasing any other reference.
|
||||
.Sh HISTORY
|
||||
These functions were introduced in
|
||||
|
@ -69,7 +69,7 @@ refcount_acquire_checked(volatile u_int *count)
|
||||
}
|
||||
}
|
||||
|
||||
static __inline int
|
||||
static __inline bool
|
||||
refcount_release(volatile u_int *count)
|
||||
{
|
||||
u_int old;
|
||||
@ -78,7 +78,7 @@ refcount_release(volatile u_int *count)
|
||||
old = atomic_fetchadd_int(count, -1);
|
||||
KASSERT(old > 0, ("refcount %p is zero", count));
|
||||
if (old > 1)
|
||||
return (0);
|
||||
return (false);
|
||||
|
||||
/*
|
||||
* Last reference. Signal the user to call the destructor.
|
||||
@ -87,14 +87,14 @@ refcount_release(volatile u_int *count)
|
||||
* at the start of the function synchronized with this fence.
|
||||
*/
|
||||
atomic_thread_fence_acq();
|
||||
return (1);
|
||||
return (true);
|
||||
}
|
||||
|
||||
/*
|
||||
* This functions returns non-zero if the refcount was
|
||||
* incremented. Else zero is returned.
|
||||
*/
|
||||
static __inline __result_use_check int
|
||||
static __inline __result_use_check bool
|
||||
refcount_acquire_if_not_zero(volatile u_int *count)
|
||||
{
|
||||
u_int old;
|
||||
@ -103,13 +103,13 @@ refcount_acquire_if_not_zero(volatile u_int *count)
|
||||
for (;;) {
|
||||
KASSERT(old < UINT_MAX, ("refcount %p overflowed", count));
|
||||
if (old == 0)
|
||||
return (0);
|
||||
return (false);
|
||||
if (atomic_fcmpset_int(count, &old, old + 1))
|
||||
return (1);
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
static __inline __result_use_check int
|
||||
static __inline __result_use_check bool
|
||||
refcount_release_if_not_last(volatile u_int *count)
|
||||
{
|
||||
u_int old;
|
||||
@ -118,9 +118,9 @@ refcount_release_if_not_last(volatile u_int *count)
|
||||
for (;;) {
|
||||
KASSERT(old > 0, ("refcount %p is zero", count));
|
||||
if (old == 1)
|
||||
return (0);
|
||||
return (false);
|
||||
if (atomic_fcmpset_int(count, &old, old - 1))
|
||||
return (1);
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user