diff mbox

[PATCHv6,04/38] helpers: linux: creating common entry for process and thread

Message ID 1462984942-53326-5-git-send-email-christophe.milard@linaro.org
State New
Headers show

Commit Message

Christophe Milard May 11, 2016, 4:41 p.m. UTC
odph_linux_pthread_t and odph_linux_process_t are joined, creating
odph_odpthread_t. Tests should be using the latter only so that
the actual implementation of the ODP thread don't leak in the test itself.
(odph_odpthread_t is opaque to the test, and is common to both
 thread and process omplementation of ODP threads)
odph_linux_pthread_t and odph_linux_process_t are kept for compatibility,
but should be removed in the future.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>
---
 helper/include/odp/helper/linux.h | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/helper/include/odp/helper/linux.h b/helper/include/odp/helper/linux.h
index c6736a0..f99b88a 100644
--- a/helper/include/odp/helper/linux.h
+++ b/helper/include/odp/helper/linux.h
@@ -44,7 +44,6 @@  typedef struct {
 	odph_linux_thr_params_t thr_params;
 } odph_linux_pthread_t;
 
-
 /** Linux process state information */
 typedef struct {
 	pid_t pid;      /**< Process ID */
@@ -52,6 +51,44 @@  typedef struct {
 	int   status;   /**< Process state change status */
 } odph_linux_process_t;
 
+/** odpthread linux type: whether an ODP thread is a linux thread or process */
+typedef enum odph_odpthread_linuxtype_e {
+	ODPTHREAD_NOT_STARTED = 0,
+	ODPTHREAD_PROCESS,
+	ODPTHREAD_PTHREAD
+} odph_odpthread_linuxtype_t;
+
+/** odpthread parameters for odp threads (pthreads and processes) */
+typedef struct {
+	int (*start)(void *);       /**< Thread entry point function */
+	void *arg;                  /**< Argument for the function */
+	odp_thread_type_t thr_type; /**< ODP thread type */
+	odp_instance_t instance;    /**< ODP instance handle */
+} odph_odpthread_params_t;
+
+/** The odpthread starting arguments, used both in process or thread mode */
+typedef struct {
+	odph_odpthread_linuxtype_t linuxtype;
+	odph_odpthread_params_t thr_params; /*copy of thread start parameter*/
+} odph_odpthread_start_args_t;
+
+/** Linux odpthread state information, used both in process or thread mode */
+typedef struct {
+	odph_odpthread_start_args_t	start_args;
+	int				cpu;	/**< CPU ID */
+	int				last;   /**< true if last table entry */
+	union {
+		struct { /* for thread implementation */
+			pthread_t	thread_id; /**< Pthread ID */
+			pthread_attr_t	attr;	/**< Pthread attributes */
+		} thread;
+		struct { /* for process implementation */
+			pid_t		pid;	/**< Process ID */
+			int		status;	/**< Process state chge status*/
+		} proc;
+	};
+} odph_odpthread_t;
+
 /**
  * Creates and launches pthreads
  *