Move macros to be able to access them from installed ODP headers. Signed-off-by: Taras Kondratiuk <taras.kondrat...@linaro.org> Signed-off-by: Taras Kondratiuk <ta...@ti.com> --- platform/linux-keystone2/Makefile.am | 1 + platform/linux-keystone2/include/odp/plat/align.h | 109 ++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 platform/linux-keystone2/include/odp/plat/align.h
diff --git a/platform/linux-keystone2/Makefile.am b/platform/linux-keystone2/Makefile.am index d17ea45..505cb97 100644 --- a/platform/linux-keystone2/Makefile.am +++ b/platform/linux-keystone2/Makefile.am @@ -58,6 +58,7 @@ odpinclude_HEADERS = \ odpplatincludedir = $(includedir)/odp/plat odpplatinclude_HEADERS = \ + $(srcdir)/include/odp/plat/align.h \ $(srcdir)/include/odp/plat/debug.h \ $(srcdir)/include/odp/plat/mcsdk_tune.h \ $(srcdir)/include/odp/plat/state.h \ diff --git a/platform/linux-keystone2/include/odp/plat/align.h b/platform/linux-keystone2/include/odp/plat/align.h new file mode 100644 index 0000000..55271a5 --- /dev/null +++ b/platform/linux-keystone2/include/odp/plat/align.h @@ -0,0 +1,109 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP internal alignments + */ + +#ifndef ODP_ALIGN_INTERNAL_H_ +#define ODP_ALIGN_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup odp_compiler_optim + * @{ + */ + +/* + * Round up + */ + +/** + * @internal + * Round up 'x' to alignment 'align' + */ +#define ODP_ALIGN_ROUNDUP(x, align)\ + ((align) * (((x) + align - 1) / (align))) + +/** + * @internal + * Round up pointer 'x' to alignment 'align' + */ +#define ODP_ALIGN_ROUNDUP_PTR(x, align)\ + ((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x), (uintptr_t)(align))) + +/** + * @internal + * Round up 'x' to cache line size alignment + */ +#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\ + ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE) + +/** + * @internal + * Round up 'x' to page size alignment + */ +#define ODP_PAGE_SIZE_ROUNDUP(x)\ + ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE) + +/* + * Round down + */ + +/** + * @internal + * Round down 'x' to 'align' alignment, which is a power of two + */ +#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\ + ((x) & (~((align) - 1))) +/** + * @internal + * Round down 'x' to cache line size alignment + */ +#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\ + ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE) + +/* + * Check align + */ + +/** + * @internal + * Check if pointer 'x' is aligned to 'align', which is a power of two + */ +#define ODP_ALIGNED_CHECK_POWER_2(x, align)\ + ((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0) + +/** + * @internal + * Check if pointer 'x' is aligned to 'align', which is a power of two + */ +#define ODP_ALIGNED_CHECK(x, align)\ + (((uintptr_t)(x)) % (align) == 0) + +/** + * @internal + * Check if value is a power of two + */ +#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0) + + +#define ODP_CONTAINEROF(ptr, type, member) \ + (type *)((uintptr_t)(ptr) - ODP_OFFSETOF(type, member)) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif -- 1.9.1 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp