From ccd54344d904b657123e4e4ba795a32212382be2 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 7 Jan 2016 09:55:45 +0100 Subject: score: Introduce Thread_Entry_information This avoids potential dead code in _Thread_Handler(). It gets rid of the dangerous function pointer casts. Update #2514. --- cpukit/posix/src/pthreadcreate.c | 18 ++++++++++-------- cpukit/posix/src/pthreadinitthreads.c | 7 +++++-- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'cpukit/posix/src') diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index 59c4e66e9d..611477ec69 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -52,6 +52,15 @@ int pthread_create( void *arg ) { + Thread_Entry_information entry = { + .adaptor = _Thread_Entry_adaptor_pointer, + .Kinds = { + .Pointer = { + .entry = start_routine, + .argument = arg + } + } + }; const pthread_attr_t *the_attr; Priority_Control core_priority; Thread_CPU_budget_algorithms budget_algorithm; @@ -219,14 +228,7 @@ int pthread_create( /* * POSIX threads are allocated and started in one operation. */ - status = _Thread_Start( - the_thread, - THREAD_START_POINTER, - start_routine, - arg, - 0, /* unused */ - NULL - ); + status = _Thread_Start( the_thread, &entry, NULL ); #if defined(RTEMS_DEBUG) /* diff --git a/cpukit/posix/src/pthreadinitthreads.c b/cpukit/posix/src/pthreadinitthreads.c index 5accf3907c..c1f9340f63 100644 --- a/cpukit/posix/src/pthreadinitthreads.c +++ b/cpukit/posix/src/pthreadinitthreads.c @@ -37,11 +37,14 @@ static void *_POSIX_Global_construction( void *arg ) { - Thread_Entry entry_point = (Thread_Entry) Configuration_POSIX_API + Thread_Control *executing = _Thread_Get_executing(); + Thread_Entry_information entry = executing->Start.Entry; + + entry.Kinds.Pointer.entry = Configuration_POSIX_API .User_initialization_threads_table[ 0 ].thread_entry; (void) arg; - _Thread_Global_construction( entry_point ); + _Thread_Global_construction( executing, &entry ); } void _POSIX_Threads_Initialize_user_threads_body(void) -- cgit v1.2.3