Skip to contentSkip to conversation

eal: use eal abstraction for defining constructors

PATCH Applied Jerin Jacob Kollanukkaran 3 participants 3 messages Mar 18, 2019 – Mar 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: use eal abstraction for defining constructors

From: Jerin Jacob <[email protected]>

Use eal's RTE_INIT abstraction for defining constructors.

---
 app/test-bbdev/main.h            | 3 +--
 app/test/resource.h              | 2 +-
 app/test/test.h                  | 3 +--
 lib/librte_mempool/rte_mempool.h | 7 +++----
 4 files changed, 6 insertions(+), 9 deletions(-)
app/test-bbdev/main.h +1 -2
index 20a55efca..2bbe1b822 100644
@@ -103,8 +103,7 @@ void add_test_command(struct test_command *t);
 		.command = RTE_STR(name), \
 		.callback = test_func_##name, \
 	}; \
-	static void __attribute__((constructor, used)) \
-	test_register_##name(void) \
+	RTE_INIT(test_register_##name) \
 	{ \
 		add_test_command(&test_struct_##name); \
 	}
app/test/resource.h +1 -1
index 223fa22ae..c75ebd4b5 100644
@@ -98,7 +98,7 @@ static struct resource linkres_ ##n = {       \
 	.begin = b,             \
 	.end = e,               \
 };                              \
-static void __attribute__((constructor, used)) resinitfn_ ##n(void) \
+RTE_INIT(resinitfn_ ##n)	\
 {                               \
 	resource_register(&linkres_ ##n);  \
 }
app/test/test.h +1 -2
index 7c2443230..9b3846b1e 100644
@@ -177,8 +177,7 @@ void add_test_command(struct test_command *t);
 		.command = RTE_STR(cmd), \
 		.callback = func, \
 	}; \
-	static void __attribute__((constructor, used)) \
-	test_register_##cmd(void) \
+	RTE_INIT(test_register_##cmd) \
 	{ \
 		add_test_command(&test_struct_##cmd); \
 	}
lib/librte_mempool/rte_mempool.h +3 -4
index 7c9cd9a2f..fd19470d7 100644
@@ -832,10 +832,9 @@ int rte_mempool_register_ops(const struct rte_mempool_ops *ops);
  * Note that the rte_mempool_register_ops fails silently here when
  * more than RTE_MEMPOOL_MAX_OPS_IDX is registered.
  */
-#define MEMPOOL_REGISTER_OPS(ops)					\
-	void mp_hdlr_init_##ops(void);					\
-	void __attribute__((constructor, used)) mp_hdlr_init_##ops(void)\
-	{								\
+#define MEMPOOL_REGISTER_OPS(ops)				\
+	RTE_INIT(mp_hdlr_init_##ops)				\
+	{							\
 		rte_mempool_register_ops(&ops);			\
 	}
 
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 74 lines · Jerin Jacob Kollanukkaran

From: Jerin Jacob <[email protected]>

Use eal's RTE_INIT abstraction for defining constructors.

---
 app/test-bbdev/main.h            | 3 +--
 app/test/resource.h              | 2 +-
 app/test/test.h                  | 3 +--
 lib/librte_mempool/rte_mempool.h | 7 +++----
 4 files changed, 6 insertions(+), 9 deletions(-)
app/test-bbdev/main.h +1 -2
index 20a55efca..2bbe1b822 100644
@@ -103,8 +103,7 @@ void add_test_command(struct test_command *t);
                .command = RTE_STR(name), \
                .callback = test_func_##name, \
        }; \
-       static void __attribute__((constructor, used)) \
-       test_register_##name(void) \
+       RTE_INIT(test_register_##name) \
        { \
                add_test_command(&test_struct_##name); \
        }
app/test/resource.h +1 -1
index 223fa22ae..c75ebd4b5 100644
@@ -98,7 +98,7 @@ static struct resource linkres_ ##n = {       \
        .begin = b,             \
        .end = e,               \
 };                              \
-static void __attribute__((constructor, used)) resinitfn_ ##n(void) \
+RTE_INIT(resinitfn_ ##n)       \
 {                               \
        resource_register(&linkres_ ##n);  \
 }
app/test/test.h +1 -2
index 7c2443230..9b3846b1e 100644
@@ -177,8 +177,7 @@ void add_test_command(struct test_command *t);
                .command = RTE_STR(cmd), \
                .callback = func, \
        }; \
-       static void __attribute__((constructor, used)) \
-       test_register_##cmd(void) \
+       RTE_INIT(test_register_##cmd) \
        { \
                add_test_command(&test_struct_##cmd); \
        }
lib/librte_mempool/rte_mempool.h +3 -5
index 7c9cd9a2f..fd19470d7 100644
@@ -832,10 +832,9 @@ int rte_mempool_register_ops(const struct
 rte_mempool_ops *ops);
  * Note that the rte_mempool_register_ops fails silently here when
  * more than RTE_MEMPOOL_MAX_OPS_IDX is registered.
  */
-#define MEMPOOL_REGISTER_OPS(ops)                                      \
-       void mp_hdlr_init_##ops(void);                                  \
-       void __attribute__((constructor, used)) mp_hdlr_init_##ops(void)\
-       {                                                               \
+#define MEMPOOL_REGISTER_OPS(ops)                              \
+       RTE_INIT(mp_hdlr_init_##ops)                            \
+       {                                                       \
                rte_mempool_register_ops(&ops);                 \
        }
 
--
Quoted 3 lines

2.21.0

Signature · 1 line
David Marchand