os_errno.h 源码
2026/7/20大约 2 分钟源码参考内核错误码头文件
os_errno.h — 错误码定义头文件
源文件路径: kernel/include/os_errno.h
引用章节: 4.6.2 错误码
完整源码
/**
***********************************************************************************************************************
* Copyright (c) 2020, China Mobile Communications Group Co.,Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* @file os_errno.h
*
* @brief Error code macro definition.
*
* @revision
* Date Author Notes
* 2020-02-25 OneOS Team First version.
***********************************************************************************************************************
*/
#ifndef __OS_ERRNO_H__
#define __OS_ERRNO_H__
#ifdef __cplusplus
extern "C" {
#endif
#define OS_SUCCESS 0 /* There is no error. */
#define OS_FAILURE -1 /* A generic error happens. */
#define OS_TIMEOUT -2 /* Timed out. */
#define OS_FULL -3 /* The resource is full. */
#define OS_EMPTY -4 /* The resource is empty. */
#define OS_NOMEM -5 /* No memory. */
#define OS_NOSYS -6 /* Function not implemented. */
#define OS_BUSY -7 /* Device or resource busy. */
#define OS_EIO -8 /* IO error. */
#define OS_INTR -9 /* Interrupted system call. */
#define OS_INVAL -10 /* Invalid argument. */
#define OS_NODEV -11 /* No such device */
#define OS_EPERM -12 /* Operation not permitted */
#define OS_EBADF -13 /* Bad file number */
#define OS_EACCES -14 /* Permission denied */
#define OS_EFAULT -15 /* Bad address */
#define OS_EDEADLK -16 /* Resource deadlock would occur */
#define OS_ENXIO -17 /* No such device or address */
#define OS_E2BIG -18 /* Arg list too long */
#define OS_ENOSYS -19 /* Function not implemented */
#define OS_EAGAIN -20 /* Try again */
#define OS_ENODATA -21 /* No data available */
#define OS_EADDRINUSE -22 /* Address already in use */
#ifdef __cplusplus
}
#endif
#endif关键说明
| 错误码 | 值 | 含义 | 典型场景 |
|---|---|---|---|
OS_SUCCESS | 0 | 成功 | 正常返回 |
OS_TIMEOUT | -2 | 超时 | os_semaphore_wait(timeout) 超时 |
OS_NOMEM | -5 | 内存不足 | os_malloc 失败 |
OS_BUSY | -7 | 资源忙 | 设备正在使用 |
OS_INVAL | -10 | 无效参数 | 传入 NULL 或非法值 |
OS_EDEADLK | -16 | 死锁 | 互斥锁递归持有检测 |