Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libeasy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HAL
libeasy
Commits
ca7b2006
Commit
ca7b2006
authored
4 weeks ago
by
Anjan Chanda
Browse files
Options
Downloads
Patches
Plain Diff
define offsetof() and container_of()
parent
67e6b91b
Branches
devel
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#207818
passed
4 weeks ago
Stage: static_code_analysis
Stage: compile_test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hlist.h
+12
-0
12 additions, 0 deletions
hlist.h
utils.h
+8
-0
8 additions, 0 deletions
utils.h
with
20 additions
and
0 deletions
hlist.h
+
12
−
0
View file @
ca7b2006
...
@@ -14,6 +14,18 @@
...
@@ -14,6 +14,18 @@
#ifndef _HLIST_H
#ifndef _HLIST_H
#define _HLIST_H
#define _HLIST_H
#ifndef offsetof
#define offsetof(type, member) ((size_t) &((type *)0)->member)
#endif
#ifndef container_of
#define container_of(ptr, type, member) \
({ \
const __typeof__(((type *) NULL)->member) *__mptr = (ptr); \
(type *) ((char *) __mptr - offsetof(type, member)); \
})
#endif
struct
hlist_node
{
struct
hlist_node
{
struct
hlist_node
*
next
;
struct
hlist_node
*
next
;
};
};
...
...
This diff is collapsed.
Click to expand it.
utils.h
+
8
−
0
View file @
ca7b2006
...
@@ -136,6 +136,14 @@ extern int get_ifoperstatus(const char *ifname, ifopstatus_t *opstatus);
...
@@ -136,6 +136,14 @@ extern int get_ifoperstatus(const char *ifname, ifopstatus_t *opstatus);
#define offsetof(type, member) ((size_t) &((type *)0)->member)
#define offsetof(type, member) ((size_t) &((type *)0)->member)
#endif
#endif
#ifndef container_of
#define container_of(ptr, type, member) \
({ \
const __typeof__(((type *) NULL)->member) *__mptr = (ptr); \
(type *) ((char *) __mptr - offsetof(type, member)); \
})
#endif
#ifndef bit
#ifndef bit
#define bit(_n) (1 << (_n))
#define bit(_n) (1 << (_n))
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment