summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/thread.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-01-07 09:55:45 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-01-11 08:47:01 +0100
commitccd54344d904b657123e4e4ba795a32212382be2 (patch)
treed490d77b6173f586137036ed07ec5bd27d8ca65a /cpukit/score/include/rtems/score/thread.h
parentsmptests/README: Delete obsolete information (diff)
downloadrtems-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/score/thread.h')
-rw-r--r--cpukit/score/include/rtems/score/thread.h90
1 files changed, 44 insertions, 46 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.