From edcc521a0e94bb198aa3197f1620c40f640334c1 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 26 Mar 2012 11:18:22 +0200 Subject: [PATCH] Add helper macros for pointer arithmetics ALIGN lets you align pointers and STRUCT_MEMBER lets you get structure members at a specific offset. These are useful in general, and will be needed for the coredump notes cleanup work. --- src/coredump/_UCD_internal.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coredump/_UCD_internal.h b/src/coredump/_UCD_internal.h index 8b36729b..5e927775 100644 --- a/src/coredump/_UCD_internal.h +++ b/src/coredump/_UCD_internal.h @@ -99,4 +99,8 @@ struct UCD_info extern coredump_phdr_t * _UCD_get_elf_image(struct UCD_info *ui, unw_word_t ip); +#define ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL)) +#define STRUCT_MEMBER_P(struct_p, struct_offset) ((void *) ((char*) (struct_p) + (long) (struct_offset))) +#define STRUCT_MEMBER(member_type, struct_p, struct_offset) (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset))) + #endif