mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-21 16:19:23 +08:00
fix[mpp_singleton]: fix init order issue
Platform: General Spec: all Error case: Constructors may be added after 65535(mpp_singleton_init) ex: mpp_platform added after 65535 when mpp_soc is refactored to c Signed-off-by: Hongjin Li <vic.hong@rock-chips.com> Signed-off-by: xiaoxu.chen <xiaoxu.chen@rock-chips.com> Change-Id: If736904beb0cd64a3e4ae3b20fd72e1198646ac7
This commit is contained in:
@@ -42,26 +42,31 @@ typedef struct MppSingletonInfo_t {
|
||||
void (*deinit)(void);
|
||||
} MppSingletonInfo;
|
||||
|
||||
#define SNGL_TO_STR(x) #x
|
||||
#define SNGL_TO_FUNC(x) __mpp_singleton_add_##x
|
||||
/* warning: constructor priorities from 0 to 100 are reserved for the implementation */
|
||||
#define SNGL_BASE_ID 101
|
||||
#define MPP_SINGLETON(id, name, init, deinit) \
|
||||
__attribute__((constructor)) \
|
||||
static void __mpp_singleton_add(void) { \
|
||||
/* increase id from base id to avoid compiler warning */ \
|
||||
__attribute__((constructor(SNGL_BASE_ID + id))) \
|
||||
static void SNGL_TO_FUNC(name)(void) { \
|
||||
MppSingletonInfo info = { \
|
||||
id, \
|
||||
name, \
|
||||
SNGL_TO_STR(name), \
|
||||
init, \
|
||||
deinit, \
|
||||
}; \
|
||||
mpp_singleton_add(&info); \
|
||||
mpp_singleton_add(&info, __FUNCTION__); \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
rk_s32 mpp_singleton_add(MppSingletonInfo *info);
|
||||
rk_s32 mpp_singleton_add(MppSingletonInfo *info, const char *caller);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MPP_SINGLETON_H__ */
|
||||
#endif /* __MPP_SINGLETON_H__ */
|
||||
|
Reference in New Issue
Block a user