kerrno.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2006-2024, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-09-22 Meco Man the first version
  9. */
  10. #ifndef __RT_KERRNO_H__
  11. #define __RT_KERRNO_H__
  12. #include <rtconfig.h>
  13. #include <rttypes.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #if defined(RT_USING_LIBC) && !defined(RT_USING_NANO)
  18. /* POSIX error code compatible */
  19. #define RT_EOK 0 /**< There is no error */
  20. #define RT_ERROR 255 /**< A generic/unknown error happens */
  21. #define RT_ETIMEOUT ETIMEDOUT /**< Timed out */
  22. #define RT_EFULL ENOSPC /**< The resource is full */
  23. #define RT_EEMPTY ENODATA /**< The resource is empty */
  24. #define RT_ENOMEM ENOMEM /**< No memory */
  25. #define RT_ENOSYS ENOSYS /**< Function not implemented */
  26. #define RT_EBUSY EBUSY /**< Busy */
  27. #define RT_EIO EIO /**< IO error */
  28. #define RT_EINTR EINTR /**< Interrupted system call */
  29. #define RT_EINVAL EINVAL /**< Invalid argument */
  30. #define RT_ENOENT ENOENT /**< No entry */
  31. #define RT_ENOSPC ENOSPC /**< No space left */
  32. #define RT_EPERM EPERM /**< Operation not permitted */
  33. #define RT_EFAULT EFAULT /**< Bad address */
  34. #define RT_ENOBUFS ENOBUFS /**< No buffer space is available */
  35. #define RT_ESCHEDISR 253 /**< scheduler failure in isr context */
  36. #define RT_ESCHEDLOCKED 252 /**< scheduler failure in critical region */
  37. #define RT_ETRAP 254 /**< Trap event */
  38. #else
  39. #define RT_EOK 0 /**< There is no error */
  40. #define RT_ERROR 1 /**< A generic/unknown error happens */
  41. #define RT_ETIMEOUT 2 /**< Timed out */
  42. #define RT_EFULL 3 /**< The resource is full */
  43. #define RT_EEMPTY 4 /**< The resource is empty */
  44. #define RT_ENOMEM 5 /**< No memory */
  45. #define RT_ENOSYS 6 /**< Function not implemented */
  46. #define RT_EBUSY 7 /**< Busy */
  47. #define RT_EIO 8 /**< IO error */
  48. #define RT_EINTR 9 /**< Interrupted system call */
  49. #define RT_EINVAL 10 /**< Invalid argument */
  50. #define RT_ENOENT 11 /**< No entry */
  51. #define RT_ENOSPC 12 /**< No space left */
  52. #define RT_EPERM 13 /**< Operation not permitted */
  53. #define RT_ETRAP 14 /**< Trap event */
  54. #define RT_EFAULT 15 /**< Bad address */
  55. #define RT_ENOBUFS 16 /**< No buffer space is available */
  56. #define RT_ESCHEDISR 17 /**< scheduler failure in isr context */
  57. #define RT_ESCHEDLOCKED 18 /**< scheduler failure in critical region */
  58. #endif /* defined(RT_USING_LIBC) && !defined(RT_USING_NANO) */
  59. rt_err_t rt_get_errno(void);
  60. void rt_set_errno(rt_err_t no);
  61. int *_rt_errno(void);
  62. const char *rt_strerror(rt_err_t error);
  63. #if !defined(RT_USING_NEWLIBC) && !defined(_WIN32)
  64. #ifndef errno
  65. #define errno *_rt_errno()
  66. #endif
  67. #endif /* !defined(RT_USING_NEWLIBC) && !defined(_WIN32) */
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif