Sfoglia il codice sorgente

RTX5: removed thread return value

Robert Rostohar 9 anni fa
parent
commit
0a3d2b3dc2

+ 1 - 1
CMSIS/RTOS2/RTX/Config/RTX_Config.c

@@ -250,7 +250,7 @@
 #include "rtx_os.h"
  
 // OS Idle Thread
-void *os_IdleThread (void *argument) {
+__NO_RETURN void os_IdleThread (void *argument) {
   (void)argument;
 
   for (;;) {}

+ 1 - 1
CMSIS/RTOS2/RTX/Examples/Simulation/RTX5_Blinky/RTE/CMSIS/RTX_Config.c

@@ -250,7 +250,7 @@
 #include "rtx_os.h"
  
 // OS Idle Thread
-void *os_IdleThread (void *argument) {
+__NO_RETURN void os_IdleThread (void *argument) {
   (void)argument;
 
   for (;;) {}

+ 15 - 2
CMSIS/RTOS2/RTX/Include/rtx_os.h

@@ -26,6 +26,20 @@
 #ifndef RTX_OS_H_
 #define RTX_OS_H_
 
+#ifndef __NO_RETURN
+#if   defined(__CC_ARM)
+#define __NO_RETURN __declspec(noreturn)
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
+#define __NO_RETURN __attribute__((noreturn))
+#elif defined(__GNUC__)
+#define __NO_RETURN __attribute__((noreturn))
+#elif defined(__ICCARM__)
+#define __NO_RETURN __noreturn
+#else
+#define __NO_RETURN
+#endif
+#endif
+
 #include <stdint.h>
 #include <stddef.h>
 
@@ -96,7 +110,6 @@ extern "C"
 
 /// Thread Flags definitions
 #define os_ThreadFlagDefStack   0x10U   ///< Default Stack flag
-#define os_ThreadFlagExitPtr    0x20U   ///< Exit Pointer flag
 
 /// Stack Marker definitions
 #define os_StackMagicWord       0xE25A2EA5U ///< Stack Magic Word (Stack Base)
@@ -386,7 +399,7 @@ extern os_info_t os_Info;               ///< OS Runtime Information
 extern uint32_t os_Error (uint32_t code, void *object_id);
 
 /// OS Idle Thread
-extern void *os_IdleThread (void *argument);
+extern void os_IdleThread (void *argument);
 
 /// OS Exception handlers
 extern void SVC_Handler     (void);

+ 1 - 2
CMSIS/RTOS2/RTX/Include1/cmsis_os.h

@@ -17,7 +17,7 @@
  *
  * ----------------------------------------------------------------------
  *
- * $Date:        12. October 2016
+ * $Date:        17. October 2016
  * $Revision:    V2.0
  *
  * Project:      CMSIS-RTOS API
@@ -58,7 +58,6 @@
  *    Thread:
  *     - extended number of thread priorities
  *     - renamed osPrioriry to osPrioriry_t
- *     - changed thread return value
  *     - replaced osThreadCreate with osThreadNew
  *     - added: osThreadState_t and osThreadGetState
  *     - added: osThreadSuspend, osThreadResume

+ 4 - 4
CMSIS/RTOS2/RTX/Source/rtx_lib.h

@@ -65,8 +65,8 @@ extern bool         os_ThreadWaitEnter   (uint8_t state, uint32_t millisec);
 extern void         os_ThreadStackCheck  (void);
 
 // Timer Library functions
-extern void  os_TimerTick   (void);
-extern void *os_TimerThread (void *argument);
+extern void os_TimerTick   (void);
+extern void os_TimerThread (void *argument);
 
 // Mutex Library functions
 extern void  os_MutexOwnerRelease (os_mutex_t *mutex_list);
@@ -119,8 +119,8 @@ extern osStatus_t       os_svcThreadYield        (void);
 extern osStatus_t       os_svcThreadSuspend      (osThreadId_t thread_id);
 extern osStatus_t       os_svcThreadResume       (osThreadId_t thread_id);
 extern osStatus_t       os_svcThreadDetach       (osThreadId_t thread_id);
-extern osStatus_t       os_svcThreadJoin         (osThreadId_t thread_id, void **exit_ptr);
-extern void             os_svcThreadExit         (void *exit_ptr);
+extern osStatus_t       os_svcThreadJoin         (osThreadId_t thread_id);
+extern void             os_svcThreadExit         (void);
 extern osStatus_t       os_svcThreadTerminate    (osThreadId_t thread_id);
 extern int32_t          os_svcThreadFlagsSet     (osThreadId_t thread_id, int32_t flags);
 extern int32_t          os_svcThreadFlagsClear   (int32_t flags);

+ 14 - 27
CMSIS/RTOS2/RTX/Source/rtx_thread.c

@@ -512,8 +512,8 @@ SVC0_0 (ThreadYield,       osStatus_t)
 SVC0_1 (ThreadSuspend,     osStatus_t,      osThreadId_t)
 SVC0_1 (ThreadResume,      osStatus_t,      osThreadId_t)
 SVC0_1 (ThreadDetach,      osStatus_t,      osThreadId_t)
-SVC0_2 (ThreadJoin,        osStatus_t,      osThreadId_t, void **)
-SVC0_1N(ThreadExit,        void,            void *)
+SVC0_1 (ThreadJoin,        osStatus_t,      osThreadId_t)
+SVC0_0N(ThreadExit,        void)
 SVC0_1 (ThreadTerminate,   osStatus_t,      osThreadId_t)
 SVC0_2 (ThreadFlagsSet,    int32_t,         osThreadId_t, int32_t)
 SVC0_1 (ThreadFlagsClear,  int32_t,         int32_t)
@@ -911,7 +911,7 @@ osStatus_t os_svcThreadDetach (osThreadId_t thread_id) {
     return osErrorParameter;
   }
 
-  if (thread->attr & osThreadDetached) {
+  if ((thread->attr & osThreadJoinable) == 0U) {
     return osErrorResource;
   }
 
@@ -924,7 +924,7 @@ osStatus_t os_svcThreadDetach (osThreadId_t thread_id) {
     os_ThreadListUnlink(&os_Info.thread.terminate_list, thread);
     os_ThreadFree(thread);
   } else {
-    thread->attr |= osThreadDetached;
+    thread->attr &= ~osThreadJoinable;
   }
 
   return osOK;
@@ -932,9 +932,8 @@ osStatus_t os_svcThreadDetach (osThreadId_t thread_id) {
 
 /// Wait for specified thread to terminate.
 /// \note API identical to osThreadJoin
-osStatus_t os_svcThreadJoin (osThreadId_t thread_id, void **exit_ptr) {
+osStatus_t os_svcThreadJoin (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
-  uint32_t    *reg;
 
   // Check parameters
   if ((thread == NULL) ||
@@ -942,7 +941,7 @@ osStatus_t os_svcThreadJoin (osThreadId_t thread_id, void **exit_ptr) {
     return osErrorParameter;
   }
 
-  if (thread->attr & osThreadDetached) {
+  if ((thread->attr & osThreadJoinable) == 0U) {
     return osErrorResource;
   }
 
@@ -953,10 +952,6 @@ osStatus_t os_svcThreadJoin (osThreadId_t thread_id, void **exit_ptr) {
   }
 
   if (thread->state == os_ThreadTerminated) {
-    if ((thread->flags & os_ThreadFlagExitPtr) && (exit_ptr != NULL)) {
-      reg = os_ThreadRegPtr(thread);
-      *exit_ptr = (void *)reg[0];
-    }
     os_ThreadListUnlink(&os_Info.thread.terminate_list, thread);
     os_ThreadFree(thread);
   } else {
@@ -972,10 +967,8 @@ osStatus_t os_svcThreadJoin (osThreadId_t thread_id, void **exit_ptr) {
 
 /// Terminate execution of current running thread.
 /// \note API identical to osThreadExit
-void os_svcThreadExit (void *exit_ptr) {
+void os_svcThreadExit (void) {
   os_thread_t *thread;
-  uint32_t    *reg;
-  void       **ptr;
 
   thread = os_ThreadGetRunning();
   if (thread == NULL) {
@@ -987,11 +980,6 @@ void os_svcThreadExit (void *exit_ptr) {
 
   // Wakeup Thread waiting to Join
   if (thread->thread_join != NULL) {
-    reg = os_ThreadRegPtr(thread->thread_join);
-    ptr = (void **)reg[1];
-    if (ptr != NULL) {
-      *ptr = exit_ptr;
-    }
     os_ThreadWaitExit(thread->thread_join, (uint32_t)osOK, false);
   }
 
@@ -1004,12 +992,11 @@ void os_svcThreadExit (void *exit_ptr) {
   os_ThreadSwitch(os_ThreadListGet(&os_Info.thread.ready));
   os_ThreadSetRunning(NULL);
 
-  if (thread->attr & osThreadDetached) {
+  if ((thread->attr & osThreadJoinable) == 0U) {
     os_ThreadFree(thread);
   } else {
     // Update Thread State and put it into Terminate Thread list
-    thread->state  = os_ThreadTerminated;
-    thread->flags |= os_ThreadFlagExitPtr;
+    thread->state = os_ThreadTerminated;
     thread->thread_prev = NULL;
     thread->thread_next = os_Info.thread.terminate_list;
     os_Info.thread.terminate_list = thread;
@@ -1065,7 +1052,7 @@ osStatus_t os_svcThreadTerminate (osThreadId_t thread_id) {
     os_ThreadDispatch(NULL);
   }
 
-  if (thread->attr & osThreadDetached) {
+  if ((thread->attr & osThreadJoinable) == 0U) {
     os_ThreadFree(thread);
   } else {
     // Update Thread State and put it into Terminate Thread list
@@ -1313,16 +1300,16 @@ osStatus_t osThreadDetach (osThreadId_t thread_id) {
 }
 
 /// Wait for specified thread to terminate.
-osStatus_t osThreadJoin (osThreadId_t thread_id, void **exit_ptr) {
+osStatus_t osThreadJoin (osThreadId_t thread_id) {
   if (__get_IPSR() != 0U) {
     return osErrorISR;                          // Not allowed in ISR
   }
-  return __svcThreadJoin(thread_id, exit_ptr);
+  return __svcThreadJoin(thread_id);
 }
 
 /// Terminate execution of current running thread.
-__NO_RETURN void osThreadExit (void *exit_ptr) {
-  __svcThreadExit(exit_ptr);
+__NO_RETURN void osThreadExit (void) {
+  __svcThreadExit();
   for (;;);
 }
 

+ 1 - 3
CMSIS/RTOS2/RTX/Source/rtx_timer.c

@@ -110,7 +110,7 @@ void os_TimerTick (void) {
 }
 
 /// Timer Thread
-void *os_TimerThread (void *argument) {
+__NO_RETURN void os_TimerThread (void *argument) {
   os_timer_finfo_t finfo;
   osStatus_t       status;
   (void)           argument;
@@ -121,8 +121,6 @@ void *os_TimerThread (void *argument) {
       (*(os_timer_func_t)finfo.fp)(finfo.arg);
     }
   }
-  
-  return NULL;
 }
 
 //  ==== Service Calls ====