From d247281a041d60f7468e5ef0dc9578d110c126a5 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Fri, 22 Nov 2024 11:15:08 +0200 Subject: [PATCH] helper: linux: deprecate process fork and join functions Deprecate unused odph_linux_process_fork(), odph_linux_process_fork_n(), and odph_linux_process_wait_n() functions which have been replaced by generic odph_thread_create() and odph_thread_join() functions. Signed-off-by: Matias Elo --- .../implementers-guide.adoc | 15 --------------- helper/include/odp/helper/linux/process.h | 19 +++++++++++++------ helper/linux/thread.c | 14 +++++++------- helper/test/linux/process.c | 4 ++-- 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/doc/implementers-guide/implementers-guide.adoc b/doc/implementers-guide/implementers-guide.adoc index c20f049069..68239476a0 100644 --- a/doc/implementers-guide/implementers-guide.adoc +++ b/doc/implementers-guide/implementers-guide.adoc @@ -563,21 +563,6 @@ In the linux helper, two functions are given to create and join ODP threads: These two functions abstract what an ODP thread really is and their usage is recommended as they would be implemented in other OS`s helper lib. -Five older functions exist to tie and ODP thread to a specific implementation: - -`odph_linux_pthread_create()` - -`odph_linux_pthread_join()` - -`odph_linux_process_fork_n()` - -`odph_linux_process_fork()` - -`odph_linux_process_wait_n()` - -The usage of these functions should not occur within ODP examples nor tests. -The usage of these functions in other application is not recommended. - [[typedefs]] == ODP Abstract Types and Implementation Typedefs ODP APIs are defined to be abstract and operate on abstract types. For example, diff --git a/helper/include/odp/helper/linux/process.h b/helper/include/odp/helper/linux/process.h index 0f34d604b8..6224093fc7 100644 --- a/helper/include/odp/helper/linux/process.h +++ b/helper/include/odp/helper/linux/process.h @@ -15,6 +15,7 @@ #ifndef ODPH_LINUX_PROCESS_H_ #define ODPH_LINUX_PROCESS_H_ +#include #include #include @@ -39,9 +40,11 @@ extern "C" { * * @return On success: 1 for the parent, 0 for the child * On failure: -1 for the parent, -2 for the child + * + * @deprecated Use odph_thread_create() instead. */ -int odph_linux_process_fork(odph_linux_process_t *proc, int cpu, - const odph_linux_thr_params_t *thr_params); +int ODPH_DEPRECATE(odph_linux_process_fork)(odph_linux_process_t *proc, int cpu, + const odph_linux_thr_params_t *thr_params); /** * Fork a number of processes @@ -55,10 +58,12 @@ int odph_linux_process_fork(odph_linux_process_t *proc, int cpu, * * @return On success: 1 for the parent, 0 for the child * On failure: -1 for the parent, -2 for the child + * + * @deprecated Use odph_thread_create() instead. */ -int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, - const odp_cpumask_t *mask, - const odph_linux_thr_params_t *thr_params); +int ODPH_DEPRECATE(odph_linux_process_fork_n)(odph_linux_process_t *proc_tbl, + const odp_cpumask_t *mask, + const odph_linux_thr_params_t *thr_params); /** * Wait for a number of processes @@ -70,8 +75,10 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, * @param num Number of processes to wait * * @return 0 on success, -1 on failure + * + * @deprecated Use odph_thread_join() instead. */ -int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num); +int ODPH_DEPRECATE(odph_linux_process_wait_n)(odph_linux_process_t *proc_tbl, int num); /** * @} diff --git a/helper/linux/thread.c b/helper/linux/thread.c index ab1ae4ee7e..27e11422eb 100644 --- a/helper/linux/thread.c +++ b/helper/linux/thread.c @@ -115,9 +115,9 @@ void ODPH_DEPRECATE(odph_linux_pthread_join)(odph_linux_pthread_t *thread_tbl, i } } -int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, - const odp_cpumask_t *mask, - const odph_linux_thr_params_t *thr_params) +int ODPH_DEPRECATE(odph_linux_process_fork_n)(odph_linux_process_t *proc_tbl, + const odp_cpumask_t *mask, + const odph_linux_thr_params_t *thr_params) { pid_t pid; int num; @@ -184,17 +184,17 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, return 1; } -int odph_linux_process_fork(odph_linux_process_t *proc, int cpu, - const odph_linux_thr_params_t *thr_params) +int ODPH_DEPRECATE(odph_linux_process_fork)(odph_linux_process_t *proc, int cpu, + const odph_linux_thr_params_t *thr_params) { odp_cpumask_t mask; odp_cpumask_zero(&mask); odp_cpumask_set(&mask, cpu); - return odph_linux_process_fork_n(proc, &mask, thr_params); + return ODPH_DEPRECATE(odph_linux_process_fork_n)(proc, &mask, thr_params); } -int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num) +int ODPH_DEPRECATE(odph_linux_process_wait_n)(odph_linux_process_t *proc_tbl, int num) { pid_t pid; int i, j; diff --git a/helper/test/linux/process.c b/helper/test/linux/process.c index 54614a6956..f7d22a1286 100644 --- a/helper/test/linux/process.c +++ b/helper/test/linux/process.c @@ -70,7 +70,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) thr_params.instance = instance; /* Fork worker processes */ - ret = odph_linux_process_fork_n(proc, &cpu_mask, &thr_params); + ret = ODPH_DEPRECATE(odph_linux_process_fork_n)(proc, &cpu_mask, &thr_params); if (ret < 0) { ODPH_ERR("Fork workers failed %i\n", ret); @@ -87,7 +87,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) } } else { /* Parent process */ - odph_linux_process_wait_n(proc, num_workers); + ODPH_DEPRECATE(odph_linux_process_wait_n)(proc, num_workers); if (odp_term_local()) { ODPH_ERR("Error: ODP local term failed.\n");