Bouffalo SDK
1.0
Bouffalolab Software Development Kit
|
#include "string.h"
#include "stdint.h"
Go to the source code of this file.
Data Structures | |
struct | bflb_dlist_node |
Macros | |
#define | bflb_container_of(ptr, type, member) ((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member))) |
#define | DLIST_OBJECT_INIT(object) |
initialize a dlist object More... | |
#define | DLIST_DEFINE(list) bflb_dlist_t list = { &(list), &(list) } |
initialize a dlist object More... | |
#define | bflb_dlist_entry(node, type, member) bflb_container_of(node, type, member) |
get the struct for this entry More... | |
#define | bflb_dlist_first_entry(ptr, type, member) bflb_dlist_entry((ptr)->next, type, member) |
#define | bflb_dlist_first_entry_or_null(ptr, type, member) (bflb_dlist_isempty(ptr) ? NULL : bflb_dlist_first_entry(ptr, type, member)) |
#define | bflb_dlist_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next) |
#define | bflb_dlist_for_each_prev(pos, head) for (pos = (head)->prev; pos != (head); pos = pos->prev) |
#define | bflb_dlist_for_each_safe(pos, n, head) |
#define | bflb_dlist_for_each_prev_safe(pos, n, head) |
#define | bflb_dlist_for_each_entry(pos, head, member) |
#define | bflb_dlist_for_each_entry_reverse(pos, head, member) |
#define | bflb_dlist_for_each_entry_safe(pos, n, head, member) |
#define | bflb_dlist_for_each_entry_safe_reverse(pos, n, head, member) |
Typedefs | |
typedef struct bflb_dlist_node | bflb_dlist_t |
Functions | |
static void | bflb_dlist_init (bflb_dlist_t *l) |
initialize a list More... | |
static void | bflb_dlist_insert_after (bflb_dlist_t *l, bflb_dlist_t *n) |
insert a node after a list More... | |
static void | bflb_dlist_insert_before (bflb_dlist_t *l, bflb_dlist_t *n) |
insert a node before a list More... | |
static void | bflb_dlist_remove (bflb_dlist_t *n) |
remove node from list. More... | |
static void | bflb_dlist_move_head (bflb_dlist_t *l, bflb_dlist_t *n) |
move node from list. More... | |
static void | bflb_dlist_move_tail (bflb_dlist_t *l, bflb_dlist_t *n) |
move node from list. More... | |
static int | bflb_dlist_isempty (const bflb_dlist_t *l) |
tests whether a list is empty More... | |
static unsigned int | bflb_dlist_len (const bflb_dlist_t *l) |
get the list length More... | |
Copyright (c) 2021 Bouffalolab team
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file bflb_list.h.
#define bflb_container_of | ( | ptr, | |
type, | |||
member | |||
) | ((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member))) |
container_of - return the member address of ptr, if the type of ptr is the struct type.
Definition at line 36 of file bflb_list.h.
#define bflb_dlist_entry | ( | node, | |
type, | |||
member | |||
) | bflb_container_of(node, type, member) |
get the struct for this entry
node | the entry point |
type | the type of structure |
member | the name of list in structure |
Definition at line 165 of file bflb_list.h.
#define bflb_dlist_first_entry | ( | ptr, | |
type, | |||
member | |||
) | bflb_dlist_entry((ptr)->next, type, member) |
dlist_first_entry - get the first element from a list : the list head to take the element from. : the type of the struct this is embedded in. : the name of the list_struct within the struct.
Note, that list is expected to be not empty.
Definition at line 176 of file bflb_list.h.
#define bflb_dlist_first_entry_or_null | ( | ptr, | |
type, | |||
member | |||
) | (bflb_dlist_isempty(ptr) ? NULL : bflb_dlist_first_entry(ptr, type, member)) |
dlist_first_entry_or_null - get the first element from a list : the list head to take the element from. : the type of the struct this is embedded in. : the name of the list_struct within the struct.
Note, that list is expected to be not empty.
Definition at line 186 of file bflb_list.h.
#define bflb_dlist_for_each | ( | pos, | |
head | |||
) | for (pos = (head)->next; pos != (head); pos = pos->next) |
dlist_for_each - iterate over a list : the dlist_t * to use as a loop cursor. : the head for your list.
Definition at line 194 of file bflb_list.h.
#define bflb_dlist_for_each_entry | ( | pos, | |
head, | |||
member | |||
) |
dlist_for_each_entry - iterate over list of given type : the type * to use as a loop cursor. : the head for your list. : the name of the list_struct within the struct.
Definition at line 224 of file bflb_list.h.
#define bflb_dlist_for_each_entry_reverse | ( | pos, | |
head, | |||
member | |||
) |
dlist_for_each_entry_reverse - iterate over list of given type : the type * to use as a loop cursor. : the head for your list. : the name of the list_struct within the struct.
Definition at line 235 of file bflb_list.h.
#define bflb_dlist_for_each_entry_safe | ( | pos, | |
n, | |||
head, | |||
member | |||
) |
dlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry : the type * to use as a loop cursor.
: another type * to use as temporary storage : the head for your list. : the name of the list_struct within the struct.
Definition at line 247 of file bflb_list.h.
#define bflb_dlist_for_each_entry_safe_reverse | ( | pos, | |
n, | |||
head, | |||
member | |||
) |
dlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry : the type * to use as a loop cursor.
: another type * to use as temporary storage : the head for your list. : the name of the list_struct within the struct.
Definition at line 260 of file bflb_list.h.
#define bflb_dlist_for_each_prev | ( | pos, | |
head | |||
) | for (pos = (head)->prev; pos != (head); pos = pos->prev) |
dlist_for_each_prev - iterate over a list : the dlist_t * to use as a loop cursor. : the head for your list.
Definition at line 202 of file bflb_list.h.
#define bflb_dlist_for_each_prev_safe | ( | pos, | |
n, | |||
head | |||
) |
Definition at line 215 of file bflb_list.h.
#define bflb_dlist_for_each_safe | ( | pos, | |
n, | |||
head | |||
) |
dlist_for_each_safe - iterate over a list safe against removal of list entry : the dlist_t * to use as a loop cursor.
: another dlist_t * to use as temporary storage : the head for your list.
Definition at line 211 of file bflb_list.h.
#define DLIST_DEFINE | ( | list | ) | bflb_dlist_t list = { &(list), &(list) } |
initialize a dlist object
Definition at line 156 of file bflb_list.h.
#define DLIST_OBJECT_INIT | ( | object | ) |
initialize a dlist object
Definition at line 149 of file bflb_list.h.
typedef struct bflb_dlist_node bflb_dlist_t |
Type for lists.
Definition at line 46 of file bflb_list.h.
|
inlinestatic |
|
inlinestatic |
insert a node after a list
l | list to insert it |
n | new node to be inserted |
Definition at line 64 of file bflb_list.h.
|
inlinestatic |
insert a node before a list
n | new node to be inserted |
l | list to insert it |
Definition at line 79 of file bflb_list.h.
|
inlinestatic |
tests whether a list is empty
l | the list to test. |
Definition at line 124 of file bflb_list.h.
|
inlinestatic |
|
inlinestatic |
move node from list.
n | the node to remove from the list. |
Definition at line 104 of file bflb_list.h.
|
inlinestatic |
move node from list.
n | the node to remove from the list. |
Definition at line 114 of file bflb_list.h.
|
inlinestatic |
remove node from list.
n | the node to remove from the list. |
Definition at line 92 of file bflb_list.h.