OP-1287 implemented new flightmodes in plan.c
[librepilot.git] / flight / pios / inc / pios_struct_helper.h
blob65bae405ab26b040a8e46f1703b5bb515a0adcbc
1 /* Taken from include/linux/kernel.h from the Linux kernel tree */
3 /**
4 * container_of - cast a member of a structure out to the containing structure
5 * @ptr: the pointer to the member.
6 * @type: the type of the container struct this is embedded in.
7 * @member: the name of the member within the struct.
9 */
11 #ifndef PIOS_STRUCT_HELPER_H
12 #define PIOS_STRUCT_HELPER_H
14 #define container_of(ptr, type, member) \
15 ({ \
16 const typeof(((type *)0)->member) * __mptr = (ptr); \
17 (type *)((char *)__mptr - offsetof(type, member)); } \
20 /**
21 * cast_struct_to_array casts an homogeneous structure instance to an array
22 * of typeof(struct_field). struct_field need to be any of the fields
23 * containing inside the struct
24 * @instance: homogeneous structure to cast
25 * @struct_field: a field contained inside the structure
27 #define cast_struct_to_array(instance, struct_field) \
28 ((typeof(struct_field) *) & (instance))
29 #endif /* PIOS_STRUCT_HELPER_H */