diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-01-07 09:55:45 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-01-11 08:47:01 +0100 |
commit | ccd54344d904b657123e4e4ba795a32212382be2 (patch) | |
tree | d490d77b6173f586137036ed07ec5bd27d8ca65a /cpukit/score/include/rtems | |
parent | smptests/README: Delete obsolete information (diff) | |
download | rtems-ccd54344d904b657123e4e4ba795a32212382be2.tar.bz2 |
score: Introduce Thread_Entry_information
This avoids potential dead code in _Thread_Handler(). It gets rid of
the dangerous function pointer casts.
Update #2514.
Diffstat (limited to 'cpukit/score/include/rtems')
-rw-r--r-- | cpukit/score/include/rtems/score/thread.h | 90 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadimpl.h | 34 |
2 files changed, 62 insertions, 62 deletions
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index 6e937e39de..f4d76d8725 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -88,15 +88,11 @@ extern "C" { typedef Timestamp_Control Thread_CPU_usage_t; -/** - * The following defines the "return type" of a thread. - * - * @note This cannot always be right. Some APIs have void - * tasks/threads, others return pointers, others may - * return a numeric value. Hopefully a pointer is - * always at least as big as an uint32_t . :) +/* + * Only provided for backward compatiblity to not break application + * configurations. */ -typedef void *Thread; +typedef void *Thread RTEMS_DEPRECATED; /** * @brief Type of the numeric argument of a thread entry function with at @@ -110,44 +106,52 @@ typedef void *Thread; typedef CPU_Uint32ptr Thread_Entry_numeric_type; /** - * The following defines the ways in which the entry point for a - * thread can be invoked. Basically, it can be passed any - * combination/permutation of a pointer and an uint32_t value. - * - * @note For now, we are ignoring the return type. + * @brief Data for idle thread entry. */ -typedef enum { - THREAD_START_NUMERIC, - THREAD_START_POINTER, - #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) - THREAD_START_BOTH_POINTER_FIRST, - THREAD_START_BOTH_NUMERIC_FIRST - #endif -} Thread_Start_types; - -/** This type corresponds to a very simple style thread entry point. */ -typedef Thread ( *Thread_Entry )( void ); /* basic type */ +typedef struct { + void *( *entry )( uintptr_t argument ); +} Thread_Entry_idle; -/** This type corresponds to a thread entry point which takes a single - * unsigned thirty-two bit integer as an argument. +/** + * @brief Data for thread entry with one numeric argument and no return value. */ -typedef Thread ( *Thread_Entry_numeric )( Thread_Entry_numeric_type ); +typedef struct { + void ( *entry )( Thread_Entry_numeric_type argument ); + Thread_Entry_numeric_type argument; +} Thread_Entry_numeric; -/** This type corresponds to a thread entry point which takes a single - * untyped pointer as an argument. +/** + * @brief Data for thread entry with one pointer argument and a pointer return + * value. */ -typedef Thread ( *Thread_Entry_pointer )( void * ); +typedef struct { + void *( *entry )( void *argument ); + void *argument; +} Thread_Entry_pointer; -/** This type corresponds to a thread entry point which takes a single - * untyped pointer and an unsigned thirty-two bit integer as arguments. +/** + * @brief Thread entry information. */ -typedef Thread ( *Thread_Entry_both_pointer_first )( void *, Thread_Entry_numeric_type ); +typedef struct { + /** + * @brief Thread entry adaptor. + * + * Calls the corresponding thread entry with the right parameters. + * + * @param executing The executing thread. + */ + void ( *adaptor )( Thread_Control *executing ); -/** This type corresponds to a thread entry point which takes a single - * unsigned thirty-two bit integer and an untyped pointer and an - * as arguments. - */ -typedef Thread ( *Thread_Entry_both_numeric_first )( Thread_Entry_numeric_type, void * ); + /** + * @brief Thread entry data used by the adaptor to call the thread entry + * function with the right parameters. + */ + union { + Thread_Entry_idle Idle; + Thread_Entry_numeric Numeric; + Thread_Entry_pointer Pointer; + } Kinds; +} Thread_Entry_information; /** * The following lists the algorithms used to manage the thread cpu budget. @@ -206,14 +210,8 @@ typedef struct { * the starting state of a thread. */ typedef struct { - /** This field is the starting address for the thread. */ - Thread_Entry entry_point; - /** This field indicates the how task is invoked. */ - Thread_Start_types prototype; - /** This field is the pointer argument passed at thread start. */ - void *pointer_argument; - /** This field is the numeric argument passed at thread start. */ - Thread_Entry_numeric_type numeric_argument; + /** This field contains the thread entry information. */ + Thread_Entry_information Entry; /*-------------- initial execution modes ----------------- */ /** This field indicates whether the thread was preemptible when * it started. diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index abdd7e6f57..f212e23928 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -185,29 +185,22 @@ bool _Thread_Initialize( * and makes it ready to execute. After this routine executes, the * thread competes with all other threads for CPU time. * - * @param the_thread is the thread to be initialized - * @param the_prototype - * @param entry_point - * @param pointer_argument - * @param numeric_argument + * @param the_thread The thread to be started. + * @param entry The thread entry information. * @param[in,out] cpu The processor if used to start an idle thread * during system initialization. Must be set to @c NULL to start a normal * thread. */ bool _Thread_Start( - Thread_Control *the_thread, - Thread_Start_types the_prototype, - void *entry_point, - void *pointer_argument, - Thread_Entry_numeric_type numeric_argument, - Per_CPU_Control *cpu + Thread_Control *the_thread, + const Thread_Entry_information *entry, + Per_CPU_Control *cpu ); bool _Thread_Restart( - Thread_Control *the_thread, - Thread_Control *executing, - void *pointer_argument, - Thread_Entry_numeric_type numeric_argument + Thread_Control *the_thread, + Thread_Control *executing, + const Thread_Entry_information *entry ); void _Thread_Yield( Thread_Control *executing ); @@ -300,6 +293,12 @@ void _Thread_Load_environment( Thread_Control *the_thread ); +void _Thread_Entry_adaptor_idle( Thread_Control *executing ); + +void _Thread_Entry_adaptor_numeric( Thread_Control *executing ); + +void _Thread_Entry_adaptor_pointer( Thread_Control *executing ); + /** * @brief Wrapper function for all threads. * @@ -325,7 +324,10 @@ void _Thread_Handler( void ); * the first POSIX initialization thread in case no RTEMS initialization tasks * are present. */ -void _Thread_Global_construction( Thread_Entry entry_point ) RTEMS_NO_RETURN; +void _Thread_Global_construction( + Thread_Control *executing, + const Thread_Entry_information *entry +) RTEMS_NO_RETURN; /** * @brief Ended the delay of a thread. |