Changeset cb10bc9 in mainline for uspace/lib/c/generic/futex.c


Ignore:
Timestamp:
2012-12-04T02:21:03Z (12 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b7eec9
Parents:
927a181e
Message:

Inlined uspace futex functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/futex.c

    r927a181e rcb10bc9  
    3535#include <futex.h>
    3636#include <atomic.h>
    37 #include <libc.h>
    38 #include <sys/types.h>
    3937
    4038/** Initialize futex counter.
     
    4947}
    5048
    51 /** Try to down the futex.
    52  *
    53  * @param futex Futex.
    54  *
    55  * @return Non-zero if the futex was acquired.
    56  * @return Zero if the futex was not acquired.
    57  *
    58  */
    59 int futex_trydown(futex_t *futex)
    60 {
    61         return cas(&futex->val, 1, 0);
    62 }
    63 
    64 /** Down the futex.
    65  *
    66  * @param futex Futex.
    67  *
    68  * @return ENOENT if there is no such virtual address.
    69  * @return Zero in the uncontended case.
    70  * @return Otherwise one of ESYNCH_OK_ATOMIC or ESYNCH_OK_BLOCKED.
    71  *
    72  */
    73 int futex_down(futex_t *futex)
    74 {
    75         if ((atomic_signed_t) atomic_predec(&futex->val) < 0)
    76                 return __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &futex->val.count);
    77        
    78         return 0;
    79 }
    80 
    81 /** Up the futex.
    82  *
    83  * @param futex Futex.
    84  *
    85  * @return ENOENT if there is no such virtual address.
    86  * @return Zero in the uncontended case.
    87  *
    88  */
    89 int futex_up(futex_t *futex)
    90 {
    91         if ((atomic_signed_t) atomic_postinc(&futex->val) < 0)
    92                 return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &futex->val.count);
    93        
    94         return 0;
    95 }
    9649
    9750/** @}
Note: See TracChangeset for help on using the changeset viewer.