Changeset 4c14b88 in mainline for uspace/lib/c/include/adt


Ignore:
Timestamp:
2013-12-31T07:57:14Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b973dc
Parents:
6297465 (diff), 208b5f5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

mainline changes

Location:
uspace/lib/c/include/adt
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/checksum.h

    r6297465 r4c14b88  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Dominik Taborsky
    33 * All rights reserved.
    44 *
     
    3030 * @{
    3131 */
    32 
    3332/** @file
    34  * Network device.
    3533 */
    3634
    37 #ifndef LIBC_NET_DEVICE_H_
    38 #define LIBC_NET_DEVICE_H_
     35#ifndef LIBC_CHECKSUM_H_
     36#define LIBC_CHECKSUM_H_
    3937
    40 #include <adt/int_map.h>
    41 #include <nic/nic.h>
     38#include <sys/types.h>
    4239
    43 /** Device identifier to generic type map declaration. */
    44 #define DEVICE_MAP_DECLARE  INT_MAP_DECLARE
    45 
    46 /** Device identifier to generic type map implementation. */
    47 #define DEVICE_MAP_IMPLEMENT  INT_MAP_IMPLEMENT
    48 
    49 /** Device identifier type. */
    50 typedef int nic_device_id_t;
    51 
    52 /** Invalid device identifier. */
    53 #define NIC_DEVICE_INVALID_ID  (-1)
     40extern uint32_t compute_crc32(uint8_t *, size_t);
     41extern uint32_t compute_crc32_seed(uint8_t *, size_t, uint32_t);
    5442
    5543#endif
  • uspace/lib/c/include/adt/list.h

    r6297465 r4c14b88  
    3838
    3939#include <assert.h>
     40#include <stdbool.h>
    4041#include <unistd.h>
    4142
     
    7273            iterator = list_get_instance(_link, itype, member), \
    7374            _link != &(list).head; _link = _link->next)
     75
     76#define list_foreach_rev(list, member, itype, iterator) \
     77        for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \
     78            for (link_t *_link = (list).head.prev; \
     79            iterator = list_get_instance(_link, itype, member), \
     80            _link != &(list).head; _link = _link->prev)
    7481
    7582/** Unlike list_foreach(), allows removing items while traversing a list.
     
    105112
    106113#define assert_link_not_used(link) \
    107         assert(((link)->prev == NULL) && ((link)->next == NULL))
     114        assert(!link_used(link))
    108115
    109116/** Returns true if the link is definitely part of a list. False if not sure. */
     
    357364}
    358365
     366/** Determine if link is used.
     367 *
     368 * @param link Link
     369 * @return @c true if link is used, @c false if not.
     370 */
     371static inline bool link_used(link_t *link)
     372{
     373        if (link->prev == NULL && link->next == NULL)
     374                return false;
     375
     376        assert(link->prev != NULL && link->next != NULL);
     377        return true;
     378}
     379
    359380extern int list_member(const link_t *, const list_t *);
    360381extern void list_concat(list_t *, list_t *);
Note: See TracChangeset for help on using the changeset viewer.