Ignore:
Timestamp:
2018-07-05T21:41:21Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c71c171
Parents:
6d8a63a
git-author:
Dzejrou <dzejrou@…> (2018-04-20 00:11:54)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
Message:

cpp: revamped c header wrappers, now only include standard symbols, others are in std::hel, fixed some bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/internal/thread.hpp

    r6d8a63a rde53138  
    3030#define LIBCPP_INTERNAL_THREAD
    3131
    32 namespace std
    33 { // TODO: fix cheaders
     32namespace std::hel
     33{
    3434    extern "C" {
    3535        #include <fibril.h>
     
    5454    struct threading_policy<fibril_tag>
    5555    {
    56         using mutex_type        = fibril_mutex_t;
    57         using thread_type       = fid_t;
    58         using condvar_type      = fibril_condvar_t;
    59         using time_unit         = suseconds_t;
    60         using shared_mutex_type = fibril_rwlock_t;
     56        using mutex_type        = hel::fibril_mutex_t;
     57        using thread_type       = hel::fid_t;
     58        using condvar_type      = hel::fibril_condvar_t;
     59        using time_unit         = hel::suseconds_t;
     60        using shared_mutex_type = hel::fibril_rwlock_t;
    6161
    6262        struct thread
     
    6565            static thread_type create(Callable clbl, Payload& pld)
    6666            {
    67                 return fibril_create(clbl, (void*)&pld);
     67                return hel::fibril_create(clbl, (void*)&pld);
    6868            }
    6969
    7070            static void start(thread_type thr)
    7171            {
    72                 fibril_add_ready(thr);
     72                hel::fibril_add_ready(thr);
    7373            }
    7474
    7575            static thread_type this_thread()
    7676            {
    77                 return fibril_get_id();
     77                return hel::fibril_get_id();
    7878            }
    7979
    8080            static void yield()
    8181            {
    82                 fibril_yield();
     82                hel::fibril_yield();
    8383            }
    8484
     
    9494            static void init(mutex_type& mtx)
    9595            {
    96                 fibril_mutex_initialize(&mtx);
     96                hel::fibril_mutex_initialize(&mtx);
    9797            }
    9898
    9999            static void lock(mutex_type& mtx)
    100100            {
    101                 fibril_mutex_lock(&mtx);
     101                hel::fibril_mutex_lock(&mtx);
    102102            }
    103103
    104104            static void unlock(mutex_type& mtx)
    105105            {
    106                 fibril_mutex_unlock(&mtx);
     106                hel::fibril_mutex_unlock(&mtx);
    107107            }
    108108
    109109            static bool try_lock(mutex_type& mtx)
    110110            {
    111                 return fibril_mutex_trylock(&mtx);
     111                return hel::fibril_mutex_trylock(&mtx);
    112112            }
    113113
     
    123123            static void init(condvar_type& cv)
    124124            {
    125                 fibril_condvar_initialize(&cv);
     125                hel::fibril_condvar_initialize(&cv);
    126126            }
    127127
    128128            static void wait(condvar_type& cv, mutex_type& mtx)
    129129            {
    130                 fibril_condvar_wait(&cv, &mtx);
     130                hel::fibril_condvar_wait(&cv, &mtx);
    131131            }
    132132
    133133            static int wait_for(condvar_type& cv, mutex_type& mtx, time_unit timeout)
    134134            {
    135                 return fibril_condvar_wait_timeout(&cv, &mtx, timeout);
     135                return hel::fibril_condvar_wait_timeout(&cv, &mtx, timeout);
    136136            }
    137137
    138138            static void signal(condvar_type& cv)
    139139            {
    140                 fibril_condvar_signal(&cv);
     140                hel::fibril_condvar_signal(&cv);
    141141            }
    142142
    143143            static void broadcast(condvar_type& cv)
    144144            {
    145                 fibril_condvar_broadcast(&cv);
     145                hel::fibril_condvar_broadcast(&cv);
    146146            }
    147147        };
     
    157157            static void sleep(time_unit time)
    158158            {
    159                 fibril_usleep(time);
     159                hel::fibril_usleep(time);
    160160            }
    161161        };
     
    165165            static void init(shared_mutex_type& mtx)
    166166            {
    167                 fibril_rwlock_initialize(&mtx);
     167                hel::fibril_rwlock_initialize(&mtx);
    168168            }
    169169
    170170            static void lock(shared_mutex_type& mtx)
    171171            {
    172                 fibril_rwlock_write_lock(&mtx);
     172                hel::fibril_rwlock_write_lock(&mtx);
    173173            }
    174174
    175175            static void unlock(shared_mutex_type& mtx)
    176176            {
    177                 fibril_rwlock_write_unlock(&mtx);
     177                hel::fibril_rwlock_write_unlock(&mtx);
    178178            }
    179179
    180180            static void lock_shared(shared_mutex_type& mtx)
    181181            {
    182                 fibril_rwlock_read_lock(&mtx);
     182                hel::fibril_rwlock_read_lock(&mtx);
    183183            }
    184184
    185185            static void unlock_shared(shared_mutex_type& mtx)
    186186            {
    187                 fibril_rwlock_read_unlock(&mtx);
     187                hel::fibril_rwlock_read_unlock(&mtx);
    188188            }
    189189
Note: See TracChangeset for help on using the changeset viewer.