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
065e3acd
Commit
065e3acd
authored
May 04, 2012
by
Alejandro Mery
Browse files
sunxi-tools: add struct list_entry, list_init(), list_append() and list_isempty()
parent
fd07c544
Changes
1
Hide whitespace changes
Inline
Side-by-side
sunxi-tools.h
View file @
065e3acd
...
...
@@ -28,4 +28,30 @@
/** shortcut to printf to stderr */
#define errf(...) fprintf(stderr, __VA_ARGS__)
/** a list hook */
struct
list_entry
{
struct
list_entry
*
prev
;
struct
list_entry
*
next
;
};
/** initialize an empty list hook */
static
inline
void
list_init
(
struct
list_entry
*
self
)
{
self
->
prev
=
self
->
next
=
self
;
}
/** append a list hook @l1 at the end of the list @l0 */
static
inline
void
list_append
(
struct
list_entry
*
l0
,
struct
list_entry
*
l1
)
{
l1
->
next
=
l0
;
l1
->
prev
=
l0
->
prev
;
l0
->
prev
=
l1
;
}
/** is list empty? */
static
inline
int
list_empty
(
struct
list_entry
*
l
)
{
return
(
l
->
prev
==
l
);
}
#endif
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