Bouffalo SDK  1.0
Bouffalolab Software Development Kit
bflb_list.h File Reference
#include "string.h"
#include "stdint.h"
Include dependency graph for bflb_list.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...
 

Detailed Description

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.

Macro Definition Documentation

◆ bflb_container_of

#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.

◆ bflb_dlist_entry

#define bflb_dlist_entry (   node,
  type,
  member 
)    bflb_container_of(node, type, member)

get the struct for this entry

Parameters
nodethe entry point
typethe type of structure
memberthe name of list in structure

Definition at line 165 of file bflb_list.h.

◆ bflb_dlist_first_entry

#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.

◆ bflb_dlist_first_entry_or_null

#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.

◆ bflb_dlist_for_each

#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.

◆ bflb_dlist_for_each_entry

#define bflb_dlist_for_each_entry (   pos,
  head,
  member 
)
Value:
for (pos = bflb_dlist_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = bflb_dlist_entry(pos->member.next, typeof(*pos), member))
#define bflb_dlist_entry(node, type, member)
get the struct for this entry
Definition: bflb_list.h:165

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.

◆ bflb_dlist_for_each_entry_reverse

#define bflb_dlist_for_each_entry_reverse (   pos,
  head,
  member 
)
Value:
for (pos = bflb_dlist_entry((head)->prev, typeof(*pos), member); \
&pos->member != (head); \
pos = bflb_dlist_entry(pos->member.prev, typeof(*pos), member))
#define bflb_dlist_entry(node, type, member)
get the struct for this entry
Definition: bflb_list.h:165

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.

◆ bflb_dlist_for_each_entry_safe

#define bflb_dlist_for_each_entry_safe (   pos,
  n,
  head,
  member 
)
Value:
for (pos = bflb_dlist_entry((head)->next, typeof(*pos), member), \
n = bflb_dlist_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = bflb_dlist_entry(n->member.next, typeof(*n), member))
#define bflb_dlist_entry(node, type, member)
get the struct for this entry
Definition: bflb_list.h:165

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.

◆ bflb_dlist_for_each_entry_safe_reverse

#define bflb_dlist_for_each_entry_safe_reverse (   pos,
  n,
  head,
  member 
)
Value:
for (pos = bflb_dlist_entry((head)->prev, typeof(*pos), field), \
n = bflb_dlist_entry(pos->member.prev, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = bflb_dlist_entry(pos->member.prev, typeof(*pos), member))
#define bflb_dlist_entry(node, type, member)
get the struct for this entry
Definition: bflb_list.h:165

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.

◆ bflb_dlist_for_each_prev

#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.

◆ bflb_dlist_for_each_prev_safe

#define bflb_dlist_for_each_prev_safe (   pos,
  n,
  head 
)
Value:
for (pos = (head)->prev, n = pos->prev; pos != (head); \
pos = n, n = pos->prev)

Definition at line 215 of file bflb_list.h.

◆ bflb_dlist_for_each_safe

#define bflb_dlist_for_each_safe (   pos,
  n,
  head 
)
Value:
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)

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.

◆ DLIST_DEFINE

#define DLIST_DEFINE (   list)    bflb_dlist_t list = { &(list), &(list) }

initialize a dlist object

Definition at line 156 of file bflb_list.h.

◆ DLIST_OBJECT_INIT

#define DLIST_OBJECT_INIT (   object)
Value:
{ \
&(object), &(object) \
}

initialize a dlist object

Definition at line 149 of file bflb_list.h.

Typedef Documentation

◆ bflb_dlist_t

typedef struct bflb_dlist_node bflb_dlist_t

Type for lists.

Definition at line 46 of file bflb_list.h.

Function Documentation

◆ bflb_dlist_init()

static void bflb_dlist_init ( bflb_dlist_t l)
inlinestatic

initialize a list

Parameters
llist to be initialized

Definition at line 53 of file bflb_list.h.

◆ bflb_dlist_insert_after()

static void bflb_dlist_insert_after ( bflb_dlist_t l,
bflb_dlist_t n 
)
inlinestatic

insert a node after a list

Parameters
llist to insert it
nnew node to be inserted

Definition at line 64 of file bflb_list.h.

Here is the caller graph for this function:

◆ bflb_dlist_insert_before()

static void bflb_dlist_insert_before ( bflb_dlist_t l,
bflb_dlist_t n 
)
inlinestatic

insert a node before a list

Parameters
nnew node to be inserted
llist to insert it

Definition at line 79 of file bflb_list.h.

Here is the caller graph for this function:

◆ bflb_dlist_isempty()

static int bflb_dlist_isempty ( const bflb_dlist_t l)
inlinestatic

tests whether a list is empty

Parameters
lthe list to test.

Definition at line 124 of file bflb_list.h.

◆ bflb_dlist_len()

static unsigned int bflb_dlist_len ( const bflb_dlist_t l)
inlinestatic

get the list length

Parameters
lthe list to get.

Definition at line 133 of file bflb_list.h.

◆ bflb_dlist_move_head()

static void bflb_dlist_move_head ( bflb_dlist_t l,
bflb_dlist_t n 
)
inlinestatic

move node from list.

Parameters
nthe node to remove from the list.

Definition at line 104 of file bflb_list.h.

Here is the call graph for this function:

◆ bflb_dlist_move_tail()

static void bflb_dlist_move_tail ( bflb_dlist_t l,
bflb_dlist_t n 
)
inlinestatic

move node from list.

Parameters
nthe node to remove from the list.

Definition at line 114 of file bflb_list.h.

Here is the call graph for this function:

◆ bflb_dlist_remove()

static void bflb_dlist_remove ( bflb_dlist_t n)
inlinestatic

remove node from list.

Parameters
nthe node to remove from the list.

Definition at line 92 of file bflb_list.h.

Here is the caller graph for this function: