diff options
author | Ambroz Bizjak <ambrop7@gmail.com> | 2014-12-21 00:25:30 +0300 |
---|---|---|
committer | Ambroz Bizjak <ambrop7@gmail.com> | 2014-12-21 00:25:30 +0300 |
commit | 872c7a87cc07cf58bf8feaf93d8dd9c767116639 (patch) | |
tree | c9ecf3800b3588ddcff7ec729fa736eef3a6b21e | |
parent | 2ed5eaaab79a200714186266306c7aca6bc1cd0b (diff) |
ncd: modules: blocker: Expose the up-state as a variable.
-rw-r--r-- | ncd/modules/blocker.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ncd/modules/blocker.c b/ncd/modules/blocker.c index d1f523c..4e7e668 100644 --- a/ncd/modules/blocker.c +++ b/ncd/modules/blocker.c @@ -35,6 +35,7 @@ * Description: provides blocking operations. Initially the blocking state is down (but this statement * does not block). On deinitialization, waits for all corresponding use() statements * to die before dying itself. + * Variables: string (empty) - the up-state (false or true). * * Synopsis: blocker::up() * Description: sets the blocking state to up. @@ -163,6 +164,18 @@ static void func_die (void *vo) o->dying = 1; } +static int func_getvar2 (void *vo, NCD_string_id_t name, NCDValMem *mem, NCDValRef *out) +{ + struct instance *o = vo; + + if (name == NCD_STRING_EMPTY) { + *out = ncd_make_boolean(mem, o->up, o->i->params->iparams->string_index); + return 1; + } + + return 0; +} + static void updown_func_new_templ (NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int up, int first_down) { ASSERT(!first_down || up) @@ -322,6 +335,7 @@ static struct NCDModule modules[] = { .type = "blocker", .func_new2 = func_new, .func_die = func_die, + .func_getvar2 = func_getvar2, .alloc_size = sizeof(struct instance) }, { .type = "blocker::up", |