aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2023-08-25 15:54:11 +0300
committerMatias Elo <matias.elo@nokia.com>2023-10-23 10:59:18 +0300
commitc5ada8c5c4a498020bc8b8cb4371a506d2800f2c (patch)
tree6d3d9d8db4b440d3dd099736113b18fbd854a001 /example
parentab22998f4d2ec452d48831689d9112ef37d78b04 (diff)
example: use new ODPH_MIN and ODPH_MAX macros
Utilize new ODPH_MIN() and ODPH_MAX() macros in example applications. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'example')
-rw-r--r--example/generator/odp_generator.c1
-rw-r--r--example/timer/odp_timer_simple.c6
-rw-r--r--example/timer/odp_timer_test.c5
-rw-r--r--example/traffic_mgmt/odp_traffic_mgmt.c10
4 files changed, 7 insertions, 15 deletions
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index b1d1f83e2..95ba04c1e 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -35,7 +35,6 @@
#define APPL_MODE_UDP 0 /**< UDP mode */
#define APPL_MODE_PING 1 /**< ping mode */
#define APPL_MODE_RCV 2 /**< receive mode */
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define PING_THR_TX 0
#define PING_THR_RX 1
diff --git a/example/timer/odp_timer_simple.c b/example/timer/odp_timer_simple.c
index 4e3120653..fdf38c9d3 100644
--- a/example/timer/odp_timer_simple.c
+++ b/example/timer/odp_timer_simple.c
@@ -19,8 +19,6 @@
#include <odp/helper/odph_api.h>
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-
int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
{
odp_instance_t instance;
@@ -71,8 +69,8 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
}
odp_timer_pool_param_init(&tparams);
- tparams.res_ns = MAX(10 * ODP_TIME_MSEC_IN_NS,
- timer_capa.highest_res_ns);
+ tparams.res_ns = ODPH_MAX(10 * ODP_TIME_MSEC_IN_NS,
+ timer_capa.highest_res_ns);
tparams.min_tmo = 10 * ODP_TIME_MSEC_IN_NS;
tparams.max_tmo = 1 * ODP_TIME_SEC_IN_NS;
tparams.num_timers = 1; /* One timer per worker */
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 0e3fa7346..924ffe13f 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -21,7 +21,6 @@
#define MAX_WORKERS (ODP_THREAD_COUNT_MAX - 1)
#define NUM_TMOS 10000 /**< Number of timers */
#define WAIT_NUM 10 /**< Max tries to rx last tmo per worker */
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
/** Test arguments */
typedef struct {
@@ -282,9 +281,7 @@ static int parse_args(int argc, char *argv[], test_args_t *args)
return -1;
args->cpu_count = 1;
- args->resolution_us = MAX(10000,
- timer_capa.highest_res_ns /
- ODP_TIME_USEC_IN_NS);
+ args->resolution_us = ODPH_MAX(10000u, timer_capa.highest_res_ns / ODP_TIME_USEC_IN_NS);
args->min_us = 0;
args->max_us = 10000000;
args->period_us = 1000000;
diff --git a/example/traffic_mgmt/odp_traffic_mgmt.c b/example/traffic_mgmt/odp_traffic_mgmt.c
index 689cac2ae..5c97c5433 100644
--- a/example/traffic_mgmt/odp_traffic_mgmt.c
+++ b/example/traffic_mgmt/odp_traffic_mgmt.c
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <odp_api.h>
+#include <odp/helper/odph_api.h>
#define NUM_SVC_CLASSES 4
#define USERS_PER_SVC_CLASS 2
@@ -39,9 +40,6 @@
#define FALSE 0
#define TRUE 1
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
#define RANDOM_BUF_LEN 1024
typedef struct {
@@ -302,7 +300,7 @@ static uint32_t tm_shaper_max_burst;
static uint64_t
clamp_rate(uint64_t rate)
{
- uint64_t val = MIN(MAX(rate, tm_shaper_min_rate), tm_shaper_max_rate);
+ uint64_t val = ODPH_MIN(ODPH_MAX(rate, tm_shaper_min_rate), tm_shaper_max_rate);
if (!rate)
return 0;
@@ -316,7 +314,7 @@ clamp_rate(uint64_t rate)
static uint32_t
clamp_burst(uint32_t burst)
{
- uint32_t val = MIN(MAX(burst, tm_shaper_min_burst), tm_shaper_max_burst);
+ uint32_t val = ODPH_MIN(ODPH_MAX(burst, tm_shaper_min_burst), tm_shaper_max_burst);
if (!burst)
return 0;
@@ -765,7 +763,7 @@ static int traffic_generator(uint32_t pkts_to_send)
queue_num = random_16() & (TM_QUEUES_PER_CLASS - 1);
tm_queue = queue_num_tbls[svc_class][queue_num];
pkt_len = ((uint32_t)((random_8() & 0x7F) + 2)) * 32;
- pkt_len = MIN(pkt_len, 1500);
+ pkt_len = ODPH_MIN(pkt_len, 1500u);
pkt = make_odp_packet(pkt_len);
pkt_cnt++;