API Reference Manual  1.45.0
odp_hello.c

This is a minimal application which demonstrates the startup and shutdown steps of an ODP application. It can be also used to debug API related build problems, etc. It does not use helpers to minimize dependency to anything else than the ODP API header file.

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2016-2018 Linaro Limited
*/
#include <stdio.h>
#include <string.h>
#include <odp_api.h>
typedef struct {
int num;
} options_t;
static int parse_args(int argc, char *argv[], options_t *opt)
{
static const char * const args[] = {"-n"};
int i, tmp;
for (i = 1; i < argc; i++) {
if ((strcmp(argv[i], args[0]) == 0) && argv[i + 1] &&
(sscanf(argv[i + 1], "%i", &tmp) == 1)) {
opt->num = tmp;
i++;
} else {
printf("\nUsage:\n"
" [%s Number of iterations]\n\n",
args[0]);
return -1;
}
}
return 0;
}
int main(int argc, char *argv[])
{
options_t opt;
int i;
memset(&opt, 0, sizeof(opt));
opt.num = 1;
if (parse_args(argc, argv, &opt))
return -1;
if (odp_init_global(&inst, NULL, NULL)) {
printf("Global init failed.\n");
return -1;
}
printf("Local init failed.\n");
return -1;
}
for (i = 0; i < opt.num; i++) {
printf("Hello world from CPU %i!\n", odp_cpu_id());
}
if (odp_term_local()) {
printf("Local term failed.\n");
return -1;
}
if (odp_term_global(inst)) {
printf("Global term failed.\n");
return -1;
}
return 0;
}
int odp_cpu_id(void)
CPU identifier.
int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type)
Thread local ODP initialization.
int odp_init_global(odp_instance_t *instance, const odp_init_t *params, const odp_platform_init_t *platform_params)
Global ODP initialization.
int odp_term_local(void)
Thread local ODP termination.
int odp_term_global(odp_instance_t instance)
Global ODP termination.
uint64_t odp_instance_t
ODP instance ID.
@ ODP_THREAD_CONTROL
Control thread.
#define ODP_TIME_SEC_IN_NS
A second in nanoseconds.
void odp_time_wait_ns(uint64_t ns)
Wait the specified number of nanoseconds.
The OpenDataPlane API.