aboutsummaryrefslogtreecommitdiffstats
path: root/src/framework/init/fw_module.h
blob: 1cfc95f517ca12700005c2de7a31008faeb780ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
*
* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef _FW_MODULE
#define _FW_MODULE
#include <pthread.h>

#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C"{
/* *INDENT-ON* */
#endif /* _cplusplus */

#include "nsfw_init.h"

/* Unique name declare */
#define NSFW__STRINGIFY(x) #x
#define NSFW_STRINGIFY(x) NSFW__STRINGIFY(x)

#define NSFW__PASTE(a,b) a##b
#define NSFW_PASTE(a,b) NSFW__PASTE(a,b)

#define NSFW_UNIQUE_ID(prefix) NSFW_PASTE(NSFW_PASTE(__LINE__, prefix), __COUNTER__)

#define NSFW_MODULE_INITFN(_fn) \
    static int _fn(void* param)
extern nsfw_module_depends_t *nsfw_module_create_depends (char *name);

#define NSFW_MODULE_SET_STATE(inst, state) ((inst)->stat = (state))

typedef struct _nsfw_module_doneNode
{
  nsfw_module_instance_t *inst;
  struct _nsfw_module_doneNode *next;
} nsfw_module_doneNode_t;

typedef struct _nsfw_module_manager
{
  pthread_mutex_t initMutex;
  int done;                     // 0 - not finished, 1 - finished, -1 - error
  nsfw_module_instance_t *inst;
  nsfw_module_doneNode_t *doneHead;
} nsfw_module_manager_t;

extern int nsfw_module_addDoneNode (nsfw_module_instance_t * inst);

extern nsfw_module_manager_t g_nsfw_module_manager;
#define nsfw_module_getManager() (&g_nsfw_module_manager)

#define NSFW_MOUDLE_INSTANCE_POOL_SIZE 64
#define NSFW_MOUDLE_DEPENDS_POOL_SIZE 128

typedef struct _nsfw_module_instance_pool
{
  int last_idx;
    nsfw_module_instance_t
    module_instance_pool[NSFW_MOUDLE_INSTANCE_POOL_SIZE];
} nsfw_module_instance_pool_t;

typedef struct _nsfw_module_depends_pool
{
  int last_idx;
  nsfw_module_depends_t module_depends_pool[NSFW_MOUDLE_DEPENDS_POOL_SIZE];
} nsfw_module_depends_pool_t;

#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif /* _cplusplus */

#endif /* _FW_MODULE */