更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_typedef.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/**
33 * @defgroup los_typedef Type define
34 * @ingroup kernel
35 */
36
37#ifndef _LOS_TYPEDEF_H
38#define _LOS_TYPEDEF_H
39#include "stddef.h"
40#include "stdbool.h"
41#include "stdint.h"
42#include "los_builddef.h"
43#include "los_toolchain.h"
44
45#ifdef __cplusplus
46#if __cplusplus
47extern "C" {
48#endif /* __cplusplus */
49#endif /* __cplusplus */
50
51#define OS_STRING(x) #x
52#define X_STRING(x) OS_STRING(x)
53
54/* type definitions */
55typedef unsigned char UINT8;
56typedef unsigned short UINT16;
57typedef unsigned int UINT32;
58typedef signed char INT8;
59typedef signed short INT16;
60typedef signed int INT32;
61typedef float FLOAT;
62typedef double DOUBLE;
63typedef char CHAR;
64
65#ifdef __LP64__
66typedef long unsigned int UINT64;
67typedef long signed int INT64;
68typedef unsigned long UINTPTR;
69typedef signed long INTPTR;
70#else
71typedef unsigned long long UINT64;
72typedef signed long long INT64;
73typedef unsigned int UINTPTR;
74typedef signed int INTPTR;
75#endif
76
77#ifdef __LP64__
78typedef __uint128_t UINT128;
79typedef INT64 ssize_t;
80typedef UINT64 size_t;
81#define LOSCFG_AARCH64
82#else
83typedef INT32 ssize_t;
84typedef UINT32 size_t;
85#endif
86
88typedef size_t BOOL;
89
90#define VOID void
91#define STATIC static
92
93#ifndef FALSE
94#define FALSE 0U
95#endif
96
97#ifndef TRUE
98#define TRUE 1U
99#endif
100
101#ifndef NULL
102#define NULL ((VOID *)0)
103#endif
104
105#define OS_NULL_BYTE ((UINT8)0xFF)
106#define OS_NULL_SHORT ((UINT16)0xFFFF)
107#define OS_NULL_INT ((UINT32)0xFFFFFFFF)
108
109#ifndef USER
110#define USER
111#endif
112/// 常用错误码对照表
113#ifndef LOS_OK
114#define LOS_OK 0 ///< Success 成功
115#endif
116
117#ifndef LOS_NOK
118#define LOS_NOK 1 ///< fail 失败
119#endif
120
121#ifndef LOS_EPERM
122#define LOS_EPERM 1 ///< 操作不允许 Operation not permitted
123#endif
124
125#ifndef LOS_ESRCH
126#define LOS_ESRCH 3 ///< No such process 没有这样的进程(暂不支持)
127#endif
128
129#ifndef LOS_EINTR
130#define LOS_EINTR 4 ///< Interrupted system call 系统调用被中断
131#endif
132
133#ifndef LOS_EBADF
134#define LOS_EBADF 9 ///< Bad file number 坏的文件描述符
135#endif
136
137#ifndef LOS_ECHILD
138#define LOS_ECHILD 10 ///< No child processes 没有子进程(暂不支持)
139#endif
140
141#ifndef LOS_EAGAIN
142#define LOS_EAGAIN 11 ///< Try again 资源暂时不可用
143#endif
144
145#ifndef LOS_ENOMEM
146#define LOS_ENOMEM 12 ///< Out of memory 内存溢出
147#endif
148
149#ifndef LOS_EACCES
150#define LOS_EACCES 13 ///< Permission denied 拒绝许可
151#endif
152
153#ifndef LOS_EFAULT
154#define LOS_EFAULT 14 ///< Bad address 错误的地址
155#endif
156
157#ifndef LOS_EBUSY
158#define LOS_EBUSY 16 ///< Device or resource busy 设备或资源忙
159#endif
160
161#ifndef LOS_EINVAL
162#define LOS_EINVAL 22 ///< Invalid argument 无效的参数
163#endif
164
165#ifndef LOS_EDEADLK
166#define LOS_EDEADLK 35 ///< Resource deadlock would occur 资源死锁错误
167#endif
168
169#ifndef LOS_EOPNOTSUPP
170#define LOS_EOPNOTSUPP 95
171#endif
172
173#ifndef LOS_ETIMEDOUT
174#define LOS_ETIMEDOUT 110
175#endif
176
177#define OS_FAIL 1
178#define OS_ERROR (UINT32)(-1)
179#define OS_INVALID (UINT32)(-1)
180#define OS_INVALID_VALUE ((UINT32)0xFFFFFFFF)
181#define OS_64BIT_MAX 0xFFFFFFFFFFFFFFFFULL
182
183#define asm __asm
184#ifdef typeof
185#undef typeof
186#endif
187#define typeof __typeof__
188
189#ifndef LOS_LABEL_DEFN
190#define LOS_LABEL_DEFN(label) label
191#endif
192
193#ifndef LOSARC_ALIGNMENT
194#define LOSARC_ALIGNMENT 8
195#endif
196/* And corresponding power of two alignment */
197#ifndef LOSARC_P2ALIGNMENT
198#ifdef LOSCFG_AARCH64
199#define LOSARC_P2ALIGNMENT 3
200#else
201#define LOSARC_P2ALIGNMENT 2
202#endif
203#endif
204
205typedef int status_t;
206typedef unsigned long vaddr_t;
207typedef unsigned long PADDR_T;
208typedef unsigned long VADDR_T;
209typedef unsigned long paddr_t;
210typedef unsigned long DMA_ADDR_T;
211typedef unsigned long ADDR_T;
212typedef unsigned long VM_OFFSET_T;
213typedef unsigned long PTE_T;
214typedef unsigned int ULONG_T;
215typedef int STATUS_T;
216
217/* Give a type or object explicit minimum alignment */
218#if !defined(LOSBLD_ATTRIB_ALIGN)
219#define LOSBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
220#endif
221
222/* Assign a defined variable to a specific section */
223#if !defined(LOSBLD_ATTRIB_SECTION)
224#define LOSBLD_ATTRIB_SECTION(__sect__) __attribute__((section(__sect__)))
225#endif
226
227/*
228 * Tell the compiler not to throw away a variable or function. Only known
229 * available on 3.3.2 or above. Old version's didn't throw them away,
230 * but using the unused attribute should stop warnings.
231 */
232#define LOSBLD_ATTRIB_USED __attribute__((used))
233
234#ifdef __cplusplus
235#if __cplusplus
236}
237#endif /* __cplusplus */
238#endif /* __cplusplus */
239
240#endif /* _LOS_TYPEDEF_H */
unsigned short UINT16
Definition: los_typedef.h:56
unsigned long PADDR_T
Definition: los_typedef.h:207
signed int INT32
Definition: los_typedef.h:60
UINT64 size_t
Definition: los_typedef.h:80
unsigned long DMA_ADDR_T
Definition: los_typedef.h:210
signed short INT16
Definition: los_typedef.h:59
int status_t
Definition: los_typedef.h:205
unsigned int ULONG_T
Definition: los_typedef.h:214
unsigned long paddr_t
Definition: los_typedef.h:209
unsigned long vaddr_t
Definition: los_typedef.h:206
unsigned long VADDR_T
Definition: los_typedef.h:208
unsigned long ADDR_T
Definition: los_typedef.h:211
long unsigned int UINT64
Definition: los_typedef.h:66
unsigned long VM_OFFSET_T
Definition: los_typedef.h:212
INT64 ssize_t
Definition: los_typedef.h:79
unsigned long PTE_T
Definition: los_typedef.h:213
signed char INT8
Definition: los_typedef.h:58
float FLOAT
Definition: los_typedef.h:61
__uint128_t UINT128
Definition: los_typedef.h:78
UINTPTR AARCHPTR
Definition: los_typedef.h:87
unsigned char UINT8
Definition: los_typedef.h:55
int STATUS_T
Definition: los_typedef.h:215
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
double DOUBLE
Definition: los_typedef.h:62
char CHAR
Definition: los_typedef.h:63
size_t BOOL
Definition: los_typedef.h:88
long signed int INT64
Definition: los_typedef.h:67
signed long INTPTR
Definition: los_typedef.h:69