Changeset 3bacee1 in mainline for kernel/generic/src


Ignore:
Timestamp:
2018-04-12T16:27:17Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3cf22f9
Parents:
76d0981d
git-author:
Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
git-committer:
Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
Message:

Make ccheck-fix again and commit more good files.

Location:
kernel/generic/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/adt/avl.c

    r76d0981d r3bacee1  
    186186                }
    187187                gpa = par;
    188                 dpc = par->key > key ? &par->lft: &par->rgt;
     188                dpc = par->key > key ? &par->lft : &par->rgt;
    189189        }
    190190
     
    308308 */
    309309static int
    310 repair(avltree_t *t, avltree_node_t *u, avltree_node_t *v, avltree_node_t *w,
     310    repair(avltree_t *t, avltree_node_t *u, avltree_node_t *v, avltree_node_t *w,
    311311    int *dir, int ro)
    312312{
     
    404404                        gpa = node->par;
    405405                        cur = NULL;
    406                         dir = (gpa->lft == node) ? LEFT: RIGHT;
     406                        dir = (gpa->lft == node) ? LEFT : RIGHT;
    407407                }
    408408        } else {
  • kernel/generic/src/adt/cht.c

    r76d0981d r3bacee1  
    407407static size_t size_to_order(size_t bucket_cnt, size_t min_order);
    408408static cht_buckets_t *alloc_buckets(size_t order, bool set_invalid,
    409         bool can_block);
     409    bool can_block);
    410410static inline cht_link_t *find_lazy(cht_t *h, void *key);
    411411static cht_link_t *search_bucket(cht_t *h, marked_ptr_t head, void *key,
    412         size_t search_hash);
     412    size_t search_hash);
    413413static cht_link_t *find_resizing(cht_t *h, void *key, size_t hash,
    414         marked_ptr_t old_head, size_t old_idx);
     414    marked_ptr_t old_head, size_t old_idx);
    415415static bool insert_impl(cht_t *h, cht_link_t *item, cht_link_t **dup_item);
    416416static bool insert_at(cht_link_t *item, const wnd_t *wnd, walk_mode_t walk_mode,
    417         bool *resizing);
     417    bool *resizing);
    418418static bool has_duplicate(cht_t *h, const cht_link_t *item, size_t hash,
    419         cht_link_t *cur, cht_link_t **dup_item);
     419    cht_link_t *cur, cht_link_t **dup_item);
    420420static cht_link_t *find_duplicate(cht_t *h, const cht_link_t *item, size_t hash,
    421         cht_link_t *start);
     421    cht_link_t *start);
    422422static bool remove_pred(cht_t *h, size_t hash, equal_pred_t pred, void *pred_arg);
    423423static bool delete_at(cht_t *h, wnd_t *wnd, walk_mode_t walk_mode,
    424         bool *deleted_but_gc, bool *resizing);
     424    bool *deleted_but_gc, bool *resizing);
    425425static bool mark_deleted(cht_link_t *cur, walk_mode_t walk_mode, bool *resizing);
    426426static bool unlink_from_pred(wnd_t *wnd, walk_mode_t walk_mode, bool *resizing);
    427427static bool find_wnd_and_gc_pred(cht_t *h, size_t hash, walk_mode_t walk_mode,
    428         equal_pred_t pred, void *pred_arg, wnd_t *wnd, bool *resizing);
     428    equal_pred_t pred, void *pred_arg, wnd_t *wnd, bool *resizing);
    429429static bool find_wnd_and_gc(cht_t *h, size_t hash, walk_mode_t walk_mode,
    430         wnd_t *wnd, bool *resizing);
     430    wnd_t *wnd, bool *resizing);
    431431static bool gc_deleted_node(cht_t *h, walk_mode_t walk_mode, wnd_t *wnd,
    432         bool *resizing);
     432    bool *resizing);
    433433static bool join_completed(cht_t *h, const wnd_t *wnd);
    434434static void upd_resizing_head(cht_t *h, size_t hash, marked_ptr_t **phead,
    435         bool *join_finishing,  walk_mode_t *walk_mode);
     435    bool *join_finishing,  walk_mode_t *walk_mode);
    436436static void item_removed(cht_t *h);
    437437static void item_inserted(cht_t *h);
     
    442442static void complete_head_move(marked_ptr_t *psrc_head, marked_ptr_t *pdest_head);
    443443static void split_bucket(cht_t *h, marked_ptr_t *psrc_head,
    444         marked_ptr_t *pdest_head, size_t split_hash);
     444    marked_ptr_t *pdest_head, size_t split_hash);
    445445static void mark_join_follows(cht_t *h, marked_ptr_t *psrc_head,
    446         size_t split_hash, wnd_t *wnd);
     446    size_t split_hash, wnd_t *wnd);
    447447static void mark_join_node(cht_link_t *join_node);
    448448static void join_buckets(cht_t *h, marked_ptr_t *psrc_head,
    449         marked_ptr_t *pdest_head, size_t split_hash);
     449    marked_ptr_t *pdest_head, size_t split_hash);
    450450static void link_to_join_node(cht_t *h, marked_ptr_t *pdest_head,
    451         cht_link_t *join_node, size_t split_hash);
     451    cht_link_t *join_node, size_t split_hash);
    452452static void resize_table(work_t *arg);
    453453static void grow_table(cht_t *h);
     
    455455static void cleanup_join_node(cht_t *h, marked_ptr_t *new_head);
    456456static void clear_join_and_gc(cht_t *h, cht_link_t *join_node,
    457         marked_ptr_t *new_head);
     457    marked_ptr_t *new_head);
    458458static void cleanup_join_follows(cht_t *h, marked_ptr_t *new_head);
    459459static marked_ptr_t make_link(const cht_link_t *next, mark_t mark);
    460 static cht_link_t * get_next(marked_ptr_t link);
     460static cht_link_t *get_next(marked_ptr_t link);
    461461static mark_t get_mark(marked_ptr_t link);
    462462static void next_wnd(wnd_t *wnd);
     
    472472static size_t shrink_idx(size_t idx);
    473473static marked_ptr_t cas_link(marked_ptr_t *link, const cht_link_t *cur_next,
    474         mark_t cur_mark, const cht_link_t *new_next, mark_t new_mark);
     474    mark_t cur_mark, const cht_link_t *new_next, mark_t new_mark);
    475475static marked_ptr_t _cas_link(marked_ptr_t *link, marked_ptr_t cur,
    476         marked_ptr_t new);
     476    marked_ptr_t new);
    477477static void cas_order_barrier(void);
    478478
     
    513513 */
    514514bool cht_create(cht_t *h, size_t init_size, size_t min_size, size_t max_load,
    515         bool can_block, cht_ops_t *op)
     515    bool can_block, cht_ops_t *op)
    516516{
    517517        assert(h);
     
    572572        size_t bucket_cnt = (1 << order);
    573573        size_t bytes =
    574                 sizeof(cht_buckets_t) + (bucket_cnt - 1) * sizeof(marked_ptr_t);
     574            sizeof(cht_buckets_t) + (bucket_cnt - 1) * sizeof(marked_ptr_t);
    575575        cht_buckets_t *b = malloc(bytes, can_block ? 0 : FRAME_ATOMIC);
    576576
     
    580580        b->order = order;
    581581
    582         marked_ptr_t head_link = set_invalid
    583                 ? make_link(&sentinel, N_INVALID)
    584                 : make_link(&sentinel, N_NORMAL);
     582        marked_ptr_t head_link = set_invalid ?
     583            make_link(&sentinel, N_INVALID) :
     584            make_link(&sentinel, N_NORMAL);
    585585
    586586        for (size_t i = 0; i < bucket_cnt; ++i) {
     
    733733/** Searches the bucket at head for key using search_hash. */
    734734static inline cht_link_t *search_bucket(cht_t *h, marked_ptr_t head, void *key,
    735         size_t search_hash)
     735    size_t search_hash)
    736736{
    737737        /*
     
    781781/** Searches for the key while the table is undergoing a resize. */
    782782static cht_link_t *find_resizing(cht_t *h, void *key, size_t hash,
    783         marked_ptr_t old_head, size_t old_idx)
     783    marked_ptr_t old_head, size_t old_idx)
    784784{
    785785        assert(N_INVALID == get_mark(old_head));
     
    10221022 */
    10231023inline static bool insert_at(cht_link_t *item, const wnd_t *wnd,
    1024         walk_mode_t walk_mode, bool *resizing)
     1024    walk_mode_t walk_mode, bool *resizing)
    10251025{
    10261026        marked_ptr_t ret;
     
    10781078 */
    10791079static inline bool has_duplicate(cht_t *h, const cht_link_t *item, size_t hash,
    1080         cht_link_t *cur, cht_link_t **dup_item)
     1080    cht_link_t *cur, cht_link_t **dup_item)
    10811081{
    10821082        assert(cur);
    1083         assert(cur == &sentinel || hash <= node_hash(h, cur)
    1084                 || node_hash(h, cur) == h->invalid_hash);
     1083        assert(cur == &sentinel || hash <= node_hash(h, cur) ||
     1084            node_hash(h, cur) == h->invalid_hash);
    10851085
    10861086        /* hash < node_hash(h, cur) */
     
    11011101/** Returns an item that is equal to \a item starting in a chain at \a start. */
    11021102static cht_link_t *find_duplicate(cht_t *h, const cht_link_t *item, size_t hash,
    1103         cht_link_t *start)
     1103    cht_link_t *start)
    11041104{
    11051105        assert(hash <= node_hash(h, start) || h->invalid_hash == node_hash(h, start));
     
    12011201
    12021202                if (!find_wnd_and_gc_pred(
    1203                         h, hash, walk_mode, pred, pred_arg, &wnd, &resizing)) {
     1203                    h, hash, walk_mode, pred, pred_arg, &wnd, &resizing)) {
    12041204                        /* Could not GC a node; or detected an unexpected resize. */
    12051205                        continue;
     
    12531253 */
    12541254static inline bool delete_at(cht_t *h, wnd_t *wnd, walk_mode_t walk_mode,
    1255         bool *deleted_but_gc, bool *resizing)
     1255    bool *deleted_but_gc, bool *resizing)
    12561256{
    12571257        assert(wnd->cur && wnd->cur != &sentinel);
     
    12831283/** Marks cur logically deleted. Returns false to request a retry. */
    12841284static inline bool mark_deleted(cht_link_t *cur, walk_mode_t walk_mode,
    1285         bool *resizing)
     1285    bool *resizing)
    12861286{
    12871287        assert(cur && cur != &sentinel);
     
    13091309
    13101310                marked_ptr_t ret =
    1311                         cas_link(&cur->link, next, cur_mark, next, cur_mark | N_DELETED);
     1311                    cas_link(&cur->link, next, cur_mark, next, cur_mark | N_DELETED);
    13121312
    13131313                if (ret != make_link(next, cur_mark))
     
    13201320/** Unlinks wnd.cur from wnd.ppred. Returns false if it should be retried. */
    13211321static inline bool unlink_from_pred(wnd_t *wnd, walk_mode_t walk_mode,
    1322         bool *resizing)
     1322    bool *resizing)
    13231323{
    13241324        assert(wnd->cur != &sentinel);
     
    13541354                if (pred_link != ret) {
    13551355                        /* If we're not resizing the table there are no JF/JN nodes. */
    1356                         *resizing = (walk_mode == WM_NORMAL)
    1357                                 && (N_JOIN_FOLLOWS & get_mark(ret));
     1356                        *resizing = (walk_mode == WM_NORMAL) &&
     1357                            (N_JOIN_FOLLOWS & get_mark(ret));
    13581358                        return false;
    13591359                }
     
    13891389 */
    13901390static bool find_wnd_and_gc_pred(cht_t *h, size_t hash, walk_mode_t walk_mode,
    1391         equal_pred_t pred, void *pred_arg, wnd_t *wnd, bool *resizing)
     1391    equal_pred_t pred, void *pred_arg, wnd_t *wnd, bool *resizing)
    13921392{
    13931393        assert(wnd->cur);
     
    14591459 */
    14601460static bool find_wnd_and_gc(cht_t *h, size_t hash, walk_mode_t walk_mode,
    1461         wnd_t *wnd, bool *resizing)
     1461    wnd_t *wnd, bool *resizing)
    14621462{
    14631463try_again:
     
    14891489/** Garbage collects the N_DELETED node at \a wnd skipping join nodes. */
    14901490static bool gc_deleted_node(cht_t *h, walk_mode_t walk_mode, wnd_t *wnd,
    1491         bool *resizing)
     1491    bool *resizing)
    14921492{
    14931493        assert(N_DELETED & get_mark(wnd->cur->link));
     
    14981498        } else {
    14991499                /* Ordinary deleted node or a deleted JOIN_FOLLOWS. */
    1500                 assert(walk_mode != WM_LEAVE_JOIN
    1501                         || !((N_JOIN | N_JOIN_FOLLOWS) & get_mark(wnd->cur->link)));
     1500                assert(walk_mode != WM_LEAVE_JOIN ||
     1501                    !((N_JOIN | N_JOIN_FOLLOWS) & get_mark(wnd->cur->link)));
    15021502
    15031503                /* Unlink an ordinary deleted node, move JOIN_FOLLOWS mark. */
     
    15911591 */
    15921592static void upd_resizing_head(cht_t *h, size_t hash, marked_ptr_t **phead,
    1593         bool *join_finishing,  walk_mode_t *walk_mode)
     1593    bool *join_finishing,  walk_mode_t *walk_mode)
    15941594{
    15951595        cht_buckets_t *b = rcu_access(h->b);
     
    16411641                        *walk_mode = WM_LEAVE_JOIN;
    16421642                }
    1643         } else if (h->new_b->order < b->order ) {
     1643        } else if (h->new_b->order < b->order) {
    16441644                /* Shrinking the table. */
    16451645
     
    17021702 */
    17031703static inline void help_head_move(marked_ptr_t *psrc_head,
    1704         marked_ptr_t *pdest_head)
     1704    marked_ptr_t *pdest_head)
    17051705{
    17061706        /* Head move has to in progress already when calling this func. */
     
    17431743                /* Mark the normal/clean src link immutable/const. */
    17441744                ret = cas_link(psrc_head, next, N_NORMAL, next, N_CONST);
    1745         } while(ret != src_link && !(N_CONST & get_mark(ret)));
     1745        } while (ret != src_link && !(N_CONST & get_mark(ret)));
    17461746}
    17471747
     
    17831783 */
    17841784static void split_bucket(cht_t *h, marked_ptr_t *psrc_head,
    1785         marked_ptr_t *pdest_head, size_t split_hash)
     1785    marked_ptr_t *pdest_head, size_t split_hash)
    17861786{
    17871787        /* Already split. */
     
    18841884 */
    18851885static void mark_join_follows(cht_t *h, marked_ptr_t *psrc_head,
    1886         size_t split_hash, wnd_t *wnd)
     1886    size_t split_hash, wnd_t *wnd)
    18871887{
    18881888        /* See comment in split_bucket(). */
     
    19091909                 * that a join node follows. It must be clean/normal.
    19101910                 */
    1911                 marked_ptr_t ret
    1912                         = cas_link(wnd->ppred, wnd->cur, N_NORMAL, wnd->cur, N_JOIN_FOLLOWS);
     1911                marked_ptr_t ret =
     1912                    cas_link(wnd->ppred, wnd->cur, N_NORMAL, wnd->cur, N_JOIN_FOLLOWS);
    19131913
    19141914                /*
     
    19161916                 * if also marked deleted - unlinking the node will move the JF mark).
    19171917                 */
    1918                 done = (ret == make_link(wnd->cur, N_NORMAL))
    1919                         || (N_JOIN_FOLLOWS & get_mark(ret));
     1918                done = (ret == make_link(wnd->cur, N_NORMAL)) ||
     1919                    (N_JOIN_FOLLOWS & get_mark(ret));
    19201920        } while (!done);
    19211921}
     
    19351935                 * because its predecessor is marked with JOIN_FOLLOWS or CONST.
    19361936                 */
    1937                 marked_ptr_t ret
    1938                         = cas_link(&join_node->link, next, mark, next, mark | N_JOIN);
     1937                marked_ptr_t ret =
     1938                    cas_link(&join_node->link, next, mark, next, mark | N_JOIN);
    19391939
    19401940                /* Successfully marked or already marked as a join node. */
    1941                 done = (ret == make_link(next, mark))
    1942                         || (N_JOIN & get_mark(ret));
    1943         } while(!done);
     1941                done = (ret == make_link(next, mark)) ||
     1942                    (N_JOIN & get_mark(ret));
     1943        } while (!done);
    19441944}
    19451945
     
    19521952 */
    19531953static void join_buckets(cht_t *h, marked_ptr_t *psrc_head,
    1954         marked_ptr_t *pdest_head, size_t split_hash)
     1954    marked_ptr_t *pdest_head, size_t split_hash)
    19551955{
    19561956        /* Buckets already joined. */
     
    20592059 */
    20602060static void link_to_join_node(cht_t *h, marked_ptr_t *pdest_head,
    2061         cht_link_t *join_node, size_t split_hash)
     2061    cht_link_t *join_node, size_t split_hash)
    20622062{
    20632063        bool done = false;
     
    20782078                if (wnd.cur != &sentinel) {
    20792079                        /* Must be from the new appended bucket. */
    2080                         assert(split_hash <= node_hash(h, wnd.cur)
    2081                                 || h->invalid_hash == node_hash(h, wnd.cur));
     2080                        assert(split_hash <= node_hash(h, wnd.cur) ||
     2081                            h->invalid_hash == node_hash(h, wnd.cur));
    20822082                        return;
    20832083                }
     
    20852085                /* Reached the tail of pdest_head - link it to the join node. */
    20862086                marked_ptr_t ret =
    2087                         cas_link(wnd.ppred, &sentinel, N_NORMAL, join_node, N_NORMAL);
     2087                    cas_link(wnd.ppred, &sentinel, N_NORMAL, join_node, N_NORMAL);
    20882088
    20892089                done = (ret == make_link(&sentinel, N_NORMAL));
     
    23202320                        size_t split_hash = calc_split_hash(old_idx, h->b->order);
    23212321                        join_buckets(h, &h->b->head[old_idx], &h->new_b->head[new_idx],
    2322                                 split_hash);
     2322                            split_hash);
    23232323                }
    23242324        }
     
    23912391/** Clears the join_node's N_JOIN mark frees it if marked N_DELETED as well. */
    23922392static void clear_join_and_gc(cht_t *h, cht_link_t *join_node,
    2393         marked_ptr_t *new_head)
     2393    marked_ptr_t *new_head)
    23942394{
    23952395        assert(join_node != &sentinel);
     
    24062406
    24072407                marked_ptr_t ret =
    2408                         _cas_link(&join_node->link, jn_link, make_link(next, cleared_mark));
     2408                    _cas_link(&join_node->link, jn_link, make_link(next, cleared_mark));
    24092409
    24102410                /* Done if the mark was cleared. Retry if a new node was inserted. */
     
    24312431
    24322432                done = find_wnd_and_gc_pred(h, jn_hash, WM_NORMAL, same_node_pred,
    2433                         join_node, &wnd, &resizing);
     2433                    join_node, &wnd, &resizing);
    24342434
    24352435                assert(!resizing);
     
    24832483                                cht_link_t *next = get_next(*cur_link);
    24842484                                marked_ptr_t ret =
    2485                                         cas_link(cur_link, next, N_JOIN_FOLLOWS, &sentinel, N_NORMAL);
    2486 
    2487                                 assert(next == &sentinel
    2488                                         || ((N_JOIN | N_JOIN_FOLLOWS) & get_mark(ret)));
     2485                                    cas_link(cur_link, next, N_JOIN_FOLLOWS, &sentinel, N_NORMAL);
     2486
     2487                                assert(next == &sentinel ||
     2488                                    ((N_JOIN | N_JOIN_FOLLOWS) & get_mark(ret)));
    24892489
    24902490                                /* Successfully cleared the JF mark of a non-deleted node. */
     
    25592559static inline size_t node_hash(cht_t *h, const cht_link_t *item)
    25602560{
    2561         assert(item->hash == h->invalid_hash
    2562                 || item->hash == sentinel.hash
    2563                 || item->hash == calc_node_hash(h, item));
     2561        assert(item->hash == h->invalid_hash ||
     2562            item->hash == sentinel.hash ||
     2563            item->hash == calc_node_hash(h, item));
    25642564
    25652565        return item->hash;
     
    25952595
    25962596/** Strips any marks from the next item link and returns the next item's address.*/
    2597 static inline cht_link_t * get_next(marked_ptr_t link)
    2598 {
    2599         return (cht_link_t*)(link & ~N_MARK_MASK);
     2597static inline cht_link_t *get_next(marked_ptr_t link)
     2598{
     2599        return (cht_link_t *)(link & ~N_MARK_MASK);
    26002600}
    26012601
     
    26202620static bool same_node_pred(void *node, const cht_link_t *item2)
    26212621{
    2622         const cht_link_t *item1 = (const cht_link_t*) node;
     2622        const cht_link_t *item1 = (const cht_link_t *) node;
    26232623        return item1 == item2;
    26242624}
     
    26262626/** Compare-and-swaps a next item link. */
    26272627static inline marked_ptr_t cas_link(marked_ptr_t *link, const cht_link_t *cur_next,
    2628         mark_t cur_mark, const cht_link_t *new_next, mark_t new_mark)
     2628    mark_t cur_mark, const cht_link_t *new_next, mark_t new_mark)
    26292629{
    26302630        return _cas_link(link, make_link(cur_next, cur_mark),
    2631                 make_link(new_next, new_mark));
     2631            make_link(new_next, new_mark));
    26322632}
    26332633
    26342634/** Compare-and-swaps a next item link. */
    26352635static inline marked_ptr_t _cas_link(marked_ptr_t *link, marked_ptr_t cur,
    2636         marked_ptr_t new)
     2636    marked_ptr_t new)
    26372637{
    26382638        assert(link != &sentinel.link);
     
    26902690         * is already visible to cpu3.   *
    26912691         */
    2692         void *expected = (void*)cur;
     2692        void *expected = (void *)cur;
    26932693
    26942694        /*
     
    26972697         * of explicit memory barriers.
    26982698         */
    2699         __atomic_compare_exchange_n((void**)link, &expected, (void *)new, false,
    2700                 __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
     2699        __atomic_compare_exchange_n((void **)link, &expected, (void *)new, false,
     2700            __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
    27012701
    27022702        return (marked_ptr_t) expected;
  • kernel/generic/src/console/cmd.c

    r76d0981d r3bacee1  
    923923
    924924        printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
    925                 sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
     925            sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
    926926
    927927        return 1;
     
    10881088                    (void *) cmd_call2);
    10891089                printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
    1090                        arg1, arg2, (void *) symaddr, symbol);
     1090                    arg1, arg2, (void *) symaddr, symbol);
    10911091                printf("Result: %#" PRIxn "\n", fnc(arg1, arg2));
    10921092                interrupts_restore(ipl);
     
    11251125                    (void *) cmd_call3);
    11261126                printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
    1127                        arg1, arg2, arg3, (void *) symaddr, symbol);
     1127                    arg1, arg2, arg3, (void *) symaddr, symbol);
    11281128                printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3));
    11291129                interrupts_restore(ipl);
     
    11881188                pointer = true;
    11891189        } else if (((char *) argv->buffer)[0] >= '0' &&
    1190                    ((char *) argv->buffer)[0] <= '9') {
     1190            ((char *) argv->buffer)[0] <= '9') {
    11911191                uint64_t value;
    11921192                rc = str_uint64_t((char *) argv->buffer, NULL, 0, true, &value);
     
    12061206                if (pointer)
    12071207                        addr = *(uintptr_t *) addr;
    1208                 printf("Writing %#" PRIx32" -> %p\n", arg1, (void *) addr);
     1208                printf("Writing %#" PRIx32 " -> %p\n", arg1, (void *) addr);
    12091209                *(uint32_t *) addr = arg1;
    12101210        } else
  • kernel/generic/src/console/kconsole.c

    r76d0981d r3bacee1  
    8686LIST_INITIALIZE(cmd_list);      /**< Command list. */
    8787
    88 static wchar_t history[KCONSOLE_HISTORY][MAX_CMDLINE] = {};
     88static wchar_t history[KCONSOLE_HISTORY][MAX_CMDLINE] = { };
    8989static size_t history_pos = 0;
    9090
     
    166166const char *cmdtab_enum(const char *name, const char **h, void **ctx)
    167167{
    168         link_t **startpos = (link_t**) ctx;
     168        link_t **startpos = (link_t **) ctx;
    169169        size_t namelen = str_length(name);
    170170
     
    376376                                beg = position - 1;
    377377                                while ((beg > 0) && (!isspace(current[beg])))
    378                                     beg--;
     378                                        beg--;
    379379
    380380                                if (isspace(current[beg]))
  • kernel/generic/src/cpu/cpu.c

    r76d0981d r3bacee1  
    6565#endif /* CONFIG_SMP */
    6666
    67                 cpus = (cpu_t *) malloc(sizeof(cpu_t) *config.cpu_count,
     67                cpus = (cpu_t *) malloc(sizeof(cpu_t) * config.cpu_count,
    6868                    FRAME_ATOMIC);
    6969                if (!cpus)
     
    7171
    7272                /* Initialize everything */
    73                 memsetb(cpus, sizeof(cpu_t) *config.cpu_count, 0);
     73                memsetb(cpus, sizeof(cpu_t) * config.cpu_count, 0);
    7474
    7575                size_t i;
  • kernel/generic/src/main/main.c

    r76d0981d r3bacee1  
    121121
    122122/** Boot arguments. */
    123 char bargs[CONFIG_BOOT_ARGUMENTS_BUFLEN] = {};
     123char bargs[CONFIG_BOOT_ARGUMENTS_BUFLEN] = { };
    124124
    125125/** Initial user-space tasks */
  • kernel/generic/src/mm/as.c

    r76d0981d r3bacee1  
    10061006                                pte_t pte;
    10071007                                bool found = page_mapping_find(as,
    1008                                      ptr + P2SZ(size), false, &pte);
     1008                                    ptr + P2SZ(size), false, &pte);
    10091009
    10101010                                assert(found);
     
    21962196                backend = &user_backend;
    21972197                if (copy_from_uspace(&backend_data.pager_info, pager_info,
    2198                         sizeof(as_area_pager_info_t)) != EOK) {
     2198                    sizeof(as_area_pager_info_t)) != EOK) {
    21992199                        return (sysarg_t) AS_MAP_FAILED;
    22002200                }
  • kernel/generic/src/mm/backend_user.c

    r76d0981d r3bacee1  
    118118        as_area_pager_info_t *pager_info = &area->backend_data.pager_info;
    119119
    120         ipc_data_t data = {};
     120        ipc_data_t data = { };
    121121        IPC_SET_IMETHOD(data, IPC_M_PAGE_IN);
    122122        IPC_SET_ARG1(data, upage - area->base);
  • kernel/generic/src/mm/frame.c

    r76d0981d r3bacee1  
    198198        size_t i = hint;
    199199        do {
    200                 if ((zones.info[i].base <= frame)
    201                     && (zones.info[i].base + zones.info[i].count >= frame + count))
     200                if ((zones.info[i].base <= frame) &&
     201                    (zones.info[i].base + zones.info[i].count >= frame + count))
    202202                        return i;
    203203
     
    551551
    552552        pfn_t cframes = SIZE2FRAMES(zone_conf_size(
    553             zones.info[z2].base - zones.info[z1].base
    554             + zones.info[z2].count));
     553            zones.info[z2].base - zones.info[z1].base +
     554            zones.info[z2].count));
    555555
    556556        /* Allocate merged zone data inside one of the zones */
     
    704704                 * the assert
    705705                 */
    706                 assert(confframe != ADDR2PFN((uintptr_t ) NULL));
     706                assert(confframe != ADDR2PFN((uintptr_t) NULL));
    707707
    708708                /* Update the known end of physical memory. */
     
    12061206        size_t free_highprio = 0;
    12071207
    1208         for (size_t i = 0;; i++) {
     1208        for (size_t i = 0; ; i++) {
    12091209                irq_spinlock_lock(&zones.lock, true);
    12101210
  • kernel/generic/src/printf/vsnprintf.c

    r76d0981d r3bacee1  
    170170        };
    171171        printf_spec_t ps = {
    172                 (int(*) (const char *, size_t, void *)) vsnprintf_str_write,
    173                 (int(*) (const wchar_t *, size_t, void *)) vsnprintf_wstr_write,
     172                (int (*) (const char *, size_t, void *)) vsnprintf_str_write,
     173                (int (*) (const wchar_t *, size_t, void *)) vsnprintf_wstr_write,
    174174                &data
    175175        };
  • kernel/generic/src/proc/task.c

    r76d0981d r3bacee1  
    112112
    113113#ifdef CONFIG_DEBUG
    114                 printf("[%"PRIu64"] ", task->taskid);
     114                printf("[%" PRIu64 "] ", task->taskid);
    115115#endif
    116116
  • kernel/generic/src/proc/thread.c

    r76d0981d r3bacee1  
    338338 *
    339339 */
    340 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
     340thread_t *thread_create(void (*func)(void *), void *arg, task_t *task,
    341341    thread_flags_t flags, const char *name)
    342342{
     
    524524                        ipc_cleanup();
    525525                        futex_task_cleanup();
    526                         LOG("Cleanup of task %" PRIu64" completed.", TASK->taskid);
     526                        LOG("Cleanup of task %" PRIu64 " completed.", TASK->taskid);
    527527                }
    528528        }
     
    542542
    543543        /* Not reached */
    544         while (true);
     544        while (true)
     545                ;
    545546}
    546547
     
    978979
    979980                                return (sys_errno_t) rc;
    980                          }
     981                        }
    981982                }
    982983
  • kernel/generic/src/synch/futex.c

    r76d0981d r3bacee1  
    171171                /* Invoke the blocking cht_destroy in the background. */
    172172                workq_global_enqueue_noblock(&task->futexes->destroy_work,
    173                         destroy_task_cache);
     173                    destroy_task_cache);
    174174        } else {
    175175                /* We can block. Invoke cht_destroy in this thread. */
     
    182182{
    183183        struct futex_cache *cache =
    184                 member_to_inst(work, struct futex_cache, destroy_work);
     184            member_to_inst(work, struct futex_cache, destroy_work);
    185185
    186186        /*
     
    319319
    320320        if (futex_ptr_link) {
    321                 futex_ptr_t *futex_ptr
    322                         = member_to_inst(futex_ptr_link, futex_ptr_t, cht_link);
     321                futex_ptr_t *futex_ptr =
     322                    member_to_inst(futex_ptr_link, futex_ptr_t, cht_link);
    323323
    324324                futex = futex_ptr->futex;
     
    485485static size_t task_fut_ht_key_hash(void *key)
    486486{
    487         return *(uintptr_t*)key;
     487        return *(uintptr_t *)key;
    488488}
    489489
     
    499499{
    500500        const futex_ptr_t *fut_ptr = member_to_inst(item, futex_ptr_t, cht_link);
    501         uintptr_t uaddr = *(uintptr_t*)key;
     501        uintptr_t uaddr = *(uintptr_t *)key;
    502502
    503503        return fut_ptr->uaddr == uaddr;
  • kernel/generic/src/synch/workqueue.c

    r76d0981d r3bacee1  
    133133static void wait_for_workers(struct work_queue *workq);
    134134static int _workq_enqueue(struct work_queue *workq, work_t *work_item,
    135         work_func_t func, bool can_block);
     135    work_func_t func, bool can_block);
    136136static void init_work_item(work_t *work_item, work_func_t func);
    137137static signal_op_t signal_worker_logic(struct work_queue *workq, bool can_block);
     
    185185
    186186/** Creates and initializes a work queue. Returns NULL upon failure. */
    187 struct work_queue * workq_create(const char *name)
     187struct work_queue *workq_create(const char *name)
    188188{
    189189        struct work_queue *workq = malloc(sizeof(struct work_queue), 0);
     
    269269
    270270        thread_t *thread = thread_create(worker_thread, workq, TASK,
    271                 THREAD_FLAG_NONE, workq->name);
     271            THREAD_FLAG_NONE, workq->name);
    272272
    273273        if (!thread) {
     
    428428 */
    429429bool workq_enqueue_noblock(struct work_queue *workq, work_t *work_item,
    430         work_func_t func)
     430    work_func_t func)
    431431{
    432432        return _workq_enqueue(workq, work_item, func, false);
     
    473473 */
    474474static int _workq_enqueue(struct work_queue *workq, work_t *work_item,
    475         work_func_t func, bool can_block)
     475    work_func_t func, bool can_block)
    476476{
    477477        assert(!workq_corrupted(workq));
     
    614614
    615615                size_t remaining_idle =
    616                         workq->idle_worker_cnt - workq->activate_pending;
     616                    workq->idle_worker_cnt - workq->activate_pending;
    617617
    618618                /* Idle workers still exist - activate one. */
     
    628628                } else {
    629629                        /* No idle workers remain. Request that a new one be created. */
    630                         bool need_worker = (active < max_concurrent_workers)
    631                                 && (workq->cur_worker_cnt < max_worker_cnt);
     630                        bool need_worker = (active < max_concurrent_workers) &&
     631                            (workq->cur_worker_cnt < max_worker_cnt);
    632632
    633633                        if (need_worker && can_block) {
     
    780780
    781781        _condvar_wait_timeout_irq_spinlock(&workq->activate_worker,
    782                 &workq->lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
     782            &workq->lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
    783783
    784784        assert(!workq_corrupted(workq));
     
    855855        bool worker_surplus = worker_unnecessary(workq);
    856856        const char *load_str = worker_surplus ? "decreasing" :
    857                 (0 < workq->activate_pending) ? "increasing" : "stable";
     857            (0 < workq->activate_pending) ? "increasing" : "stable";
    858858
    859859        irq_spinlock_unlock(&workq->lock, true);
    860860
    861861        printf(
    862                 "Configuration: max_worker_cnt=%zu, min_worker_cnt=%zu,\n"
    863                 " max_concurrent_workers=%zu, max_items_per_worker=%zu\n"
    864                 "Workers: %zu\n"
    865                 "Active:  %zu (workers currently processing work)\n"
    866                 "Blocked: %zu (work functions sleeping/blocked)\n"
    867                 "Idle:    %zu (idle workers waiting for more work)\n"
    868                 "Items:   %zu (queued not yet dispatched work)\n"
    869                 "Stopping: %d\n"
    870                 "Load: %s\n",
    871                 max_worker_cnt, min_worker_cnt,
    872                 max_concurrent_workers, max_items_per_worker,
    873                 total,
    874                 active,
    875                 blocked,
    876                 idle,
    877                 items,
    878                 stopping,
    879                 load_str
    880         );
     862            "Configuration: max_worker_cnt=%zu, min_worker_cnt=%zu,\n"
     863            " max_concurrent_workers=%zu, max_items_per_worker=%zu\n"
     864            "Workers: %zu\n"
     865            "Active:  %zu (workers currently processing work)\n"
     866            "Blocked: %zu (work functions sleeping/blocked)\n"
     867            "Idle:    %zu (idle workers waiting for more work)\n"
     868            "Items:   %zu (queued not yet dispatched work)\n"
     869            "Stopping: %d\n"
     870            "Load: %s\n",
     871            max_worker_cnt, min_worker_cnt,
     872            max_concurrent_workers, max_items_per_worker,
     873            total,
     874            active,
     875            blocked,
     876            idle,
     877            items,
     878            stopping,
     879            load_str);
    881880}
    882881
     
    896895        while (list_empty(&info->work_queues) && !stop) {
    897896                errno_t ret = _condvar_wait_timeout_irq_spinlock(&info->req_cv,
    898                         &info->lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
     897                    &info->lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
    899898
    900899                stop = (ret == EINTR);
     
    903902        if (!stop) {
    904903                *pworkq = list_get_instance(list_first(&info->work_queues),
    905                         struct work_queue, nb_link);
     904                    struct work_queue, nb_link);
    906905
    907906                assert(!workq_corrupted(*pworkq));
     
    933932
    934933        nonblock_adder.thread = thread_create(thr_nonblock_add_worker,
    935                 &nonblock_adder, TASK, THREAD_FLAG_NONE, "kworkq-nb");
     934            &nonblock_adder, TASK, THREAD_FLAG_NONE, "kworkq-nb");
    936935
    937936        if (nonblock_adder.thread) {
  • kernel/generic/src/sysinfo/stats.c

    r76d0981d r3bacee1  
    7474 *
    7575 */
    76 static load_t load_exp[LOAD_STEPS] = {1884, 2014, 2037};
     76static load_t load_exp[LOAD_STEPS] = { 1884, 2014, 2037 };
    7777
    7878/** Running average of the number of ready threads */
    79 static load_t avenrdy[LOAD_STEPS] = {0, 0, 0};
     79static load_t avenrdy[LOAD_STEPS] = { 0, 0, 0 };
    8080
    8181/** Load calculation lock */
  • kernel/generic/src/udebug/udebug.c

    r76d0981d r3bacee1  
    170170
    171171        mutex_unlock(&THREAD->udebug.lock);
    172         mutex_unlock(&TASK->udebug.lock);
     172        mutex_unlock(&TASK->udebug.lock);
    173173}
    174174
Note: See TracChangeset for help on using the changeset viewer.