redef.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef __REDEF_H
  2. #define __REDEF_H
  3. /************************************************************
  4. * @brief redeg.h
  5. * @author jiejie
  6. * @github https://github.com/jiejieTop
  7. * @date 2018-xx-xx
  8. * @version v1.0
  9. * @note 这个文件重定义一些变量与错误的宏
  10. ***********************************************************/
  11. #include "include.h"
  12. /* exact-width signed integer types */
  13. typedef signed char int8_t;
  14. typedef signed short int int16_t;
  15. typedef signed int int32_t;
  16. /* exact-width unsigned integer types */
  17. typedef unsigned char uint8_t;
  18. typedef unsigned short int uint16_t;
  19. typedef unsigned int uint32_t;
  20. typedef int32_t err_t; /**< Type for error number */
  21. /* minimum values of exact-width signed integer types */
  22. #define INT8_MIN -128
  23. #define INT16_MIN -32768
  24. #define INT32_MIN (~0x7fffffff) /* -2147483648 is unsigned */
  25. #define INT64_MIN __INT64_C(~0x7fffffffffffffff) /* -9223372036854775808 is unsigned */
  26. /* maximum values of exact-width signed integer types */
  27. #define INT8_MAX 127
  28. #define INT16_MAX 32767
  29. #define INT32_MAX 2147483647
  30. #define INT64_MAX __INT64_C(9223372036854775807)
  31. /* maximum values of exact-width unsigned integer types */
  32. #define UINT8_MAX 255
  33. #define UINT16_MAX 65535
  34. #define UINT32_MAX 4294967295u
  35. #define UINT64_MAX __UINT64_C(18446744073709551615)
  36. /* 32bit CPU */
  37. typedef long base_t; /**< Nbit CPU related date type */
  38. typedef unsigned long ubase_t; /**< Nbit unsigned CPU related data type */
  39. /************************** 暂时不用区域 **********************************/
  40. //typedef uint32_t time_t; /**< Type for time stamp */
  41. //typedef uint32_t tick_t; /**< Type for tick count */
  42. //typedef base_t flag_t; /**< Type for flags */
  43. //typedef ubase_t size_t; /**< Type for size number */
  44. //typedef ubase_t dev_t; /**< Type for device */
  45. //typedef base_t off_t; /**< Type for offset */
  46. /************************** 暂时不用区域 **********************************/
  47. /* Compiler Related Definitions */
  48. #ifdef __CC_ARM /* ARM Compiler */
  49. #include <stdarg.h>
  50. #define SECTION(x) __attribute__((section(x)))
  51. #define UNUSED __attribute__((unused))
  52. #define USED __attribute__((used))
  53. #define ALIGN(n) __attribute__((aligned(n)))
  54. #define WEAK __weak
  55. #define inline static __inline
  56. #elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
  57. #include <stdarg.h>
  58. #define SECTION(x) @ x
  59. #define UNUSED
  60. #define USED __root
  61. #define PRAGMA(x) _Pragma(#x)
  62. #define ALIGN(n) PRAGMA(data_alignment=n)
  63. #define WEAK __weak
  64. #define inline static inline
  65. #elif defined (__GNUC__) /* GNU GCC Compiler */
  66. #define SECTION(x) __attribute__((section(x)))
  67. #define UNUSED __attribute__((unused))
  68. #define USED __attribute__((used))
  69. #define ALIGN(n) __attribute__((aligned(n)))
  70. #define WEAK __attribute__((weak))
  71. #define inline static __inline
  72. #elif defined (__ADSPBLACKFIN__) /* for VisualDSP++ Compiler */
  73. #include <stdarg.h>
  74. #define SECTION(x) __attribute__((section(x)))
  75. #define UNUSED __attribute__((unused))
  76. #define USED __attribute__((used))
  77. #define ALIGN(n) __attribute__((aligned(n)))
  78. #define WEAK __attribute__((weak))
  79. #define inline static inline
  80. #elif defined (_MSC_VER)
  81. #include <stdarg.h>
  82. #define SECTION(x)
  83. #define UNUSED
  84. #define USED
  85. #define ALIGN(n) __declspec(align(n))
  86. #define WEAK
  87. #define inline static __inline
  88. #elif defined (__TI_COMPILER_VERSION__)
  89. #include <stdarg.h>
  90. /* The way that TI compiler set section is different from other(at least
  91. * GCC and MDK) compilers. See ARM Optimizing C/C++ Compiler 5.9.3 for more
  92. * details. */
  93. #define SECTION(x)
  94. #define UNUSED
  95. #define USED
  96. #define PRAGMA(x) _Pragma(#x)
  97. #define ALIGN(n)
  98. #define WEAK
  99. #define inline static inline
  100. #else
  101. #error not supported tool chain
  102. #endif
  103. /************************************************************
  104. * @note 下面是记录ERR返回值的宏
  105. ***********************************************************/
  106. #define NULL ( 0 )
  107. #define ERR_OK ( 0 )
  108. #define ERR_NOK ( -1 )
  109. #define ERR_NULL ( -2 )
  110. #define ERR_UNUSE ( -3 )
  111. #endif /* __REDEF_H */
  112. /********************************END OF FILE***************************************/