Changeset 156b6406 in mainline for uspace/lib/c/include/futex.h


Ignore:
Timestamp:
2012-12-04T16:42:06Z (11 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b188002
Parents:
b7acf38
Message:

Differentiated futexes when used with mutex semantics from those with semaphore semantics.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/futex.h

    rb7acf38 r156b6406  
    5555#define FUTEX_INITIALIZE(val) {{ (val) }, 0}
    5656
    57 #define futex_down(fut) \
     57#define futex_lock(fut) \
    5858({ \
    5959        rcu_read_lock(); \
    6060        (fut)->upgraded = rcu_access(_upgrade_futexes); \
    6161        if ((fut)->upgraded) \
    62                 (void) _futex_down((fut)); \
     62                (void) futex_down((fut)); \
    6363})
    6464
    65 #define futex_trydown(fut) \
     65#define futex_trylock(fut) \
    6666({ \
    6767        rcu_read_lock(); \
    6868        int _upgraded = rcu_access(_upgrade_futexes); \
    6969        if (_upgraded) { \
    70                 int _acquired = _futex_trydown((fut)); \
     70                int _acquired = futex_trydown((fut)); \
    7171                if (!_acquired) { \
    7272                        rcu_read_unlock(); \
     
    8181})
    8282               
    83 #define futex_up(fut) \
     83#define futex_unlock(fut) \
    8484({ \
    8585        if ((fut)->upgraded) \
    86                 (void) _futex_up((fut)); \
     86                (void) futex_up((fut)); \
    8787        rcu_read_unlock(); \
    8888})
     
    9696#define FUTEX_INITIALIZE(val) {{ (val) }}
    9797
    98 #define futex_down(fut)     (void)_futex_down((fut))
    99 #define futex_trydown(fut)  _futex_trydown((fut))
    100 #define futex_up(fut)       (void)_futex_up((fut))
     98#define futex_lock(fut)     (void) futex_down((fut))
     99#define futex_trylock(fut)  futex_trydown((fut))
     100#define futex_unlock(fut)   (void) futex_up((fut))
    101101               
    102102#endif
     
    112112 *
    113113 */
    114 static inline int _futex_trydown(futex_t *futex)
     114static inline int futex_trydown(futex_t *futex)
    115115{
    116116        return cas(&futex->val, 1, 0);
     
    126126 *
    127127 */
    128 static inline int _futex_down(futex_t *futex)
     128static inline int futex_down(futex_t *futex)
    129129{
    130130        if ((atomic_signed_t) atomic_predec(&futex->val) < 0)
     
    142142 *
    143143 */
    144 static inline int _futex_up(futex_t *futex)
     144static inline int futex_up(futex_t *futex)
    145145{
    146146        if ((atomic_signed_t) atomic_postinc(&futex->val) < 0)
Note: See TracChangeset for help on using the changeset viewer.