Changeset 156b6406 in mainline for uspace/lib/c/include/futex.h
- Timestamp:
- 2012-12-04T16:42:06Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b188002
- Parents:
- b7acf38
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/futex.h
rb7acf38 r156b6406 55 55 #define FUTEX_INITIALIZE(val) {{ (val) }, 0} 56 56 57 #define futex_ down(fut) \57 #define futex_lock(fut) \ 58 58 ({ \ 59 59 rcu_read_lock(); \ 60 60 (fut)->upgraded = rcu_access(_upgrade_futexes); \ 61 61 if ((fut)->upgraded) \ 62 (void) _futex_down((fut)); \62 (void) futex_down((fut)); \ 63 63 }) 64 64 65 #define futex_try down(fut) \65 #define futex_trylock(fut) \ 66 66 ({ \ 67 67 rcu_read_lock(); \ 68 68 int _upgraded = rcu_access(_upgrade_futexes); \ 69 69 if (_upgraded) { \ 70 int _acquired = _futex_trydown((fut)); \70 int _acquired = futex_trydown((fut)); \ 71 71 if (!_acquired) { \ 72 72 rcu_read_unlock(); \ … … 81 81 }) 82 82 83 #define futex_u p(fut) \83 #define futex_unlock(fut) \ 84 84 ({ \ 85 85 if ((fut)->upgraded) \ 86 (void) _futex_up((fut)); \86 (void) futex_up((fut)); \ 87 87 rcu_read_unlock(); \ 88 88 }) … … 96 96 #define FUTEX_INITIALIZE(val) {{ (val) }} 97 97 98 #define futex_ down(fut) (void)_futex_down((fut))99 #define futex_try down(fut) _futex_trydown((fut))100 #define futex_u p(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)) 101 101 102 102 #endif … … 112 112 * 113 113 */ 114 static inline int _futex_trydown(futex_t *futex)114 static inline int futex_trydown(futex_t *futex) 115 115 { 116 116 return cas(&futex->val, 1, 0); … … 126 126 * 127 127 */ 128 static inline int _futex_down(futex_t *futex)128 static inline int futex_down(futex_t *futex) 129 129 { 130 130 if ((atomic_signed_t) atomic_predec(&futex->val) < 0) … … 142 142 * 143 143 */ 144 static inline int _futex_up(futex_t *futex)144 static inline int futex_up(futex_t *futex) 145 145 { 146 146 if ((atomic_signed_t) atomic_postinc(&futex->val) < 0)
Note:
See TracChangeset
for help on using the changeset viewer.