X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Fust%2Fcore.h;h=8c1c490eedde18b0615741ee1ec1a9773c0589ab;hb=14641debd03ba299bd06040cb62e0dbdef7fac81;hp=c6057ea7b0a93e13de955d1c903a4f4cd2f8b3a4;hpb=518d7abb8e3720433c611499f704c3bd9d554102;p=lttng-ust.git diff --git a/include/ust/core.h b/include/ust/core.h index c6057ea7..8c1c490e 100644 --- a/include/ust/core.h +++ b/include/ust/core.h @@ -19,46 +19,11 @@ #define UST_CORE_H #include +#include #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) -#if defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT) - -/* - * Calculate the offset needed to align the type. - * size_of_type must be non-zero. - */ -static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type) -{ - size_t alignment = min(sizeof(void *), size_of_type); - return (alignment - align_drift) & (alignment - 1); -} -/* Default arch alignment */ -#define LTT_ALIGN - -static inline int ltt_get_alignment(void) -{ - return sizeof(void *); -} - -#else - -static inline unsigned int ltt_align(size_t align_drift, - size_t size_of_type) -{ - return 0; -} - -#define LTT_ALIGN __attribute__((packed)) - -static inline int ltt_get_alignment(void) -{ - return 0; -} -#endif /* defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT) */ - - /* ARRAYS */ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -115,19 +80,27 @@ static inline long IS_ERR(const void *ptr) #define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER; #define DECLARE_MUTEX(m) extern pthread_mutex_t (m); -#define mutex_lock(m) pthread_mutex_lock(m) - -#define mutex_unlock(m) pthread_mutex_unlock(m) - - /* MALLOCATION */ -#define zmalloc(s) calloc(1, s) +#include + +static inline +void *zmalloc(size_t len) +{ + return calloc(1, len); +} -/* ATTRIBUTES */ +static inline +void *malloc_align(size_t len) +{ + return malloc(ALIGN(len, CAA_CACHE_LINE_SIZE)); +} -/* FIXME: define this */ -#define ____cacheline_aligned +static inline +void *zmalloc_align(size_t len) +{ + return calloc(1, ALIGN(len, CAA_CACHE_LINE_SIZE)); +} /* MATH */ @@ -151,8 +124,16 @@ static __inline__ int get_count_order(unsigned int count) return order; } -#define container_of(ptr, type, member) ({ \ +#define _ust_container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) +#ifndef inline_memcpy +#define inline_memcpy memcpy +#endif + +#ifndef __same_type +#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#endif + #endif /* UST_CORE_H */