• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
47 extern "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 */
55 typedef unsigned char      UINT8;
56 typedef unsigned short     UINT16;
57 typedef unsigned int       UINT32;
58 typedef signed char        INT8;
59 typedef signed short       INT16;
60 typedef signed int         INT32;
61 typedef float              FLOAT;
62 typedef double             DOUBLE;
63 typedef char               CHAR;
64 
65 #ifdef __LP64__
66 typedef long unsigned int  UINT64;
67 typedef long signed int    INT64;
68 typedef unsigned long      UINTPTR;
69 typedef signed long        INTPTR;
70 #else
71 typedef unsigned long long UINT64;
72 typedef signed long long   INT64;
73 typedef unsigned int       UINTPTR;
74 typedef signed int         INTPTR;
75 #endif
76 
77 #ifdef __LP64__
78 typedef __uint128_t        UINT128;
79 typedef INT64              ssize_t;
80 typedef UINT64             size_t;
81 #define LOSCFG_AARCH64
82 #else
83 typedef INT32              ssize_t;
84 typedef UINT32             size_t;
85 #endif
86 
87 typedef UINTPTR            AARCHPTR;
88 typedef 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
115 #endif
116 
117 #ifndef LOS_NOK
118 #define LOS_NOK            1
119 #endif
120 
121 #ifndef LOS_EPERM
122 #define LOS_EPERM          1
123 #endif
124 
125 #ifndef LOS_ESRCH
126 #define LOS_ESRCH          3
127 #endif
128 
129 #ifndef LOS_EINTR
130 #define LOS_EINTR          4
131 #endif
132 
133 #ifndef LOS_EBADF
134 #define LOS_EBADF          9
135 #endif
136 
137 #ifndef LOS_ECHILD
138 #define LOS_ECHILD         10
139 #endif
140 
141 #ifndef LOS_EAGAIN
142 #define LOS_EAGAIN         11
143 #endif
144 
145 #ifndef LOS_ENOMEM
146 #define LOS_ENOMEM         12
147 #endif
148 
149 #ifndef LOS_EACCES
150 #define LOS_EACCES         13
151 #endif
152 
153 #ifndef LOS_EFAULT
154 #define LOS_EFAULT         14
155 #endif
156 
157 #ifndef LOS_EBUSY
158 #define LOS_EBUSY          16
159 #endif
160 
161 #ifndef LOS_EINVAL
162 #define LOS_EINVAL         22
163 #endif
164 
165 #ifndef LOS_EDEADLK
166 #define LOS_EDEADLK        35
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 
205 typedef int status_t;
206 typedef unsigned long vaddr_t;
207 typedef unsigned long PADDR_T;
208 typedef unsigned long VADDR_T;
209 typedef unsigned long paddr_t;
210 typedef unsigned long DMA_ADDR_T;
211 typedef unsigned long ADDR_T;
212 typedef unsigned long VM_OFFSET_T;
213 typedef unsigned long PTE_T;
214 typedef unsigned int  ULONG_T;
215 typedef 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 */
241