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


Ignore:
Timestamp:
2018-06-26T17:34:23Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b59318e
Parents:
38e3427
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-25 20:50:53)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-26 17:34:23)
Message:

Improve the debugging options for futexes.

File:
1 edited

Legend:

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

    r38e3427 rf6372be9  
    3939#include <errno.h>
    4040#include <libc.h>
     41#include <time.h>
    4142
    4243typedef struct futex {
    4344        atomic_t val;
     45#ifdef CONFIG_DEBUG_FUTEX
     46        _Atomic void *owner;
     47#endif
    4448} futex_t;
    4549
    4650extern void futex_initialize(futex_t *futex, int value);
     51
     52#ifdef CONFIG_DEBUG_FUTEX
     53
     54#define FUTEX_INITIALIZE(val) {{ (val) }, NULL }
     55#define FUTEX_INITIALIZER     FUTEX_INITIALIZE(1)
     56
     57void __futex_assert_is_locked(futex_t *, const char *);
     58void __futex_assert_is_not_locked(futex_t *, const char *);
     59void __futex_lock(futex_t *, const char *);
     60void __futex_unlock(futex_t *, const char *);
     61bool __futex_trylock(futex_t *, const char *);
     62void __futex_give_to(futex_t *, void *, const char *);
     63
     64#define futex_lock(futex) __futex_lock((futex), #futex)
     65#define futex_unlock(futex) __futex_unlock((futex), #futex)
     66#define futex_trylock(futex) __futex_trylock((futex), #futex)
     67
     68#define futex_give_to(futex, new_owner) __futex_give_to((futex), (new_owner), #futex)
     69#define futex_assert_is_locked(futex) __futex_assert_is_locked((futex), #futex)
     70#define futex_assert_is_not_locked(futex) __futex_assert_is_not_locked((futex), #futex)
     71
     72#else
    4773
    4874#define FUTEX_INITIALIZE(val) {{ (val) }}
     
    5278#define futex_trylock(fut)  futex_trydown((fut))
    5379#define futex_unlock(fut)   (void) futex_up((fut))
     80
     81#define futex_give_to(fut, owner) ((void)0)
     82#define futex_assert_is_locked(fut) assert((atomic_signed_t) (fut)->val.count <= 0)
     83#define futex_assert_is_not_locked(fut) ((void)0)
     84
     85#endif
    5486
    5587/** Try to down the futex.
Note: See TracChangeset for help on using the changeset viewer.