Changeset bc56f30 in mainline for uspace/lib/c/include/fibril_synch.h


Ignore:
Timestamp:
2019-05-27T12:38:26Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0d14c25
Parents:
4d51c60
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-13 16:06:49)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-05-27 12:38:26)
Message:

Make some libc and libposix headers usable in C++

These headers either get included from standard C++ headers,
or are standard themselves, which means any unnamespaced nonstandard
identifiers are a problem. This commit attempts to fix those
issues, and removes hacks previously used in libcpp to work around it.

File:
1 edited

Legend:

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

    r4d51c60 rbc56f30  
    4040#include <time.h>
    4141#include <stdbool.h>
    42 
    43 typedef struct {
    44         fibril_owner_info_t oi;  /**< Keep this the first thing. */
    45         int counter;
    46         list_t waiters;
    47 } fibril_mutex_t;
     42#include <_bits/decls.h>
     43
     44#ifndef __cplusplus
    4845
    4946#define FIBRIL_MUTEX_INITIALIZER(name) \
     
    5855#define FIBRIL_MUTEX_INITIALIZE(name) \
    5956        fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name)
    60 
    61 typedef struct {
    62         fibril_owner_info_t oi;  /**< Keep this the first thing. */
    63         unsigned int writers;
    64         unsigned int readers;
    65         list_t waiters;
    66 } fibril_rwlock_t;
    6757
    6858#define FIBRIL_RWLOCK_INITIALIZER(name) \
     
    7969        fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name)
    8070
    81 typedef struct {
    82         list_t waiters;
    83 } fibril_condvar_t;
    84 
    8571#define FIBRIL_CONDVAR_INITIALIZER(name) \
    8672        { \
     
    9076#define FIBRIL_CONDVAR_INITIALIZE(name) \
    9177        fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name)
     78
     79#define FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) \
     80        { \
     81                .count = (cnt), \
     82                .waiters = LIST_INITIALIZER((name).waiters), \
     83        }
     84
     85#define FIBRIL_SEMAPHORE_INITIALIZE(name, cnt) \
     86        fibril_semaphore_t name = FIBRIL_SEMAPHORE_INITIALIZER(name, cnt)
     87
     88#endif
     89
     90__HELENOS_DECLS_BEGIN;
     91
     92typedef struct {
     93        fibril_owner_info_t oi;  /**< Keep this the first thing. */
     94        int counter;
     95        list_t waiters;
     96} fibril_mutex_t;
     97
     98typedef struct {
     99        fibril_owner_info_t oi;  /**< Keep this the first thing. */
     100        unsigned int writers;
     101        unsigned int readers;
     102        list_t waiters;
     103} fibril_rwlock_t;
     104
     105typedef struct {
     106        list_t waiters;
     107} fibril_condvar_t;
    92108
    93109typedef void (*fibril_timer_fun_t)(void *);
     
    134150} fibril_semaphore_t;
    135151
    136 #define FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) \
    137         { \
    138                 .count = (cnt), \
    139                 .waiters = LIST_INITIALIZER((name).waiters), \
    140         }
    141 
    142 #define FIBRIL_SEMAPHORE_INITIALIZE(name, cnt) \
    143         fibril_semaphore_t name = FIBRIL_SEMAPHORE_INITIALIZER(name, cnt)
    144 
    145152extern void __fibril_synch_init(void);
    146153extern void __fibril_synch_fini(void);
     
    190197extern void mpsc_close(mpsc_t *);
    191198
     199__HELENOS_DECLS_END;
     200
    192201#endif
    193202
Note: See TracChangeset for help on using the changeset viewer.