Browse Source

core: thread_flags: optimize thread_flags_wait_one, fix doxygen

pr/gpio
Kaspar Schleiser 7 years ago
parent
commit
46143c6bdc
  1. 2
      core/include/thread_flags.h
  2. 6
      core/thread_flags.c

2
core/include/thread_flags.h

@ -124,7 +124,7 @@ thread_flags_t thread_flags_wait_all(thread_flags_t mask);
* @brief Wait for any flags in mask to become set (blocking), one at a time
*
* This function is like thread_flags_wait_any(), but will only clear and return
* one flag at a time, most significant set bit first.
* one flag at a time, least significant set bit first.
*
* @param[in] mask mask of flags to wait for
*

6
core/thread_flags.c

@ -79,8 +79,10 @@ thread_flags_t thread_flags_wait_one(thread_flags_t mask)
{
_thread_flags_wait_any(mask);
thread_t *me = (thread_t*) sched_active_thread;
unsigned tmp = me->flags & mask;
return _thread_flags_clear_atomic(me, thread_flags_clear(1 << bitarithm_lsb(tmp)));
thread_flags_t tmp = me->flags & mask;
/* clear all but least significant bit */
tmp &= (~tmp + 1);
return _thread_flags_clear_atomic(me, tmp);
}
thread_flags_t thread_flags_wait_all(thread_flags_t mask)

Loading…
Cancel
Save