diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-20 13:49:05 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-20 15:03:32 +0200 |
commit | 595b333ad2b40d3bb23ef03374b14e4b8dcf49db (patch) | |
tree | f2584c50dd82fe577dfb599eb82b7807f2a012d1 /rtemsbsd/rtems/rtems-bsd-sx.c | |
parent | Fix struct ucred warnings (diff) | |
download | rtems-libbsd-595b333ad2b40d3bb23ef03374b14e4b8dcf49db.tar.bz2 |
Add INVARIANTS support
Diffstat (limited to 'rtemsbsd/rtems/rtems-bsd-sx.c')
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-sx.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/rtemsbsd/rtems/rtems-bsd-sx.c b/rtemsbsd/rtems/rtems-bsd-sx.c index 46ab2d17..dcf3a009 100644 --- a/rtemsbsd/rtems/rtems-bsd-sx.c +++ b/rtemsbsd/rtems/rtems-bsd-sx.c @@ -7,7 +7,7 @@ */ /* - * Copyright (c) 2009-2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -39,6 +39,7 @@ #include <machine/rtems-bsd-kernel-space.h> #include <machine/rtems-bsd-muteximpl.h> +#include <machine/rtems-bsd-thread.h> #include <rtems/bsd/sys/param.h> #include <rtems/bsd/sys/types.h> @@ -71,6 +72,10 @@ struct lock_class lock_class_sx = { #endif }; +#define sx_xholder(sx) ((sx)->mutex.owner) + +#define sx_recursed(sx) ((sx)->mutex.nest_level != 0) + void assert_sx(struct lock_object *lock, int what) { @@ -177,9 +182,11 @@ _sx_downgrade(struct sx *sx, const char *file, int line) void _sx_assert(struct sx *sx, int what, const char *file, int line) { +#ifndef __rtems__ #ifndef WITNESS int slocked = 0; #endif +#endif /* __rtems__ */ if (panicstr != NULL) return; @@ -187,13 +194,16 @@ _sx_assert(struct sx *sx, int what, const char *file, int line) case SA_SLOCKED: case SA_SLOCKED | SA_NOTRECURSED: case SA_SLOCKED | SA_RECURSED: +#ifndef __rtems__ #ifndef WITNESS slocked = 1; /* FALLTHROUGH */ #endif +#endif /* __rtems__ */ case SA_LOCKED: case SA_LOCKED | SA_NOTRECURSED: case SA_LOCKED | SA_RECURSED: +#ifndef __rtems__ #ifdef WITNESS witness_assert(&sx->lock_object, what, file, line); #else @@ -221,10 +231,13 @@ _sx_assert(struct sx *sx, int what, const char *file, int line) } #endif break; +#else /* __rtems__ */ + /* FALLTHROUGH */ +#endif /* __rtems__ */ case SA_XLOCKED: case SA_XLOCKED | SA_NOTRECURSED: case SA_XLOCKED | SA_RECURSED: - if (sx_xholder(sx) != curthread) + if (sx_xholder(sx) != _Thread_Get_executing()) panic("Lock %s not exclusively locked @ %s:%d\n", sx->lock_object.lo_name, file, line); if (sx_recursed(sx)) { @@ -244,7 +257,7 @@ _sx_assert(struct sx *sx, int what, const char *file, int line) * reliably check to see if we hold a shared lock or * not. */ - if (sx_xholder(sx) == curthread) + if (sx_xholder(sx) == _Thread_Get_executing()) panic("Lock %s exclusively locked @ %s:%d\n", sx->lock_object.lo_name, file, line); #endif |