Changeset 498ced1 in mainline
- Timestamp:
- 2018-08-11T02:43:32Z (6 years ago)
- 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)
- Location:
- uspace
- Files:
-
- 1 added
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/rcutest/rcutest.c
rb13d80b r498ced1 35 35 */ 36 36 37 #include <atomic.h> 37 38 #include <stdio.h> 38 39 #include <stdlib.h> -
uspace/app/wavplay/main.c
rb13d80b r498ced1 35 35 36 36 #include <assert.h> 37 #include <atomic.h> 37 38 #include <errno.h> 38 39 #include <fibril_synch.h> -
uspace/lib/c/generic/assert.c
rb13d80b r498ced1 35 35 #include <io/kio.h> 36 36 #include <stdlib.h> 37 #include <atomic.h>38 37 #include <stacktrace.h> 39 38 #include <stdint.h> 40 39 #include <task.h> 41 40 42 static atomic_t failed_asserts = { 0 };41 __thread int failed_asserts = 0; 43 42 44 43 void __helenos_assert_quick_abort(const char *cond, const char *file, unsigned int line) … … 69 68 * Check if this is a nested or parallel assert. 70 69 */ 71 if (atomic_postinc(&failed_asserts)) 70 failed_asserts++; 71 if (failed_asserts > 0) 72 72 abort(); 73 73 -
uspace/lib/c/generic/async/client.c
rb13d80b r498ced1 185 185 list_initialize(&session_ns.exch_list); 186 186 fibril_mutex_initialize(&session_ns.mutex); 187 atomic_set(&session_ns.refcnt, 0);187 session_ns.exchanges = 0; 188 188 } 189 189 … … 605 605 } 606 606 607 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));607 async_sess_t *sess = calloc(1, sizeof(async_sess_t)); 608 608 if (sess == NULL) { 609 609 errno = ENOMEM; … … 627 627 628 628 fibril_mutex_initialize(&sess->remote_state_mtx); 629 sess->remote_state_data = NULL;630 631 629 list_initialize(&sess->exch_list); 632 630 fibril_mutex_initialize(&sess->mutex); 633 atomic_set(&sess->refcnt, 0);634 631 635 632 return sess; … … 676 673 } 677 674 678 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));675 async_sess_t *sess = calloc(1, sizeof(async_sess_t)); 679 676 if (sess == NULL) { 680 677 errno = ENOMEM; … … 698 695 699 696 fibril_mutex_initialize(&sess->remote_state_mtx); 700 sess->remote_state_data = NULL;701 702 697 list_initialize(&sess->exch_list); 703 698 fibril_mutex_initialize(&sess->mutex); 704 atomic_set(&sess->refcnt, 0);705 699 706 700 return sess; … … 712 706 async_sess_t *async_connect_kbox(task_id_t id) 713 707 { 714 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));708 async_sess_t *sess = calloc(1, sizeof(async_sess_t)); 715 709 if (sess == NULL) { 716 710 errno = ENOMEM; … … 729 723 sess->mgmt = EXCHANGE_ATOMIC; 730 724 sess->phone = phone; 731 sess->arg1 = 0;732 sess->arg2 = 0;733 sess->arg3 = 0;734 725 735 726 fibril_mutex_initialize(&sess->remote_state_mtx); 736 sess->remote_state_data = NULL;737 738 727 list_initialize(&sess->exch_list); 739 728 fibril_mutex_initialize(&sess->mutex); 740 atomic_set(&sess->refcnt, 0);741 729 742 730 return sess; … … 761 749 assert(sess); 762 750 763 if (atomic_get(&sess->refcnt) > 0)764 return EBUSY;765 766 751 fibril_mutex_lock(&async_sess_mutex); 752 753 assert(sess->exchanges == 0); 767 754 768 755 errno_t rc = async_hangup_internal(sess->phone); … … 874 861 } 875 862 863 if (exch != NULL) 864 sess->exchanges++; 865 876 866 fibril_mutex_unlock(&async_sess_mutex); 877 867 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); 884 870 885 871 return exch; … … 903 889 mgmt = sess->iface & IFACE_EXCHANGE_MASK; 904 890 905 atomic_dec(&sess->refcnt);906 907 891 if (mgmt == EXCHANGE_SERIALIZE) 908 892 fibril_mutex_unlock(&sess->mutex); 909 893 910 894 fibril_mutex_lock(&async_sess_mutex); 895 896 sess->exchanges--; 911 897 912 898 list_append(&exch->sess_link, &sess->exch_list); -
uspace/lib/c/generic/async/server.c
rb13d80b r498ced1 129 129 130 130 task_id_t in_task_id; 131 atomic_t refcnt;131 int refcnt; 132 132 void *data; 133 133 } client_t; … … 327 327 if (link) { 328 328 client = hash_table_get_inst(link, client_t, link); 329 atomic_inc(&client->refcnt);329 client->refcnt++; 330 330 } else if (create) { 331 331 // TODO: move the malloc out of critical section … … 336 336 client->data = async_client_data_create(); 337 337 338 atomic_set(&client->refcnt, 1);338 client->refcnt = 1; 339 339 hash_table_insert(&client_hash_table, &client->link); 340 340 } … … 351 351 fibril_rmutex_lock(&client_mutex); 352 352 353 if ( atomic_predec(&client->refcnt)== 0) {353 if (--client->refcnt == 0) { 354 354 hash_table_remove(&client_hash_table, &client->in_task_id); 355 355 destroy = true; … … 1574 1574 } 1575 1575 1576 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));1576 async_sess_t *sess = calloc(1, sizeof(async_sess_t)); 1577 1577 if (sess == NULL) { 1578 1578 async_answer_0(&call, ENOMEM); … … 1583 1583 sess->mgmt = mgmt; 1584 1584 sess->phone = phandle; 1585 sess->arg1 = 0;1586 sess->arg2 = 0;1587 sess->arg3 = 0;1588 1585 1589 1586 fibril_mutex_initialize(&sess->remote_state_mtx); 1590 sess->remote_state_data = NULL;1591 1592 1587 list_initialize(&sess->exch_list); 1593 1588 fibril_mutex_initialize(&sess->mutex); 1594 atomic_set(&sess->refcnt, 0);1595 1589 1596 1590 /* Acknowledge the connected phone */ … … 1622 1616 return NULL; 1623 1617 1624 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));1618 async_sess_t *sess = calloc(1, sizeof(async_sess_t)); 1625 1619 if (sess == NULL) 1626 1620 return NULL; … … 1629 1623 sess->mgmt = mgmt; 1630 1624 sess->phone = phandle; 1631 sess->arg1 = 0;1632 sess->arg2 = 0;1633 sess->arg3 = 0;1634 1625 1635 1626 fibril_mutex_initialize(&sess->remote_state_mtx); 1636 sess->remote_state_data = NULL;1637 1638 1627 list_initialize(&sess->exch_list); 1639 1628 fibril_mutex_initialize(&sess->mutex); 1640 atomic_set(&sess->refcnt, 0);1641 1629 1642 1630 return sess; -
uspace/lib/c/generic/ddi.c
rb13d80b r498ced1 34 34 35 35 #include <assert.h> 36 #include <atomic.h>37 36 #include <stdio.h> 38 37 #include <errno.h> -
uspace/lib/c/generic/private/async.h
rb13d80b r498ced1 70 70 71 71 /** Number of opened exchanges */ 72 atomic_t refcnt;72 int exchanges; 73 73 74 74 /** Mutex for stateful connections */ -
uspace/lib/c/generic/private/fibril.h
rb13d80b r498ced1 34 34 #include <tls.h> 35 35 #include <abi/proc/uarg.h> 36 #include <atomic.h>37 36 #include <fibril.h> 38 37 -
uspace/lib/c/include/async.h
rb13d80b r498ced1 43 43 #include <fibril.h> 44 44 #include <sys/time.h> 45 #include <atomic.h>46 45 #include <stdbool.h> 47 46 #include <abi/proc/task.h> -
uspace/lib/drv/generic/driver.c
rb13d80b r498ced1 578 578 static void dev_add_ref(ddf_dev_t *dev) 579 579 { 580 atomic_inc(&dev->refcnt);580 refcount_up(&dev->refcnt); 581 581 } 582 582 … … 587 587 static void dev_del_ref(ddf_dev_t *dev) 588 588 { 589 if ( atomic_predec(&dev->refcnt) == 0)589 if (refcount_down(&dev->refcnt)) 590 590 delete_device(dev); 591 591 } … … 600 600 { 601 601 dev_add_ref(fun->dev); 602 atomic_inc(&fun->refcnt);602 refcount_up(&fun->refcnt); 603 603 } 604 604 … … 611 611 ddf_dev_t *dev = fun->dev; 612 612 613 if ( atomic_predec(&fun->refcnt) == 0)613 if (refcount_down(&fun->refcnt)) 614 614 delete_function(fun); 615 615 -
uspace/lib/drv/generic/private/driver.h
rb13d80b r498ced1 38 38 39 39 #include <async.h> 40 #include <refcount.h> 40 41 #include <ipc/devman.h> 41 42 #include <ipc/dev_iface.h> … … 51 52 52 53 /** Reference count */ 53 atomic_ t refcnt;54 atomic_refcount_t refcnt; 54 55 55 56 /** Session with the parent device driver */ … … 75 76 76 77 /** Reference count */ 77 atomic_ t refcnt;78 atomic_refcount_t refcnt; 78 79 79 80 /** Device which this function belogs to */ -
uspace/lib/usbhost/include/usb/host/endpoint.h
rb13d80b r498ced1 42 42 43 43 #include <adt/list.h> 44 #include <atomic.h>45 44 #include <fibril_synch.h> 45 #include <refcount.h> 46 46 #include <stdbool.h> 47 47 #include <sys/time.h> … … 78 78 device_t *device; 79 79 /** Reference count. */ 80 atomic_ t refcnt;80 atomic_refcount_t refcnt; 81 81 82 82 /** An inherited guard */ -
uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
rb13d80b r498ced1 38 38 #define LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H 39 39 40 #include <atomic.h>41 40 #include <errno.h> 41 #include <refcount.h> 42 42 #include <stddef.h> 43 43 #include <stdint.h> -
uspace/lib/usbhost/src/endpoint.c
rb13d80b r498ced1 36 36 37 37 #include <assert.h> 38 #include <atomic.h>39 38 #include <mem.h> 40 39 #include <stdlib.h> … … 60 59 ep->device = dev; 61 60 62 atomic_set(&ep->refcnt, 0);61 refcount_init(&ep->refcnt); 63 62 fibril_condvar_initialize(&ep->avail); 64 63 … … 91 90 void endpoint_add_ref(endpoint_t *ep) 92 91 { 93 atomic_inc(&ep->refcnt);92 refcount_up(&ep->refcnt); 94 93 } 95 94 … … 115 114 void endpoint_del_ref(endpoint_t *ep) 116 115 { 117 if ( atomic_predec(&ep->refcnt) == 0) {116 if (refcount_down(&ep->refcnt)) 118 117 endpoint_destroy(ep); 119 }120 118 } 121 119 -
uspace/srv/audio/hound/audio_data.c
rb13d80b r498ced1 59 59 adata->size = size - overflow; 60 60 adata->format = format; 61 atomic_set(&adata->refcount, 1);61 refcount_init(&adata->refcount); 62 62 } 63 63 return adata; … … 71 71 { 72 72 assert(adata); 73 assert(atomic_get(&adata->refcount) > 0); 74 atomic_inc(&adata->refcount); 73 refcount_up(&adata->refcount); 75 74 } 76 75 … … 82 81 { 83 82 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)) { 87 84 free(adata->data); 88 85 free(adata); -
uspace/srv/audio/hound/audio_data.h
rb13d80b r498ced1 38 38 39 39 #include <adt/list.h> 40 #include < atomic.h>40 #include <refcount.h> 41 41 #include <errno.h> 42 42 #include <fibril_synch.h> … … 52 52 pcm_format_t format; 53 53 /** Reference counter */ 54 atomic_ t refcount;54 atomic_refcount_t refcount; 55 55 } audio_data_t; 56 56 -
uspace/srv/bd/vbd/disk.c
rb13d80b r498ced1 244 244 { 245 245 log_msg(LOG_DEFAULT, LVL_DEBUG2, "vbds_part_add_ref"); 246 atomic_inc(&part->refcnt);246 refcount_up(&part->refcnt); 247 247 } 248 248 … … 250 250 { 251 251 log_msg(LOG_DEFAULT, LVL_DEBUG2, "vbds_part_del_ref"); 252 if ( atomic_predec(&part->refcnt) == 0) {252 if (refcount_down(&part->refcnt)) { 253 253 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - free part"); 254 254 free(part); … … 328 328 part->block0 = lpinfo.block0; 329 329 part->nblocks = lpinfo.nblocks; 330 atomic_set(&part->refcnt, 1);330 refcount_init(&part->refcnt); 331 331 332 332 bd_srvs_init(&part->bds); -
uspace/srv/bd/vbd/types/vbd.h
rb13d80b r498ced1 39 39 40 40 #include <adt/list.h> 41 #include <atomic.h>42 41 #include <bd_srv.h> 43 42 #include <label/label.h> 44 43 #include <loc.h> 44 #include <refcount.h> 45 45 #include <stdbool.h> 46 46 #include <stddef.h> … … 83 83 aoff64_t nblocks; 84 84 /** Reference count */ 85 atomic_ t refcnt;85 atomic_refcount_t refcnt; 86 86 } vbds_part_t; 87 87 -
uspace/srv/devman/dev.c
rb13d80b r498ced1 48 48 return NULL; 49 49 50 atomic_set(&dev->refcnt, 0);50 refcount_init(&dev->refcnt); 51 51 list_initialize(&dev->functions); 52 52 link_initialize(&dev->driver_devices); … … 74 74 void dev_add_ref(dev_node_t *dev) 75 75 { 76 atomic_inc(&dev->refcnt);76 refcount_up(&dev->refcnt); 77 77 } 78 78 … … 85 85 void dev_del_ref(dev_node_t *dev) 86 86 { 87 if ( atomic_predec(&dev->refcnt) == 0)87 if (refcount_down(&dev->refcnt)) 88 88 delete_dev_node(dev); 89 89 } -
uspace/srv/devman/devman.h
rb13d80b r498ced1 41 41 #include <ipc/loc.h> 42 42 #include <fibril_synch.h> 43 #include < atomic.h>43 #include <refcount.h> 44 44 #include <async.h> 45 45 … … 115 115 struct dev_node { 116 116 /** Reference count */ 117 atomic_ t refcnt;117 atomic_refcount_t refcnt; 118 118 119 119 /** The global unique identifier of the device. */ … … 155 155 struct fun_node { 156 156 /** Reference count */ 157 atomic_ t refcnt;157 atomic_refcount_t refcnt; 158 158 /** State */ 159 159 fun_state_t state; -
uspace/srv/devman/driver.c
rb13d80b r498ced1 406 406 } 407 407 408 log_msg(LOG_DEFAULT, LVL_DEBUG, "pass_devices_to_driver: dev->refcnt=%d\n",409 (int)atomic_get(&dev->refcnt));410 408 dev_add_ref(dev); 411 409 -
uspace/srv/devman/fun.c
rb13d80b r498ced1 60 60 61 61 fun->state = FUN_INIT; 62 atomic_set(&fun->refcnt, 0);62 refcount_init(&fun->refcnt); 63 63 fibril_mutex_initialize(&fun->busy_lock); 64 64 link_initialize(&fun->dev_functions); … … 89 89 void fun_add_ref(fun_node_t *fun) 90 90 { 91 atomic_inc(&fun->refcnt);91 refcount_up(&fun->refcnt); 92 92 } 93 93 … … 100 100 void fun_del_ref(fun_node_t *fun) 101 101 { 102 if ( atomic_predec(&fun->refcnt) == 0)102 if (refcount_down(&fun->refcnt)) 103 103 delete_fun_node(fun); 104 104 } -
uspace/srv/fs/exfat/exfat.h
rb13d80b r498ced1 38 38 #include <fibril_synch.h> 39 39 #include <libfs.h> 40 #include <atomic.h>41 40 #include <stdint.h> 42 41 #include <stdbool.h> -
uspace/srv/fs/fat/fat.h
rb13d80b r498ced1 38 38 #include <fibril_synch.h> 39 39 #include <libfs.h> 40 #include <atomic.h>41 40 #include <stdint.h> 42 41 #include <stdbool.h> -
uspace/srv/fs/tmpfs/tmpfs.h
rb13d80b r498ced1 35 35 36 36 #include <libfs.h> 37 #include <atomic.h>38 37 #include <stddef.h> 39 38 #include <stdbool.h> -
uspace/srv/fs/tmpfs/tmpfs_ops.c
rb13d80b r498ced1 43 43 #include <async.h> 44 44 #include <errno.h> 45 #include <atomic.h>46 45 #include <stdlib.h> 47 46 #include <str.h> -
uspace/srv/fs/udf/udf.h
rb13d80b r498ced1 37 37 #include <fibril_synch.h> 38 38 #include <libfs.h> 39 #include <atomic.h>40 39 #include <stddef.h> 41 40 #include <stdint.h> -
uspace/srv/hid/compositor/compositor.c
rb13d80b r498ced1 33 33 */ 34 34 35 #include <assert.h> 35 36 #include <stddef.h> 36 37 #include <stdint.h> … … 46 47 #include <stdlib.h> 47 48 48 #include < atomic.h>49 #include <refcount.h> 49 50 #include <fibril_synch.h> 50 51 #include <adt/prodcons.h> … … 93 94 typedef struct { 94 95 link_t link; 95 atomic_ t ref_cnt;96 atomic_refcount_t ref_cnt; 96 97 window_flags_t flags; 97 98 service_id_t in_dsid; … … 223 224 224 225 link_initialize(&win->link); 225 atomic_set(&win->ref_cnt, 0);226 refcount_init(&win->ref_cnt); 226 227 prodcons_initialize(&win->queue); 227 228 transform_identity(&win->transform); … … 240 241 static void window_destroy(window_t *win) 241 242 { 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); 254 256 } 255 257 … … 988 990 } 989 991 } 992 993 if (win) 994 refcount_up(&win->ref_cnt); 995 990 996 fibril_mutex_unlock(&window_list_mtx); 991 997 992 998 if (win) { 993 atomic_inc(&win->ref_cnt);994 999 async_answer_0(icall, EOK); 995 1000 } else { … … 1005 1010 if (!IPC_GET_IMETHOD(call)) { 1006 1011 async_answer_0(&call, EOK); 1007 atomic_dec(&win->ref_cnt);1008 1012 window_destroy(win); 1009 1013 return; … … 1024 1028 if (!IPC_GET_IMETHOD(call)) { 1025 1029 comp_window_close(win, &call); 1026 atomic_dec(&win->ref_cnt);1027 1030 window_destroy(win); 1028 1031 return; -
uspace/srv/hid/console/console.c
rb13d80b r498ced1 34 34 35 35 #include <async.h> 36 #include <atomic.h> 36 37 #include <stdio.h> 37 38 #include <adt/prodcons.h> -
uspace/srv/net/tcp/conn.c
rb13d80b r498ced1 128 128 129 129 /* 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); 131 132 132 133 /* Allocate receive buffer */ … … 238 239 void tcp_conn_addref(tcp_conn_t *conn) 239 240 { 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); 243 245 } 244 246 … … 251 253 void tcp_conn_delref(tcp_conn_t *conn) 252 254 { 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)) 257 259 tcp_conn_free(conn); 258 260 } -
uspace/srv/net/tcp/tcp_type.h
rb13d80b r498ced1 41 41 #include <fibril.h> 42 42 #include <fibril_synch.h> 43 #include <refcount.h> 43 44 #include <stddef.h> 44 45 #include <stdint.h> … … 248 249 fibril_mutex_t lock; 249 250 /** Reference count */ 250 atomic_ t refcnt;251 atomic_refcount_t refcnt; 251 252 252 253 /** Connection state */ -
uspace/srv/net/udp/assoc.c
rb13d80b r498ced1 91 91 92 92 /* One for the user */ 93 atomic_set(&assoc->refcnt, 1);93 refcount_init(&assoc->refcnt); 94 94 95 95 /* Initialize receive queue */ … … 145 145 { 146 146 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: upd_assoc_addref(%p)", assoc->name, assoc); 147 atomic_inc(&assoc->refcnt);147 refcount_up(&assoc->refcnt); 148 148 } 149 149 … … 158 158 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: udp_assoc_delref(%p)", assoc->name, assoc); 159 159 160 if ( atomic_predec(&assoc->refcnt) == 0)160 if (refcount_down(&assoc->refcnt)) 161 161 udp_assoc_free(assoc); 162 162 } -
uspace/srv/net/udp/udp_type.h
rb13d80b r498ced1 41 41 #include <inet/endpoint.h> 42 42 #include <ipc/loc.h> 43 #include <refcount.h> 43 44 #include <stdbool.h> 44 45 #include <stddef.h> … … 114 115 fibril_mutex_t lock; 115 116 /** Reference count */ 116 atomic_ t refcnt;117 atomic_refcount_t refcnt; 117 118 118 119 /** Receive queue */ -
uspace/srv/vfs/vfs.c
rb13d80b r498ced1 49 49 #include <str.h> 50 50 #include <as.h> 51 #include <atomic.h>52 51 #include <macros.h> 53 52 #include "vfs.h" -
uspace/srv/volsrv/part.c
rb13d80b r498ced1 179 179 } 180 180 181 atomic_set(&part->refcnt, 1);181 refcount_init(&part->refcnt); 182 182 link_initialize(&part->lparts); 183 183 part->parts = NULL; … … 524 524 if (part->svc_id == sid) { 525 525 /* Add reference */ 526 atomic_inc(&part->refcnt);526 refcount_up(&part->refcnt); 527 527 *rpart = part; 528 528 return EOK; … … 547 547 void vol_part_del_ref(vol_part_t *part) 548 548 { 549 if ( atomic_predec(&part->refcnt) == 0)549 if (refcount_down(&part->refcnt)) 550 550 vol_part_delete(part); 551 551 } -
uspace/srv/volsrv/types/part.h
rb13d80b r498ced1 39 39 40 40 #include <adt/list.h> 41 #include < atomic.h>41 #include <refcount.h> 42 42 #include <fibril_synch.h> 43 43 #include <stdbool.h> … … 51 51 link_t lparts; 52 52 /** Reference count */ 53 atomic_ t refcnt;53 atomic_refcount_t refcnt; 54 54 /** Service ID */ 55 55 service_id_t svc_id; -
uspace/srv/volsrv/types/volume.h
rb13d80b r498ced1 39 39 40 40 #include <adt/list.h> 41 #include < atomic.h>41 #include <refcount.h> 42 42 #include <fibril_synch.h> 43 43 #include <sif.h> … … 50 50 link_t lvolumes; 51 51 /** Reference count */ 52 atomic_ t refcnt;52 atomic_refcount_t refcnt; 53 53 /** Volume label */ 54 54 char *label; -
uspace/srv/volsrv/volume.c
rb13d80b r498ced1 83 83 } 84 84 85 atomic_set(&volume->refcnt, 1);85 refcount_init(&volume->refcnt); 86 86 link_initialize(&volume->lvolumes); 87 87 volume->volumes = NULL; … … 245 245 str_size(label) > 0) { 246 246 /* Add reference */ 247 atomic_inc(&volume->refcnt);247 refcount_up(&volume->refcnt); 248 248 *rvolume = volume; 249 249 return EOK; … … 309 309 void vol_volume_del_ref(vol_volume_t *volume) 310 310 { 311 if ( atomic_predec(&volume->refcnt) == 0) {311 if (refcount_down(&volume->refcnt)) { 312 312 /* No more references. Check if volume is persistent. */ 313 313 if (!vol_volume_is_persist(volume)) {
Note:
See TracChangeset
for help on using the changeset viewer.