Changeset 498ced1 in mainline


Ignore:
Timestamp:
2018-08-11T02:43:32Z (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:
05882233
Parents:
b13d80b
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-11 02:29:02)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-11 02:43:32)
Message:

Unify reference counting and remove some unnecessary instances of <atomic.h>

Location:
uspace
Files:
1 added
38 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/rcutest/rcutest.c

    rb13d80b r498ced1  
    3535 */
    3636
     37#include <atomic.h>
    3738#include <stdio.h>
    3839#include <stdlib.h>
  • uspace/app/wavplay/main.c

    rb13d80b r498ced1  
    3535
    3636#include <assert.h>
     37#include <atomic.h>
    3738#include <errno.h>
    3839#include <fibril_synch.h>
  • uspace/lib/c/generic/assert.c

    rb13d80b r498ced1  
    3535#include <io/kio.h>
    3636#include <stdlib.h>
    37 #include <atomic.h>
    3837#include <stacktrace.h>
    3938#include <stdint.h>
    4039#include <task.h>
    4140
    42 static atomic_t failed_asserts = { 0 };
     41__thread int failed_asserts = 0;
    4342
    4443void __helenos_assert_quick_abort(const char *cond, const char *file, unsigned int line)
     
    6968         * Check if this is a nested or parallel assert.
    7069         */
    71         if (atomic_postinc(&failed_asserts))
     70        failed_asserts++;
     71        if (failed_asserts > 0)
    7272                abort();
    7373
  • uspace/lib/c/generic/async/client.c

    rb13d80b r498ced1  
    185185        list_initialize(&session_ns.exch_list);
    186186        fibril_mutex_initialize(&session_ns.mutex);
    187         atomic_set(&session_ns.refcnt, 0);
     187        session_ns.exchanges = 0;
    188188}
    189189
     
    605605        }
    606606
    607         async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
     607        async_sess_t *sess = calloc(1, sizeof(async_sess_t));
    608608        if (sess == NULL) {
    609609                errno = ENOMEM;
     
    627627
    628628        fibril_mutex_initialize(&sess->remote_state_mtx);
    629         sess->remote_state_data = NULL;
    630 
    631629        list_initialize(&sess->exch_list);
    632630        fibril_mutex_initialize(&sess->mutex);
    633         atomic_set(&sess->refcnt, 0);
    634631
    635632        return sess;
     
    676673        }
    677674
    678         async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
     675        async_sess_t *sess = calloc(1, sizeof(async_sess_t));
    679676        if (sess == NULL) {
    680677                errno = ENOMEM;
     
    698695
    699696        fibril_mutex_initialize(&sess->remote_state_mtx);
    700         sess->remote_state_data = NULL;
    701 
    702697        list_initialize(&sess->exch_list);
    703698        fibril_mutex_initialize(&sess->mutex);
    704         atomic_set(&sess->refcnt, 0);
    705699
    706700        return sess;
     
    712706async_sess_t *async_connect_kbox(task_id_t id)
    713707{
    714         async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
     708        async_sess_t *sess = calloc(1, sizeof(async_sess_t));
    715709        if (sess == NULL) {
    716710                errno = ENOMEM;
     
    729723        sess->mgmt = EXCHANGE_ATOMIC;
    730724        sess->phone = phone;
    731         sess->arg1 = 0;
    732         sess->arg2 = 0;
    733         sess->arg3 = 0;
    734725
    735726        fibril_mutex_initialize(&sess->remote_state_mtx);
    736         sess->remote_state_data = NULL;
    737 
    738727        list_initialize(&sess->exch_list);
    739728        fibril_mutex_initialize(&sess->mutex);
    740         atomic_set(&sess->refcnt, 0);
    741729
    742730        return sess;
     
    761749        assert(sess);
    762750
    763         if (atomic_get(&sess->refcnt) > 0)
    764                 return EBUSY;
    765 
    766751        fibril_mutex_lock(&async_sess_mutex);
     752
     753        assert(sess->exchanges == 0);
    767754
    768755        errno_t rc = async_hangup_internal(sess->phone);
     
    874861        }
    875862
     863        if (exch != NULL)
     864                sess->exchanges++;
     865
    876866        fibril_mutex_unlock(&async_sess_mutex);
    877867
    878         if (exch != NULL) {
    879                 atomic_inc(&sess->refcnt);
    880 
    881                 if (mgmt == EXCHANGE_SERIALIZE)
    882                         fibril_mutex_lock(&sess->mutex);
    883         }
     868        if (exch != NULL && mgmt == EXCHANGE_SERIALIZE)
     869                fibril_mutex_lock(&sess->mutex);
    884870
    885871        return exch;
     
    903889                mgmt = sess->iface & IFACE_EXCHANGE_MASK;
    904890
    905         atomic_dec(&sess->refcnt);
    906 
    907891        if (mgmt == EXCHANGE_SERIALIZE)
    908892                fibril_mutex_unlock(&sess->mutex);
    909893
    910894        fibril_mutex_lock(&async_sess_mutex);
     895
     896        sess->exchanges--;
    911897
    912898        list_append(&exch->sess_link, &sess->exch_list);
  • uspace/lib/c/generic/async/server.c

    rb13d80b r498ced1  
    129129
    130130        task_id_t in_task_id;
    131         atomic_t refcnt;
     131        int refcnt;
    132132        void *data;
    133133} client_t;
     
    327327        if (link) {
    328328                client = hash_table_get_inst(link, client_t, link);
    329                 atomic_inc(&client->refcnt);
     329                client->refcnt++;
    330330        } else if (create) {
    331331                // TODO: move the malloc out of critical section
     
    336336                        client->data = async_client_data_create();
    337337
    338                         atomic_set(&client->refcnt, 1);
     338                        client->refcnt = 1;
    339339                        hash_table_insert(&client_hash_table, &client->link);
    340340                }
     
    351351        fibril_rmutex_lock(&client_mutex);
    352352
    353         if (atomic_predec(&client->refcnt) == 0) {
     353        if (--client->refcnt == 0) {
    354354                hash_table_remove(&client_hash_table, &client->in_task_id);
    355355                destroy = true;
     
    15741574        }
    15751575
    1576         async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
     1576        async_sess_t *sess = calloc(1, sizeof(async_sess_t));
    15771577        if (sess == NULL) {
    15781578                async_answer_0(&call, ENOMEM);
     
    15831583        sess->mgmt = mgmt;
    15841584        sess->phone = phandle;
    1585         sess->arg1 = 0;
    1586         sess->arg2 = 0;
    1587         sess->arg3 = 0;
    15881585
    15891586        fibril_mutex_initialize(&sess->remote_state_mtx);
    1590         sess->remote_state_data = NULL;
    1591 
    15921587        list_initialize(&sess->exch_list);
    15931588        fibril_mutex_initialize(&sess->mutex);
    1594         atomic_set(&sess->refcnt, 0);
    15951589
    15961590        /* Acknowledge the connected phone */
     
    16221616                return NULL;
    16231617
    1624         async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
     1618        async_sess_t *sess = calloc(1, sizeof(async_sess_t));
    16251619        if (sess == NULL)
    16261620                return NULL;
     
    16291623        sess->mgmt = mgmt;
    16301624        sess->phone = phandle;
    1631         sess->arg1 = 0;
    1632         sess->arg2 = 0;
    1633         sess->arg3 = 0;
    16341625
    16351626        fibril_mutex_initialize(&sess->remote_state_mtx);
    1636         sess->remote_state_data = NULL;
    1637 
    16381627        list_initialize(&sess->exch_list);
    16391628        fibril_mutex_initialize(&sess->mutex);
    1640         atomic_set(&sess->refcnt, 0);
    16411629
    16421630        return sess;
  • uspace/lib/c/generic/ddi.c

    rb13d80b r498ced1  
    3434
    3535#include <assert.h>
    36 #include <atomic.h>
    3736#include <stdio.h>
    3837#include <errno.h>
  • uspace/lib/c/generic/private/async.h

    rb13d80b r498ced1  
    7070
    7171        /** Number of opened exchanges */
    72         atomic_t refcnt;
     72        int exchanges;
    7373
    7474        /** Mutex for stateful connections */
  • uspace/lib/c/generic/private/fibril.h

    rb13d80b r498ced1  
    3434#include <tls.h>
    3535#include <abi/proc/uarg.h>
    36 #include <atomic.h>
    3736#include <fibril.h>
    3837
  • uspace/lib/c/include/async.h

    rb13d80b r498ced1  
    4343#include <fibril.h>
    4444#include <sys/time.h>
    45 #include <atomic.h>
    4645#include <stdbool.h>
    4746#include <abi/proc/task.h>
  • uspace/lib/drv/generic/driver.c

    rb13d80b r498ced1  
    578578static void dev_add_ref(ddf_dev_t *dev)
    579579{
    580         atomic_inc(&dev->refcnt);
     580        refcount_up(&dev->refcnt);
    581581}
    582582
     
    587587static void dev_del_ref(ddf_dev_t *dev)
    588588{
    589         if (atomic_predec(&dev->refcnt) == 0)
     589        if (refcount_down(&dev->refcnt))
    590590                delete_device(dev);
    591591}
     
    600600{
    601601        dev_add_ref(fun->dev);
    602         atomic_inc(&fun->refcnt);
     602        refcount_up(&fun->refcnt);
    603603}
    604604
     
    611611        ddf_dev_t *dev = fun->dev;
    612612
    613         if (atomic_predec(&fun->refcnt) == 0)
     613        if (refcount_down(&fun->refcnt))
    614614                delete_function(fun);
    615615
  • uspace/lib/drv/generic/private/driver.h

    rb13d80b r498ced1  
    3838
    3939#include <async.h>
     40#include <refcount.h>
    4041#include <ipc/devman.h>
    4142#include <ipc/dev_iface.h>
     
    5152
    5253        /** Reference count */
    53         atomic_t refcnt;
     54        atomic_refcount_t refcnt;
    5455
    5556        /** Session with the parent device driver */
     
    7576
    7677        /** Reference count */
    77         atomic_t refcnt;
     78        atomic_refcount_t refcnt;
    7879
    7980        /** Device which this function belogs to */
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    rb13d80b r498ced1  
    4242
    4343#include <adt/list.h>
    44 #include <atomic.h>
    4544#include <fibril_synch.h>
     45#include <refcount.h>
    4646#include <stdbool.h>
    4747#include <sys/time.h>
     
    7878        device_t *device;
    7979        /** Reference count. */
    80         atomic_t refcnt;
     80        atomic_refcount_t refcnt;
    8181
    8282        /** An inherited guard */
  • uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h

    rb13d80b r498ced1  
    3838#define LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H
    3939
    40 #include <atomic.h>
    4140#include <errno.h>
     41#include <refcount.h>
    4242#include <stddef.h>
    4343#include <stdint.h>
  • uspace/lib/usbhost/src/endpoint.c

    rb13d80b r498ced1  
    3636
    3737#include <assert.h>
    38 #include <atomic.h>
    3938#include <mem.h>
    4039#include <stdlib.h>
     
    6059        ep->device = dev;
    6160
    62         atomic_set(&ep->refcnt, 0);
     61        refcount_init(&ep->refcnt);
    6362        fibril_condvar_initialize(&ep->avail);
    6463
     
    9190void endpoint_add_ref(endpoint_t *ep)
    9291{
    93         atomic_inc(&ep->refcnt);
     92        refcount_up(&ep->refcnt);
    9493}
    9594
     
    115114void endpoint_del_ref(endpoint_t *ep)
    116115{
    117         if (atomic_predec(&ep->refcnt) == 0) {
     116        if (refcount_down(&ep->refcnt))
    118117                endpoint_destroy(ep);
    119         }
    120118}
    121119
  • uspace/srv/audio/hound/audio_data.c

    rb13d80b r498ced1  
    5959                adata->size = size - overflow;
    6060                adata->format = format;
    61                 atomic_set(&adata->refcount, 1);
     61                refcount_init(&adata->refcount);
    6262        }
    6363        return adata;
     
    7171{
    7272        assert(adata);
    73         assert(atomic_get(&adata->refcount) > 0);
    74         atomic_inc(&adata->refcount);
     73        refcount_up(&adata->refcount);
    7574}
    7675
     
    8281{
    8382        assert(adata);
    84         assert(atomic_get(&adata->refcount) > 0);
    85         atomic_count_t refc = atomic_predec(&adata->refcount);
    86         if (refc == 0) {
     83        if (refcount_down(&adata->refcount)) {
    8784                free(adata->data);
    8885                free(adata);
  • uspace/srv/audio/hound/audio_data.h

    rb13d80b r498ced1  
    3838
    3939#include <adt/list.h>
    40 #include <atomic.h>
     40#include <refcount.h>
    4141#include <errno.h>
    4242#include <fibril_synch.h>
     
    5252        pcm_format_t format;
    5353        /** Reference counter */
    54         atomic_t refcount;
     54        atomic_refcount_t refcount;
    5555} audio_data_t;
    5656
  • uspace/srv/bd/vbd/disk.c

    rb13d80b r498ced1  
    244244{
    245245        log_msg(LOG_DEFAULT, LVL_DEBUG2, "vbds_part_add_ref");
    246         atomic_inc(&part->refcnt);
     246        refcount_up(&part->refcnt);
    247247}
    248248
     
    250250{
    251251        log_msg(LOG_DEFAULT, LVL_DEBUG2, "vbds_part_del_ref");
    252         if (atomic_predec(&part->refcnt) == 0) {
     252        if (refcount_down(&part->refcnt)) {
    253253                log_msg(LOG_DEFAULT, LVL_DEBUG2, " - free part");
    254254                free(part);
     
    328328        part->block0 = lpinfo.block0;
    329329        part->nblocks = lpinfo.nblocks;
    330         atomic_set(&part->refcnt, 1);
     330        refcount_init(&part->refcnt);
    331331
    332332        bd_srvs_init(&part->bds);
  • uspace/srv/bd/vbd/types/vbd.h

    rb13d80b r498ced1  
    3939
    4040#include <adt/list.h>
    41 #include <atomic.h>
    4241#include <bd_srv.h>
    4342#include <label/label.h>
    4443#include <loc.h>
     44#include <refcount.h>
    4545#include <stdbool.h>
    4646#include <stddef.h>
     
    8383        aoff64_t nblocks;
    8484        /** Reference count */
    85         atomic_t refcnt;
     85        atomic_refcount_t refcnt;
    8686} vbds_part_t;
    8787
  • uspace/srv/devman/dev.c

    rb13d80b r498ced1  
    4848                return NULL;
    4949
    50         atomic_set(&dev->refcnt, 0);
     50        refcount_init(&dev->refcnt);
    5151        list_initialize(&dev->functions);
    5252        link_initialize(&dev->driver_devices);
     
    7474void dev_add_ref(dev_node_t *dev)
    7575{
    76         atomic_inc(&dev->refcnt);
     76        refcount_up(&dev->refcnt);
    7777}
    7878
     
    8585void dev_del_ref(dev_node_t *dev)
    8686{
    87         if (atomic_predec(&dev->refcnt) == 0)
     87        if (refcount_down(&dev->refcnt))
    8888                delete_dev_node(dev);
    8989}
  • uspace/srv/devman/devman.h

    rb13d80b r498ced1  
    4141#include <ipc/loc.h>
    4242#include <fibril_synch.h>
    43 #include <atomic.h>
     43#include <refcount.h>
    4444#include <async.h>
    4545
     
    115115struct dev_node {
    116116        /** Reference count */
    117         atomic_t refcnt;
     117        atomic_refcount_t refcnt;
    118118
    119119        /** The global unique identifier of the device. */
     
    155155struct fun_node {
    156156        /** Reference count */
    157         atomic_t refcnt;
     157        atomic_refcount_t refcnt;
    158158        /** State */
    159159        fun_state_t state;
  • uspace/srv/devman/driver.c

    rb13d80b r498ced1  
    406406                }
    407407
    408                 log_msg(LOG_DEFAULT, LVL_DEBUG, "pass_devices_to_driver: dev->refcnt=%d\n",
    409                     (int)atomic_get(&dev->refcnt));
    410408                dev_add_ref(dev);
    411409
  • uspace/srv/devman/fun.c

    rb13d80b r498ced1  
    6060
    6161        fun->state = FUN_INIT;
    62         atomic_set(&fun->refcnt, 0);
     62        refcount_init(&fun->refcnt);
    6363        fibril_mutex_initialize(&fun->busy_lock);
    6464        link_initialize(&fun->dev_functions);
     
    8989void fun_add_ref(fun_node_t *fun)
    9090{
    91         atomic_inc(&fun->refcnt);
     91        refcount_up(&fun->refcnt);
    9292}
    9393
     
    100100void fun_del_ref(fun_node_t *fun)
    101101{
    102         if (atomic_predec(&fun->refcnt) == 0)
     102        if (refcount_down(&fun->refcnt))
    103103                delete_fun_node(fun);
    104104}
  • uspace/srv/fs/exfat/exfat.h

    rb13d80b r498ced1  
    3838#include <fibril_synch.h>
    3939#include <libfs.h>
    40 #include <atomic.h>
    4140#include <stdint.h>
    4241#include <stdbool.h>
  • uspace/srv/fs/fat/fat.h

    rb13d80b r498ced1  
    3838#include <fibril_synch.h>
    3939#include <libfs.h>
    40 #include <atomic.h>
    4140#include <stdint.h>
    4241#include <stdbool.h>
  • uspace/srv/fs/tmpfs/tmpfs.h

    rb13d80b r498ced1  
    3535
    3636#include <libfs.h>
    37 #include <atomic.h>
    3837#include <stddef.h>
    3938#include <stdbool.h>
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    rb13d80b r498ced1  
    4343#include <async.h>
    4444#include <errno.h>
    45 #include <atomic.h>
    4645#include <stdlib.h>
    4746#include <str.h>
  • uspace/srv/fs/udf/udf.h

    rb13d80b r498ced1  
    3737#include <fibril_synch.h>
    3838#include <libfs.h>
    39 #include <atomic.h>
    4039#include <stddef.h>
    4140#include <stdint.h>
  • uspace/srv/hid/compositor/compositor.c

    rb13d80b r498ced1  
    3333 */
    3434
     35#include <assert.h>
    3536#include <stddef.h>
    3637#include <stdint.h>
     
    4647#include <stdlib.h>
    4748
    48 #include <atomic.h>
     49#include <refcount.h>
    4950#include <fibril_synch.h>
    5051#include <adt/prodcons.h>
     
    9394typedef struct {
    9495        link_t link;
    95         atomic_t ref_cnt;
     96        atomic_refcount_t ref_cnt;
    9697        window_flags_t flags;
    9798        service_id_t in_dsid;
     
    223224
    224225        link_initialize(&win->link);
    225         atomic_set(&win->ref_cnt, 0);
     226        refcount_init(&win->ref_cnt);
    226227        prodcons_initialize(&win->queue);
    227228        transform_identity(&win->transform);
     
    240241static void window_destroy(window_t *win)
    241242{
    242         if ((win) && (atomic_get(&win->ref_cnt) == 0)) {
    243                 while (!list_empty(&win->queue.list)) {
    244                         window_event_t *event = (window_event_t *) list_first(&win->queue.list);
    245                         list_remove(&event->link);
    246                         free(event);
    247                 }
    248 
    249                 if (win->surface)
    250                         surface_destroy(win->surface);
    251 
    252                 free(win);
    253         }
     243        if (!win || !refcount_down(&win->ref_cnt))
     244                return;
     245
     246        while (!list_empty(&win->queue.list)) {
     247                window_event_t *event = (window_event_t *) list_first(&win->queue.list);
     248                list_remove(&event->link);
     249                free(event);
     250        }
     251
     252        if (win->surface)
     253                surface_destroy(win->surface);
     254
     255        free(win);
    254256}
    255257
     
    988990                }
    989991        }
     992
     993        if (win)
     994                refcount_up(&win->ref_cnt);
     995
    990996        fibril_mutex_unlock(&window_list_mtx);
    991997
    992998        if (win) {
    993                 atomic_inc(&win->ref_cnt);
    994999                async_answer_0(icall, EOK);
    9951000        } else {
     
    10051010                        if (!IPC_GET_IMETHOD(call)) {
    10061011                                async_answer_0(&call, EOK);
    1007                                 atomic_dec(&win->ref_cnt);
    10081012                                window_destroy(win);
    10091013                                return;
     
    10241028                        if (!IPC_GET_IMETHOD(call)) {
    10251029                                comp_window_close(win, &call);
    1026                                 atomic_dec(&win->ref_cnt);
    10271030                                window_destroy(win);
    10281031                                return;
  • uspace/srv/hid/console/console.c

    rb13d80b r498ced1  
    3434
    3535#include <async.h>
     36#include <atomic.h>
    3637#include <stdio.h>
    3738#include <adt/prodcons.h>
  • uspace/srv/net/tcp/conn.c

    rb13d80b r498ced1  
    128128
    129129        /* One for the user, one for not being in closed state */
    130         atomic_set(&conn->refcnt, 2);
     130        refcount_init(&conn->refcnt);
     131        refcount_up(&conn->refcnt);
    131132
    132133        /* Allocate receive buffer */
     
    238239void tcp_conn_addref(tcp_conn_t *conn)
    239240{
    240         log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_addref(%p) before=%zu",
    241             conn->name, conn, atomic_get(&conn->refcnt));
    242         atomic_inc(&conn->refcnt);
     241        log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_addref(%p)",
     242            conn->name, conn);
     243
     244        refcount_up(&conn->refcnt);
    243245}
    244246
     
    251253void tcp_conn_delref(tcp_conn_t *conn)
    252254{
    253         log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_delref(%p) before=%zu",
    254             conn->name, conn, atomic_get(&conn->refcnt));
    255 
    256         if (atomic_predec(&conn->refcnt) == 0)
     255        log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_delref(%p)",
     256            conn->name, conn);
     257
     258        if (refcount_down(&conn->refcnt))
    257259                tcp_conn_free(conn);
    258260}
  • uspace/srv/net/tcp/tcp_type.h

    rb13d80b r498ced1  
    4141#include <fibril.h>
    4242#include <fibril_synch.h>
     43#include <refcount.h>
    4344#include <stddef.h>
    4445#include <stdint.h>
     
    248249        fibril_mutex_t lock;
    249250        /** Reference count */
    250         atomic_t refcnt;
     251        atomic_refcount_t refcnt;
    251252
    252253        /** Connection state */
  • uspace/srv/net/udp/assoc.c

    rb13d80b r498ced1  
    9191
    9292        /* One for the user */
    93         atomic_set(&assoc->refcnt, 1);
     93        refcount_init(&assoc->refcnt);
    9494
    9595        /* Initialize receive queue */
     
    145145{
    146146        log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: upd_assoc_addref(%p)", assoc->name, assoc);
    147         atomic_inc(&assoc->refcnt);
     147        refcount_up(&assoc->refcnt);
    148148}
    149149
     
    158158        log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: udp_assoc_delref(%p)", assoc->name, assoc);
    159159
    160         if (atomic_predec(&assoc->refcnt) == 0)
     160        if (refcount_down(&assoc->refcnt))
    161161                udp_assoc_free(assoc);
    162162}
  • uspace/srv/net/udp/udp_type.h

    rb13d80b r498ced1  
    4141#include <inet/endpoint.h>
    4242#include <ipc/loc.h>
     43#include <refcount.h>
    4344#include <stdbool.h>
    4445#include <stddef.h>
     
    114115        fibril_mutex_t lock;
    115116        /** Reference count */
    116         atomic_t refcnt;
     117        atomic_refcount_t refcnt;
    117118
    118119        /** Receive queue */
  • uspace/srv/vfs/vfs.c

    rb13d80b r498ced1  
    4949#include <str.h>
    5050#include <as.h>
    51 #include <atomic.h>
    5251#include <macros.h>
    5352#include "vfs.h"
  • uspace/srv/volsrv/part.c

    rb13d80b r498ced1  
    179179        }
    180180
    181         atomic_set(&part->refcnt, 1);
     181        refcount_init(&part->refcnt);
    182182        link_initialize(&part->lparts);
    183183        part->parts = NULL;
     
    524524                if (part->svc_id == sid) {
    525525                        /* Add reference */
    526                         atomic_inc(&part->refcnt);
     526                        refcount_up(&part->refcnt);
    527527                        *rpart = part;
    528528                        return EOK;
     
    547547void vol_part_del_ref(vol_part_t *part)
    548548{
    549         if (atomic_predec(&part->refcnt) == 0)
     549        if (refcount_down(&part->refcnt))
    550550                vol_part_delete(part);
    551551}
  • uspace/srv/volsrv/types/part.h

    rb13d80b r498ced1  
    3939
    4040#include <adt/list.h>
    41 #include <atomic.h>
     41#include <refcount.h>
    4242#include <fibril_synch.h>
    4343#include <stdbool.h>
     
    5151        link_t lparts;
    5252        /** Reference count */
    53         atomic_t refcnt;
     53        atomic_refcount_t refcnt;
    5454        /** Service ID */
    5555        service_id_t svc_id;
  • uspace/srv/volsrv/types/volume.h

    rb13d80b r498ced1  
    3939
    4040#include <adt/list.h>
    41 #include <atomic.h>
     41#include <refcount.h>
    4242#include <fibril_synch.h>
    4343#include <sif.h>
     
    5050        link_t lvolumes;
    5151        /** Reference count */
    52         atomic_t refcnt;
     52        atomic_refcount_t refcnt;
    5353        /** Volume label */
    5454        char *label;
  • uspace/srv/volsrv/volume.c

    rb13d80b r498ced1  
    8383        }
    8484
    85         atomic_set(&volume->refcnt, 1);
     85        refcount_init(&volume->refcnt);
    8686        link_initialize(&volume->lvolumes);
    8787        volume->volumes = NULL;
     
    245245                    str_size(label) > 0) {
    246246                        /* Add reference */
    247                         atomic_inc(&volume->refcnt);
     247                        refcount_up(&volume->refcnt);
    248248                        *rvolume = volume;
    249249                        return EOK;
     
    309309void vol_volume_del_ref(vol_volume_t *volume)
    310310{
    311         if (atomic_predec(&volume->refcnt) == 0) {
     311        if (refcount_down(&volume->refcnt)) {
    312312                /* No more references. Check if volume is persistent. */
    313313                if (!vol_volume_is_persist(volume)) {
Note: See TracChangeset for help on using the changeset viewer.