Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
05846bc3
Commit
05846bc3
authored
May 06, 2012
by
Alejandro Mery
Browse files
sunxi-tools.h: add list_insert() and list_next() helpers
parent
25e78f0c
Changes
1
Show whitespace changes
Inline
Side-by-side
sunxi-tools.h
View file @
05846bc3
...
...
@@ -47,14 +47,21 @@ static inline void list_init(struct list_entry *self)
self
->
prev
=
self
->
next
=
self
;
}
/** appends a list hook @l1 at the end of the list @l0 */
static
inline
void
list_append
(
struct
list_entry
*
l0
,
struct
list_entry
*
l1
)
/** puts an entry between two other on a list */
static
inline
void
list_inject
(
struct
list_entry
*
l
,
struct
list_entry
*
prev
,
struct
list_entry
*
next
)
{
l1
->
next
=
l0
;
l1
->
prev
=
l0
->
prev
;
l0
->
prev
=
l1
;
l
->
prev
=
prev
;
l
->
next
=
next
;
next
->
prev
=
l
;
prev
->
next
=
l
;
}
#define list_insert(H, E) list_inject((E), (H), (H)->next)
#define list_append(H, E) list_inject((E), (H)->prev, (H))
/** removes an entry for the list where it's contained */
static
inline
void
list_remove
(
struct
list_entry
*
l
)
{
...
...
@@ -63,16 +70,23 @@ static inline void list_remove(struct list_entry *l)
prev
->
next
=
next
;
}
/** returns first element of a list */
static
inline
struct
list_entry
*
list_first
(
struct
list_entry
*
l
)
{
return
(
l
->
next
==
l
)
?
NULL
:
l
->
next
;
}
/** returns last element of a list */
static
inline
struct
list_entry
*
list_last
(
struct
list_entry
*
l
)
{
return
(
l
->
prev
==
l
)
?
NULL
:
l
->
prev
;
}
/** returns first element of a list */
static
inline
struct
list_entry
*
list_first
(
struct
list_entry
*
l
)
/** returns next element on a list */
static
inline
struct
list_entry
*
list_next
(
struct
list_entry
*
l
,
struct
list_entry
*
e
)
{
return
(
l
->
next
==
l
)
?
NULL
:
l
->
next
;
return
(
e
->
next
==
l
)
?
NULL
:
e
->
next
;
}
/** is list empty? */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment