2015-04-11 07:44:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2015-12-04 23:09:39 +08:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Common toolchain abstraction
|
|
|
|
*
|
2015-10-21 00:42:33 +08:00
|
|
|
* Macros to abstract compiler capabilities (common to all toolchains).
|
2015-07-02 05:22:39 +08:00
|
|
|
*/
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2015-12-16 00:44:54 +08:00
|
|
|
/* Abstract use of extern keyword for compatibility between C and C++ */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN_C extern "C"
|
|
|
|
#else
|
|
|
|
#define EXTERN_C extern
|
|
|
|
#endif
|
|
|
|
|
2015-12-22 01:08:00 +08:00
|
|
|
/* Use TASK_ENTRY_CPP to tag task entry points defined in C++ files. */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define TASK_ENTRY_CPP extern "C"
|
|
|
|
#endif
|
|
|
|
|
2015-04-11 07:44:37 +08:00
|
|
|
/*
|
|
|
|
* Generate a reference to an external symbol.
|
|
|
|
* The reference indicates to the linker that the symbol is required
|
|
|
|
* by the module containing the reference and should be included
|
|
|
|
* in the image if the module is in the image.
|
|
|
|
*
|
|
|
|
* The assembler directive ".set" is used to define a local symbol.
|
|
|
|
* No memory is allocated, and the local symbol does not appear in
|
|
|
|
* the symbol table.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _ASMLANGUAGE
|
|
|
|
#define REQUIRES(sym) .set sym ## _Requires, sym
|
|
|
|
#else
|
|
|
|
#define REQUIRES(sym) __asm__ (".set " # sym "_Requires, " # sym "\n\t");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _ASMLANGUAGE
|
|
|
|
#define SECTION .section
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the project is being built for speed (i.e. not for minimum size) then
|
|
|
|
* align functions and branches in executable sections to improve performance.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _ASMLANGUAGE
|
|
|
|
|
2015-10-09 18:20:52 +08:00
|
|
|
#ifdef CONFIG_X86
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
#ifdef PERF_OPT
|
|
|
|
#define PERFOPT_ALIGN .balign 16
|
|
|
|
#else
|
|
|
|
#define PERFOPT_ALIGN .balign 1
|
|
|
|
#endif
|
|
|
|
|
2015-06-06 10:27:08 +08:00
|
|
|
#elif defined(CONFIG_ARM)
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_ISA_THUMB
|
|
|
|
#define PERFOPT_ALIGN .balign 2
|
|
|
|
#else
|
|
|
|
#define PERFOPT_ALIGN .balign 4
|
|
|
|
#endif
|
|
|
|
|
2015-06-06 10:27:49 +08:00
|
|
|
#elif defined(CONFIG_ARC)
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
#define PERFOPT_ALIGN .balign 4
|
|
|
|
|
2017-02-11 04:58:08 +08:00
|
|
|
#elif defined(CONFIG_NIOS2) || defined(CONFIG_RISCV32) || \
|
|
|
|
defined(CONFIG_XTENSA)
|
2016-04-29 05:45:08 +08:00
|
|
|
#define PERFOPT_ALIGN .balign 4
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#error Architecture unsupported
|
|
|
|
|
2015-04-11 07:44:37 +08:00
|
|
|
#endif
|
|
|
|
|
2016-08-19 00:25:00 +08:00
|
|
|
#define GC_SECTION(sym) SECTION .text.##sym, "ax"
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
|
|
|
/* force inlining a function */
|
|
|
|
|
|
|
|
#if !defined(_ASMLANGUAGE)
|
|
|
|
#define ALWAYS_INLINE inline __attribute__((always_inline))
|
|
|
|
#endif
|
|
|
|
|
2015-05-22 03:07:12 +08:00
|
|
|
#define _STRINGIFY(x) #x
|
2015-11-24 02:27:23 +08:00
|
|
|
#define STRINGIFY(s) _STRINGIFY(s)
|
2015-05-22 03:07:12 +08:00
|
|
|
|
2015-05-26 22:21:42 +08:00
|
|
|
/* Indicate that an array will be used for stack space. */
|
|
|
|
|
2017-02-17 02:37:25 +08:00
|
|
|
#if !defined(_ASMLANGUAGE)
|
|
|
|
#define __stack __aligned(STACK_ALIGN)
|
|
|
|
#endif
|
2015-05-26 22:21:42 +08:00
|
|
|
|
2015-11-27 01:53:53 +08:00
|
|
|
/* concatenate the values of the arguments into one */
|
|
|
|
#define _DO_CONCAT(x, y) x ## y
|
|
|
|
#define _CONCAT(x, y) _DO_CONCAT(x, y)
|
2016-09-26 19:16:33 +08:00
|
|
|
|
2017-03-31 11:47:34 +08:00
|
|
|
#ifndef BUILD_ASSERT
|
2016-09-26 19:16:33 +08:00
|
|
|
/* compile-time assertion that makes the build fail */
|
|
|
|
#define BUILD_ASSERT(EXPR) typedef char __build_assert_failure[(EXPR) ? 1 : -1]
|
2017-03-31 11:47:34 +08:00
|
|
|
#endif
|
2017-03-31 11:43:12 +08:00
|
|
|
#ifndef BUILD_ASSERT_MSG
|
|
|
|
/* build assertion with message -- common implementation swallows message. */
|
|
|
|
#define BUILD_ASSERT_MSG(EXPR, MSG) BUILD_ASSERT(EXPR)
|
|
|
|
#endif
|