Changeset e89a06a in mainline for uspace/lib/c


Ignore:
Timestamp:
2018-07-06T22:13:20Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be0f5e4
Parents:
6419c6e
Message:

Encapsulate partitions list in volume server. (Global state is not good coding practice.)

Location:
uspace/lib/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/loc.c

    r6419c6e re89a06a  
    4848static bool loc_callback_created = false;
    4949static loc_cat_change_cb_t cat_change_cb = NULL;
     50static void *cat_change_arg = NULL;
    5051
    5152static async_sess_t *loc_supp_block_sess = NULL;
     
    7071                        fibril_mutex_lock(&loc_callback_mutex);
    7172                        loc_cat_change_cb_t cb_fun = cat_change_cb;
     73                        void *cb_arg = cat_change_arg;
    7274                        fibril_mutex_unlock(&loc_callback_mutex);
    7375
     
    7577
    7678                        if (cb_fun != NULL)
    77                                 (*cb_fun)();
     79                                (*cb_fun)(cb_arg);
    7880
    7981                        break;
     
    859861}
    860862
    861 errno_t loc_register_cat_change_cb(loc_cat_change_cb_t cb_fun)
     863errno_t loc_register_cat_change_cb(loc_cat_change_cb_t cb_fun, void *cb_arg)
    862864{
    863865        fibril_mutex_lock(&loc_callback_mutex);
     866        if (cat_change_cb != NULL) {
     867                fibril_mutex_unlock(&loc_callback_mutex);
     868                return EEXIST;
     869        }
     870
    864871        if (loc_callback_create() != EOK) {
    865872                fibril_mutex_unlock(&loc_callback_mutex);
     
    868875
    869876        cat_change_cb = cb_fun;
     877        cat_change_arg = cb_arg;
    870878        fibril_mutex_unlock(&loc_callback_mutex);
    871879
  • uspace/lib/c/include/loc.h

    r6419c6e re89a06a  
    4040#include <stdbool.h>
    4141
    42 typedef void (*loc_cat_change_cb_t)(void);
     42typedef void (*loc_cat_change_cb_t)(void *);
    4343
    4444extern async_exch_t *loc_exchange_begin_blocking(iface_t);
     
    7575extern size_t loc_get_services(service_id_t, loc_sdesc_t **);
    7676extern errno_t loc_get_categories(category_id_t **, size_t *);
    77 extern errno_t loc_register_cat_change_cb(loc_cat_change_cb_t);
    78 
     77extern errno_t loc_register_cat_change_cb(loc_cat_change_cb_t, void *);
    7978
    8079#endif
Note: See TracChangeset for help on using the changeset viewer.