| 164 | } |
| 165 | |
| 166 | static inline bool CondVar_EndWait(CondVar* cv, s32 num_threads) |
| 167 | { |
| 168 | bool hasWaiters; |
| 169 | s32 val; |
| 170 | |
| 171 | do { |
| 172 | val = __ldrex(cv); |
| 173 | hasWaiters = val < 0; |
| 174 | if (hasWaiters) |
| 175 | { |
| 176 | if (num_threads < 0) |
| 177 | val = 0; |
| 178 | else if (val <= -num_threads) |
| 179 | val += num_threads; |
| 180 | else |
| 181 | val = 0; |
| 182 | } |
| 183 | } while (__strex(cv, val)); |
| 184 | |
| 185 | return hasWaiters; |
| 186 | } |
| 187 | |
| 188 | void CondVar_Init(CondVar* cv) |
| 189 | { |
no test coverage detected