Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Main Page
Related Pages
Supported Boards
Modules
Namespaces
Namespace List
Namespace Members
All
Functions
Variables
Enumerations
Data Structures
Data Structures
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
w
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerator
Related Symbols
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
p
q
r
s
t
u
v
w
x
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
►
RIOT OS
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
container.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2014 Freie Universität Berlin
3
* 2017 HAW-Hamburg
4
*
5
* This file is subject to the terms and conditions of the GNU Lesser
6
* General Public License v2.1. See the file LICENSE in the top level
7
* directory for more details.
8
*/
9
21
#ifndef CONTAINER_H
22
#define CONTAINER_H
23
24
#include <stddef.h>
25
#include <stdint.h>
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
30
31
/* uncrustify gets mightily confused by these macros... */
32
/* begin{code-style-ignore} */
33
47
#if __STDC_VERSION__ >= 201112L
48
# define container_of(PTR, TYPE, MEMBER) \
49
(_Generic((PTR), \
50
const __typeof__ (((TYPE *) 0)->MEMBER) *: \
51
((TYPE *) ((uintptr_t) (PTR) - offsetof(TYPE, MEMBER))), \
52
__typeof__ (((TYPE *) 0)->MEMBER) *: \
53
((TYPE *) ((uintptr_t) (PTR) - offsetof(TYPE, MEMBER))) \
54
))
55
#elif defined __GNUC__
56
# define container_of(PTR, TYPE, MEMBER) \
57
(__extension__ ({ \
58
__extension__ const __typeof__ (((TYPE *) 0)->MEMBER) *__m____ = (PTR); \
59
((TYPE *) ((uintptr_t) __m____ - offsetof(TYPE, MEMBER))); \
60
}))
61
#else
62
# define container_of(PTR, TYPE, MEMBER) \
63
((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER)))
62
# define container_of(PTR, TYPE, MEMBER) \
…
64
#endif
65
74
#define index_of(ARRAY, ELEMENT) (((uintptr_t)(ELEMENT) - (uintptr_t)(ARRAY)) / sizeof((ARRAY)[0]))
75
82
#ifndef ARRAY_SIZE
83
#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
84
#endif
85
86
#ifdef __cplusplus
87
}
88
#endif
89
90
#endif
/* CONTAINER_H */
Generated on Wed Mar 26 2025 08:27:17 by
1.12.0