From: Mathieu Desnoyers Date: Fri, 18 Nov 2011 18:36:03 +0000 (-0500) Subject: Extend align.h X-Git-Tag: v1.9.1~70 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=993e8a491eba696a20f91c3688b90f2b155a8c9c;p=lttng-ust.git Extend align.h Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/align.h b/include/lttng/align.h index 94d0d6e3..0a5363ea 100644 --- a/include/lttng/align.h +++ b/include/lttng/align.h @@ -17,12 +17,13 @@ */ #include +#include -/* - * Align pointer on natural object alignment. - */ -#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj))) -#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj))) +#define PAGE_SIZE sysconf(_SC_PAGE_SIZE) +#define PAGE_MASK (~(PAGE_SIZE - 1)) +#define __ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask)) +#define ALIGN(v, align) __ALIGN_MASK(v, (typeof(v)) (align) - 1) +#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) /** * offset_align - Calculate the offset needed to align an object on its natural diff --git a/include/lttng/core.h b/include/lttng/core.h index 9243941c..838cdb20 100644 --- a/include/lttng/core.h +++ b/include/lttng/core.h @@ -25,16 +25,6 @@ #include #include -/* ALIGNMENT SHORTCUTS */ - -#include - -#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) -#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) -#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) -#define PAGE_SIZE sysconf(_SC_PAGE_SIZE) -#define PAGE_MASK (~(PAGE_SIZE-1)) - /* Min / Max */ #define min_t(type, x, y) ({ \ @@ -58,18 +48,6 @@ void *zmalloc(size_t len) return calloc(1, len); } -static inline -void *malloc_align(size_t len) -{ - return malloc(ALIGN(len, CAA_CACHE_LINE_SIZE)); -} - -static inline -void *zmalloc_align(size_t len) -{ - return calloc(1, ALIGN(len, CAA_CACHE_LINE_SIZE)); -} - /* MATH */ static inline unsigned int hweight32(unsigned int w)