1 /**
2  * @file bt_errno.h
3  * @copyright Copyright (C) 2015-2018 Alibaba Group Holding Limited
4  */
5 
6 #ifndef AOS_ERRNO_H_BT
7 #define AOS_ERRNO_H_BT
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /**
14  * @addtogroup aos_errno errno
15  * Define standard errno.
16  *
17  * @{
18  */
19 
20 //#if defined(__GNUC__)&&!defined(__CC_ARM)||defined(_WIN32)
21 #if 0
22 #include <bt_errno.h>
23 
24 #else
25 /* Define standard errno for __CC_ARM and __ICCARM__ */
26 #define  EPERM         1  /**< Operation not permitted */
27 #define  ENOENT        2  /**< No such file or directory */
28 #define  ESRCH         3  /**< No such process */
29 #define  EINTR         4  /**< Interrupted system call */
30 #define  EIO           5  /**< I/O error */
31 #define  ENXIO         6  /**< No such device or address */
32 #define  E2BIG         7  /**< Arg list too long */
33 #define  ENOEXEC       8  /**< Exec format error */
34 #define  EBADF         9  /**< Bad file number */
35 #define  ECHILD       10  /**< No child processes */
36 #define  EAGAIN       11  /**< Try again */
37 
38 #ifdef   ENOMEM
39 #undef   ENOMEM
40 #endif
41 
42 #define  ENOMEM       12  /**< Out of memory */
43 #define  EACCES       13  /**< Permission denied */
44 #define  EFAULT       14  /**< Bad address */
45 #define  ENOTBLK      15  /**< Block device required */
46 #define  EBUSY        16  /**< Device or resource busy */
47 #define  EEXIST       17  /**< File exists */
48 #define  EXDEV        18  /**< Cross-device link */
49 #define  ENODEV       19  /**< No such device */
50 #define  ENOTDIR      20  /**< Not a directory */
51 #define  EISDIR       21  /**< Is a directory */
52 
53 #ifdef   EINVAL
54 #undef   EINVAL
55 #endif
56 
57 #define  EINVAL       22  /**< Invalid argument */
58 #define  ENFILE       23  /**< File table overflow */
59 #define  EMFILE       24  /**< Too many open files */
60 #define  ENOTTY       25  /**< Not a typewriter */
61 #define  ETXTBSY      26  /**< Text file busy */
62 #define  EFBIG        27  /**< File too large */
63 #define  ENOSPC       28  /**< No space left on device */
64 #define  ESPIPE       29  /**< Illegal seek */
65 #define  EROFS        30  /**< Read-only file system */
66 #define  EMLINK       31  /**< Too many links */
67 #define  EPIPE        32  /**< Broken pipe */
68 
69 #ifdef   EDOM
70 #undef   EDOM
71 #define  EDOM         33  /**< Math argument out of domain of func */
72 #endif
73 
74 #ifdef   ERANGE
75 #undef   ERANGE
76 #define  ERANGE       34  /**< Math result not representable */
77 #endif
78 
79 #define  EDEADLK      35  /**< Resource deadlock would occur */
80 #define  ENAMETOOLONG 36  /**< File name too long */
81 #define  ENOLCK       37  /**< No record locks available */
82 #define  ENOSYS       38  /**< Function not implemented */
83 #define  ENOTEMPTY    39  /**< Directory not empty */
84 #define  ELOOP        40  /**< Too many symbolic links encountered */
85 #define  EWOULDBLOCK  EAGAIN  /**< Operation would block */
86 #define  ENOMSG       42  /**< No message of desired type */
87 #define  EIDRM        43  /**< Identifier removed */
88 #define  ECHRNG       44  /**< Channel number out of range */
89 #define  EL2NSYNC     45  /**<* Level 2 not synchronized */
90 #define  EL3HLT       46  /**< Level 3 halted */
91 #define  EL3RST       47  /**< Level 3 reset */
92 #define  ELNRNG       48  /**< Link number out of range */
93 #define  EUNATCH      49  /**< Protocol driver not attached */
94 #define  ENOCSI       50  /* No CSI structure available */
95 #define  EL2HLT       51  /**< Level 2 halted */
96 #define  EBADE        52  /**< Invalid exchange */
97 #define  EBADR        53  /**< Invalid request descriptor */
98 #define  EXFULL       54  /**< Exchange full */
99 #define  ENOANO       55  /**< No anode */
100 #define  EBADRQC      56  /**< Invalid request code */
101 #define  EBADSLT      57  /**< Invalid slot */
102 
103 #define  EDEADLOCK    EDEADLK
104 
105 #define  EBFONT       59  /**< Bad font file format */
106 #define  ENOSTR       60  /**< Device not a stream */
107 #define  ENODATA      61  /**< No data available */
108 #define  ETIME        62  /**< Timer expired */
109 #define  ENOSR        63  /**< Out of streams resources */
110 #define  ENONET       64  /**< Machine is not on the network */
111 #define  ENOPKG       65  /**< Package not installed */
112 #define  EREMOTE      66  /**< Object is remote */
113 #define  ENOLINK      67  /**< Link has been severed */
114 #define  EADV         68  /**< Advertise error */
115 #define  ESRMNT       69  /**< Srmount error */
116 #define  ECOMM        70  /**< Communication error on send */
117 #define  EPROTO       71  /**< Protocol error */
118 #define  EMULTIHOP    72  /**< Multihop attempted */
119 #define  EDOTDOT      73  /**< RFS specific error */
120 #define  EBADMSG      74  /**< Not a data message */
121 #define  EOVERFLOW    75  /**< Value too large for defined data type */
122 #define  ENOTUNIQ     76  /**< Name not unique on network */
123 #define  EBADFD       77  /**< File descriptor in bad state */
124 #define  EREMCHG      78  /**< Remote address changed */
125 #define  ELIBACC      79  /**< Can not access a needed shared library */
126 #define  ELIBBAD      80  /**< Accessing a corrupted shared library */
127 #define  ELIBSCN      81  /**< .lib section in a.out corrupted */
128 #define  ELIBMAX      82  /**< Attempting to link in too many shared libraries */
129 #define  ELIBEXEC     83  /**< Cannot exec a shared library directly */
130 
131 #ifdef   EILSEQ
132 #undef   EILSEQ
133 #endif
134 
135 #define  EILSEQ       84  /**< Illegal byte sequence */
136 #define  ERESTART     85  /**< Interrupted system call should be restarted */
137 #define  ESTRPIPE     86  /**< Streams pipe error */
138 #define  EUSERS       87  /**< Too many users */
139 #define  ENOTSOCK     88  /**< Socket operation on non-socket */
140 #define  EDESTADDRREQ 89  /**< Destination address required */
141 #define  EMSGSIZE     90  /**< Message too long */
142 #define  EPROTOTYPE   91  /**< Protocol wrong type for socket */
143 #define  ENOPROTOOPT  92  /**< Protocol not available */
144 #define  EPROTONOSUPPORT 93  /**< Protocol not supported */
145 #define  ESOCKTNOSUPPORT 94  /**< Socket type not supported */
146 #define  EOPNOTSUPP      95  /**< Operation not supported on transport endpoint */
147 #define  EPFNOSUPPORT    96  /**< Protocol family not supported */
148 #define  EAFNOSUPPORT    97  /**< Address family not supported by protocol */
149 #define  EADDRINUSE      98  /**< Address already in use */
150 #define  EADDRNOTAVAIL   99  /**< Cannot assign requested address */
151 #define  ENETDOWN       100  /**< Network is down */
152 #define  ENETUNREACH    101  /**< Network is unreachable */
153 #define  ENETRESET      102  /**< Network dropped connection because of reset */
154 #define  ECONNABORTED   103  /**< Software caused connection abort */
155 #define  ECONNRESET     104  /**< Connection reset by peer */
156 #define  ENOBUFS        105  /**<* No buffer space available */
157 #define  EISCONN        106  /**< Transport endpoint is already connected */
158 #define  ENOTCONN       107  /**< Transport endpoint is not connected */
159 #define  ESHUTDOWN      108  /**< Cannot send after transport endpoint shutdown */
160 #define  ETOOMANYREFS   109  /**< Too many references: cannot splice */
161 #define  ETIMEDOUT      110  /**< Connection timed out */
162 #define  ECONNREFUSED   111  /**< Connection refused */
163 #define  EHOSTDOWN      112  /**< Host is down */
164 #define  EHOSTUNREACH   113  /**< No route to host */
165 #define  EALREADY       114  /**< Operation already in progress */
166 #define  EINPROGRESS    115  /**< Operation now in progress */
167 #define  ESTALE         116  /**< Stale NFS file handle */
168 #define  EUCLEAN        117  /**< Structure needs cleaning */
169 #define  ENOTNAM        118  /**< Not a XENIX named type file */
170 #define  ENAVAIL        119  /**< No XENIX semaphores available */
171 #define  EISNAM         120  /**< Is a named type file */
172 #define  EREMOTEIO      121  /**< Remote I/O error */
173 #define  EDQUOT         122  /**< Quota exceeded */
174 
175 #define  ENOMEDIUM      123  /**< No medium found */
176 #define  EMEDIUMTYPE    124  /**< Wrong medium type */
177 
178 #define ENOTSUP         134     /*  Not supported */
179 #define ECANCELED       140    /* Operation canceled */
180 #define ENSROK                    0 /**< DNS server returned answer with no data */
181 #define ENSRNODATA              160 /**< DNS server returned answer with no data */
182 #define ENSRFORMERR             161 /**< DNS server claims query was misformatted */
183 #define ENSRSERVFAIL            162 /**< DNS server returned general failure */
184 #define ENSRNOTFOUND            163 /**< Domain name not found */
185 #define ENSRNOTIMP              164 /**< DNS server does not implement requested operation */
186 #define ENSRREFUSED             165 /**< DNS server refused query */
187 #define ENSRBADQUERY            166 /**< Misformatted DNS query */
188 #define ENSRBADNAME             167 /**< Misformatted domain name */
189 #define ENSRBADFAMILY           168 /**< Unsupported address family */
190 #define ENSRBADRESP             169 /**< Misformatted DNS reply */
191 #define ENSRCONNREFUSED         170 /**< Could not contact DNS servers */
192 #define ENSRTIMEOUT             171 /**< Timeout while contacting DNS servers */
193 #define ENSROF                  172 /**< End of file */
194 #define ENSRFILE                173 /**< Error reading file */
195 #define ENSRNOMEM               174 /**< Out of memory */
196 #define ENSRDESTRUCTION         175 /**< Application terminated lookup */
197 #define ENSRQUERYDOMAINTOOLONG  176 /**< Domain name is too long */
198 #define ENSRCNAMELOOP           177 /**< Domain name is too long */
199 
200 #endif /* defined(__GNUC__)&&!defined(__CC_ARM)||defined(_WIN32) */
201 
202 /**
203  * Redefine the errno, Only use in framework/app
204  */
205 #ifdef BUILD_BIN
206 
207 #undef set_errno
208 #define set_errno(err) do { if (err) { errno = (err); } } while(0)
209 
210 #else /* BUILD_BIN */
211 
212 #ifdef BUILD_APP
213 /**
214  * Get system errno.
215  *
216  * @return  int: return system errno for app bin.
217  */
218 extern int  get_errno(void);
219 /**
220  * Set system errno.
221  *
222  * @param[in]  err       err to set into system.
223  *
224  * @return  none.
225  */
226 extern void set_errno(int err);
227 
228 #undef errno
229 #define errno get_errno()   /* Get system errno, unique copy for system */
230 
231 #endif /* BUILD_APP */
232 
233 #endif /* BUILD_BIN */
234 
235 /** @} */
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 
241 #endif /* AOS_ERRNO_H */
242 
243