Skip to content

Commit

Permalink
list: Rename struct list to struct ovs_list
Browse files Browse the repository at this point in the history
struct list is a common name and can't be used in public headers.

Signed-off-by: Thomas Graf <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
Thomas Graf committed Dec 15, 2014
1 parent 8c7be52 commit ca6ba70
Show file tree
Hide file tree
Showing 70 changed files with 333 additions and 331 deletions.
2 changes: 1 addition & 1 deletion CodingStyle.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ e.g.:
/* An event that will wake the following call to poll_block(). */
struct poll_waiter {
/* Set when the waiter is created. */
struct list node; /* Element in global waiters list. */
struct ovs_list node; /* Element in global waiters list. */
int fd; /* File descriptor. */
short int events; /* Events to wait for (POLLIN, POLLOUT). */
poll_fd_func *function; /* Callback function, if any, or null. */
Expand Down
2 changes: 1 addition & 1 deletion lib/fat-rwlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct fat_rwlock_slot {
*
* fat_rwlock_destroy() sets 'rwlock' to NULL to indicate that this
* slot may be destroyed. */
struct list list_node; /* In struct rwlock's 'threads' list. */
struct ovs_list list_node; /* In struct rwlock's 'threads' list. */
struct fat_rwlock *rwlock; /* Owner. */

/* Mutex.
Expand Down
2 changes: 1 addition & 1 deletion lib/fat-rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct OVS_LOCKABLE fat_rwlock {

/* Contains "struct fat_rwlock_slot"s, one for each thread that has taken
* this lock. Guarded by 'mutex'. */
struct list threads OVS_GUARDED;
struct ovs_list threads OVS_GUARDED;
struct ovs_mutex mutex;
};

Expand Down
8 changes: 4 additions & 4 deletions lib/guarded-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ guarded_list_is_empty(const struct guarded_list *list)
* the list. */
size_t
guarded_list_push_back(struct guarded_list *list,
struct list *node, size_t max)
struct ovs_list *node, size_t max)
{
size_t retval = 0;

Expand All @@ -65,10 +65,10 @@ guarded_list_push_back(struct guarded_list *list,
return retval;
}

struct list *
struct ovs_list *
guarded_list_pop_front(struct guarded_list *list)
{
struct list *node = NULL;
struct ovs_list *node = NULL;

ovs_mutex_lock(&list->mutex);
if (list->n) {
Expand All @@ -81,7 +81,7 @@ guarded_list_pop_front(struct guarded_list *list)
}

size_t
guarded_list_pop_all(struct guarded_list *list, struct list *elements)
guarded_list_pop_all(struct guarded_list *list, struct ovs_list *elements)
{
size_t n;

Expand Down
8 changes: 4 additions & 4 deletions lib/guarded-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

struct guarded_list {
struct ovs_mutex mutex;
struct list list;
struct ovs_list list;
size_t n;
};

Expand All @@ -38,9 +38,9 @@ void guarded_list_destroy(struct guarded_list *);

bool guarded_list_is_empty(const struct guarded_list *);

size_t guarded_list_push_back(struct guarded_list *, struct list *,
size_t guarded_list_push_back(struct guarded_list *, struct ovs_list *,
size_t max);
struct list *guarded_list_pop_front(struct guarded_list *);
size_t guarded_list_pop_all(struct guarded_list *, struct list *);
struct ovs_list *guarded_list_pop_front(struct guarded_list *);
size_t guarded_list_pop_all(struct guarded_list *, struct ovs_list *);

#endif /* guarded-list.h */
2 changes: 1 addition & 1 deletion lib/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct jsonrpc {
struct json_parser *parser;

/* Output. */
struct list output; /* Contains "struct ofpbuf"s. */
struct ovs_list output; /* Contains "struct ofpbuf"s. */
size_t output_count; /* Number of elements in "output". */
size_t backlog;
};
Expand Down
6 changes: 3 additions & 3 deletions lib/lacp.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ enum slave_status {
};

struct lacp {
struct list node; /* Node in all_lacps list. */
struct ovs_list node; /* Node in all_lacps list. */
char *name; /* Name of this lacp object. */
uint8_t sys_id[ETH_ADDR_LEN]; /* System ID. */
uint16_t sys_priority; /* System Priority. */
Expand Down Expand Up @@ -132,8 +132,8 @@ struct slave {
};

static struct ovs_mutex mutex;
static struct list all_lacps__ = LIST_INITIALIZER(&all_lacps__);
static struct list *const all_lacps OVS_GUARDED_BY(mutex) = &all_lacps__;
static struct ovs_list all_lacps__ = LIST_INITIALIZER(&all_lacps__);
static struct ovs_list *const all_lacps OVS_GUARDED_BY(mutex) = &all_lacps__;

static void lacp_update_attached(struct lacp *) OVS_REQUIRES(mutex);

Expand Down
100 changes: 50 additions & 50 deletions lib/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,40 @@
#include "util.h"

/* Doubly linked list head or element. */
struct list {
struct list *prev; /* Previous list element. */
struct list *next; /* Next list element. */
struct ovs_list {
struct ovs_list *prev; /* Previous list element. */
struct ovs_list *next; /* Next list element. */
};

#define LIST_INITIALIZER(LIST) { LIST, LIST }

static inline void list_init(struct list *);
static inline void list_poison(struct list *);
static inline void list_init(struct ovs_list *);
static inline void list_poison(struct ovs_list *);

/* List insertion. */
static inline void list_insert(struct list *, struct list *);
static inline void list_splice(struct list *before, struct list *first,
struct list *last);
static inline void list_push_front(struct list *, struct list *);
static inline void list_push_back(struct list *, struct list *);
static inline void list_replace(struct list *, const struct list *);
static inline void list_moved(struct list *);
static inline void list_move(struct list *dst, struct list *src);
static inline void list_insert(struct ovs_list *, struct ovs_list *);
static inline void list_splice(struct ovs_list *before, struct ovs_list *first,
struct ovs_list *last);
static inline void list_push_front(struct ovs_list *, struct ovs_list *);
static inline void list_push_back(struct ovs_list *, struct ovs_list *);
static inline void list_replace(struct ovs_list *, const struct ovs_list *);
static inline void list_moved(struct ovs_list *);
static inline void list_move(struct ovs_list *dst, struct ovs_list *src);

/* List removal. */
static inline struct list *list_remove(struct list *);
static inline struct list *list_pop_front(struct list *);
static inline struct list *list_pop_back(struct list *);
static inline struct ovs_list *list_remove(struct ovs_list *);
static inline struct ovs_list *list_pop_front(struct ovs_list *);
static inline struct ovs_list *list_pop_back(struct ovs_list *);

/* List elements. */
static inline struct list *list_front(const struct list *);
static inline struct list *list_back(const struct list *);
static inline struct ovs_list *list_front(const struct ovs_list *);
static inline struct ovs_list *list_back(const struct ovs_list *);

/* List properties. */
static inline size_t list_size(const struct list *);
static inline bool list_is_empty(const struct list *);
static inline bool list_is_singleton(const struct list *);
static inline bool list_is_short(const struct list *);
static inline size_t list_size(const struct ovs_list *);
static inline bool list_is_empty(const struct ovs_list *);
static inline bool list_is_singleton(const struct ovs_list *);
static inline bool list_is_short(const struct ovs_list *);

#define LIST_FOR_EACH(ITER, MEMBER, LIST) \
for (INIT_CONTAINER(ITER, (LIST)->next, MEMBER); \
Expand Down Expand Up @@ -85,22 +85,22 @@ static inline bool list_is_short(const struct list *);

/* Initializes 'list' as an empty list. */
static inline void
list_init(struct list *list)
list_init(struct ovs_list *list)
{
list->next = list->prev = list;
}

/* Initializes 'list' with pointers that will (probably) cause segfaults if
* dereferenced and, better yet, show up clearly in a debugger. */
static inline void
list_poison(struct list *list)
list_poison(struct ovs_list *list)
{
memset(list, 0xcc, sizeof *list);
}

/* Inserts 'elem' just before 'before'. */
static inline void
list_insert(struct list *before, struct list *elem)
list_insert(struct ovs_list *before, struct ovs_list *elem)
{
elem->prev = before->prev;
elem->next = before;
Expand All @@ -111,7 +111,7 @@ list_insert(struct list *before, struct list *elem)
/* Removes elements 'first' though 'last' (exclusive) from their current list,
then inserts them just before 'before'. */
static inline void
list_splice(struct list *before, struct list *first, struct list *last)
list_splice(struct ovs_list *before, struct ovs_list *first, struct ovs_list *last)
{
if (first == last) {
return;
Expand All @@ -132,23 +132,23 @@ list_splice(struct list *before, struct list *first, struct list *last)
/* Inserts 'elem' at the beginning of 'list', so that it becomes the front in
'list'. */
static inline void
list_push_front(struct list *list, struct list *elem)
list_push_front(struct ovs_list *list, struct ovs_list *elem)
{
list_insert(list->next, elem);
}

/* Inserts 'elem' at the end of 'list', so that it becomes the back in
* 'list'. */
static inline void
list_push_back(struct list *list, struct list *elem)
list_push_back(struct ovs_list *list, struct ovs_list *elem)
{
list_insert(list, elem);
}

/* Puts 'elem' in the position currently occupied by 'position'.
* Afterward, 'position' is not part of a list. */
static inline void
list_replace(struct list *element, const struct list *position)
list_replace(struct ovs_list *element, const struct ovs_list *position)
{
element->next = position->next;
element->next->prev = element;
Expand All @@ -163,7 +163,7 @@ list_replace(struct list *element, const struct list *position)
* of a non-empty list. It fails badly, however, if 'list' is the head of an
* empty list; just use list_init() in that case. */
static inline void
list_moved(struct list *list)
list_moved(struct ovs_list *list)
{
list->prev->next = list->next->prev = list;
}
Expand All @@ -172,7 +172,7 @@ list_moved(struct list *list)
* around in memory. The effect is that, if 'src' was the head of a list, now
* 'dst' is the head of a list containing the same elements. */
static inline void
list_move(struct list *dst, struct list *src)
list_move(struct ovs_list *dst, struct ovs_list *src)
{
if (!list_is_empty(src)) {
*dst = *src;
Expand All @@ -184,8 +184,8 @@ list_move(struct list *dst, struct list *src)

/* Removes 'elem' from its list and returns the element that followed it.
Undefined behavior if 'elem' is not in a list. */
static inline struct list *
list_remove(struct list *elem)
static inline struct ovs_list *
list_remove(struct ovs_list *elem)
{
elem->prev->next = elem->next;
elem->next->prev = elem->prev;
Expand All @@ -194,32 +194,32 @@ list_remove(struct list *elem)

/* Removes the front element from 'list' and returns it. Undefined behavior if
'list' is empty before removal. */
static inline struct list *
list_pop_front(struct list *list)
static inline struct ovs_list *
list_pop_front(struct ovs_list *list)
{
struct list *front = list->next;
struct ovs_list *front = list->next;

list_remove(front);
return front;
}

/* Removes the back element from 'list' and returns it.
Undefined behavior if 'list' is empty before removal. */
static inline struct list *
list_pop_back(struct list *list)
static inline struct ovs_list *
list_pop_back(struct ovs_list *list)
{
struct list *back = list->prev;
struct ovs_list *back = list->prev;

list_remove(back);
return back;
}

/* Returns the front element in 'list_'.
Undefined behavior if 'list_' is empty. */
static inline struct list *
list_front(const struct list *list_)
static inline struct ovs_list *
list_front(const struct ovs_list *list_)
{
struct list *list = CONST_CAST(struct list *, list_);
struct ovs_list *list = CONST_CAST(struct ovs_list *, list_);

ovs_assert(!list_is_empty(list));

Expand All @@ -228,10 +228,10 @@ list_front(const struct list *list_)

/* Returns the back element in 'list_'.
Undefined behavior if 'list_' is empty. */
static inline struct list *
list_back(const struct list *list_)
static inline struct ovs_list *
list_back(const struct ovs_list *list_)
{
struct list *list = CONST_CAST(struct list *, list_);
struct ovs_list *list = CONST_CAST(struct ovs_list *, list_);

ovs_assert(!list_is_empty(list));

Expand All @@ -241,9 +241,9 @@ list_back(const struct list *list_)
/* Returns the number of elements in 'list'.
Runs in O(n) in the number of elements. */
static inline size_t
list_size(const struct list *list)
list_size(const struct ovs_list *list)
{
const struct list *e;
const struct ovs_list *e;
size_t cnt = 0;

for (e = list->next; e != list; e = e->next) {
Expand All @@ -254,21 +254,21 @@ list_size(const struct list *list)

/* Returns true if 'list' is empty, false otherwise. */
static inline bool
list_is_empty(const struct list *list)
list_is_empty(const struct ovs_list *list)
{
return list->next == list;
}

/* Returns true if 'list' has exactly 1 element, false otherwise. */
static inline bool
list_is_singleton(const struct list *list)
list_is_singleton(const struct ovs_list *list)
{
return list_is_short(list) && !list_is_empty(list);
}

/* Returns true if 'list' has 0 or 1 elements, false otherwise. */
static inline bool
list_is_short(const struct list *list)
list_is_short(const struct ovs_list *list)
{
return list->next == list->prev;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/mac-learning.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mac_table_hash(const struct mac_learning *ml, const uint8_t mac[ETH_ADDR_LEN],
}

static struct mac_entry *
mac_entry_from_lru_node(struct list *list)
mac_entry_from_lru_node(struct ovs_list *list)
{
return CONTAINER_OF(list, struct mac_entry, lru_node);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/mac-learning.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct mac_entry {

/* The following are marked guarded to prevent users from iterating over or
* accessing a mac_entry without hodling the parent mac_learning rwlock. */
struct list lru_node OVS_GUARDED; /* Element in 'lrus' list. */
struct ovs_list lru_node OVS_GUARDED; /* Element in 'lrus' list. */

/* Learned port. */
union {
Expand All @@ -74,7 +74,7 @@ static inline bool mac_entry_is_grat_arp_locked(const struct mac_entry *mac)
/* MAC learning table. */
struct mac_learning {
struct hmap table; /* Learning table. */
struct list lrus OVS_GUARDED; /* In-use entries, least recently used at the
struct ovs_list lrus OVS_GUARDED; /* In-use entries, least recently used at the
front, most recently used at the back. */
uint32_t secret; /* Secret for randomizing hash table. */
unsigned long *flood_vlans; /* Bitmap of learning disabled VLANs. */
Expand Down
Loading

0 comments on commit ca6ba70

Please sign in to comment.