1 /** 2 * @file errno.h 3 * @copyright Copyright (C) 2015-2018 Alibaba Group Holding Limited 4 */ 5 6 #ifndef AOS_RHINO_P_H 7 #define AOS_RHINO_P_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 #include <k_api.h> 14 #include "aos/errno.h" 15 #include "aos/kernel.h" 16 17 #define CHECK_HANDLE(hdl) do { \ 18 if (hdl == NULL || (void *)(*hdl) == NULL) { \ 19 return -EINVAL; \ 20 } \ 21 } while (0) 22 23 #define MS2TICK(ms) krhino_ms_to_ticks(ms) 24 rhino2stderrno(int ret)25static inline aos_status_t rhino2stderrno(int ret) 26 { 27 switch (ret) { 28 case RHINO_SUCCESS: 29 case RHINO_MUTEX_OWNER_NESTED: 30 case RHINO_STOPPED: 31 return 0; 32 case RHINO_SYS_SP_ERR: 33 case RHINO_NULL_PTR: 34 case RHINO_MM_FREE_ADDR_ERR: 35 return -EFAULT; 36 37 case RHINO_INV_PARAM: 38 case RHINO_INV_ALIGN: 39 case RHINO_KOBJ_TYPE_ERR: 40 case RHINO_MM_POOL_SIZE_ERR: 41 case RHINO_MM_ALLOC_SIZE_ERR: 42 case RHINO_INV_SCHED_WAY: 43 case RHINO_TASK_INV_STACK_SIZE: 44 case RHINO_BEYOND_MAX_PRI: 45 case RHINO_BUF_QUEUE_INV_SIZE: 46 case RHINO_BUF_QUEUE_SIZE_ZERO: 47 case RHINO_BUF_QUEUE_MSG_SIZE_OVERFLOW: 48 case RHINO_QUEUE_FULL: 49 case RHINO_QUEUE_NOT_FULL: 50 case RHINO_SEM_OVF: 51 case RHINO_WORKQUEUE_EXIST: 52 case RHINO_WORKQUEUE_NOT_EXIST: 53 case RHINO_WORKQUEUE_WORK_EXIST: 54 return -EINVAL; 55 56 case RHINO_BLK_TIMEOUT: 57 return -ETIMEDOUT ; 58 case RHINO_KOBJ_BLK: 59 return -EAGAIN; 60 61 case RHINO_NO_MEM: 62 return -ENOMEM; 63 64 case RHINO_KOBJ_DEL_ERR: 65 case RHINO_SCHED_DISABLE: 66 case RHINO_SCHED_ALREADY_ENABLED: 67 case RHINO_SCHED_LOCK_COUNT_OVF: 68 case RHINO_TASK_NOT_SUSPENDED: 69 case RHINO_TASK_DEL_NOT_ALLOWED: 70 case RHINO_TASK_SUSPEND_NOT_ALLOWED: 71 case RHINO_SUSPENDED_COUNT_OVF: 72 case RHINO_PRI_CHG_NOT_ALLOWED: 73 case RHINO_NOT_CALLED_BY_INTRPT: 74 case RHINO_NO_THIS_EVENT_OPT: 75 case RHINO_TIMER_STATE_INV: 76 case RHINO_BUF_QUEUE_FULL: 77 case RHINO_SEM_TASK_WAITING: 78 case RHINO_MUTEX_NOT_RELEASED_BY_OWNER: 79 case RHINO_WORKQUEUE_WORK_RUNNING: 80 return -EPERM; 81 82 case RHINO_TRY_AGAIN: 83 case RHINO_WORKQUEUE_BUSY: 84 return -EAGAIN; 85 86 default: 87 return -1; 88 } 89 90 return -1; 91 } 92 93 #ifdef __cplusplus 94 } 95 #endif 96 97 #endif /* AOS_RHINO_P_H */ 98 99