embARC_toolchain.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* ------------------------------------------
  2. * Copyright (c) 2016, Synopsys, Inc. All rights reserved.
  3. * Redistribution and use in source and binary forms, with or without modification,
  4. * are permitted provided that the following conditions are met:
  5. * 1) Redistributions of source code must retain the above copyright notice, this
  6. * list of conditions and the following disclaimer.
  7. * 2) Redistributions in binary form must reproduce the above copyright notice,
  8. * this list of conditions and the following disclaimer in the documentation and/or
  9. * other materials provided with the distribution.
  10. * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
  11. * be used to endorse or promote products derived from this software without
  12. * specific prior written permission.
  13. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  14. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  17. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * \version 2016.05
  25. * \date 2014-12-25
  26. * \author Wayne Ren(Wei.Ren@synopsys.com)
  27. --------------------------------------------- */
  28. /**
  29. * \file
  30. * \ingroup TOOLCHAIN
  31. * \brief toolchain dependent definitions
  32. */
  33. #include <stdint.h> /* C99 standard lib */
  34. #include <limits.h> /* C99 standard lib */
  35. #include <stddef.h> /* C99 standard lib */
  36. #include <stdbool.h> /* C99 standard lib */
  37. #include "embARC_BSP_config.h"
  38. /**
  39. * \addtogroup TOOLCHAIN
  40. * @{
  41. */
  42. #ifndef _EMBARC_TOOLCHAIN_H_
  43. #define _EMBARC_TOOLCHAIN_H_
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /*
  48. * macro definitions of compiler extend function
  49. */
  50. #ifndef __cplusplus /* C++ supports inline */
  51. #if __STDC_VERSION__ < 199901L /* C99 supports inline */
  52. #ifndef inline
  53. #define inline __inline__ /* inline function */
  54. #endif
  55. #endif /* __STDC_VERSION__ < 199901L */
  56. #endif /* __cplusplus */
  57. #ifndef Inline
  58. #define Inline static __inline__ /* inline function */
  59. #endif
  60. #ifndef __cplusplus /* C++ supports asm */
  61. #ifndef asm
  62. #define asm __asm__ /* inline asm */
  63. #endif
  64. #endif /* __cplusplus */
  65. #ifndef Asm
  66. #define Asm __asm__ volatile /* inline asm (no optimization) */
  67. #endif
  68. /* compiler attributes */
  69. #define EMBARC_FORCEINLINE __attribute__((always_inline))
  70. #define EMBARC_NOINLINE __attribute__((noinline))
  71. #define EMBARC_PACKED __attribute__((packed))
  72. #define EMBARC_WEAK __attribute__((weak))
  73. #define EMBARC_ALIAS(f) __attribute__((weak, alias (#f)))
  74. #define EMBARC_LINKTO(f) __attribute__((alias (#f)))
  75. #define EMBARC_NORETURN __attribute__((noreturn))
  76. #define EMBARC_NAKED __attribute__((naked)) /* function without return */
  77. #define EMBARC_ALIGNED(x) __attribute__((aligned(x)))
  78. /* array count macro */
  79. #define EMBARC_ARRAY_COUNT(x) (sizeof(x)/sizeof(x[0]))
  80. /* convert macro argument to string */
  81. /* note: this needs one level of indirection, accomplished with the helper macro
  82. * __EMBARC_TO_STRING */
  83. #define __EMBARC_TO_STRING(x) #x
  84. #define EMBARC_TO_STRING(x) __EMBARC_TO_STRING(x)
  85. #if defined(__GNU__)
  86. /* GNU tool specific definitions */
  87. #elif defined(__MW__)
  88. /* Metaware tool specific definitions */
  89. /* Metaware toolchain related definitions */
  90. #else
  91. #error "unsupported toolchain"
  92. #endif
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif /* _EMBARC_TOOLCHAIN_H_ */
  97. /** }@ */