diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-04-24 16:07:10 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-05-01 07:27:24 +0300 |
commit | 1ac794cb618fea55db81cc697f46442bf70469d8 (patch) | |
tree | 8ca947a95897977118ab1694458fb918459cd162 /include | |
parent | f0eb503db4c14176f165ca067798b079571decda (diff) | |
download | opensbi-1ac794cb618fea55db81cc697f46442bf70469d8.tar.xz |
include: Add array_size() macro
Getting array size of a dynmaic array can be very handy hence
this patch.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/sbi/sbi_types.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/sbi/sbi_types.h b/include/sbi/sbi_types.h index 153c185..0952d5c 100644 --- a/include/sbi/sbi_types.h +++ b/include/sbi/sbi_types.h @@ -78,6 +78,8 @@ typedef unsigned long physical_size_t; const typeof(((type *)0)->member) * __mptr = (ptr); \ (type *)((char *)__mptr - offsetof(type, member)); }) +#define array_size(x) (sizeof(x) / sizeof((x)[0])) + #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define CLAMP(a, lo, hi) MIN(MAX(a, lo), hi) |