Skip to content

Commit

Permalink
Add INVARIANTS support
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhub committed May 20, 2015
1 parent 7d44707 commit 595b333
Show file tree
Hide file tree
Showing 17 changed files with 378 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ LIB_C_FILES += freebsd/sys/libkern/fls.c
LIB_C_FILES += freebsd/sys/libkern/inet_ntoa.c
LIB_C_FILES += freebsd/sys/libkern/random.c
LIB_C_FILES += freebsd/sys/vm/uma_core.c
LIB_C_FILES += freebsd/sys/vm/uma_dbg.c
LIB_C_FILES += freebsd/sys/cam/cam.c
LIB_C_FILES += freebsd/sys/cam/scsi/scsi_all.c
LIB_C_FILES += freebsd/sys/crypto/sha1.c
Expand Down
2 changes: 2 additions & 0 deletions freebsd/sys/kern/kern_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,9 @@ knote_fdclose(struct thread *td, int fd)
struct knote *kn;
int influx;

#ifndef __rtems__
FILEDESC_XLOCK_ASSERT(fdp);
#endif /* __rtems__ */

/*
* We shouldn't have to worry about new kevents appearing on fd
Expand Down
2 changes: 2 additions & 0 deletions freebsd/sys/kern/kern_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,9 @@ intr_event_schedule_thread(struct intr_event *ie)
RANDOM_INTERRUPT);
}

#ifndef __rtems__
KASSERT(p != NULL, ("ithread %s has no process", ie->ie_name));
#endif /* __rtems__ */

/*
* Set it_need to tell the thread to keep running if it is already
Expand Down
4 changes: 4 additions & 0 deletions freebsd/sys/kern/kern_synch.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ _sleep(void *ident, struct lock_object *lock, int priority,
"Sleeping on \"%s\"", wmesg);
KASSERT(timo != 0 || mtx_owned(&Giant) || lock != NULL,
("sleeping without a lock"));
#ifndef __rtems__
KASSERT(p != NULL, ("msleep1"));
#endif /* __rtems__ */
KASSERT(ident != NULL && TD_IS_RUNNING(td), ("msleep"));
#ifndef __rtems__
if (priority & PDROP)
Expand Down Expand Up @@ -415,8 +417,10 @@ wakeup(void *ident)
wakeup_swapper = sleepq_broadcast(ident, SLEEPQ_SLEEP, 0, 0);
sleepq_release(ident);
if (wakeup_swapper) {
#ifndef __rtems__
KASSERT(ident != &proc0,
("wakeup and wakeup_swapper and proc0"));
#endif /* __rtems__ */
kick_proc0();
}
}
Expand Down
4 changes: 4 additions & 0 deletions freebsd/sys/kern/kern_timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,9 @@ _callout_stop_safe(c, safe)
KASSERT(!cc_cme_migrating(cc),
("callout wrongly scheduled for migration"));
CC_UNLOCK(cc);
#ifndef __rtems__
KASSERT(!sq_locked, ("sleepqueue chain locked"));
#endif /* __rtems__ */
return (1);
} else if ((c->c_flags & CALLOUT_DFRMIGRATION) != 0) {
c->c_flags &= ~CALLOUT_DFRMIGRATION;
Expand All @@ -1107,7 +1109,9 @@ _callout_stop_safe(c, safe)
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
c, c->c_func, c->c_arg);
CC_UNLOCK(cc);
#ifndef __rtems__
KASSERT(!sq_locked, ("sleepqueue chain still locked"));
#endif /* __rtems__ */
return (0);
}
#ifndef __rtems__
Expand Down
2 changes: 2 additions & 0 deletions freebsd/sys/kern/subr_sleepqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,10 @@ sleepq_add(void *wchan, struct lock_object *lock, const char *wmesg, int flags,
MPASS((queue >= 0) && (queue < NR_SLEEPQS));

/* If this thread is not allowed to sleep, die a horrible death. */
#ifndef __rtems__
KASSERT(!(td->td_pflags & TDP_NOSLEEPING),
("Trying sleep, but thread marked as sleeping prohibited"));
#endif /* __rtems__ */

/* Look up the sleep queue associated with the wait channel 'wchan'. */
sq = sleepq_lookup(wchan);
Expand Down
2 changes: 2 additions & 0 deletions freebsd/sys/kern/subr_taskqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ taskqueue_enqueue_timeout(struct taskqueue *queue,
TQ_LOCK(queue);
KASSERT(timeout_task->q == NULL || timeout_task->q == queue,
("Migrated queue"));
#ifndef __rtems__
KASSERT(!queue->tq_spin, ("Timeout for spin-queue"));
#endif /* __rtems__ */
timeout_task->q = queue;
res = timeout_task->t.ta_pending;
if (ticks == 0) {
Expand Down
2 changes: 2 additions & 0 deletions freebsd/sys/kern/subr_uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ uiomove_faultflag(void *cp, int n, struct uio *uio, int nofault)

KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE,
("uiomove: mode"));
#ifndef __rtems__
KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == td,
("uiomove proc"));
#endif /* __rtems__ */
if (!nofault)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"Calling uiomove()");
Expand Down
4 changes: 4 additions & 0 deletions freebsd/sys/sys/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,11 @@ int set_dumper(struct dumperinfo *);
int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t);
void dumpsys(struct dumperinfo *);
int doadump(boolean_t);
#ifndef __rtems__
extern int dumping; /* system is dumping */
#else /* __rtems__ */
#define dumping 0
#endif /* __rtems__ */

#endif /* _KERNEL */

Expand Down
4 changes: 4 additions & 0 deletions freebsd/sys/sys/proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,11 @@ do { \
#define TD_IS_SWAPPED(td) ((td)->td_inhibitors & TDI_SWAPPED)
#define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK)
#define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT)
#ifndef __rtems__
#define TD_IS_RUNNING(td) ((td)->td_state == TDS_RUNNING)
#else /* __rtems__ */
#define TD_IS_RUNNING(td) (1)
#endif /* __rtems__ */
#define TD_ON_RUNQ(td) ((td)->td_state == TDS_RUNQ)
#define TD_CAN_RUN(td) ((td)->td_state == TDS_CAN_RUN)
#define TD_IS_INHIBITED(td) ((td)->td_state == TDS_INHIBITED)
Expand Down

0 comments on commit 595b333

Please sign in to comment.