Tests updated to use shm handle and new addr function.
Signed-off-by: Petri Savolainen <[email protected]>
---
example/generator/odp_generator.c | 13 +++++++++----
example/l2fwd/odp_l2fwd.c | 13 +++++++++----
example/odp_example/odp_example.c | 12 ++++++++++--
example/packet/odp_pktio.c | 13 +++++++++----
example/timer/odp_timer_test.c | 6 ++++--
test/api_test/odp_shm_test.c | 10 +++++++---
test/api_test/odp_timer_ping.c | 6 ++++--
7 files changed, 52 insertions(+), 21 deletions(-)
diff --git a/example/generator/odp_generator.c
b/example/generator/odp_generator.c
index 10c7b31..27fc868 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -523,6 +523,7 @@ int main(int argc, char *argv[])
int i;
int first_core;
int core_count;
+ odp_shm_t shm;
/* Init ODP before calling anything else */
if (odp_init_global()) {
@@ -537,8 +538,10 @@ int main(int argc, char *argv[])
odp_atomic_init_u64(&counters.icmp);
/* Reserve memory for args from shared mem */
- args = odp_shm_reserve("shm_args", sizeof(args_t),
- ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("shm_args", sizeof(args_t),
+ ODP_CACHE_LINE_SIZE, 0);
+ args = odp_shm_addr(shm);
+
if (args == NULL) {
ODP_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
@@ -582,8 +585,10 @@ int main(int argc, char *argv[])
odp_init_local(thr_id);
/* Create packet pool */
- pool_base = odp_shm_reserve("shm_packet_pool",
- SHM_PKT_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("shm_packet_pool",
+ SHM_PKT_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ pool_base = odp_shm_addr(shm);
+
if (pool_base == NULL) {
ODP_ERR("Error: packet pool mem alloc failed.\n");
exit(EXIT_FAILURE);
diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
index e19aa94..6c1d64a 100644
--- a/example/l2fwd/odp_l2fwd.c
+++ b/example/l2fwd/odp_l2fwd.c
@@ -321,6 +321,7 @@ int main(int argc, char *argv[])
int first_core;
int core_count;
odp_pktio_t pktio;
+ odp_shm_t shm;
/* Init ODP before calling anything else */
if (odp_init_global()) {
@@ -329,8 +330,10 @@ int main(int argc, char *argv[])
}
/* Reserve memory for args from shared mem */
- gbl_args = odp_shm_reserve("shm_args", sizeof(args_t),
- ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("shm_args", sizeof(args_t),
+ ODP_CACHE_LINE_SIZE, 0);
+ gbl_args = odp_shm_addr(shm);
+
if (gbl_args == NULL) {
ODP_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
@@ -380,8 +383,10 @@ int main(int argc, char *argv[])
odp_init_local(thr_id);
/* Create packet pool */
- pool_base = odp_shm_reserve("shm_packet_pool",
- SHM_PKT_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("shm_packet_pool",
+ SHM_PKT_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ pool_base = odp_shm_addr(shm);
+
if (pool_base == NULL) {
ODP_ERR("Error: packet pool mem alloc failed.\n");
exit(EXIT_FAILURE);
diff --git a/example/odp_example/odp_example.c
b/example/odp_example/odp_example.c
index e99df85..c80dbbc 100644
--- a/example/odp_example/odp_example.c
+++ b/example/odp_example/odp_example.c
@@ -943,6 +943,7 @@ int main(int argc, char *argv[])
int i, j;
int prios;
int first_core;
+ odp_shm_t shm;
printf("\nODP example starts\n");
@@ -1003,8 +1004,15 @@ int main(int argc, char *argv[])
/*
* Create message pool
*/
- pool_base = odp_shm_reserve("msg_pool",
- MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("msg_pool",
+ MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+
+ pool_base = odp_shm_addr(shm);
+
+ if (pool_base == NULL) {
+ ODP_ERR("Shared memory reserve failed.\n");
+ return -1;
+ }
pool = odp_buffer_pool_create("msg_pool", pool_base, MSG_POOL_SIZE,
sizeof(test_message_t),
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 7f2d43f..41315f7 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -309,6 +309,7 @@ int main(int argc, char *argv[])
int i;
int first_core;
int core_count;
+ odp_shm_t shm;
/* Init ODP before calling anything else */
if (odp_init_global()) {
@@ -317,8 +318,10 @@ int main(int argc, char *argv[])
}
/* Reserve memory for args from shared mem */
- args = odp_shm_reserve("shm_args", sizeof(args_t),
- ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("shm_args", sizeof(args_t),
+ ODP_CACHE_LINE_SIZE, 0);
+ args = odp_shm_addr(shm);
+
if (args == NULL) {
ODP_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
@@ -358,8 +361,10 @@ int main(int argc, char *argv[])
odp_init_local(thr_id);
/* Create packet pool */
- pool_base = odp_shm_reserve("shm_packet_pool",
- SHM_PKT_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("shm_packet_pool",
+ SHM_PKT_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ pool_base = odp_shm_addr(shm);
+
if (pool_base == NULL) {
ODP_ERR("Error: packet pool mem alloc failed.\n");
exit(EXIT_FAILURE);
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index fd46f16..6e1715d 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -248,6 +248,7 @@ int main(int argc, char *argv[])
int first_core;
uint64_t cycles, ns;
odp_queue_param_t param;
+ odp_shm_t shm;
printf("\nODP timer example starts\n");
@@ -310,8 +311,9 @@ int main(int argc, char *argv[])
/*
* Create message pool
*/
- pool_base = odp_shm_reserve("msg_pool",
- MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("msg_pool",
+ MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ pool_base = odp_shm_addr(shm);
pool = odp_buffer_pool_create("msg_pool", pool_base, MSG_POOL_SIZE,
0,
diff --git a/test/api_test/odp_shm_test.c b/test/api_test/odp_shm_test.c
index 376b06f..6208e78 100644
--- a/test/api_test/odp_shm_test.c
+++ b/test/api_test/odp_shm_test.c
@@ -19,6 +19,7 @@ static void *run_thread(void *arg)
{
pthrd_arg *parg = (pthrd_arg *)arg;
int thr;
+ odp_shm_t shm;
thr = odp_thread_id();
@@ -26,7 +27,8 @@ static void *run_thread(void *arg)
switch (parg->testcase) {
case ODP_SHM_TEST:
- test_shared_data = odp_shm_lookup("test_shared_data");
+ shm = odp_shm_lookup("test_shared_data");
+ test_shared_data = odp_shm_addr(shm);
printf(" [%i] shared data at %p\n", thr, test_shared_data);
break;
default:
@@ -40,14 +42,16 @@ static void *run_thread(void *arg)
int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
{
pthrd_arg thrdarg;
+ odp_shm_t shm;
if (odp_test_global_init() != 0)
return -1;
odp_print_system_info();
- test_shared_data = odp_shm_reserve("test_shared_data",
- sizeof(test_shared_data_t), 128, 0);
+ shm = odp_shm_reserve("test_shared_data",
+ sizeof(test_shared_data_t), 128, 0);
+ test_shared_data = odp_shm_addr(shm);
memset(test_shared_data, 0, sizeof(test_shared_data_t));
printf("test shared data at %p\n\n", test_shared_data);
diff --git a/test/api_test/odp_timer_ping.c b/test/api_test/odp_timer_ping.c
index a31567a..5ae379f 100644
--- a/test/api_test/odp_timer_ping.c
+++ b/test/api_test/odp_timer_ping.c
@@ -315,6 +315,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
odp_buffer_pool_t pool;
void *pool_base;
int i;
+ odp_shm_t shm;
if (odp_test_global_init() != 0)
return -1;
@@ -327,8 +328,9 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
/*
* Create message pool
*/
- pool_base = odp_shm_reserve("msg_pool",
- MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ shm = odp_shm_reserve("msg_pool",
+ MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+ pool_base = odp_shm_addr(shm);
pool = odp_buffer_pool_create("msg_pool", pool_base, MSG_POOL_SIZE,
BUF_SIZE,
--
2.1.0
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp