00

Committer:
ganlikun
Date:
Sun Jun 12 14:02:44 2022 +0000
Revision:
0:13413ea9a877
00

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ganlikun 0:13413ea9a877 1 /*
ganlikun 0:13413ea9a877 2 * mbed Microcontroller Library
ganlikun 0:13413ea9a877 3 * Copyright (c) 2006-2016 ARM Limited
ganlikun 0:13413ea9a877 4 *
ganlikun 0:13413ea9a877 5 * Licensed under the Apache License, Version 2.0 (the "License");
ganlikun 0:13413ea9a877 6 * you may not use this file except in compliance with the License.
ganlikun 0:13413ea9a877 7 * You may obtain a copy of the License at
ganlikun 0:13413ea9a877 8 *
ganlikun 0:13413ea9a877 9 * http://www.apache.org/licenses/LICENSE-2.0
ganlikun 0:13413ea9a877 10 *
ganlikun 0:13413ea9a877 11 * Unless required by applicable law or agreed to in writing, software
ganlikun 0:13413ea9a877 12 * distributed under the License is distributed on an "AS IS" BASIS,
ganlikun 0:13413ea9a877 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ganlikun 0:13413ea9a877 14 * See the License for the specific language governing permissions and
ganlikun 0:13413ea9a877 15 * limitations under the License.
ganlikun 0:13413ea9a877 16 *
ganlikun 0:13413ea9a877 17 */
ganlikun 0:13413ea9a877 18
ganlikun 0:13413ea9a877 19 #ifndef RETARGET_H
ganlikun 0:13413ea9a877 20 #define RETARGET_H
ganlikun 0:13413ea9a877 21
ganlikun 0:13413ea9a877 22 #if __cplusplus
ganlikun 0:13413ea9a877 23 #include <cstdio>
ganlikun 0:13413ea9a877 24 #endif //__cplusplus
ganlikun 0:13413ea9a877 25 #include <stdint.h>
ganlikun 0:13413ea9a877 26 #include <stddef.h>
ganlikun 0:13413ea9a877 27
ganlikun 0:13413ea9a877 28 /* We can get the following standard types from sys/types for gcc, but we
ganlikun 0:13413ea9a877 29 * need to define the types ourselves for the other compilers that normally
ganlikun 0:13413ea9a877 30 * target embedded systems */
ganlikun 0:13413ea9a877 31 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
ganlikun 0:13413ea9a877 32 typedef signed int ssize_t; ///< Signed size type, usually encodes negative errors
ganlikun 0:13413ea9a877 33 typedef signed long off_t; ///< Offset in a data stream
ganlikun 0:13413ea9a877 34 typedef unsigned int mode_t; ///< Mode for opening files
ganlikun 0:13413ea9a877 35 typedef unsigned int dev_t; ///< Device ID type
ganlikun 0:13413ea9a877 36 typedef unsigned long ino_t; ///< File serial number
ganlikun 0:13413ea9a877 37 typedef unsigned int nlink_t; ///< Number of links to a file
ganlikun 0:13413ea9a877 38 typedef unsigned int uid_t; ///< User ID
ganlikun 0:13413ea9a877 39 typedef unsigned int gid_t; ///< Group ID
ganlikun 0:13413ea9a877 40
ganlikun 0:13413ea9a877 41 #define O_RDONLY 0 ///< Open for reading
ganlikun 0:13413ea9a877 42 #define O_WRONLY 1 ///< Open for writing
ganlikun 0:13413ea9a877 43 #define O_RDWR 2 ///< Open for reading and writing
ganlikun 0:13413ea9a877 44 #define O_CREAT 0x0200 ///< Create file if it does not exist
ganlikun 0:13413ea9a877 45 #define O_TRUNC 0x0400 ///< Truncate file to zero length
ganlikun 0:13413ea9a877 46 #define O_EXCL 0x0800 ///< Fail if file exists
ganlikun 0:13413ea9a877 47 #define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write
ganlikun 0:13413ea9a877 48
ganlikun 0:13413ea9a877 49 #define NAME_MAX 255 ///< Maximum size of a name in a file path
ganlikun 0:13413ea9a877 50
ganlikun 0:13413ea9a877 51 #include <time.h>
ganlikun 0:13413ea9a877 52
ganlikun 0:13413ea9a877 53 #else
ganlikun 0:13413ea9a877 54
ganlikun 0:13413ea9a877 55 #include <sys/fcntl.h>
ganlikun 0:13413ea9a877 56 #include <sys/types.h>
ganlikun 0:13413ea9a877 57 #include <sys/syslimits.h>
ganlikun 0:13413ea9a877 58
ganlikun 0:13413ea9a877 59 #endif
ganlikun 0:13413ea9a877 60
ganlikun 0:13413ea9a877 61
ganlikun 0:13413ea9a877 62 /* DIR declarations must also be here */
ganlikun 0:13413ea9a877 63 #if __cplusplus
ganlikun 0:13413ea9a877 64 namespace mbed {
ganlikun 0:13413ea9a877 65 class FileHandle;
ganlikun 0:13413ea9a877 66 class DirHandle;
ganlikun 0:13413ea9a877 67 std::FILE *mbed_fdopen(FileHandle *fh, const char *mode);
ganlikun 0:13413ea9a877 68 }
ganlikun 0:13413ea9a877 69 typedef mbed::DirHandle DIR;
ganlikun 0:13413ea9a877 70 #else
ganlikun 0:13413ea9a877 71 typedef struct Dir DIR;
ganlikun 0:13413ea9a877 72 #endif
ganlikun 0:13413ea9a877 73
ganlikun 0:13413ea9a877 74 #if __cplusplus
ganlikun 0:13413ea9a877 75 extern "C" {
ganlikun 0:13413ea9a877 76 #endif
ganlikun 0:13413ea9a877 77 DIR *opendir(const char*);
ganlikun 0:13413ea9a877 78 struct dirent *readdir(DIR *);
ganlikun 0:13413ea9a877 79 int closedir(DIR*);
ganlikun 0:13413ea9a877 80 void rewinddir(DIR*);
ganlikun 0:13413ea9a877 81 long telldir(DIR*);
ganlikun 0:13413ea9a877 82 void seekdir(DIR*, long);
ganlikun 0:13413ea9a877 83 int mkdir(const char *name, mode_t n);
ganlikun 0:13413ea9a877 84 #if __cplusplus
ganlikun 0:13413ea9a877 85 };
ganlikun 0:13413ea9a877 86 #endif
ganlikun 0:13413ea9a877 87
ganlikun 0:13413ea9a877 88
ganlikun 0:13413ea9a877 89 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
ganlikun 0:13413ea9a877 90 /* The intent of this section is to unify the errno error values to match
ganlikun 0:13413ea9a877 91 * the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is
ganlikun 0:13413ea9a877 92 * necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some
ganlikun 0:13413ea9a877 93 * symbol definitions used by the POSIX filesystem API to return errno codes.
ganlikun 0:13413ea9a877 94 * Note also that ARMCC errno.h defines some symbol values differently from
ganlikun 0:13413ea9a877 95 * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against
ganlikun 0:13413ea9a877 96 * this and future changes by changing the symbol definition as shown below.
ganlikun 0:13413ea9a877 97 */
ganlikun 0:13413ea9a877 98 #undef EPERM
ganlikun 0:13413ea9a877 99 #define EPERM 1 /* Operation not permitted */
ganlikun 0:13413ea9a877 100 #undef ENOENT
ganlikun 0:13413ea9a877 101 #define ENOENT 2 /* No such file or directory */
ganlikun 0:13413ea9a877 102 #undef ESRCH
ganlikun 0:13413ea9a877 103 #define ESRCH 3 /* No such process */
ganlikun 0:13413ea9a877 104 #undef EINTR
ganlikun 0:13413ea9a877 105 #define EINTR 4 /* Interrupted system call */
ganlikun 0:13413ea9a877 106 #undef EIO
ganlikun 0:13413ea9a877 107 #define EIO 5 /* I/O error */
ganlikun 0:13413ea9a877 108 #undef ENXIO
ganlikun 0:13413ea9a877 109 #define ENXIO 6 /* No such device or address */
ganlikun 0:13413ea9a877 110 #undef E2BIG
ganlikun 0:13413ea9a877 111 #define E2BIG 7 /* Argument list too long */
ganlikun 0:13413ea9a877 112 #undef ENOEXEC
ganlikun 0:13413ea9a877 113 #define ENOEXEC 8 /* Exec format error */
ganlikun 0:13413ea9a877 114 #undef EBADF
ganlikun 0:13413ea9a877 115 #define EBADF 9 /* Bad file number */
ganlikun 0:13413ea9a877 116 #undef ECHILD
ganlikun 0:13413ea9a877 117 #define ECHILD 10 /* No child processes */
ganlikun 0:13413ea9a877 118 #undef EAGAIN
ganlikun 0:13413ea9a877 119 #define EAGAIN 11 /* Try again */
ganlikun 0:13413ea9a877 120 #undef ENOMEM
ganlikun 0:13413ea9a877 121 #define ENOMEM 12 /* Out of memory */
ganlikun 0:13413ea9a877 122 #undef EACCES
ganlikun 0:13413ea9a877 123 #define EACCES 13 /* Permission denied */
ganlikun 0:13413ea9a877 124 #undef EFAULT
ganlikun 0:13413ea9a877 125 #define EFAULT 14 /* Bad address */
ganlikun 0:13413ea9a877 126 #undef ENOTBLK
ganlikun 0:13413ea9a877 127 #define ENOTBLK 15 /* Block device required */
ganlikun 0:13413ea9a877 128 #undef EBUSY
ganlikun 0:13413ea9a877 129 #define EBUSY 16 /* Device or resource busy */
ganlikun 0:13413ea9a877 130 #undef EEXIST
ganlikun 0:13413ea9a877 131 #define EEXIST 17 /* File exists */
ganlikun 0:13413ea9a877 132 #undef EXDEV
ganlikun 0:13413ea9a877 133 #define EXDEV 18 /* Cross-device link */
ganlikun 0:13413ea9a877 134 #undef ENODEV
ganlikun 0:13413ea9a877 135 #define ENODEV 19 /* No such device */
ganlikun 0:13413ea9a877 136 #undef ENOTDIR
ganlikun 0:13413ea9a877 137 #define ENOTDIR 20 /* Not a directory */
ganlikun 0:13413ea9a877 138 #undef EISDIR
ganlikun 0:13413ea9a877 139 #define EISDIR 21 /* Is a directory */
ganlikun 0:13413ea9a877 140 #undef EINVAL
ganlikun 0:13413ea9a877 141 #define EINVAL 22 /* Invalid argument */
ganlikun 0:13413ea9a877 142 #undef ENFILE
ganlikun 0:13413ea9a877 143 #define ENFILE 23 /* File table overflow */
ganlikun 0:13413ea9a877 144 #undef EMFILE
ganlikun 0:13413ea9a877 145 #define EMFILE 24 /* Too many open files */
ganlikun 0:13413ea9a877 146 #undef ENOTTY
ganlikun 0:13413ea9a877 147 #define ENOTTY 25 /* Not a typewriter */
ganlikun 0:13413ea9a877 148 #undef ETXTBSY
ganlikun 0:13413ea9a877 149 #define ETXTBSY 26 /* Text file busy */
ganlikun 0:13413ea9a877 150 #undef EFBIG
ganlikun 0:13413ea9a877 151 #define EFBIG 27 /* File too large */
ganlikun 0:13413ea9a877 152 #undef ENOSPC
ganlikun 0:13413ea9a877 153 #define ENOSPC 28 /* No space left on device */
ganlikun 0:13413ea9a877 154 #undef ESPIPE
ganlikun 0:13413ea9a877 155 #define ESPIPE 29 /* Illegal seek */
ganlikun 0:13413ea9a877 156 #undef EROFS
ganlikun 0:13413ea9a877 157 #define EROFS 30 /* Read-only file system */
ganlikun 0:13413ea9a877 158 #undef EMLINK
ganlikun 0:13413ea9a877 159 #define EMLINK 31 /* Too many links */
ganlikun 0:13413ea9a877 160 #undef EPIPE
ganlikun 0:13413ea9a877 161 #define EPIPE 32 /* Broken pipe */
ganlikun 0:13413ea9a877 162 #undef EDOM
ganlikun 0:13413ea9a877 163 #define EDOM 33 /* Math argument out of domain of func */
ganlikun 0:13413ea9a877 164 #undef ERANGE
ganlikun 0:13413ea9a877 165 #define ERANGE 34 /* Math result not representable */
ganlikun 0:13413ea9a877 166 #undef EDEADLK
ganlikun 0:13413ea9a877 167 #define EDEADLK 35 /* Resource deadlock would occur */
ganlikun 0:13413ea9a877 168 #undef ENAMETOOLONG
ganlikun 0:13413ea9a877 169 #define ENAMETOOLONG 36 /* File name too long */
ganlikun 0:13413ea9a877 170 #undef ENOLCK
ganlikun 0:13413ea9a877 171 #define ENOLCK 37 /* No record locks available */
ganlikun 0:13413ea9a877 172 #undef ENOSYS
ganlikun 0:13413ea9a877 173 #define ENOSYS 38 /* Function not implemented */
ganlikun 0:13413ea9a877 174 #undef ENOTEMPTY
ganlikun 0:13413ea9a877 175 #define ENOTEMPTY 39 /* Directory not empty */
ganlikun 0:13413ea9a877 176 #undef ELOOP
ganlikun 0:13413ea9a877 177 #define ELOOP 40 /* Too many symbolic links encountered */
ganlikun 0:13413ea9a877 178 #undef EWOULDBLOCK
ganlikun 0:13413ea9a877 179 #define EWOULDBLOCK EAGAIN /* Operation would block */
ganlikun 0:13413ea9a877 180 #undef ENOMSG
ganlikun 0:13413ea9a877 181 #define ENOMSG 42 /* No message of desired type */
ganlikun 0:13413ea9a877 182 #undef EIDRM
ganlikun 0:13413ea9a877 183 #define EIDRM 43 /* Identifier removed */
ganlikun 0:13413ea9a877 184 #undef ECHRNG
ganlikun 0:13413ea9a877 185 #define ECHRNG 44 /* Channel number out of range */
ganlikun 0:13413ea9a877 186 #undef EL2NSYNC
ganlikun 0:13413ea9a877 187 #define EL2NSYNC 45 /* Level 2 not synchronized */
ganlikun 0:13413ea9a877 188 #undef EL3HLT
ganlikun 0:13413ea9a877 189 #define EL3HLT 46 /* Level 3 halted */
ganlikun 0:13413ea9a877 190 #undef EL3RST
ganlikun 0:13413ea9a877 191 #define EL3RST 47 /* Level 3 reset */
ganlikun 0:13413ea9a877 192 #undef ELNRNG
ganlikun 0:13413ea9a877 193 #define ELNRNG 48 /* Link number out of range */
ganlikun 0:13413ea9a877 194 #undef EUNATCH
ganlikun 0:13413ea9a877 195 #define EUNATCH 49 /* Protocol driver not attached */
ganlikun 0:13413ea9a877 196 #undef ENOCSI
ganlikun 0:13413ea9a877 197 #define ENOCSI 50 /* No CSI structure available */
ganlikun 0:13413ea9a877 198 #undef EL2HLT
ganlikun 0:13413ea9a877 199 #define EL2HLT 51 /* Level 2 halted */
ganlikun 0:13413ea9a877 200 #undef EBADE
ganlikun 0:13413ea9a877 201 #define EBADE 52 /* Invalid exchange */
ganlikun 0:13413ea9a877 202 #undef EBADR
ganlikun 0:13413ea9a877 203 #define EBADR 53 /* Invalid request descriptor */
ganlikun 0:13413ea9a877 204 #undef EXFULL
ganlikun 0:13413ea9a877 205 #define EXFULL 54 /* Exchange full */
ganlikun 0:13413ea9a877 206 #undef ENOANO
ganlikun 0:13413ea9a877 207 #define ENOANO 55 /* No anode */
ganlikun 0:13413ea9a877 208 #undef EBADRQC
ganlikun 0:13413ea9a877 209 #define EBADRQC 56 /* Invalid request code */
ganlikun 0:13413ea9a877 210 #undef EBADSLT
ganlikun 0:13413ea9a877 211 #define EBADSLT 57 /* Invalid slot */
ganlikun 0:13413ea9a877 212 #undef EDEADLOCK
ganlikun 0:13413ea9a877 213 #define EDEADLOCK EDEADLK /* Resource deadlock would occur */
ganlikun 0:13413ea9a877 214 #undef EBFONT
ganlikun 0:13413ea9a877 215 #define EBFONT 59 /* Bad font file format */
ganlikun 0:13413ea9a877 216 #undef ENOSTR
ganlikun 0:13413ea9a877 217 #define ENOSTR 60 /* Device not a stream */
ganlikun 0:13413ea9a877 218 #undef ENODATA
ganlikun 0:13413ea9a877 219 #define ENODATA 61 /* No data available */
ganlikun 0:13413ea9a877 220 #undef ETIME
ganlikun 0:13413ea9a877 221 #define ETIME 62 /* Timer expired */
ganlikun 0:13413ea9a877 222 #undef ENOSR
ganlikun 0:13413ea9a877 223 #define ENOSR 63 /* Out of streams resources */
ganlikun 0:13413ea9a877 224 #undef ENONET
ganlikun 0:13413ea9a877 225 #define ENONET 64 /* Machine is not on the network */
ganlikun 0:13413ea9a877 226 #undef ENOPKG
ganlikun 0:13413ea9a877 227 #define ENOPKG 65 /* Package not installed */
ganlikun 0:13413ea9a877 228 #undef EREMOTE
ganlikun 0:13413ea9a877 229 #define EREMOTE 66 /* Object is remote */
ganlikun 0:13413ea9a877 230 #undef ENOLINK
ganlikun 0:13413ea9a877 231 #define ENOLINK 67 /* Link has been severed */
ganlikun 0:13413ea9a877 232 #undef EADV
ganlikun 0:13413ea9a877 233 #define EADV 68 /* Advertise error */
ganlikun 0:13413ea9a877 234 #undef ESRMNT
ganlikun 0:13413ea9a877 235 #define ESRMNT 69 /* Srmount error */
ganlikun 0:13413ea9a877 236 #undef ECOMM
ganlikun 0:13413ea9a877 237 #define ECOMM 70 /* Communication error on send */
ganlikun 0:13413ea9a877 238 #undef EPROTO
ganlikun 0:13413ea9a877 239 #define EPROTO 71 /* Protocol error */
ganlikun 0:13413ea9a877 240 #undef EMULTIHOP
ganlikun 0:13413ea9a877 241 #define EMULTIHOP 72 /* Multihop attempted */
ganlikun 0:13413ea9a877 242 #undef EDOTDOT
ganlikun 0:13413ea9a877 243 #define EDOTDOT 73 /* RFS specific error */
ganlikun 0:13413ea9a877 244 #undef EBADMSG
ganlikun 0:13413ea9a877 245 #define EBADMSG 74 /* Not a data message */
ganlikun 0:13413ea9a877 246 #undef EOVERFLOW
ganlikun 0:13413ea9a877 247 #define EOVERFLOW 75 /* Value too large for defined data type */
ganlikun 0:13413ea9a877 248 #undef ENOTUNIQ
ganlikun 0:13413ea9a877 249 #define ENOTUNIQ 76 /* Name not unique on network */
ganlikun 0:13413ea9a877 250 #undef EBADFD
ganlikun 0:13413ea9a877 251 #define EBADFD 77 /* File descriptor in bad state */
ganlikun 0:13413ea9a877 252 #undef EREMCHG
ganlikun 0:13413ea9a877 253 #define EREMCHG 78 /* Remote address changed */
ganlikun 0:13413ea9a877 254 #undef ELIBACC
ganlikun 0:13413ea9a877 255 #define ELIBACC 79 /* Can not access a needed shared library */
ganlikun 0:13413ea9a877 256 #undef ELIBBAD
ganlikun 0:13413ea9a877 257 #define ELIBBAD 80 /* Accessing a corrupted shared library */
ganlikun 0:13413ea9a877 258 #undef ELIBSCN
ganlikun 0:13413ea9a877 259 #define ELIBSCN 81 /* .lib section in a.out corrupted */
ganlikun 0:13413ea9a877 260 #undef ELIBMAX
ganlikun 0:13413ea9a877 261 #define ELIBMAX 82 /* Attempting to link in too many shared libraries */
ganlikun 0:13413ea9a877 262 #undef ELIBEXEC
ganlikun 0:13413ea9a877 263 #define ELIBEXEC 83 /* Cannot exec a shared library directly */
ganlikun 0:13413ea9a877 264 #undef EILSEQ
ganlikun 0:13413ea9a877 265 #define EILSEQ 84 /* Illegal byte sequence */
ganlikun 0:13413ea9a877 266 #undef ERESTART
ganlikun 0:13413ea9a877 267 #define ERESTART 85 /* Interrupted system call should be restarted */
ganlikun 0:13413ea9a877 268 #undef ESTRPIPE
ganlikun 0:13413ea9a877 269 #define ESTRPIPE 86 /* Streams pipe error */
ganlikun 0:13413ea9a877 270 #undef EUSERS
ganlikun 0:13413ea9a877 271 #define EUSERS 87 /* Too many users */
ganlikun 0:13413ea9a877 272 #undef ENOTSOCK
ganlikun 0:13413ea9a877 273 #define ENOTSOCK 88 /* Socket operation on non-socket */
ganlikun 0:13413ea9a877 274 #undef EDESTADDRREQ
ganlikun 0:13413ea9a877 275 #define EDESTADDRREQ 89 /* Destination address required */
ganlikun 0:13413ea9a877 276 #undef EMSGSIZE
ganlikun 0:13413ea9a877 277 #define EMSGSIZE 90 /* Message too long */
ganlikun 0:13413ea9a877 278 #undef EPROTOTYPE
ganlikun 0:13413ea9a877 279 #define EPROTOTYPE 91 /* Protocol wrong type for socket */
ganlikun 0:13413ea9a877 280 #undef ENOPROTOOPT
ganlikun 0:13413ea9a877 281 #define ENOPROTOOPT 92 /* Protocol not available */
ganlikun 0:13413ea9a877 282 #undef EPROTONOSUPPORT
ganlikun 0:13413ea9a877 283 #define EPROTONOSUPPORT 93 /* Protocol not supported */
ganlikun 0:13413ea9a877 284 #undef ESOCKTNOSUPPORT
ganlikun 0:13413ea9a877 285 #define ESOCKTNOSUPPORT 94 /* Socket type not supported */
ganlikun 0:13413ea9a877 286 #undef EOPNOTSUPP
ganlikun 0:13413ea9a877 287 #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
ganlikun 0:13413ea9a877 288 #undef EPFNOSUPPORT
ganlikun 0:13413ea9a877 289 #define EPFNOSUPPORT 96 /* Protocol family not supported */
ganlikun 0:13413ea9a877 290 #undef EAFNOSUPPORT
ganlikun 0:13413ea9a877 291 #define EAFNOSUPPORT 97 /* Address family not supported by protocol */
ganlikun 0:13413ea9a877 292 #undef EADDRINUSE
ganlikun 0:13413ea9a877 293 #define EADDRINUSE 98 /* Address already in use */
ganlikun 0:13413ea9a877 294 #undef EADDRNOTAVAIL
ganlikun 0:13413ea9a877 295 #define EADDRNOTAVAIL 99 /* Cannot assign requested address */
ganlikun 0:13413ea9a877 296 #undef ENETDOWN
ganlikun 0:13413ea9a877 297 #define ENETDOWN 100 /* Network is down */
ganlikun 0:13413ea9a877 298 #undef ENETUNREACH
ganlikun 0:13413ea9a877 299 #define ENETUNREACH 101 /* Network is unreachable */
ganlikun 0:13413ea9a877 300 #undef ENETRESET
ganlikun 0:13413ea9a877 301 #define ENETRESET 102 /* Network dropped connection because of reset */
ganlikun 0:13413ea9a877 302 #undef ECONNABORTED
ganlikun 0:13413ea9a877 303 #define ECONNABORTED 103 /* Software caused connection abort */
ganlikun 0:13413ea9a877 304 #undef ECONNRESET
ganlikun 0:13413ea9a877 305 #define ECONNRESET 104 /* Connection reset by peer */
ganlikun 0:13413ea9a877 306 #undef ENOBUFS
ganlikun 0:13413ea9a877 307 #define ENOBUFS 105 /* No buffer space available */
ganlikun 0:13413ea9a877 308 #undef EISCONN
ganlikun 0:13413ea9a877 309 #define EISCONN 106 /* Transport endpoint is already connected */
ganlikun 0:13413ea9a877 310 #undef ENOTCONN
ganlikun 0:13413ea9a877 311 #define ENOTCONN 107 /* Transport endpoint is not connected */
ganlikun 0:13413ea9a877 312 #undef ESHUTDOWN
ganlikun 0:13413ea9a877 313 #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
ganlikun 0:13413ea9a877 314 #undef ETOOMANYREFS
ganlikun 0:13413ea9a877 315 #define ETOOMANYREFS 109 /* Too many references: cannot splice */
ganlikun 0:13413ea9a877 316 #undef ETIMEDOUT
ganlikun 0:13413ea9a877 317 #define ETIMEDOUT 110 /* Connection timed out */
ganlikun 0:13413ea9a877 318 #undef ECONNREFUSED
ganlikun 0:13413ea9a877 319 #define ECONNREFUSED 111 /* Connection refused */
ganlikun 0:13413ea9a877 320 #undef EHOSTDOWN
ganlikun 0:13413ea9a877 321 #define EHOSTDOWN 112 /* Host is down */
ganlikun 0:13413ea9a877 322 #undef EHOSTUNREACH
ganlikun 0:13413ea9a877 323 #define EHOSTUNREACH 113 /* No route to host */
ganlikun 0:13413ea9a877 324 #undef EALREADY
ganlikun 0:13413ea9a877 325 #define EALREADY 114 /* Operation already in progress */
ganlikun 0:13413ea9a877 326 #undef EINPROGRESS
ganlikun 0:13413ea9a877 327 #define EINPROGRESS 115 /* Operation now in progress */
ganlikun 0:13413ea9a877 328 #undef ESTALE
ganlikun 0:13413ea9a877 329 #define ESTALE 116 /* Stale NFS file handle */
ganlikun 0:13413ea9a877 330 #undef EUCLEAN
ganlikun 0:13413ea9a877 331 #define EUCLEAN 117 /* Structure needs cleaning */
ganlikun 0:13413ea9a877 332 #undef ENOTNAM
ganlikun 0:13413ea9a877 333 #define ENOTNAM 118 /* Not a XENIX named type file */
ganlikun 0:13413ea9a877 334 #undef ENAVAIL
ganlikun 0:13413ea9a877 335 #define ENAVAIL 119 /* No XENIX semaphores available */
ganlikun 0:13413ea9a877 336 #undef EISNAM
ganlikun 0:13413ea9a877 337 #define EISNAM 120 /* Is a named type file */
ganlikun 0:13413ea9a877 338 #undef EREMOTEIO
ganlikun 0:13413ea9a877 339 #define EREMOTEIO 121 /* Remote I/O error */
ganlikun 0:13413ea9a877 340 #undef EDQUOT
ganlikun 0:13413ea9a877 341 #define EDQUOT 122 /* Quota exceeded */
ganlikun 0:13413ea9a877 342 #undef ENOMEDIUM
ganlikun 0:13413ea9a877 343 #define ENOMEDIUM 123 /* No medium found */
ganlikun 0:13413ea9a877 344 #undef EMEDIUMTYPE
ganlikun 0:13413ea9a877 345 #define EMEDIUMTYPE 124 /* Wrong medium type */
ganlikun 0:13413ea9a877 346 #undef ECANCELED
ganlikun 0:13413ea9a877 347 #define ECANCELED 125 /* Operation Canceled */
ganlikun 0:13413ea9a877 348 #undef ENOKEY
ganlikun 0:13413ea9a877 349 #define ENOKEY 126 /* Required key not available */
ganlikun 0:13413ea9a877 350 #undef EKEYEXPIRED
ganlikun 0:13413ea9a877 351 #define EKEYEXPIRED 127 /* Key has expired */
ganlikun 0:13413ea9a877 352 #undef EKEYREVOKED
ganlikun 0:13413ea9a877 353 #define EKEYREVOKED 128 /* Key has been revoked */
ganlikun 0:13413ea9a877 354 #undef EKEYREJECTED
ganlikun 0:13413ea9a877 355 #define EKEYREJECTED 129 /* Key was rejected by service */
ganlikun 0:13413ea9a877 356 #undef EOWNERDEAD
ganlikun 0:13413ea9a877 357 #define EOWNERDEAD 130 /* Owner died */
ganlikun 0:13413ea9a877 358 #undef ENOTRECOVERABLE
ganlikun 0:13413ea9a877 359 #define ENOTRECOVERABLE 131 /* State not recoverable */
ganlikun 0:13413ea9a877 360 #endif
ganlikun 0:13413ea9a877 361
ganlikun 0:13413ea9a877 362 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
ganlikun 0:13413ea9a877 363 /* Missing stat.h defines.
ganlikun 0:13413ea9a877 364 * The following are sys/stat.h definitions not currently present in the ARMCC
ganlikun 0:13413ea9a877 365 * errno.h. Note, ARMCC errno.h defines some symbol values differing from
ganlikun 0:13413ea9a877 366 * GCC_ARM/IAR/standard POSIX definitions. Guard against this and future
ganlikun 0:13413ea9a877 367 * changes by changing the symbol definition for filesystem use.
ganlikun 0:13413ea9a877 368 */
ganlikun 0:13413ea9a877 369 #define _IFMT 0170000 //< type of file
ganlikun 0:13413ea9a877 370 #define _IFSOCK 0140000 //< socket
ganlikun 0:13413ea9a877 371 #define _IFLNK 0120000 //< symbolic link
ganlikun 0:13413ea9a877 372 #define _IFREG 0100000 //< regular
ganlikun 0:13413ea9a877 373 #define _IFBLK 0060000 //< block special
ganlikun 0:13413ea9a877 374 #define _IFDIR 0040000 //< directory
ganlikun 0:13413ea9a877 375 #define _IFCHR 0020000 //< character special
ganlikun 0:13413ea9a877 376 #define _IFIFO 0010000 //< fifo special
ganlikun 0:13413ea9a877 377
ganlikun 0:13413ea9a877 378 #define S_IFMT _IFMT //< type of file
ganlikun 0:13413ea9a877 379 #define S_IFSOCK _IFSOCK //< socket
ganlikun 0:13413ea9a877 380 #define S_IFLNK _IFLNK //< symbolic link
ganlikun 0:13413ea9a877 381 #define S_IFREG _IFREG //< regular
ganlikun 0:13413ea9a877 382 #define S_IFBLK _IFBLK //< block special
ganlikun 0:13413ea9a877 383 #define S_IFDIR _IFDIR //< directory
ganlikun 0:13413ea9a877 384 #define S_IFCHR _IFCHR //< character special
ganlikun 0:13413ea9a877 385 #define S_IFIFO _IFIFO //< fifo special
ganlikun 0:13413ea9a877 386
ganlikun 0:13413ea9a877 387 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
ganlikun 0:13413ea9a877 388 #define S_IRUSR 0000400 ///< read permission, owner
ganlikun 0:13413ea9a877 389 #define S_IWUSR 0000200 ///< write permission, owner
ganlikun 0:13413ea9a877 390 #define S_IXUSR 0000100 ///< execute/search permission, owner
ganlikun 0:13413ea9a877 391 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
ganlikun 0:13413ea9a877 392 #define S_IRGRP 0000040 ///< read permission, group
ganlikun 0:13413ea9a877 393 #define S_IWGRP 0000020 ///< write permission, grougroup
ganlikun 0:13413ea9a877 394 #define S_IXGRP 0000010 ///< execute/search permission, group
ganlikun 0:13413ea9a877 395 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
ganlikun 0:13413ea9a877 396 #define S_IROTH 0000004 ///< read permission, other
ganlikun 0:13413ea9a877 397 #define S_IWOTH 0000002 ///< write permission, other
ganlikun 0:13413ea9a877 398 #define S_IXOTH 0000001 ///< execute/search permission, other
ganlikun 0:13413ea9a877 399
ganlikun 0:13413ea9a877 400 /* Refer to sys/stat standard
ganlikun 0:13413ea9a877 401 * Note: Not all fields may be supported by the underlying filesystem
ganlikun 0:13413ea9a877 402 */
ganlikun 0:13413ea9a877 403 struct stat {
ganlikun 0:13413ea9a877 404 dev_t st_dev; ///< Device ID containing file
ganlikun 0:13413ea9a877 405 ino_t st_ino; ///< File serial number
ganlikun 0:13413ea9a877 406 mode_t st_mode; ///< Mode of file
ganlikun 0:13413ea9a877 407 nlink_t st_nlink; ///< Number of links to file
ganlikun 0:13413ea9a877 408
ganlikun 0:13413ea9a877 409 uid_t st_uid; ///< User ID
ganlikun 0:13413ea9a877 410 gid_t st_gid; ///< Group ID
ganlikun 0:13413ea9a877 411
ganlikun 0:13413ea9a877 412 off_t st_size; ///< Size of file in bytes
ganlikun 0:13413ea9a877 413
ganlikun 0:13413ea9a877 414 time_t st_atime; ///< Time of last access
ganlikun 0:13413ea9a877 415 time_t st_mtime; ///< Time of last data modification
ganlikun 0:13413ea9a877 416 time_t st_ctime; ///< Time of last status change
ganlikun 0:13413ea9a877 417 };
ganlikun 0:13413ea9a877 418
ganlikun 0:13413ea9a877 419 #endif /* defined(__ARMCC_VERSION) || defined(__ICCARM__) */
ganlikun 0:13413ea9a877 420
ganlikun 0:13413ea9a877 421
ganlikun 0:13413ea9a877 422 /* The following are dirent.h definitions are declared here to garuntee
ganlikun 0:13413ea9a877 423 * consistency where structure may be different with different toolchains
ganlikun 0:13413ea9a877 424 */
ganlikun 0:13413ea9a877 425 struct dirent {
ganlikun 0:13413ea9a877 426 char d_name[NAME_MAX+1]; ///< Name of file
ganlikun 0:13413ea9a877 427 uint8_t d_type; ///< Type of file
ganlikun 0:13413ea9a877 428 };
ganlikun 0:13413ea9a877 429
ganlikun 0:13413ea9a877 430 enum {
ganlikun 0:13413ea9a877 431 DT_UNKNOWN, ///< The file type could not be determined.
ganlikun 0:13413ea9a877 432 DT_FIFO, ///< This is a named pipe (FIFO).
ganlikun 0:13413ea9a877 433 DT_CHR, ///< This is a character device.
ganlikun 0:13413ea9a877 434 DT_DIR, ///< This is a directory.
ganlikun 0:13413ea9a877 435 DT_BLK, ///< This is a block device.
ganlikun 0:13413ea9a877 436 DT_REG, ///< This is a regular file.
ganlikun 0:13413ea9a877 437 DT_LNK, ///< This is a symbolic link.
ganlikun 0:13413ea9a877 438 DT_SOCK, ///< This is a UNIX domain socket.
ganlikun 0:13413ea9a877 439 };
ganlikun 0:13413ea9a877 440
ganlikun 0:13413ea9a877 441 #endif /* RETARGET_H */
ganlikun 0:13413ea9a877 442