Changeset 5110d0a in mainline for kernel/generic/src/synch/semaphore.c


Ignore:
Timestamp:
2023-02-07T16:02:50Z (2 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7c5320c
Parents:
8a55346
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-06 16:44:26)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-07 16:02:50)
Message:

Turn a bunch of macros into regular functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/semaphore.c

    r8a55346 r5110d0a  
    5353{
    5454        waitq_initialize(&sem->wq);
    55         waitq_count_set(&sem->wq, val);
     55        if (val != 0)
     56                waitq_count_set(&sem->wq, val);
    5657}
    5758
    58 /** Semaphore down
    59  *
    60  * Semaphore down.
    61  * Conditional mode and mode with timeout can be requested.
     59errno_t _semaphore_down_timeout(semaphore_t *sem, uint32_t usec, unsigned flags)
     60{
     61        errno_t rc = waitq_sleep_timeout(&sem->wq, usec, flags, NULL);
     62        assert(rc == EOK || rc == ETIMEOUT || rc == EAGAIN);
     63        return rc;
     64}
     65
     66errno_t semaphore_trydown(semaphore_t *sem)
     67{
     68        return _semaphore_down_timeout(sem, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING);
     69}
     70
     71/** Semaphore down with timeout
    6272 *
    6373 * @param sem   Semaphore.
    6474 * @param usec  Timeout in microseconds.
    65  * @param flags Select mode of operation.
    66  *
    67  * For exact description of possible combinations of
    68  * usec and flags, see comment for waitq_sleep_timeout().
    6975 *
    7076 * @return See comment for waitq_sleep_timeout().
    7177 *
    7278 */
    73 errno_t _semaphore_down_timeout(semaphore_t *sem, uint32_t usec, unsigned int flags)
     79errno_t semaphore_down_timeout(semaphore_t *sem, uint32_t usec)
    7480{
    75         return waitq_sleep_timeout(&sem->wq, usec, flags, NULL);
     81        return _semaphore_down_timeout(sem, usec, SYNCH_FLAGS_NON_BLOCKING);
     82}
     83
     84void semaphore_down(semaphore_t *sem)
     85{
     86        errno_t rc = waitq_sleep(&sem->wq);
     87        assert(rc == EOK);
    7688}
    7789
Note: See TracChangeset for help on using the changeset viewer.