Many open source projects have moved to using SPDX identifiers to specify license information, reducing the amount of boilerplate code in every source file. This patch replaces the bulk of SPDK .c, .cpp and Makefiles with the BSD-3-Clause identifier. Almost all of these files share the exact same license text, and this patch only modifies the files that contain the most common license text. There can be slight variations because the third clause contains company names - most say "Intel Corporation", but there are instances for Nvidia, Samsung, Eideticom and even "the copyright holder". Used a bash script to automate replacement of the license text with SPDX identifier which is checked into scripts/spdx.sh. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Iaa88ab5e92ea471691dc298cfe41ebfb5d169780 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12904 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Dong Yi <dongx.yi@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: <qun.wan@intel.com>
158 lines
4.2 KiB
C
158 lines
4.2 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright (c) Intel Corporation.
|
|
* All rights reserved.
|
|
*/
|
|
|
|
#ifndef __OCF_LIST_H__
|
|
#define __OCF_LIST_H__
|
|
|
|
#define LIST_POISON1 ((void *) 0x00100100)
|
|
#define LIST_POISON2 ((void *) 0x00200200)
|
|
|
|
/**
|
|
* List entry structure mimicking linux kernel based one.
|
|
*/
|
|
struct list_head {
|
|
struct list_head *next;
|
|
struct list_head *prev;
|
|
} __attribute__((aligned(64)));
|
|
|
|
/**
|
|
* start an empty list
|
|
*/
|
|
#define INIT_LIST_HEAD(l) { (l)->prev = l; (l)->next = l; }
|
|
|
|
/**
|
|
* Add item to list head.
|
|
* @param it list entry to be added
|
|
* @param l1 list main node (head)
|
|
*/
|
|
static inline void list_add(struct list_head *it, struct list_head *l1)
|
|
{
|
|
it->prev = l1;
|
|
it->next = l1->next;
|
|
|
|
l1->next->prev = it;
|
|
l1->next = it;
|
|
}
|
|
|
|
/**
|
|
* Add item it to tail.
|
|
* @param it list entry to be added
|
|
* @param l1 list main node (head)
|
|
*/
|
|
static inline void list_add_tail(struct list_head *it, struct list_head *l1)
|
|
{
|
|
it->prev = l1->prev;
|
|
it->next = l1;
|
|
|
|
l1->prev->next = it;
|
|
l1->prev = it;
|
|
}
|
|
|
|
/**
|
|
* check if a list is empty (return true)
|
|
*/
|
|
static inline int list_empty(struct list_head *it)
|
|
{
|
|
return it->next == it;
|
|
}
|
|
|
|
/**
|
|
* delete an entry from a list
|
|
*/
|
|
static inline void list_del(struct list_head *it)
|
|
{
|
|
it->next->prev = it->prev;
|
|
it->prev->next = it->next;
|
|
}
|
|
|
|
static inline void list_move_tail(struct list_head *list,
|
|
struct list_head *head)
|
|
{
|
|
list_del(list);
|
|
list_add_tail(list, head);
|
|
}
|
|
|
|
static inline void list_move(struct list_head *list,
|
|
struct list_head *head)
|
|
{
|
|
list_del(list);
|
|
list_add(list, head);
|
|
}
|
|
|
|
/**
|
|
* Extract an entry.
|
|
* @param list_head_i list head item, from which entry is extracted
|
|
* @param item_type type (struct) of list entry
|
|
* @param field_name name of list_head field within item_type
|
|
*/
|
|
#define list_entry(list_head_i, item_type, field_name) \
|
|
(item_type *)(((void*)(list_head_i)) - offsetof(item_type, field_name))
|
|
|
|
#define list_first_entry(list_head_i, item_type, field_name) \
|
|
list_entry((list_head_i)->next, item_type, field_name)
|
|
|
|
/**
|
|
* @param iterator uninitialized list_head pointer, to be used as iterator
|
|
* @param plist list head (main node)
|
|
*/
|
|
#define list_for_each(iterator, plist) \
|
|
for (iterator = (plist)->next; \
|
|
(iterator)->next != (plist)->next; \
|
|
iterator = (iterator)->next)
|
|
|
|
/**
|
|
* Safe version of list_for_each which works even if entries are deleted during
|
|
* loop.
|
|
* @param iterator uninitialized list_head pointer, to be used as iterator
|
|
* @param q another uninitialized list_head, used as helper
|
|
* @param plist list head (main node)
|
|
*/
|
|
/*
|
|
* Algorithm handles situation, where q is deleted.
|
|
* consider in example 3 element list with header h:
|
|
*
|
|
* h -> 1 -> 2 -> 3 ->
|
|
*1. i q
|
|
*
|
|
*2. i q
|
|
*
|
|
*3. q i
|
|
*/
|
|
#define list_for_each_safe(iterator, q, plist) \
|
|
for (iterator = (q = (plist)->next->next)->prev; \
|
|
(q) != (plist)->next; \
|
|
iterator = (q = (q)->next)->prev)
|
|
|
|
#define _list_entry_helper(item, head, field_name) list_entry(head, typeof(*item), field_name)
|
|
|
|
/**
|
|
* Iterate over list entries.
|
|
* @param list pointer to list item (iterator)
|
|
* @param plist pointer to list_head item
|
|
* @param field_name name of list_head field in list entry
|
|
*/
|
|
#define list_for_each_entry(item, plist, field_name) \
|
|
for (item = _list_entry_helper(item, (plist)->next, field_name); \
|
|
_list_entry_helper(item, (item)->field_name.next, field_name) !=\
|
|
_list_entry_helper(item, (plist)->next, field_name); \
|
|
item = _list_entry_helper(item, (item)->field_name.next, field_name))
|
|
|
|
/**
|
|
* Safe version of list_for_each_entry which works even if entries are deleted
|
|
* during loop.
|
|
* @param list pointer to list item (iterator)
|
|
* @param q another pointer to list item, used as helper
|
|
* @param plist pointer to list_head item
|
|
* @param field_name name of list_head field in list entry
|
|
*/
|
|
#define list_for_each_entry_safe(item, q, plist, field_name) \
|
|
for (item = _list_entry_helper(item, (plist)->next, field_name), \
|
|
q = _list_entry_helper(item, (item)->field_name.next, field_name); \
|
|
_list_entry_helper(item, (item)->field_name.next, field_name) != \
|
|
_list_entry_helper(item, (plist)->next, field_name); \
|
|
item = q, q = _list_entry_helper(q, (q)->field_name.next, field_name))
|
|
|
|
#endif
|