The prosthetic control(MIT)

Committer:
ganlikun
Date:
Thu Jun 23 05:23:34 2022 +0000
Revision:
0:20e0c61e0684
01

Who changed what in which revision?

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