mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
core: add convenience macros to local.h
Move ARRAY_SIZE() from tplg_local.h to local.h and add container_of() macro to local.h. Both macros are generic but are initially used by topology. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
634712d21c
commit
ab9633d581
2 changed files with 7 additions and 1 deletions
|
|
@ -350,4 +350,11 @@ int snd_config_search_alias_hooks(snd_config_t *config,
|
|||
|
||||
int _snd_conf_generic_id(const char *id);
|
||||
|
||||
/* convenience macros */
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue