cb_def.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * SPDX-License-Identifier: Apache-2.0
  3. *
  4. * Change Logs:
  5. * Date Author Notes
  6. * 2022-03-16 tyx first implementation
  7. */
  8. #ifndef CB_DEF_H_
  9. #define CB_DEF_H_
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. // version information
  14. #define CB_MAINVERSION 1L /**< major version number */
  15. #define CB_SUBVERSION 0L /**< minor version number */
  16. #define CB_REVISION 0L /**< revise version number */
  17. #define CB_VERSION "1.1.0"
  18. // basic
  19. typedef signed char cb_int8_t;
  20. typedef unsigned char cb_uint8_t;
  21. typedef signed short cb_int16_t;
  22. typedef unsigned short cb_uint16_t;
  23. typedef signed int cb_int32_t;
  24. typedef unsigned int cb_uint32_t;
  25. typedef unsigned long long cb_uint64_t;
  26. typedef unsigned long cb_size_t;
  27. // bool values
  28. #define cb_true (1)
  29. #define cb_false (0)
  30. // null
  31. #define cb_null (0)
  32. // compiler
  33. #if defined(__ARMCC_VERSION) /* ARM Compiler */
  34. #define cb_inline static __inline
  35. #elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
  36. #define cb_inline static inline
  37. #elif defined (__GNUC__) /* GNU GCC Compiler */
  38. #define cb_inline static __inline
  39. #elif defined (__ADSPBLACKFIN__) /* for VisualDSP++ Compiler */
  40. #define cb_inline static inline
  41. #elif defined (_MSC_VER)
  42. #define cb_inline static __inline
  43. #elif defined (__TI_COMPILER_VERSION__)
  44. #define cb_inline static inline
  45. #elif defined (__TASKING__)
  46. #define cb_inline static inline
  47. #else
  48. #error not suppocbed tool chain
  49. #endif
  50. // define
  51. #define CB_ARRAY_SIZE(_array) (sizeof(_array) / sizeof((_array)[0]))
  52. #define CB_ALIGN(size, align) (((size) + (align) - 1) & ~((align) - 1))
  53. #define CB_ALIGN_DOWN(size, align) ((size) & ~((align) - 1))
  54. #define CB_BITS_LONG (sizeof(unsigned long) * 8UL)
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. #endif /* __CB_DEF_H__ */