summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys/refcount.h
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/sys/refcount.h')
-rw-r--r--freebsd/sys/sys/refcount.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/freebsd/sys/sys/refcount.h b/freebsd/sys/sys/refcount.h
index b169f542..4611664e 100644
--- a/freebsd/sys/sys/refcount.h
+++ b/freebsd/sys/sys/refcount.h
@@ -29,6 +29,7 @@
#ifndef __SYS_REFCOUNT_H__
#define __SYS_REFCOUNT_H__
+#include <sys/limits.h>
#include <machine/atomic.h>
#ifdef _KERNEL
@@ -48,11 +49,8 @@ static __inline void
refcount_acquire(volatile u_int *count)
{
-#ifndef __rtems__
+ KASSERT(*count < UINT_MAX, ("refcount %p overflowed", count));
atomic_add_acq_int(count, 1);
-#else /* __rtems__ */
- atomic_add_acq_int((volatile int *) count, 1);
-#endif /* __rtems__ */
}
static __inline int
@@ -61,11 +59,7 @@ refcount_release(volatile u_int *count)
u_int old;
/* XXX: Should this have a rel membar? */
-#ifndef __rtems__
old = atomic_fetchadd_int(count, -1);
-#else /* __rtems__ */
- old = atomic_fetchadd_int((volatile int *) count, -1);
-#endif /* __rtems__ */
KASSERT(old > 0, ("negative refcount %p", count));
return (old == 1);
}