Check Thread Flags. \param[in] thread thread object. \param[in] flags specifies the flags to check. \param[in] options specifies flags options (osFlagsXxxx). \return thread flags before clearing or 0 if specified flags have not been set.
| 94 | /// \param[in] options specifies flags options (osFlagsXxxx). |
| 95 | /// \return thread flags before clearing or 0 if specified flags have not been set. |
| 96 | static uint32_t ThreadFlagsCheck (os_thread_t *thread, uint32_t flags, uint32_t options) { |
| 97 | #if (EXCLUSIVE_ACCESS == 0) |
| 98 | uint32_t primask; |
| 99 | #endif |
| 100 | uint32_t thread_flags; |
| 101 | |
| 102 | if ((options & osFlagsNoClear) == 0U) { |
| 103 | #if (EXCLUSIVE_ACCESS == 0) |
| 104 | primask = __get_PRIMASK(); |
| 105 | __disable_irq(); |
| 106 | |
| 107 | thread_flags = thread->thread_flags; |
| 108 | if ((((options & osFlagsWaitAll) != 0U) && ((thread_flags & flags) != flags)) || |
| 109 | (((options & osFlagsWaitAll) == 0U) && ((thread_flags & flags) == 0U))) { |
| 110 | thread_flags = 0U; |
| 111 | } else { |
| 112 | thread->thread_flags &= ~flags; |
| 113 | } |
| 114 | |
| 115 | if (primask == 0U) { |
| 116 | __enable_irq(); |
| 117 | } |
| 118 | #else |
| 119 | if ((options & osFlagsWaitAll) != 0U) { |
| 120 | thread_flags = atomic_chk32_all(&thread->thread_flags, flags); |
| 121 | } else { |
| 122 | thread_flags = atomic_chk32_any(&thread->thread_flags, flags); |
| 123 | } |
| 124 | #endif |
| 125 | } else { |
| 126 | thread_flags = thread->thread_flags; |
| 127 | if ((((options & osFlagsWaitAll) != 0U) && ((thread_flags & flags) != flags)) || |
| 128 | (((options & osFlagsWaitAll) == 0U) && ((thread_flags & flags) == 0U))) { |
| 129 | thread_flags = 0U; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | return thread_flags; |
| 134 | } |
| 135 | |
| 136 | |
| 137 | // ==== Library functions ==== |
no test coverage detected