Changeset aaa3c457 in mainline for uspace/lib/c/generic/private


Ignore:
Timestamp:
2018-11-12T10:36:10Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a43dfcb
Parents:
3ce781f4 (diff), 6874bd2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jakub Jermář <jakub@…> (2018-11-12 10:36:10)
git-committer:
GitHub <noreply@…> (2018-11-12 10:36:10)
Message:

Merge pull request #56 from jermar/futexremoval

Remove kernel support for futexes in favor of waitq kobjects.

Location:
uspace/lib/c/generic/private
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/private/async.h

    r3ce781f4 raaa3c457  
    9595
    9696extern void __async_server_init(void);
     97extern void __async_server_fini(void);
    9798extern void __async_client_init(void);
     99extern void __async_client_fini(void);
    98100extern void __async_ports_init(void);
     101extern void __async_ports_fini(void);
    99102
    100103extern errno_t async_create_port_internal(iface_t, async_port_handler_t,
  • uspace/lib/c/generic/private/fibril.h

    r3ce781f4 raaa3c457  
    7979
    8080extern void __fibrils_init(void);
     81extern void __fibrils_fini(void);
    8182
    8283extern void fibril_wait_for(fibril_event_t *);
     
    120121} fibril_rmutex_t;
    121122
    122 #define FIBRIL_RMUTEX_INITIALIZER(name) \
    123         { .futex = FUTEX_INITIALIZE(1) }
    124 
    125 #define FIBRIL_RMUTEX_INITIALIZE(name) \
    126         fibril_rmutex_t name = FIBRIL_RMUTEX_INITIALIZER(name)
    127 
    128 extern void fibril_rmutex_initialize(fibril_rmutex_t *);
     123extern errno_t fibril_rmutex_initialize(fibril_rmutex_t *);
     124extern void fibril_rmutex_destroy(fibril_rmutex_t *);
    129125extern void fibril_rmutex_lock(fibril_rmutex_t *);
    130126extern bool fibril_rmutex_trylock(fibril_rmutex_t *);
  • uspace/lib/c/generic/private/futex.h

    r3ce781f4 raaa3c457  
    4242#include <time.h>
    4343#include <fibril.h>
     44#include <abi/cap.h>
     45#include <abi/synch.h>
    4446
    4547typedef struct futex {
    4648        volatile atomic_int val;
     49        volatile cap_waitq_handle_t whandle;
     50
    4751#ifdef CONFIG_DEBUG_FUTEX
    4852        _Atomic(fibril_t *) owner;
     
    5054} futex_t;
    5155
    52 extern void futex_initialize(futex_t *futex, int value);
     56extern errno_t futex_initialize(futex_t *futex, int value);
     57
     58static inline errno_t futex_destroy(futex_t *futex)
     59{
     60        if (futex->whandle) {
     61                errno_t rc;
     62                rc = __SYSCALL1(SYS_WAITQ_DESTROY, (sysarg_t) futex->whandle);
     63                futex->whandle = CAP_NIL;
     64                return rc;
     65        }
     66        return EOK;
     67}
    5368
    5469#ifdef CONFIG_DEBUG_FUTEX
    55 
    56 #define FUTEX_INITIALIZE(val) { (val) , NULL }
    57 #define FUTEX_INITIALIZER     FUTEX_INITIALIZE(1)
    5870
    5971void __futex_assert_is_locked(futex_t *, const char *);
     
    7486#else
    7587
    76 #define FUTEX_INITIALIZE(val) { (val) }
    77 #define FUTEX_INITIALIZER     FUTEX_INITIALIZE(1)
    78 
    7988#define futex_lock(fut)     (void) futex_down((fut))
    8089#define futex_trylock(fut)  futex_trydown((fut))
     
    8695
    8796#endif
     97
     98static inline errno_t futex_allocate_waitq(futex_t *futex)
     99{
     100        return __SYSCALL1(SYS_WAITQ_CREATE, (sysarg_t) &futex->whandle);
     101}
    88102
    89103/** Down the futex with timeout, composably.
     
    107121{
    108122        // TODO: Add tests for this.
     123
     124        assert(futex->whandle != CAP_NIL);
    109125
    110126        if (atomic_fetch_sub_explicit(&futex->val, 1, memory_order_acquire) > 0)
     
    132148        }
    133149
    134         return __SYSCALL2(SYS_FUTEX_SLEEP, (sysarg_t) futex, (sysarg_t) timeout);
     150        return __SYSCALL3(SYS_WAITQ_SLEEP, (sysarg_t) futex->whandle,
     151            (sysarg_t) timeout, (sysarg_t) SYNCH_FLAGS_FUTEX);
    135152}
    136153
     
    147164{
    148165        if (atomic_fetch_add_explicit(&futex->val, 1, memory_order_release) < 0)
    149                 return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) futex);
     166                return __SYSCALL1(SYS_WAITQ_WAKEUP, (sysarg_t) futex->whandle);
    150167
    151168        return EOK;
  • uspace/lib/c/generic/private/malloc.h

    r3ce781f4 raaa3c457  
    3737
    3838extern void __malloc_init(void);
     39extern void __malloc_fini(void);
    3940
    4041#endif
Note: See TracChangeset for help on using the changeset viewer.