Fix INVARIANTS support

This commit is contained in:
Sebastian Huber
2017-05-18 09:35:46 +02:00
parent 5be4f06fa8
commit 62c8ca0ead
10 changed files with 138 additions and 195 deletions

View File

@@ -2108,8 +2108,10 @@ static void
kqueue_destroy(struct kqueue *kq)
{
#ifndef __rtems__
KASSERT(kq->kq_fdp == NULL,
("kqueue still attached to a file descriptor"));
#endif /* __rtems__ */
seldrain(&kq->kq_sel);
knlist_destroy(&kq->kq_sel.si_note);
mtx_destroy(&kq->kq_lock);

View File

@@ -84,8 +84,10 @@ lock_init(struct lock_object *lock, struct lock_class *class, const char *name,
int i;
/* Check for double-init and zero object. */
#ifndef __rtems__
KASSERT(flags & LO_NEW || !lock_initialized(lock),
("lock \"%s\" %p already initialized", name, lock));
#endif /* __rtems__ */
/* Look up lock class to find its index. */
for (i = 0; i < LOCK_CLASS_MAX; i++)

View File

@@ -112,6 +112,7 @@ void _rm_assert(const struct rmlock *rm, int what, const char *file,
#define rm_rlock(rm, tracker) do { (void)tracker; rw_rlock(rm); } while (0)
#define rm_runlock(rm, tracker) do { (void)tracker; rw_runlock(rm); } while (0)
#define rm_sleep rw_sleep
#define _rm_assert _rw_assert
#endif /* __rtems__ */

View File

@@ -164,6 +164,10 @@ int _rw_try_rlock(struct rwlock *rw, const char *file, int line);
void _rw_runlock(struct rwlock *rw, const char *file, int line);
int _rw_try_upgrade(struct rwlock *rw, const char *file, int line);
void _rw_downgrade(struct rwlock *rw, const char *file, int line);
#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
void _rw_assert(const struct rwlock *rw, int what, const char *file,
int line);
#endif
#endif /* __rtems__ */
#ifndef __rtems__

View File

@@ -105,7 +105,11 @@ enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
VM_GUEST_VMWARE, VM_GUEST_KVM, VM_LAST };
#if defined(WITNESS) || defined(INVARIANT_SUPPORT)
#ifndef __rtems__
void kassert_panic(const char *fmt, ...) __printflike(1, 2);
#else /* __rtems__ */
#define kassert_panic panic
#endif /* __rtems__ */
#endif
#ifdef INVARIANTS /* The option is always available */

View File

@@ -2204,8 +2204,10 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"uma_zalloc_arg: zone \"%s\"", zone->uz_name);
}
#ifndef __rtems__
KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
("uma_zalloc_arg: called with spinlock or critical section held"));
#endif /* __rtems__ */
#ifdef DEBUG_MEMGUARD
if (memguard_cmp_zone(zone)) {
@@ -2742,8 +2744,10 @@ uma_zfree_arg(uma_zone_t zone, void *item, void *udata)
CTR2(KTR_UMA, "uma_zfree_arg thread %x zone %s", curthread,
zone->uz_name);
#ifndef __rtems__
KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
("uma_zfree_arg: called with spinlock or critical section held"));
#endif /* __rtems__ */
/* uma_zfree(..., NULL) does nothing, to match free(9). */
if (item == NULL)