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