libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [PATCH 1/2] Add helper macros for pointer arithmetics


From: Alexander Larsson
Subject: [Libunwind-devel] [PATCH 1/2] Add helper macros for pointer arithmetics
Date: Mon, 26 Mar 2012 11:18:22 +0200

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.
---
 include/libunwind_i.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/libunwind_i.h b/include/libunwind_i.h
index 2ece7f0..f769b13 100644
--- a/include/libunwind_i.h
+++ b/include/libunwind_i.h
@@ -108,6 +108,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.  */
 #endif
 
 #define ARRAY_SIZE(a)  (sizeof (a) / sizeof ((a)[0]))
+#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)))
 
 /* Make it easy to write thread-safe code which may or may not be
    linked against libpthread.  The macros below can be used
-- 
1.7.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]