*/
#include <lttng/bug.h>
+#include <unistd.h>
-/*
- * 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
#include <urcu/arch.h>
#include <urcu/compiler.h>
-/* ALIGNMENT SHORTCUTS */
-
-#include <unistd.h>
-
-#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) ({ \
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)