Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5869ce0 in mainline


Ignore:
Timestamp:
2012-03-01T23:22:32Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
0030eef
Parents:
3d23553
Message:

extend sysinfo generated subtree interface

Location:
kernel/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/sysinfo/sysinfo.h

    r3d23553 r5869ce0  
    7373typedef union {
    7474        sysarg_t val;               /**< Constant numberic value */
     75        sysinfo_data_t data;        /**< Constant binary data */
    7576        sysinfo_fn_val_t fn_val;    /**< Generated numeric value function */
    7677        sysinfo_fn_data_t fn_data;  /**< Generated binary data function */
    77         sysinfo_data_t data;        /**< Constant binary data */
    7878} sysinfo_item_val_t;
    7979
     
    9595
    9696/** Generated subtree function */
    97 typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool);
     97typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool, void *);
     98
     99/** Sysinfo generated subtree data
     100 *
     101 */
     102typedef struct {
     103        sysinfo_fn_subtree_t fn;  /**< Generated subtree function */
     104        void *data;               /**< Private data */
     105} sysinfo_fn_subtree_data_t;
    98106
    99107/** Sysinfo subtree (union)
     
    101109 */
    102110typedef union {
    103         struct sysinfo_item *table;     /**< Fixed subtree (list of subitems) */
    104         sysinfo_fn_subtree_t get_data;  /**< Generated subtree function */
     111        struct sysinfo_item *table;           /**< Fixed subtree (list of subitems) */
     112        sysinfo_fn_subtree_data_t generator;  /**< Generated subtree */
    105113} sysinfo_subtree_t;
    106114
     
    130138
    131139extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **,
    132     sysinfo_fn_subtree_t);
     140    sysinfo_fn_subtree_t, void *);
    133141
    134142extern void sysinfo_init(void);
  • kernel/generic/src/sysinfo/stats.c

    r3d23553 r5869ce0  
    451451 * @param name    Task ID (string-encoded number).
    452452 * @param dry_run Do not get the data, just calculate the size.
     453 * @param data    Unused.
    453454 *
    454455 * @return Sysinfo return holder. The type of the returned
     
    460461 *
    461462 */
    462 static sysinfo_return_t get_stats_task(const char *name, bool dry_run)
     463static sysinfo_return_t get_stats_task(const char *name, bool dry_run,
     464    void *data)
    463465{
    464466        /* Initially no return value */
     
    520522 * @param name    Thread ID (string-encoded number).
    521523 * @param dry_run Do not get the data, just calculate the size.
     524 * @param data    Unused.
    522525 *
    523526 * @return Sysinfo return holder. The type of the returned
     
    529532 *
    530533 */
    531 static sysinfo_return_t get_stats_thread(const char *name, bool dry_run)
     534static sysinfo_return_t get_stats_thread(const char *name, bool dry_run,
     535    void *data)
    532536{
    533537        /* Initially no return value */
     
    634638 * @param name    Exception number (string-encoded number).
    635639 * @param dry_run Do not get the data, just calculate the size.
     640 * @param data    Unused.
    636641 *
    637642 * @return Sysinfo return holder. The type of the returned
     
    643648 *
    644649 */
    645 static sysinfo_return_t get_stats_exception(const char *name, bool dry_run)
     650static sysinfo_return_t get_stats_exception(const char *name, bool dry_run,
     651    void *data)
    646652{
    647653        /* Initially no return value */
     
    817823        sysinfo_set_item_fn_data("system.threads", NULL, get_stats_threads);
    818824        sysinfo_set_item_fn_data("system.exceptions", NULL, get_stats_exceptions);
    819         sysinfo_set_subtree_fn("system.tasks", NULL, get_stats_task);
    820         sysinfo_set_subtree_fn("system.threads", NULL, get_stats_thread);
    821         sysinfo_set_subtree_fn("system.exceptions", NULL, get_stats_exception);
     825        sysinfo_set_subtree_fn("system.tasks", NULL, get_stats_task, NULL);
     826        sysinfo_set_subtree_fn("system.threads", NULL, get_stats_thread, NULL);
     827        sysinfo_set_subtree_fn("system.exceptions", NULL, get_stats_exception, NULL);
    822828}
    823829
  • kernel/generic/src/sysinfo/sysinfo.c

    r3d23553 r5869ce0  
    151151                        case SYSINFO_SUBTREE_FUNCTION:
    152152                                /* Get generated data */
    153                                 **ret = cur->subtree.get_data(name + i + 1, dry_run);
     153                                **ret = cur->subtree.generator.fn(name + i + 1, dry_run,
     154                                    cur->subtree.generator.data);
    154155                                return NULL;
    155156                        default:
     
    431432 *             a new root item (NULL for global sysinfo root).
    432433 * @param fn   Subtree generator function.
     434 * @param data Private data to be passed to the generator.
    433435 *
    434436 */
    435437void sysinfo_set_subtree_fn(const char *name, sysinfo_item_t **root,
    436     sysinfo_fn_subtree_t fn)
     438    sysinfo_fn_subtree_t fn, void *data)
    437439{
    438440        /* Protect sysinfo tree consistency */
     
    448450        if ((item != NULL) && (item->subtree_type != SYSINFO_SUBTREE_TABLE)) {
    449451                item->subtree_type = SYSINFO_SUBTREE_FUNCTION;
    450                 item->subtree.get_data = fn;
     452                item->subtree.generator.fn = fn;
     453                item->subtree.generator.data = data;
    451454        }
    452455       
Note: See TracChangeset for help on using the changeset viewer.