list.h (256281) | list.h (271127) |
---|---|
1/*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. | 1/*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. |
5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. |
|
5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. --- 289 unchanged lines hidden (view full) --- 302hlist_move_list(struct hlist_head *old, struct hlist_head *new) 303{ 304 305 new->first = old->first; 306 if (new->first) 307 new->first->pprev = &new->first; 308 old->first = NULL; 309} | 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. --- 289 unchanged lines hidden (view full) --- 303hlist_move_list(struct hlist_head *old, struct hlist_head *new) 304{ 305 306 new->first = old->first; 307 if (new->first) 308 new->first->pprev = &new->first; 309 old->first = NULL; 310} |
311 312/** 313 * list_is_singular - tests whether a list has just one entry. 314 * @head: the list to test. 315 */ 316static inline int list_is_singular(const struct list_head *head) 317{ 318 return !list_empty(head) && (head->next == head->prev); 319} 320 321static inline void __list_cut_position(struct list_head *list, 322 struct list_head *head, struct list_head *entry) 323{ 324 struct list_head *new_first = entry->next; 325 list->next = head->next; 326 list->next->prev = list; 327 list->prev = entry; 328 entry->next = list; 329 head->next = new_first; 330 new_first->prev = head; 331} 332 333/** 334 * list_cut_position - cut a list into two 335 * @list: a new list to add all removed entries 336 * @head: a list with entries 337 * @entry: an entry within head, could be the head itself 338 * and if so we won't cut the list 339 * 340 * This helper moves the initial part of @head, up to and 341 * including @entry, from @head to @list. You should 342 * pass on @entry an element you know is on @head. @list 343 * should be an empty list or a list you do not care about 344 * losing its data. 345 * 346 */ 347static inline void list_cut_position(struct list_head *list, 348 struct list_head *head, struct list_head *entry) 349{ 350 if (list_empty(head)) 351 return; 352 if (list_is_singular(head) && 353 (head->next != entry && head != entry)) 354 return; 355 if (entry == head) 356 INIT_LIST_HEAD(list); 357 else 358 __list_cut_position(list, head, entry); 359} 360 361/** 362 * list_is_last - tests whether @list is the last entry in list @head 363 * @list: the entry to test 364 * @head: the head of the list 365 */ 366static inline int list_is_last(const struct list_head *list, 367 const struct list_head *head) 368{ 369 return list->next == head; 370} |
|
310 311#define hlist_entry(ptr, type, field) container_of(ptr, type, field) 312 313#define hlist_for_each(p, head) \ 314 for (p = (head)->first; p; p = p->next) 315 316#define hlist_for_each_safe(p, n, head) \ 317 for (p = (head)->first; p && ({ n = p->next; 1; }); p = n) --- 4 unchanged lines hidden (view full) --- 322 323#define hlist_for_each_entry_continue(tp, p, field) \ 324 for (p = (p)->next; \ 325 p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next) 326 327#define hlist_for_each_entry_from(tp, p, field) \ 328 for (; p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next) 329 | 371 372#define hlist_entry(ptr, type, field) container_of(ptr, type, field) 373 374#define hlist_for_each(p, head) \ 375 for (p = (head)->first; p; p = p->next) 376 377#define hlist_for_each_safe(p, n, head) \ 378 for (p = (head)->first; p && ({ n = p->next; 1; }); p = n) --- 4 unchanged lines hidden (view full) --- 383 384#define hlist_for_each_entry_continue(tp, p, field) \ 385 for (p = (p)->next; \ 386 p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next) 387 388#define hlist_for_each_entry_from(tp, p, field) \ 389 for (; p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next) 390 |
330#define hlist_for_each_entry_safe(tp, p, n, head, field) \ 331 for (p = (head)->first; p ? \ 332 (n = p->next) | (tp = hlist_entry(p, typeof(*tp), field)) : \ 333 NULL; p = n) | 391#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \ 392 for (pos = (head)->first; \ 393 (pos) != 0 && ({ n = (pos)->next; \ 394 tpos = hlist_entry((pos), typeof(*(tpos)), member); 1;}); \ 395 pos = (n)) |
334 335#endif /* _LINUX_LIST_H_ */ | 396 397#endif /* _LINUX_LIST_H_ */ |