rt_clib.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /******************************************************************************
  2. 版权所有:
  3. 文件名称: rt_clib.h
  4. 文件版本: 01.01
  5. 创建作者: sunxi
  6. 创建日期: 2020-03-30
  7. 功能说明: 标准C库的接口.
  8. 其它说明:
  9. 修改记录:
  10. */
  11. #ifndef _RT_CLIB_H
  12. #define _RT_CLIB_H
  13. /*------------------------------- 头文件 --------------------------------------
  14. */
  15. #include "limits.h"
  16. /*------------------------------- 宏定义 --------------------------------------
  17. */
  18. // linux内核中的sprintf不支持浮点打印
  19. // rt_sprintf支持浮点打印。
  20. #define rt_sprintf sprintf
  21. // 正负浮点数四舍五入,float double类型自适应
  22. #define rt_round(f) ((f < 0) ? (f - 0.5) : (f + 0.5))
  23. #if 1
  24. // #define USHORT_MAX ((unsigned short)(~0U))
  25. // #define SHORT_MAX ((signed short)(USHORT_MAX>>1))
  26. #define SHORT_MIN (-SHORT_MAX - 1)
  27. #if 0 // sunxi 20220425 csky-toolchain/lib/gcc/csky-linux-gnuabiv2/6.3.0/include-fixed/limits.h 已经定义了
  28. #define INT_MAX ((int)(~0U >> 1))
  29. #define INT_MIN (-INT_MAX - 1)
  30. #define UINT_MAX (~0U)
  31. #define LONG_MAX ((long)(~0UL >> 1))
  32. #define LONG_MIN (-LONG_MAX - 1)
  33. #define ULONG_MAX (~0UL)
  34. #define LLONG_MAX ((long long)(~0ULL >> 1))
  35. #define LLONG_MIN (-LLONG_MAX - 1)
  36. #define ULLONG_MAX (~0ULL)
  37. #endif
  38. #endif
  39. /*------------------------------ 类型结构 -------------------------------------
  40. */
  41. /*------------------------------ 函数声明 -------------------------------------
  42. */
  43. #if 0
  44. void abort(void);
  45. void * bsearch(const void *key, const void *base0, int nmemb, int size, int (*compar)(const void *, const void *));
  46. long strtol(const char *nptr, char **endptr, int base);
  47. unsigned long strtoul(const char *nptr, char **endptr, int base);
  48. long atol(const char *str);
  49. long atoi(const char *str);
  50. #endif
  51. float sqrtf(float x);
  52. float atan2f(float y, float x);
  53. int rt_sprintf(char *buf, const char *fmt, ...);
  54. void swap32(void *p);
  55. void swap16(void *p);
  56. #endif //_RT_CLIB_H
  57. /*------------------------------ 文件结束 -------------------------------------
  58. */