Tizen RT Libs&Environment  v1.0 D5
errno.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /************************************************************************
19  * include/errno.h
20  *
21  * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ************************************************************************/
60 
63 #ifndef __INCLUDE_ERRNO_H
64 #define __INCLUDE_ERRNO_H
65 
66 /************************************************************************
67  * Included Files
68  ************************************************************************/
69 
70 #include <tinyara/compiler.h>
71 
72 /************************************************************************
73  * Pre-processor Definitions
74  ************************************************************************/
75 /* How can we access the errno variable? */
76 
77 #if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
78 /* Flat build */
79 
80 #if defined(CONFIG_LIB_SYSCALL) && !defined(__KERNEL__)
81 /* We still might be using system calls in user code. If so, then
82  * user code will have no direct access to the errno variable.
83  */
84 
85 #undef __DIRECT_ERRNO_ACCESS
86 
87 #else
88 /* Flat build with no system calls OR internal kernel logic... There
89  * is direct access.
90  */
91 
92 #define __DIRECT_ERRNO_ACCESS 1
93 #endif
94 
95 #elif defined(CONFIG_BUILD_PROTECTED)
96 #if defined(__KERNEL__)
97 /* Kernel portion of protected build. Kernel code has direct access */
98 
99 #define __DIRECT_ERRNO_ACCESS 1
100 
101 #else
102 /* User portion of protected build. Application code has only indirect
103  * access
104  */
105 
106 #undef __DIRECT_ERRNO_ACCESS
107 #endif
108 
109 #elif defined(CONFIG_BUILD_KERNEL) && !defined(__KERNEL__)
110 #if defined(__KERNEL__)
111 /* Kernel build. Kernel code has direct access */
112 
113 #define __DIRECT_ERRNO_ACCESS 1
114 
115 #else
116 /* User libraries for the kernel. Only indirect access from user
117  * libraries */
118 
119 #undef __DIRECT_ERRNO_ACCESS
120 #endif
121 #endif
122 
123 /* Convenience/compatibility definition.
124  *
125  * For a flat, all kernel-mode build, the error can be read and written
126  * from all code using a simple pointer.
127  */
128 
129 #ifdef __DIRECT_ERRNO_ACCESS
130 
131 #define errno *get_errno_ptr()
132 #define set_errno(e) do { errno = (int)(e); } while (0)
133 #define get_errno(e) errno
134 
135 #else
136 
137 /* We doing separate user-/kernel-mode builds, then the errno has to be
138  * a little differently. In kernel-mode, the TCB errno value can still be
139  * read and written using a pointer from code executing within the
140  * kernel.
141  *
142  * But in user-mode, the errno can only be read using the name 'errno'.
143  * The non-standard API set_errno() must explicitly be used from user-
144  * mode code in order to set the errno value.
145  *
146  * The same is true of the case where we have syscalls enabled but this
147  * is not a kernel build, then we really have no option but to use the
148  * set_errno() accessor function explicitly, even from OS logic!
149  */
150 
151 #define errno get_errno()
152 
153 #endif /* __DIRECT_ERRNO_ACCESS */
154 
155 /* Definitions of error numbers and the string that would be
156  * returned by strerror().
157  */
158 
159 #define EPERM 1
160 #define EPERM_STR "Operation not permitted"
161 #define ENOENT 2
162 #define ENOENT_STR "No such file or directory"
163 #define ESRCH 3
164 #define ESRCH_STR "No such process"
165 #define EINTR 4
166 #define EINTR_STR "Interrupted system call"
167 #define EIO 5
168 #define EIO_STR "I/O error"
169 #define ENXIO 6
170 #define ENXIO_STR "No such device or address"
171 #define E2BIG 7
172 #define E2BIG_STR "Arg list too long"
173 #define ENOEXEC 8
174 #define ENOEXEC_STR "Exec format error"
175 #define EBADF 9
176 #define EBADF_STR "Bad file number"
177 #define ECHILD 10
178 #define ECHILD_STR "No child processes"
179 #define EAGAIN 11
180 #define EWOULDBLOCK EAGAIN
181 #define EAGAIN_STR "Try again"
182 #define ENOMEM 12
183 #define ENOMEM_STR "Out of memory"
184 #define EACCES 13
185 #define EACCES_STR "Permission denied"
186 #define EFAULT 14
187 #define EFAULT_STR "Bad address"
188 #define ENOTBLK 15
189 #define ENOTBLK_STR "Block device required"
190 #define EBUSY 16
191 #define EBUSY_STR "Device or resource busy"
192 #define EEXIST 17
193 #define EEXIST_STR "File exists"
194 #define EXDEV 18
195 #define EXDEV_STR "Cross-device link"
196 #define ENODEV 19
197 #define ENODEV_STR "No such device"
198 #define ENOTDIR 20
199 #define ENOTDIR_STR "Not a directory"
200 #define EISDIR 21
201 #define EISDIR_STR "Is a directory"
202 #define EINVAL 22
203 #define EINVAL_STR "Invalid argument"
204 #define ENFILE 23
205 #define ENFILE_STR "File table overflow"
206 #define EMFILE 24
207 #define EMFILE_STR "Too many open files"
208 #define ENOTTY 25
209 #define ENOTTY_STR "Not a typewriter"
210 #define ETXTBSY 26
211 #define ETXTBSY_STR "Text file busy"
212 #define EFBIG 27
213 #define EFBIG_STR "File too large"
214 #define ENOSPC 28
215 #define ENOSPC_STR "No space left on device"
216 #define ESPIPE 29
217 #define ESPIPE_STR "Illegal seek"
218 #define EROFS 30
219 #define EROFS_STR "Read-only file system"
220 #define EMLINK 31
221 #define EMLINK_STR "Too many links"
222 #define EPIPE 32
223 #define EPIPE_STR "Broken pipe"
224 #define EDOM 33
225 #define EDOM_STR "Math argument out of domain of func"
226 #define ERANGE 34
227 #define ERANGE_STR "Math result not representable"
228 #define EDEADLK 35
229 #define EDEADLOCK EDEADLK
230 #define EDEADLK_STR "Resource deadlock would occur"
231 #define ENAMETOOLONG 36
232 #define ENAMETOOLONG_STR "File name too long"
233 #define ENOLCK 37
234 #define ENOLCK_STR "No record locks available"
235 #define ENOSYS 38
236 #define ENOSYS_STR "Function not implemented"
237 #define ENOTEMPTY 39
238 #define ENOTEMPTY_STR "Directory not empty"
239 #define ELOOP 40
240 #define ELOOP_STR "Too many symbolic links encountered"
241 #define ENOMSG 42
242 #define ENOMSG_STR "No message of desired type"
243 #define EIDRM 43
244 #define EIDRM_STR "Identifier removed"
245 #define ECHRNG 44
246 #define ECHRNG_STR "Channel number out of range"
247 #define EL2NSYNC 45
248 #define EL2NSYNC_STR "Level 2 not synchronized"
249 #define EL3HLT 46
250 #define EL3HLT_STR "Level 3 halted"
251 #define EL3RST 47
252 #define EL3RST_STR "Level 3 reset"
253 #define ELNRNG 48
254 #define ELNRNG_STR "Link number out of range"
255 #define EUNATCH 49
256 #define EUNATCH_STR "Protocol driver not attached"
257 #define ENOCSI 50
258 #define ENOCSI_STR "No CSI structure available"
259 #define EL2HLT 51
260 #define EL2HLT_STR "Level 2 halted"
261 #define EBADE 52
262 #define EBADE_STR "Invalid exchange"
263 #define EBADR 53
264 #define EBADR_STR "Invalid request descriptor"
265 #define EXFULL 54
266 #define EXFULL_STR "Exchange full"
267 #define ENOANO 55
268 #define ENOANO_STR "No anode"
269 #define EBADRQC 56
270 #define EBADRQC_STR "Invalid request code"
271 #define EBADSLT 57
272 #define EBADSLT_STR "Invalid slot"
273 #define EBFONT 59
274 #define EBFONT_STR "Bad font file format"
275 #define ENOSTR 60
276 #define ENOSTR_STR "Device not a stream"
277 #define ENODATA 61
278 #define ENODATA_STR "No data available"
279 #define ETIME 62
280 #define ETIME_STR "Timer expired"
281 #define ENOSR 63
282 #define ENOSR_STR "Out of streams resources"
283 #define ENONET 64
284 #define ENONET_STR "Machine is not on the network"
285 #define ENOPKG 65
286 #define ENOPKG_STR "Package not installed"
287 #define EREMOTE 66
288 #define EREMOTE_STR "Object is remote"
289 #define ENOLINK 67
290 #define ENOLINK_STR "Link has been severed"
291 #define EADV 68
292 #define EADV_STR "Advertise error"
293 #define ESRMNT 69
294 #define ESRMNT_STR "Srmount error"
295 #define ECOMM 70
296 #define ECOMM_STR "Communication error on send"
297 #define EPROTO 71
298 #define EPROTO_STR "Protocol error"
299 #define EMULTIHOP 72
300 #define EMULTIHOP_STR "Multihop attempted"
301 #define EDOTDOT 73
302 #define EDOTDOT_STR "RFS specific error"
303 #define EBADMSG 74
304 #define EBADMSG_STR "Not a data message"
305 #define EOVERFLOW 75
306 #define EOVERFLOW_STR "Value too large for defined data type"
307 #define ENOTUNIQ 76
308 #define ENOTUNIQ_STR "Name not unique on network"
309 #define EBADFD 77
310 #define EBADFD_STR "File descriptor in bad state"
311 #define EREMCHG 78
312 #define EREMCHG_STR "Remote address changed"
313 #define ELIBACC 79
314 #define ELIBACC_STR "Can not access a needed shared library"
315 #define ELIBBAD 80
316 #define ELIBBAD_STR "Accessing a corrupted shared library"
317 #define ELIBSCN 81
318 #define ELIBSCN_STR ".lib section in a.out corrupted"
319 #define ELIBMAX 82
320 #define ELIBMAX_STR "Attempting to link in too many shared libraries"
321 #define ELIBEXEC 83
322 #define ELIBEXEC_STR "Cannot exec a shared library directly"
323 #define EILSEQ 84
324 #define EILSEQ_STR "Illegal byte sequence"
325 #define ERESTART 85
326 #define ERESTART_STR "Interrupted system call should be restarted"
327 #define ESTRPIPE 86
328 #define ESTRPIPE_STR "Streams pipe error"
329 #define EUSERS 87
330 #define EUSERS_STR "Too many users"
331 #define ENOTSOCK 88
332 #define ENOTSOCK_STR "Socket operation on non-socket"
333 #define EDESTADDRREQ 89
334 #define EDESTADDRREQ_STR "Destination address required"
335 #define EMSGSIZE 90
336 #define EMSGSIZE_STR "Message too long"
337 #define EPROTOTYPE 91
338 #define EPROTOTYPE_STR "Protocol wrong type for socket"
339 #define ENOPROTOOPT 92
340 #define ENOPROTOOPT_STR "Protocol not available"
341 #define EPROTONOSUPPORT 93
342 #define EPROTONOSUPPORT_STR "Protocol not supported"
343 #define ESOCKTNOSUPPORT 94
344 #define ESOCKTNOSUPPORT_STR "Socket type not supported"
345 #define EOPNOTSUPP 95
346 #define EOPNOTSUPP_STR "Operation not supported on transport endpoint"
347 #define EPFNOSUPPORT 96
348 #define EPFNOSUPPORT_STR "Protocol family not supported"
349 #define EAFNOSUPPORT 97
350 #define EAFNOSUPPORT_STR "Address family not supported by protocol"
351 #define EADDRINUSE 98
352 #define EADDRINUSE_STR "Address already in use"
353 #define EADDRNOTAVAIL 99
354 #define EADDRNOTAVAIL_STR "Cannot assign requested address"
355 #define ENETDOWN 100
356 #define ENETDOWN_STR "Network is down"
357 #define ENETUNREACH 101
358 #define ENETUNREACH_STR "Network is unreachable"
359 #define ENETRESET 102
360 #define ENETRESET_STR "Network dropped connection because of reset"
361 #define ECONNABORTED 103
362 #define ECONNABORTED_STR "Software caused connection abort"
363 #define ECONNRESET 104
364 #define ECONNRESET_STR "Connection reset by peer"
365 #define ENOBUFS 105
366 #define ENOBUFS_STR "No buffer space available"
367 #define EISCONN 106
368 #define EISCONN_STR "Transport endpoint is already connected"
369 #define ENOTCONN 107
370 #define ENOTCONN_STR "Transport endpoint is not connected"
371 #define ESHUTDOWN 108
372 #define ESHUTDOWN_STR "Cannot send after transport endpoint shutdown"
373 #define ETOOMANYREFS 109
374 #define ETOOMANYREFS_STR "Too many references: cannot splice"
375 #define ETIMEDOUT 110
376 #define ETIMEDOUT_STR "Connection timed out"
377 #define ECONNREFUSED 111
378 #define ECONNREFUSED_STR "Connection refused"
379 #define EHOSTDOWN 112
380 #define EHOSTDOWN_STR "Host is down"
381 #define EHOSTUNREACH 113
382 #define EHOSTUNREACH_STR "No route to host"
383 #define EALREADY 114
384 #define EALREADY_STR "Operation already in progress"
385 #define EINPROGRESS 115
386 #define EINPROGRESS_STR "Operation now in progress"
387 #define ESTALE 116
388 #define ESTALE_STR "Stale NFS file handle"
389 #define EUCLEAN 117
390 #define EUCLEAN_STR "Structure needs cleaning"
391 #define ENOTNAM 118
392 #define ENOTNAM_STR "Not a XENIX named type file"
393 #define ENAVAIL 119
394 #define ENAVAIL_STR "No XENIX semaphores available"
395 #define EISNAM 120
396 #define EISNAM_STR "Is a named type file"
397 #define EREMOTEIO 121
398 #define EREMOTEIO_STR "Remote I/O error"
399 #define EDQUOT 122
400 #define EDQUOT_STR "Quota exceeded"
401 #define ENOMEDIUM 123
402 #define ENOMEDIUM_STR "No medium found"
403 #define EMEDIUMTYPE 124
404 #define EMEDIUMTYPE_STR "Wrong medium type"
405 #define ECANCELED 125
406 #define ECANCELED_STR "Operation cancelled"
407 #define EINVAL_SECTOR 126
408 #define EINVAL_SECTOR_STR "Invalid sector"
409 
410 /************************************************************************
411  * Type Declarations
412  ************************************************************************/
413 
414 /************************************************************************
415  * Global Function Prototypes
416  ************************************************************************/
417 
418 #undef EXTERN
419 #if defined(__cplusplus)
420 #define EXTERN extern "C"
421 extern "C" {
422 #else
423 #define EXTERN extern
424 #endif
425 
426 /* Return a pointer to the thread specific errno. NOTE: When doing a
427  * kernel-/user-mode build, this function can only be used within the
428  * kernel-mode space.
429  *
430  * In the user-mode space, set_errno() and get_errno() are always available,
431  * either as macros or via syscalls.
432  */
433 
439 FAR int *get_errno_ptr(void);
440 
441 #ifndef __DIRECT_ERRNO_ACCESS
442 
449 void set_errno(int errcode);
450 
457 int get_errno(void);
458 #endif
459 
460 #undef EXTERN
461 #if defined(__cplusplus)
462 }
463 #endif
464 
465 #endif /* __INCLUDE_ERRNO_H */
466 // end of ERRNO_KERNEL
#define set_errno(e)
Definition: errno.h:132
#define get_errno(e)
Definition: errno.h:133
FAR int * get_errno_ptr(void)
Return a pointer to the thread specific errno.