Changeset e89a06a in mainline for uspace/lib


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
Files:
4 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
  • uspace/lib/hound/include/hound/server.h

    r6419c6e re89a06a  
    4040#include <loc.h>
    4141
    42 typedef void (*dev_change_callback_t)(void);
     42typedef void (*dev_change_callback_t)(void *);
    4343typedef errno_t (*device_callback_t)(service_id_t, const char *);
    4444
    4545errno_t hound_server_register(const char *name, service_id_t *id);
    4646void hound_server_unregister(service_id_t id);
    47 errno_t hound_server_set_device_change_callback(dev_change_callback_t cb);
     47errno_t hound_server_set_device_change_callback(dev_change_callback_t cb,
     48    void *);
    4849errno_t hound_server_devices_iterate(device_callback_t callback);
    4950
  • uspace/lib/hound/src/protocol.c

    r6419c6e re89a06a  
    750750 * @return Error code.
    751751 */
    752 errno_t hound_server_set_device_change_callback(dev_change_callback_t cb)
    753 {
    754         return loc_register_cat_change_cb(cb);
     752errno_t hound_server_set_device_change_callback(dev_change_callback_t cb,
     753    void *arg)
     754{
     755        return loc_register_cat_change_cb(cb, arg);
    755756}
    756757
Note: See TracChangeset for help on using the changeset viewer.