compiler.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2017 ALLWINNERTECH TECHNOLOGY CO., LTD. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the
  12. * distribution.
  13. * 3. Neither the name of ALLWINNERTECH TECHNOLOGY CO., LTD. nor the names of
  14. * its contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef _COMPILER_H_
  30. #define _COMPILER_H_
  31. #if defined(__CC_ARM)
  32. /* ARM Compiler */
  33. #define inline __inline
  34. //#define __inline __inline
  35. #define __inline__ __inline
  36. #ifndef __always_inline
  37. #define __always_inline __forceinline
  38. #endif
  39. #ifndef __noinline
  40. #define __noinline
  41. #endif
  42. #if defined(__GNUC__)
  43. /* ARM Compiler support GNU */
  44. #define __packed __attribute__((__packed__))
  45. #else
  46. //#define __packed __packed
  47. #endif
  48. //#define __asm __asm
  49. //#define __weak __weak
  50. #elif defined(__GNUC__)
  51. /* GNU Compiler */
  52. // #include <sys/cdefs.h>
  53. //#define inline inline
  54. #define __inline inline
  55. #define __inline__ inline
  56. #ifdef __always_inline
  57. #undef __always_inline /* already defined in <sys/cdefs.h> */
  58. #define __always_inline inline __attribute__((always_inline))
  59. #else
  60. #define __always_inline inline __attribute__((always_inline))
  61. #endif
  62. #ifndef __noinline
  63. #define __noinline __attribute__((__noinline__))
  64. #endif
  65. // #define __packed __attribute__((__packed__))
  66. #define __asm asm
  67. #define __weak __attribute__((weak))
  68. #ifdef __CONFIG_XIP_SECTION_FUNC_LEVEL
  69. #define __xip_text __attribute__((section (".xip_text")))
  70. #define __xip_rodata __attribute__((section (".xip_rodata")))
  71. #define __nonxip_text __attribute__((section (".nonxip_text")))
  72. #define __nonxip_data __attribute__((section (".nonxip_data")))
  73. #define __nonxip_rodata __attribute__((section (".nonxip_rodata")))
  74. #else /* __CONFIG_XIP_SECTION_FUNC_LEVEL */
  75. #define __xip_text
  76. #define __xip_rodata
  77. #define __nonxip_text
  78. #define __nonxip_data
  79. #define __nonxip_rodata
  80. #endif /* __CONFIG_XIP_SECTION_FUNC_LEVEL */
  81. #else
  82. #error "Compiler not supported."
  83. #endif
  84. #endif /* _COMPILER_H_ */