소스 검색

ncd: NCDModule: add flags field and migrate "can_resolve_when_down" field into a flag

ambrop7 13 년 전
부모
커밋
cd0a213dae
7개의 변경된 파일22개의 추가작업 그리고 17개의 파일을 삭제
  1. 1 1
      ncd/NCDModule.c
  2. 9 4
      ncd/NCDModule.h
  3. 2 2
      ncd/modules/call.c
  4. 7 7
      ncd/modules/call2.c
  5. 1 1
      ncd/modules/depend.c
  6. 1 1
      ncd/modules/dynamic_depend.c
  7. 1 1
      ncd/modules/multidepend.c

+ 1 - 1
ncd/NCDModule.c

@@ -273,7 +273,7 @@ static int can_resolve (NCDModuleInst *n)
         case STATE_DOWN_UNCLEAN:
         case STATE_DOWN_PCLEAN:
         case STATE_DOWN_DIE:
-            return n->m->can_resolve_when_down;
+            return !!(n->m->flags & NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN);
         default:
             return 0;
     }

+ 9 - 4
ncd/NCDModule.h

@@ -698,6 +698,8 @@ typedef int (*NCDModule_func_getobj) (void *o, const char *name, NCDObject *out_
  */
 typedef void (*NCDModule_func_clean) (void *o);
 
+#define NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN (1 << 0)
+
 /**
  * Structure encapsulating the implementation of a module backend.
  */
@@ -746,11 +748,14 @@ struct NCDModule {
     NCDModule_func_clean func_clean;
     
     /**
-     * Whether the interpreter is allowed to call func_getvar and func_getobj
-     * even when the backend instance is in down state (as opposed to just
-     * in up state).
+     * Various flags.
+     * 
+     * - NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
+     *   Whether the interpreter is allowed to call func_getvar and func_getobj
+     *   even when the backend instance is in down state (as opposed to just
+     *   in up state.
      */
-    int can_resolve_when_down;
+    int flags;
 };
 
 /**

+ 2 - 2
ncd/modules/call.c

@@ -358,14 +358,14 @@ static const struct NCDModule modules[] = {
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = "callrefhere::call",
         .func_new = func_new,
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = NULL
     }

+ 7 - 7
ncd/modules/call2.c

@@ -432,49 +432,49 @@ static const struct NCDModule modules[] = {
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = "call2_if",
         .func_new = func_new_call_if,
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = "call2_ifelse",
         .func_new = func_new_call_ifelse,
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = "embcall2",
         .func_new = func_new_embcall,
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = "embcall2_if",
         .func_new = func_new_embcall_if,
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = "embcall2_ifelse",
         .func_new = func_new_embcall_ifelse,
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = "embcall2_multif",
         .func_new = func_new_embcall_multif,
         .func_die = func_die,
         .func_clean = func_clean,
         .func_getobj = func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = NULL
     }

+ 1 - 1
ncd/modules/depend.c

@@ -433,7 +433,7 @@ static const struct NCDModule modules[] = {
         .func_die = depend_func_die,
         .func_clean = depend_func_clean,
         .func_getobj = depend_func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = NULL
     }

+ 1 - 1
ncd/modules/dynamic_depend.c

@@ -518,7 +518,7 @@ static const struct NCDModule modules[] = {
         .func_die = depend_func_die,
         .func_clean = depend_func_clean,
         .func_getobj = depend_func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = NULL
     }

+ 1 - 1
ncd/modules/multidepend.c

@@ -383,7 +383,7 @@ static const struct NCDModule modules[] = {
         .func_die = depend_func_die,
         .func_clean = depend_func_clean,
         .func_getobj = depend_func_getobj,
-        .can_resolve_when_down = 1
+        .flags = NCDMODULE_FLAG_CAN_RESOLVE_WHEN_DOWN
     }, {
         .type = NULL
     }