Initial commit
mbed-dev-master/platform/mbed_retarget.h@0:bb348c97df44, 2020-09-16 (annotated)
- Committer:
- lypinator
- Date:
- Wed Sep 16 01:11:49 2020 +0000
- Revision:
- 0:bb348c97df44
Added PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lypinator | 0:bb348c97df44 | 1 | /* |
lypinator | 0:bb348c97df44 | 2 | * mbed Microcontroller Library |
lypinator | 0:bb348c97df44 | 3 | * Copyright (c) 2006-2016 ARM Limited |
lypinator | 0:bb348c97df44 | 4 | * |
lypinator | 0:bb348c97df44 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
lypinator | 0:bb348c97df44 | 6 | * you may not use this file except in compliance with the License. |
lypinator | 0:bb348c97df44 | 7 | * You may obtain a copy of the License at |
lypinator | 0:bb348c97df44 | 8 | * |
lypinator | 0:bb348c97df44 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
lypinator | 0:bb348c97df44 | 10 | * |
lypinator | 0:bb348c97df44 | 11 | * Unless required by applicable law or agreed to in writing, software |
lypinator | 0:bb348c97df44 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
lypinator | 0:bb348c97df44 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
lypinator | 0:bb348c97df44 | 14 | * See the License for the specific language governing permissions and |
lypinator | 0:bb348c97df44 | 15 | * limitations under the License. |
lypinator | 0:bb348c97df44 | 16 | * |
lypinator | 0:bb348c97df44 | 17 | */ |
lypinator | 0:bb348c97df44 | 18 | |
lypinator | 0:bb348c97df44 | 19 | #ifndef RETARGET_H |
lypinator | 0:bb348c97df44 | 20 | #define RETARGET_H |
lypinator | 0:bb348c97df44 | 21 | |
lypinator | 0:bb348c97df44 | 22 | #if __cplusplus |
lypinator | 0:bb348c97df44 | 23 | #include <cstdio> |
lypinator | 0:bb348c97df44 | 24 | #else |
lypinator | 0:bb348c97df44 | 25 | #include <stdio.h> |
lypinator | 0:bb348c97df44 | 26 | #endif //__cplusplus |
lypinator | 0:bb348c97df44 | 27 | #include <stdint.h> |
lypinator | 0:bb348c97df44 | 28 | #include <stddef.h> |
lypinator | 0:bb348c97df44 | 29 | |
lypinator | 0:bb348c97df44 | 30 | /* Include logic for errno so we can get errno defined but not bring in error_t, |
lypinator | 0:bb348c97df44 | 31 | * including errno here prevents an include later, which would redefine our |
lypinator | 0:bb348c97df44 | 32 | * error codes |
lypinator | 0:bb348c97df44 | 33 | */ |
lypinator | 0:bb348c97df44 | 34 | #ifndef __error_t_defined |
lypinator | 0:bb348c97df44 | 35 | #define __error_t_defined 1 |
lypinator | 0:bb348c97df44 | 36 | #include <errno.h> |
lypinator | 0:bb348c97df44 | 37 | #undef __error_t_defined |
lypinator | 0:bb348c97df44 | 38 | #else |
lypinator | 0:bb348c97df44 | 39 | #include <errno.h> |
lypinator | 0:bb348c97df44 | 40 | #endif |
lypinator | 0:bb348c97df44 | 41 | |
lypinator | 0:bb348c97df44 | 42 | /* We can get the following standard types from sys/types for gcc, but we |
lypinator | 0:bb348c97df44 | 43 | * need to define the types ourselves for the other compilers that normally |
lypinator | 0:bb348c97df44 | 44 | * target embedded systems */ |
lypinator | 0:bb348c97df44 | 45 | typedef signed int ssize_t; ///< Signed size type, usually encodes negative errors |
lypinator | 0:bb348c97df44 | 46 | typedef signed long off_t; ///< Offset in a data stream |
lypinator | 0:bb348c97df44 | 47 | typedef unsigned int nfds_t; ///< Number of file descriptors |
lypinator | 0:bb348c97df44 | 48 | typedef unsigned long long fsblkcnt_t; ///< Count of file system blocks |
lypinator | 0:bb348c97df44 | 49 | #if defined(__ARMCC_VERSION) || !defined(__GNUC__) |
lypinator | 0:bb348c97df44 | 50 | typedef unsigned int mode_t; ///< Mode for opening files |
lypinator | 0:bb348c97df44 | 51 | typedef unsigned int dev_t; ///< Device ID type |
lypinator | 0:bb348c97df44 | 52 | typedef unsigned long ino_t; ///< File serial number |
lypinator | 0:bb348c97df44 | 53 | typedef unsigned int nlink_t; ///< Number of links to a file |
lypinator | 0:bb348c97df44 | 54 | typedef unsigned int uid_t; ///< User ID |
lypinator | 0:bb348c97df44 | 55 | typedef unsigned int gid_t; ///< Group ID |
lypinator | 0:bb348c97df44 | 56 | #endif |
lypinator | 0:bb348c97df44 | 57 | |
lypinator | 0:bb348c97df44 | 58 | /* Flags for open() and fcntl(GETFL/SETFL) |
lypinator | 0:bb348c97df44 | 59 | * At present, fcntl only supports reading and writing O_NONBLOCK |
lypinator | 0:bb348c97df44 | 60 | */ |
lypinator | 0:bb348c97df44 | 61 | #define O_RDONLY 0 ///< Open for reading |
lypinator | 0:bb348c97df44 | 62 | #define O_WRONLY 1 ///< Open for writing |
lypinator | 0:bb348c97df44 | 63 | #define O_RDWR 2 ///< Open for reading and writing |
lypinator | 0:bb348c97df44 | 64 | #define O_NONBLOCK 0x0004 ///< Non-blocking mode |
lypinator | 0:bb348c97df44 | 65 | #define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write |
lypinator | 0:bb348c97df44 | 66 | #define O_CREAT 0x0200 ///< Create file if it does not exist |
lypinator | 0:bb348c97df44 | 67 | #define O_TRUNC 0x0400 ///< Truncate file to zero length |
lypinator | 0:bb348c97df44 | 68 | #define O_EXCL 0x0800 ///< Fail if file exists |
lypinator | 0:bb348c97df44 | 69 | #define O_BINARY 0x8000 ///< Open file in binary mode |
lypinator | 0:bb348c97df44 | 70 | |
lypinator | 0:bb348c97df44 | 71 | #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) |
lypinator | 0:bb348c97df44 | 72 | |
lypinator | 0:bb348c97df44 | 73 | #define NAME_MAX 255 ///< Maximum size of a name in a file path |
lypinator | 0:bb348c97df44 | 74 | |
lypinator | 0:bb348c97df44 | 75 | #define STDIN_FILENO 0 |
lypinator | 0:bb348c97df44 | 76 | #define STDOUT_FILENO 1 |
lypinator | 0:bb348c97df44 | 77 | #define STDERR_FILENO 2 |
lypinator | 0:bb348c97df44 | 78 | |
lypinator | 0:bb348c97df44 | 79 | #include <time.h> |
lypinator | 0:bb348c97df44 | 80 | |
lypinator | 0:bb348c97df44 | 81 | /** \addtogroup platform */ |
lypinator | 0:bb348c97df44 | 82 | /** @{*/ |
lypinator | 0:bb348c97df44 | 83 | /** |
lypinator | 0:bb348c97df44 | 84 | * \defgroup platform_retarget Retarget functions |
lypinator | 0:bb348c97df44 | 85 | * @{ |
lypinator | 0:bb348c97df44 | 86 | */ |
lypinator | 0:bb348c97df44 | 87 | |
lypinator | 0:bb348c97df44 | 88 | /* DIR declarations must also be here */ |
lypinator | 0:bb348c97df44 | 89 | #if __cplusplus |
lypinator | 0:bb348c97df44 | 90 | namespace mbed { |
lypinator | 0:bb348c97df44 | 91 | |
lypinator | 0:bb348c97df44 | 92 | class FileHandle; |
lypinator | 0:bb348c97df44 | 93 | class DirHandle; |
lypinator | 0:bb348c97df44 | 94 | |
lypinator | 0:bb348c97df44 | 95 | /** Targets may implement this to change stdin, stdout, stderr. |
lypinator | 0:bb348c97df44 | 96 | * |
lypinator | 0:bb348c97df44 | 97 | * If the application hasn't provided mbed_override_console, this is called |
lypinator | 0:bb348c97df44 | 98 | * to give the target a chance to specify a FileHandle for the console. |
lypinator | 0:bb348c97df44 | 99 | * |
lypinator | 0:bb348c97df44 | 100 | * If this is not provided or returns NULL, the console will be: |
lypinator | 0:bb348c97df44 | 101 | * - UARTSerial if configuration option "platform.stdio-buffered-serial" is |
lypinator | 0:bb348c97df44 | 102 | * true and the target has DEVICE_SERIAL; |
lypinator | 0:bb348c97df44 | 103 | * - Raw HAL serial via serial_getc and serial_putc if |
lypinator | 0:bb348c97df44 | 104 | * "platform.stdio-buffered-serial" is false and the target has DEVICE_SERIAL; |
lypinator | 0:bb348c97df44 | 105 | * - stdout/stderr will be a sink and stdin will input a stream of 0s if the |
lypinator | 0:bb348c97df44 | 106 | * target does not have DEVICE_SERIAL. |
lypinator | 0:bb348c97df44 | 107 | * |
lypinator | 0:bb348c97df44 | 108 | * @param fd file descriptor - STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO |
lypinator | 0:bb348c97df44 | 109 | * @return pointer to FileHandle to override normal stream otherwise NULL |
lypinator | 0:bb348c97df44 | 110 | */ |
lypinator | 0:bb348c97df44 | 111 | FileHandle *mbed_target_override_console(int fd); |
lypinator | 0:bb348c97df44 | 112 | |
lypinator | 0:bb348c97df44 | 113 | /** Applications may implement this to change stdin, stdout, stderr. |
lypinator | 0:bb348c97df44 | 114 | * |
lypinator | 0:bb348c97df44 | 115 | * This hook gives the application a chance to specify a custom FileHandle |
lypinator | 0:bb348c97df44 | 116 | * for the console. |
lypinator | 0:bb348c97df44 | 117 | * |
lypinator | 0:bb348c97df44 | 118 | * If this is not provided or returns NULL, the console will be specified |
lypinator | 0:bb348c97df44 | 119 | * by mbed_target_override_console, else will default to serial - see |
lypinator | 0:bb348c97df44 | 120 | * mbed_target_override_console for more details. |
lypinator | 0:bb348c97df44 | 121 | * |
lypinator | 0:bb348c97df44 | 122 | * Example: |
lypinator | 0:bb348c97df44 | 123 | * @code |
lypinator | 0:bb348c97df44 | 124 | * FileHandle* mbed::mbed_override_console(int) { |
lypinator | 0:bb348c97df44 | 125 | * static UARTSerial my_serial(D0, D1); |
lypinator | 0:bb348c97df44 | 126 | * return &my_serial; |
lypinator | 0:bb348c97df44 | 127 | * } |
lypinator | 0:bb348c97df44 | 128 | * @endcode |
lypinator | 0:bb348c97df44 | 129 | |
lypinator | 0:bb348c97df44 | 130 | * @param fd file descriptor - STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO |
lypinator | 0:bb348c97df44 | 131 | * @return pointer to FileHandle to override normal stream otherwise NULL |
lypinator | 0:bb348c97df44 | 132 | */ |
lypinator | 0:bb348c97df44 | 133 | FileHandle *mbed_override_console(int fd); |
lypinator | 0:bb348c97df44 | 134 | |
lypinator | 0:bb348c97df44 | 135 | } |
lypinator | 0:bb348c97df44 | 136 | |
lypinator | 0:bb348c97df44 | 137 | typedef mbed::DirHandle DIR; |
lypinator | 0:bb348c97df44 | 138 | #else |
lypinator | 0:bb348c97df44 | 139 | typedef struct Dir DIR; |
lypinator | 0:bb348c97df44 | 140 | #endif |
lypinator | 0:bb348c97df44 | 141 | |
lypinator | 0:bb348c97df44 | 142 | /* The intent of this section is to unify the errno error values to match |
lypinator | 0:bb348c97df44 | 143 | * the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is |
lypinator | 0:bb348c97df44 | 144 | * necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some |
lypinator | 0:bb348c97df44 | 145 | * symbol definitions used by the POSIX filesystem API to return errno codes. |
lypinator | 0:bb348c97df44 | 146 | * Note also that ARMCC errno.h defines some symbol values differently from |
lypinator | 0:bb348c97df44 | 147 | * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against |
lypinator | 0:bb348c97df44 | 148 | * this and future changes by changing the symbol definition as shown below. |
lypinator | 0:bb348c97df44 | 149 | */ |
lypinator | 0:bb348c97df44 | 150 | #undef EPERM |
lypinator | 0:bb348c97df44 | 151 | #define EPERM 1 /* Operation not permitted */ |
lypinator | 0:bb348c97df44 | 152 | #undef ENOENT |
lypinator | 0:bb348c97df44 | 153 | #define ENOENT 2 /* No such file or directory */ |
lypinator | 0:bb348c97df44 | 154 | #undef ESRCH |
lypinator | 0:bb348c97df44 | 155 | #define ESRCH 3 /* No such process */ |
lypinator | 0:bb348c97df44 | 156 | #undef EINTR |
lypinator | 0:bb348c97df44 | 157 | #define EINTR 4 /* Interrupted system call */ |
lypinator | 0:bb348c97df44 | 158 | #undef EIO |
lypinator | 0:bb348c97df44 | 159 | #define EIO 5 /* I/O error */ |
lypinator | 0:bb348c97df44 | 160 | #undef ENXIO |
lypinator | 0:bb348c97df44 | 161 | #define ENXIO 6 /* No such device or address */ |
lypinator | 0:bb348c97df44 | 162 | #undef E2BIG |
lypinator | 0:bb348c97df44 | 163 | #define E2BIG 7 /* Argument list too long */ |
lypinator | 0:bb348c97df44 | 164 | #undef ENOEXEC |
lypinator | 0:bb348c97df44 | 165 | #define ENOEXEC 8 /* Exec format error */ |
lypinator | 0:bb348c97df44 | 166 | #undef EBADF |
lypinator | 0:bb348c97df44 | 167 | #define EBADF 9 /* Bad file number */ |
lypinator | 0:bb348c97df44 | 168 | #undef ECHILD |
lypinator | 0:bb348c97df44 | 169 | #define ECHILD 10 /* No child processes */ |
lypinator | 0:bb348c97df44 | 170 | #undef EAGAIN |
lypinator | 0:bb348c97df44 | 171 | #define EAGAIN 11 /* Try again */ |
lypinator | 0:bb348c97df44 | 172 | #undef ENOMEM |
lypinator | 0:bb348c97df44 | 173 | #define ENOMEM 12 /* Out of memory */ |
lypinator | 0:bb348c97df44 | 174 | #undef EACCES |
lypinator | 0:bb348c97df44 | 175 | #define EACCES 13 /* Permission denied */ |
lypinator | 0:bb348c97df44 | 176 | #undef EFAULT |
lypinator | 0:bb348c97df44 | 177 | #define EFAULT 14 /* Bad address */ |
lypinator | 0:bb348c97df44 | 178 | #undef ENOTBLK |
lypinator | 0:bb348c97df44 | 179 | #define ENOTBLK 15 /* Block device required */ |
lypinator | 0:bb348c97df44 | 180 | #undef EBUSY |
lypinator | 0:bb348c97df44 | 181 | #define EBUSY 16 /* Device or resource busy */ |
lypinator | 0:bb348c97df44 | 182 | #undef EEXIST |
lypinator | 0:bb348c97df44 | 183 | #define EEXIST 17 /* File exists */ |
lypinator | 0:bb348c97df44 | 184 | #undef EXDEV |
lypinator | 0:bb348c97df44 | 185 | #define EXDEV 18 /* Cross-device link */ |
lypinator | 0:bb348c97df44 | 186 | #undef ENODEV |
lypinator | 0:bb348c97df44 | 187 | #define ENODEV 19 /* No such device */ |
lypinator | 0:bb348c97df44 | 188 | #undef ENOTDIR |
lypinator | 0:bb348c97df44 | 189 | #define ENOTDIR 20 /* Not a directory */ |
lypinator | 0:bb348c97df44 | 190 | #undef EISDIR |
lypinator | 0:bb348c97df44 | 191 | #define EISDIR 21 /* Is a directory */ |
lypinator | 0:bb348c97df44 | 192 | #undef EINVAL |
lypinator | 0:bb348c97df44 | 193 | #define EINVAL 22 /* Invalid argument */ |
lypinator | 0:bb348c97df44 | 194 | #undef ENFILE |
lypinator | 0:bb348c97df44 | 195 | #define ENFILE 23 /* File table overflow */ |
lypinator | 0:bb348c97df44 | 196 | #undef EMFILE |
lypinator | 0:bb348c97df44 | 197 | #define EMFILE 24 /* Too many open files */ |
lypinator | 0:bb348c97df44 | 198 | #undef ENOTTY |
lypinator | 0:bb348c97df44 | 199 | #define ENOTTY 25 /* Not a typewriter */ |
lypinator | 0:bb348c97df44 | 200 | #undef ETXTBSY |
lypinator | 0:bb348c97df44 | 201 | #define ETXTBSY 26 /* Text file busy */ |
lypinator | 0:bb348c97df44 | 202 | #undef EFBIG |
lypinator | 0:bb348c97df44 | 203 | #define EFBIG 27 /* File too large */ |
lypinator | 0:bb348c97df44 | 204 | #undef ENOSPC |
lypinator | 0:bb348c97df44 | 205 | #define ENOSPC 28 /* No space left on device */ |
lypinator | 0:bb348c97df44 | 206 | #undef ESPIPE |
lypinator | 0:bb348c97df44 | 207 | #define ESPIPE 29 /* Illegal seek */ |
lypinator | 0:bb348c97df44 | 208 | #undef EROFS |
lypinator | 0:bb348c97df44 | 209 | #define EROFS 30 /* Read-only file system */ |
lypinator | 0:bb348c97df44 | 210 | #undef EMLINK |
lypinator | 0:bb348c97df44 | 211 | #define EMLINK 31 /* Too many links */ |
lypinator | 0:bb348c97df44 | 212 | #undef EPIPE |
lypinator | 0:bb348c97df44 | 213 | #define EPIPE 32 /* Broken pipe */ |
lypinator | 0:bb348c97df44 | 214 | #undef EDOM |
lypinator | 0:bb348c97df44 | 215 | #define EDOM 33 /* Math argument out of domain of func */ |
lypinator | 0:bb348c97df44 | 216 | #undef ERANGE |
lypinator | 0:bb348c97df44 | 217 | #define ERANGE 34 /* Math result not representable */ |
lypinator | 0:bb348c97df44 | 218 | #undef EDEADLK |
lypinator | 0:bb348c97df44 | 219 | #define EDEADLK 35 /* Resource deadlock would occur */ |
lypinator | 0:bb348c97df44 | 220 | #undef ENAMETOOLONG |
lypinator | 0:bb348c97df44 | 221 | #define ENAMETOOLONG 36 /* File name too long */ |
lypinator | 0:bb348c97df44 | 222 | #undef ENOLCK |
lypinator | 0:bb348c97df44 | 223 | #define ENOLCK 37 /* No record locks available */ |
lypinator | 0:bb348c97df44 | 224 | #undef ENOSYS |
lypinator | 0:bb348c97df44 | 225 | #define ENOSYS 38 /* Function not implemented */ |
lypinator | 0:bb348c97df44 | 226 | #undef ENOTEMPTY |
lypinator | 0:bb348c97df44 | 227 | #define ENOTEMPTY 39 /* Directory not empty */ |
lypinator | 0:bb348c97df44 | 228 | #undef ELOOP |
lypinator | 0:bb348c97df44 | 229 | #define ELOOP 40 /* Too many symbolic links encountered */ |
lypinator | 0:bb348c97df44 | 230 | #undef EWOULDBLOCK |
lypinator | 0:bb348c97df44 | 231 | #define EWOULDBLOCK EAGAIN /* Operation would block */ |
lypinator | 0:bb348c97df44 | 232 | #undef ENOMSG |
lypinator | 0:bb348c97df44 | 233 | #define ENOMSG 42 /* No message of desired type */ |
lypinator | 0:bb348c97df44 | 234 | #undef EIDRM |
lypinator | 0:bb348c97df44 | 235 | #define EIDRM 43 /* Identifier removed */ |
lypinator | 0:bb348c97df44 | 236 | #undef ECHRNG |
lypinator | 0:bb348c97df44 | 237 | #define ECHRNG 44 /* Channel number out of range */ |
lypinator | 0:bb348c97df44 | 238 | #undef EL2NSYNC |
lypinator | 0:bb348c97df44 | 239 | #define EL2NSYNC 45 /* Level 2 not synchronized */ |
lypinator | 0:bb348c97df44 | 240 | #undef EL3HLT |
lypinator | 0:bb348c97df44 | 241 | #define EL3HLT 46 /* Level 3 halted */ |
lypinator | 0:bb348c97df44 | 242 | #undef EL3RST |
lypinator | 0:bb348c97df44 | 243 | #define EL3RST 47 /* Level 3 reset */ |
lypinator | 0:bb348c97df44 | 244 | #undef ELNRNG |
lypinator | 0:bb348c97df44 | 245 | #define ELNRNG 48 /* Link number out of range */ |
lypinator | 0:bb348c97df44 | 246 | #undef EUNATCH |
lypinator | 0:bb348c97df44 | 247 | #define EUNATCH 49 /* Protocol driver not attached */ |
lypinator | 0:bb348c97df44 | 248 | #undef ENOCSI |
lypinator | 0:bb348c97df44 | 249 | #define ENOCSI 50 /* No CSI structure available */ |
lypinator | 0:bb348c97df44 | 250 | #undef EL2HLT |
lypinator | 0:bb348c97df44 | 251 | #define EL2HLT 51 /* Level 2 halted */ |
lypinator | 0:bb348c97df44 | 252 | #undef EBADE |
lypinator | 0:bb348c97df44 | 253 | #define EBADE 52 /* Invalid exchange */ |
lypinator | 0:bb348c97df44 | 254 | #undef EBADR |
lypinator | 0:bb348c97df44 | 255 | #define EBADR 53 /* Invalid request descriptor */ |
lypinator | 0:bb348c97df44 | 256 | #undef EXFULL |
lypinator | 0:bb348c97df44 | 257 | #define EXFULL 54 /* Exchange full */ |
lypinator | 0:bb348c97df44 | 258 | #undef ENOANO |
lypinator | 0:bb348c97df44 | 259 | #define ENOANO 55 /* No anode */ |
lypinator | 0:bb348c97df44 | 260 | #undef EBADRQC |
lypinator | 0:bb348c97df44 | 261 | #define EBADRQC 56 /* Invalid request code */ |
lypinator | 0:bb348c97df44 | 262 | #undef EBADSLT |
lypinator | 0:bb348c97df44 | 263 | #define EBADSLT 57 /* Invalid slot */ |
lypinator | 0:bb348c97df44 | 264 | #undef EDEADLOCK |
lypinator | 0:bb348c97df44 | 265 | #define EDEADLOCK EDEADLK /* Resource deadlock would occur */ |
lypinator | 0:bb348c97df44 | 266 | #undef EBFONT |
lypinator | 0:bb348c97df44 | 267 | #define EBFONT 59 /* Bad font file format */ |
lypinator | 0:bb348c97df44 | 268 | #undef ENOSTR |
lypinator | 0:bb348c97df44 | 269 | #define ENOSTR 60 /* Device not a stream */ |
lypinator | 0:bb348c97df44 | 270 | #undef ENODATA |
lypinator | 0:bb348c97df44 | 271 | #define ENODATA 61 /* No data available */ |
lypinator | 0:bb348c97df44 | 272 | #undef ETIME |
lypinator | 0:bb348c97df44 | 273 | #define ETIME 62 /* Timer expired */ |
lypinator | 0:bb348c97df44 | 274 | #undef ENOSR |
lypinator | 0:bb348c97df44 | 275 | #define ENOSR 63 /* Out of streams resources */ |
lypinator | 0:bb348c97df44 | 276 | #undef ENONET |
lypinator | 0:bb348c97df44 | 277 | #define ENONET 64 /* Machine is not on the network */ |
lypinator | 0:bb348c97df44 | 278 | #undef ENOPKG |
lypinator | 0:bb348c97df44 | 279 | #define ENOPKG 65 /* Package not installed */ |
lypinator | 0:bb348c97df44 | 280 | #undef EREMOTE |
lypinator | 0:bb348c97df44 | 281 | #define EREMOTE 66 /* Object is remote */ |
lypinator | 0:bb348c97df44 | 282 | #undef ENOLINK |
lypinator | 0:bb348c97df44 | 283 | #define ENOLINK 67 /* Link has been severed */ |
lypinator | 0:bb348c97df44 | 284 | #undef EADV |
lypinator | 0:bb348c97df44 | 285 | #define EADV 68 /* Advertise error */ |
lypinator | 0:bb348c97df44 | 286 | #undef ESRMNT |
lypinator | 0:bb348c97df44 | 287 | #define ESRMNT 69 /* Srmount error */ |
lypinator | 0:bb348c97df44 | 288 | #undef ECOMM |
lypinator | 0:bb348c97df44 | 289 | #define ECOMM 70 /* Communication error on send */ |
lypinator | 0:bb348c97df44 | 290 | #undef EPROTO |
lypinator | 0:bb348c97df44 | 291 | #define EPROTO 71 /* Protocol error */ |
lypinator | 0:bb348c97df44 | 292 | #undef EMULTIHOP |
lypinator | 0:bb348c97df44 | 293 | #define EMULTIHOP 72 /* Multihop attempted */ |
lypinator | 0:bb348c97df44 | 294 | #undef EDOTDOT |
lypinator | 0:bb348c97df44 | 295 | #define EDOTDOT 73 /* RFS specific error */ |
lypinator | 0:bb348c97df44 | 296 | #undef EBADMSG |
lypinator | 0:bb348c97df44 | 297 | #define EBADMSG 74 /* Not a data message */ |
lypinator | 0:bb348c97df44 | 298 | #undef EOVERFLOW |
lypinator | 0:bb348c97df44 | 299 | #define EOVERFLOW 75 /* Value too large for defined data type */ |
lypinator | 0:bb348c97df44 | 300 | #undef ENOTUNIQ |
lypinator | 0:bb348c97df44 | 301 | #define ENOTUNIQ 76 /* Name not unique on network */ |
lypinator | 0:bb348c97df44 | 302 | #undef EBADFD |
lypinator | 0:bb348c97df44 | 303 | #define EBADFD 77 /* File descriptor in bad state */ |
lypinator | 0:bb348c97df44 | 304 | #undef EREMCHG |
lypinator | 0:bb348c97df44 | 305 | #define EREMCHG 78 /* Remote address changed */ |
lypinator | 0:bb348c97df44 | 306 | #undef ELIBACC |
lypinator | 0:bb348c97df44 | 307 | #define ELIBACC 79 /* Can not access a needed shared library */ |
lypinator | 0:bb348c97df44 | 308 | #undef ELIBBAD |
lypinator | 0:bb348c97df44 | 309 | #define ELIBBAD 80 /* Accessing a corrupted shared library */ |
lypinator | 0:bb348c97df44 | 310 | #undef ELIBSCN |
lypinator | 0:bb348c97df44 | 311 | #define ELIBSCN 81 /* .lib section in a.out corrupted */ |
lypinator | 0:bb348c97df44 | 312 | #undef ELIBMAX |
lypinator | 0:bb348c97df44 | 313 | #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ |
lypinator | 0:bb348c97df44 | 314 | #undef ELIBEXEC |
lypinator | 0:bb348c97df44 | 315 | #define ELIBEXEC 83 /* Cannot exec a shared library directly */ |
lypinator | 0:bb348c97df44 | 316 | #undef EILSEQ |
lypinator | 0:bb348c97df44 | 317 | #define EILSEQ 84 /* Illegal byte sequence */ |
lypinator | 0:bb348c97df44 | 318 | #undef ERESTART |
lypinator | 0:bb348c97df44 | 319 | #define ERESTART 85 /* Interrupted system call should be restarted */ |
lypinator | 0:bb348c97df44 | 320 | #undef ESTRPIPE |
lypinator | 0:bb348c97df44 | 321 | #define ESTRPIPE 86 /* Streams pipe error */ |
lypinator | 0:bb348c97df44 | 322 | #undef EUSERS |
lypinator | 0:bb348c97df44 | 323 | #define EUSERS 87 /* Too many users */ |
lypinator | 0:bb348c97df44 | 324 | #undef ENOTSOCK |
lypinator | 0:bb348c97df44 | 325 | #define ENOTSOCK 88 /* Socket operation on non-socket */ |
lypinator | 0:bb348c97df44 | 326 | #undef EDESTADDRREQ |
lypinator | 0:bb348c97df44 | 327 | #define EDESTADDRREQ 89 /* Destination address required */ |
lypinator | 0:bb348c97df44 | 328 | #undef EMSGSIZE |
lypinator | 0:bb348c97df44 | 329 | #define EMSGSIZE 90 /* Message too long */ |
lypinator | 0:bb348c97df44 | 330 | #undef EPROTOTYPE |
lypinator | 0:bb348c97df44 | 331 | #define EPROTOTYPE 91 /* Protocol wrong type for socket */ |
lypinator | 0:bb348c97df44 | 332 | #undef ENOPROTOOPT |
lypinator | 0:bb348c97df44 | 333 | #define ENOPROTOOPT 92 /* Protocol not available */ |
lypinator | 0:bb348c97df44 | 334 | #undef EPROTONOSUPPORT |
lypinator | 0:bb348c97df44 | 335 | #define EPROTONOSUPPORT 93 /* Protocol not supported */ |
lypinator | 0:bb348c97df44 | 336 | #undef ESOCKTNOSUPPORT |
lypinator | 0:bb348c97df44 | 337 | #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ |
lypinator | 0:bb348c97df44 | 338 | #undef EOPNOTSUPP |
lypinator | 0:bb348c97df44 | 339 | #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ |
lypinator | 0:bb348c97df44 | 340 | #undef EPFNOSUPPORT |
lypinator | 0:bb348c97df44 | 341 | #define EPFNOSUPPORT 96 /* Protocol family not supported */ |
lypinator | 0:bb348c97df44 | 342 | #undef EAFNOSUPPORT |
lypinator | 0:bb348c97df44 | 343 | #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ |
lypinator | 0:bb348c97df44 | 344 | #undef EADDRINUSE |
lypinator | 0:bb348c97df44 | 345 | #define EADDRINUSE 98 /* Address already in use */ |
lypinator | 0:bb348c97df44 | 346 | #undef EADDRNOTAVAIL |
lypinator | 0:bb348c97df44 | 347 | #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ |
lypinator | 0:bb348c97df44 | 348 | #undef ENETDOWN |
lypinator | 0:bb348c97df44 | 349 | #define ENETDOWN 100 /* Network is down */ |
lypinator | 0:bb348c97df44 | 350 | #undef ENETUNREACH |
lypinator | 0:bb348c97df44 | 351 | #define ENETUNREACH 101 /* Network is unreachable */ |
lypinator | 0:bb348c97df44 | 352 | #undef ENETRESET |
lypinator | 0:bb348c97df44 | 353 | #define ENETRESET 102 /* Network dropped connection because of reset */ |
lypinator | 0:bb348c97df44 | 354 | #undef ECONNABORTED |
lypinator | 0:bb348c97df44 | 355 | #define ECONNABORTED 103 /* Software caused connection abort */ |
lypinator | 0:bb348c97df44 | 356 | #undef ECONNRESET |
lypinator | 0:bb348c97df44 | 357 | #define ECONNRESET 104 /* Connection reset by peer */ |
lypinator | 0:bb348c97df44 | 358 | #undef ENOBUFS |
lypinator | 0:bb348c97df44 | 359 | #define ENOBUFS 105 /* No buffer space available */ |
lypinator | 0:bb348c97df44 | 360 | #undef EISCONN |
lypinator | 0:bb348c97df44 | 361 | #define EISCONN 106 /* Transport endpoint is already connected */ |
lypinator | 0:bb348c97df44 | 362 | #undef ENOTCONN |
lypinator | 0:bb348c97df44 | 363 | #define ENOTCONN 107 /* Transport endpoint is not connected */ |
lypinator | 0:bb348c97df44 | 364 | #undef ESHUTDOWN |
lypinator | 0:bb348c97df44 | 365 | #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ |
lypinator | 0:bb348c97df44 | 366 | #undef ETOOMANYREFS |
lypinator | 0:bb348c97df44 | 367 | #define ETOOMANYREFS 109 /* Too many references: cannot splice */ |
lypinator | 0:bb348c97df44 | 368 | #undef ETIMEDOUT |
lypinator | 0:bb348c97df44 | 369 | #define ETIMEDOUT 110 /* Connection timed out */ |
lypinator | 0:bb348c97df44 | 370 | #undef ECONNREFUSED |
lypinator | 0:bb348c97df44 | 371 | #define ECONNREFUSED 111 /* Connection refused */ |
lypinator | 0:bb348c97df44 | 372 | #undef EHOSTDOWN |
lypinator | 0:bb348c97df44 | 373 | #define EHOSTDOWN 112 /* Host is down */ |
lypinator | 0:bb348c97df44 | 374 | #undef EHOSTUNREACH |
lypinator | 0:bb348c97df44 | 375 | #define EHOSTUNREACH 113 /* No route to host */ |
lypinator | 0:bb348c97df44 | 376 | #undef EALREADY |
lypinator | 0:bb348c97df44 | 377 | #define EALREADY 114 /* Operation already in progress */ |
lypinator | 0:bb348c97df44 | 378 | #undef EINPROGRESS |
lypinator | 0:bb348c97df44 | 379 | #define EINPROGRESS 115 /* Operation now in progress */ |
lypinator | 0:bb348c97df44 | 380 | #undef ESTALE |
lypinator | 0:bb348c97df44 | 381 | #define ESTALE 116 /* Stale NFS file handle */ |
lypinator | 0:bb348c97df44 | 382 | #undef EUCLEAN |
lypinator | 0:bb348c97df44 | 383 | #define EUCLEAN 117 /* Structure needs cleaning */ |
lypinator | 0:bb348c97df44 | 384 | #undef ENOTNAM |
lypinator | 0:bb348c97df44 | 385 | #define ENOTNAM 118 /* Not a XENIX named type file */ |
lypinator | 0:bb348c97df44 | 386 | #undef ENAVAIL |
lypinator | 0:bb348c97df44 | 387 | #define ENAVAIL 119 /* No XENIX semaphores available */ |
lypinator | 0:bb348c97df44 | 388 | #undef EISNAM |
lypinator | 0:bb348c97df44 | 389 | #define EISNAM 120 /* Is a named type file */ |
lypinator | 0:bb348c97df44 | 390 | #undef EREMOTEIO |
lypinator | 0:bb348c97df44 | 391 | #define EREMOTEIO 121 /* Remote I/O error */ |
lypinator | 0:bb348c97df44 | 392 | #undef EDQUOT |
lypinator | 0:bb348c97df44 | 393 | #define EDQUOT 122 /* Quota exceeded */ |
lypinator | 0:bb348c97df44 | 394 | #undef ENOMEDIUM |
lypinator | 0:bb348c97df44 | 395 | #define ENOMEDIUM 123 /* No medium found */ |
lypinator | 0:bb348c97df44 | 396 | #undef EMEDIUMTYPE |
lypinator | 0:bb348c97df44 | 397 | #define EMEDIUMTYPE 124 /* Wrong medium type */ |
lypinator | 0:bb348c97df44 | 398 | #undef ECANCELED |
lypinator | 0:bb348c97df44 | 399 | #define ECANCELED 125 /* Operation Canceled */ |
lypinator | 0:bb348c97df44 | 400 | #undef ENOKEY |
lypinator | 0:bb348c97df44 | 401 | #define ENOKEY 126 /* Required key not available */ |
lypinator | 0:bb348c97df44 | 402 | #undef EKEYEXPIRED |
lypinator | 0:bb348c97df44 | 403 | #define EKEYEXPIRED 127 /* Key has expired */ |
lypinator | 0:bb348c97df44 | 404 | #undef EKEYREVOKED |
lypinator | 0:bb348c97df44 | 405 | #define EKEYREVOKED 128 /* Key has been revoked */ |
lypinator | 0:bb348c97df44 | 406 | #undef EKEYREJECTED |
lypinator | 0:bb348c97df44 | 407 | #define EKEYREJECTED 129 /* Key was rejected by service */ |
lypinator | 0:bb348c97df44 | 408 | #undef EOWNERDEAD |
lypinator | 0:bb348c97df44 | 409 | #define EOWNERDEAD 130 /* Owner died */ |
lypinator | 0:bb348c97df44 | 410 | #undef ENOTRECOVERABLE |
lypinator | 0:bb348c97df44 | 411 | #define ENOTRECOVERABLE 131 /* State not recoverable */ |
lypinator | 0:bb348c97df44 | 412 | |
lypinator | 0:bb348c97df44 | 413 | /* Missing stat.h defines. |
lypinator | 0:bb348c97df44 | 414 | * The following are sys/stat.h definitions not currently present in the ARMCC |
lypinator | 0:bb348c97df44 | 415 | * errno.h. Note, ARMCC errno.h defines some symbol values differing from |
lypinator | 0:bb348c97df44 | 416 | * GCC_ARM/IAR/standard POSIX definitions. Guard against this and future |
lypinator | 0:bb348c97df44 | 417 | * changes by changing the symbol definition for filesystem use. |
lypinator | 0:bb348c97df44 | 418 | */ |
lypinator | 0:bb348c97df44 | 419 | #define _IFMT 0170000 //< type of file |
lypinator | 0:bb348c97df44 | 420 | #define _IFSOCK 0140000 //< socket |
lypinator | 0:bb348c97df44 | 421 | #define _IFLNK 0120000 //< symbolic link |
lypinator | 0:bb348c97df44 | 422 | #define _IFREG 0100000 //< regular |
lypinator | 0:bb348c97df44 | 423 | #define _IFBLK 0060000 //< block special |
lypinator | 0:bb348c97df44 | 424 | #define _IFDIR 0040000 //< directory |
lypinator | 0:bb348c97df44 | 425 | #define _IFCHR 0020000 //< character special |
lypinator | 0:bb348c97df44 | 426 | #define _IFIFO 0010000 //< fifo special |
lypinator | 0:bb348c97df44 | 427 | |
lypinator | 0:bb348c97df44 | 428 | #define S_IFMT _IFMT //< type of file |
lypinator | 0:bb348c97df44 | 429 | #define S_IFSOCK _IFSOCK //< socket |
lypinator | 0:bb348c97df44 | 430 | #define S_IFLNK _IFLNK //< symbolic link |
lypinator | 0:bb348c97df44 | 431 | #define S_IFREG _IFREG //< regular |
lypinator | 0:bb348c97df44 | 432 | #define S_IFBLK _IFBLK //< block special |
lypinator | 0:bb348c97df44 | 433 | #define S_IFDIR _IFDIR //< directory |
lypinator | 0:bb348c97df44 | 434 | #define S_IFCHR _IFCHR //< character special |
lypinator | 0:bb348c97df44 | 435 | #define S_IFIFO _IFIFO //< fifo special |
lypinator | 0:bb348c97df44 | 436 | |
lypinator | 0:bb348c97df44 | 437 | #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) |
lypinator | 0:bb348c97df44 | 438 | #define S_IRUSR 0000400 ///< read permission, owner |
lypinator | 0:bb348c97df44 | 439 | #define S_IWUSR 0000200 ///< write permission, owner |
lypinator | 0:bb348c97df44 | 440 | #define S_IXUSR 0000100 ///< execute/search permission, owner |
lypinator | 0:bb348c97df44 | 441 | #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) |
lypinator | 0:bb348c97df44 | 442 | #define S_IRGRP 0000040 ///< read permission, group |
lypinator | 0:bb348c97df44 | 443 | #define S_IWGRP 0000020 ///< write permission, group |
lypinator | 0:bb348c97df44 | 444 | #define S_IXGRP 0000010 ///< execute/search permission, group |
lypinator | 0:bb348c97df44 | 445 | #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) |
lypinator | 0:bb348c97df44 | 446 | #define S_IROTH 0000004 ///< read permission, other |
lypinator | 0:bb348c97df44 | 447 | #define S_IWOTH 0000002 ///< write permission, other |
lypinator | 0:bb348c97df44 | 448 | #define S_IXOTH 0000001 ///< execute/search permission, other |
lypinator | 0:bb348c97df44 | 449 | |
lypinator | 0:bb348c97df44 | 450 | /* Refer to sys/stat standard |
lypinator | 0:bb348c97df44 | 451 | * Note: Not all fields may be supported by the underlying filesystem |
lypinator | 0:bb348c97df44 | 452 | */ |
lypinator | 0:bb348c97df44 | 453 | struct stat { |
lypinator | 0:bb348c97df44 | 454 | dev_t st_dev; ///< Device ID containing file |
lypinator | 0:bb348c97df44 | 455 | ino_t st_ino; ///< File serial number |
lypinator | 0:bb348c97df44 | 456 | mode_t st_mode; ///< Mode of file |
lypinator | 0:bb348c97df44 | 457 | nlink_t st_nlink; ///< Number of links to file |
lypinator | 0:bb348c97df44 | 458 | |
lypinator | 0:bb348c97df44 | 459 | uid_t st_uid; ///< User ID |
lypinator | 0:bb348c97df44 | 460 | gid_t st_gid; ///< Group ID |
lypinator | 0:bb348c97df44 | 461 | |
lypinator | 0:bb348c97df44 | 462 | off_t st_size; ///< Size of file in bytes |
lypinator | 0:bb348c97df44 | 463 | |
lypinator | 0:bb348c97df44 | 464 | time_t st_atime; ///< Time of last access |
lypinator | 0:bb348c97df44 | 465 | time_t st_mtime; ///< Time of last data modification |
lypinator | 0:bb348c97df44 | 466 | time_t st_ctime; ///< Time of last status change |
lypinator | 0:bb348c97df44 | 467 | }; |
lypinator | 0:bb348c97df44 | 468 | |
lypinator | 0:bb348c97df44 | 469 | struct statvfs { |
lypinator | 0:bb348c97df44 | 470 | unsigned long f_bsize; ///< Filesystem block size |
lypinator | 0:bb348c97df44 | 471 | unsigned long f_frsize; ///< Fragment size (block size) |
lypinator | 0:bb348c97df44 | 472 | |
lypinator | 0:bb348c97df44 | 473 | fsblkcnt_t f_blocks; ///< Number of blocks |
lypinator | 0:bb348c97df44 | 474 | fsblkcnt_t f_bfree; ///< Number of free blocks |
lypinator | 0:bb348c97df44 | 475 | fsblkcnt_t f_bavail; ///< Number of free blocks for unprivileged users |
lypinator | 0:bb348c97df44 | 476 | |
lypinator | 0:bb348c97df44 | 477 | unsigned long f_fsid; ///< Filesystem ID |
lypinator | 0:bb348c97df44 | 478 | |
lypinator | 0:bb348c97df44 | 479 | unsigned long f_namemax; ///< Maximum filename length |
lypinator | 0:bb348c97df44 | 480 | }; |
lypinator | 0:bb348c97df44 | 481 | |
lypinator | 0:bb348c97df44 | 482 | /* The following are dirent.h definitions are declared here to guarantee |
lypinator | 0:bb348c97df44 | 483 | * consistency where structure may be different with different toolchains |
lypinator | 0:bb348c97df44 | 484 | */ |
lypinator | 0:bb348c97df44 | 485 | struct dirent { |
lypinator | 0:bb348c97df44 | 486 | char d_name[NAME_MAX + 1]; ///< Name of file |
lypinator | 0:bb348c97df44 | 487 | uint8_t d_type; ///< Type of file |
lypinator | 0:bb348c97df44 | 488 | }; |
lypinator | 0:bb348c97df44 | 489 | |
lypinator | 0:bb348c97df44 | 490 | enum { |
lypinator | 0:bb348c97df44 | 491 | DT_UNKNOWN, ///< The file type could not be determined. |
lypinator | 0:bb348c97df44 | 492 | DT_FIFO, ///< This is a named pipe (FIFO). |
lypinator | 0:bb348c97df44 | 493 | DT_CHR, ///< This is a character device. |
lypinator | 0:bb348c97df44 | 494 | DT_DIR, ///< This is a directory. |
lypinator | 0:bb348c97df44 | 495 | DT_BLK, ///< This is a block device. |
lypinator | 0:bb348c97df44 | 496 | DT_REG, ///< This is a regular file. |
lypinator | 0:bb348c97df44 | 497 | DT_LNK, ///< This is a symbolic link. |
lypinator | 0:bb348c97df44 | 498 | DT_SOCK, ///< This is a UNIX domain socket. |
lypinator | 0:bb348c97df44 | 499 | }; |
lypinator | 0:bb348c97df44 | 500 | |
lypinator | 0:bb348c97df44 | 501 | /* fcntl.h defines */ |
lypinator | 0:bb348c97df44 | 502 | #define F_GETFL 3 |
lypinator | 0:bb348c97df44 | 503 | #define F_SETFL 4 |
lypinator | 0:bb348c97df44 | 504 | |
lypinator | 0:bb348c97df44 | 505 | struct pollfd { |
lypinator | 0:bb348c97df44 | 506 | int fd; |
lypinator | 0:bb348c97df44 | 507 | short events; |
lypinator | 0:bb348c97df44 | 508 | short revents; |
lypinator | 0:bb348c97df44 | 509 | }; |
lypinator | 0:bb348c97df44 | 510 | |
lypinator | 0:bb348c97df44 | 511 | /* POSIX-compatible I/O functions */ |
lypinator | 0:bb348c97df44 | 512 | #if __cplusplus |
lypinator | 0:bb348c97df44 | 513 | extern "C" { |
lypinator | 0:bb348c97df44 | 514 | #endif |
lypinator | 0:bb348c97df44 | 515 | int open(const char *path, int oflag, ...); |
lypinator | 0:bb348c97df44 | 516 | #ifndef __IAR_SYSTEMS_ICC__ /* IAR provides fdopen itself */ |
lypinator | 0:bb348c97df44 | 517 | #if __cplusplus |
lypinator | 0:bb348c97df44 | 518 | std::FILE *fdopen(int fildes, const char *mode); |
lypinator | 0:bb348c97df44 | 519 | #else |
lypinator | 0:bb348c97df44 | 520 | FILE *fdopen(int fildes, const char *mode); |
lypinator | 0:bb348c97df44 | 521 | #endif |
lypinator | 0:bb348c97df44 | 522 | #endif |
lypinator | 0:bb348c97df44 | 523 | ssize_t write(int fildes, const void *buf, size_t nbyte); |
lypinator | 0:bb348c97df44 | 524 | ssize_t read(int fildes, void *buf, size_t nbyte); |
lypinator | 0:bb348c97df44 | 525 | off_t lseek(int fildes, off_t offset, int whence); |
lypinator | 0:bb348c97df44 | 526 | int isatty(int fildes); |
lypinator | 0:bb348c97df44 | 527 | int fsync(int fildes); |
lypinator | 0:bb348c97df44 | 528 | int fstat(int fildes, struct stat *st); |
lypinator | 0:bb348c97df44 | 529 | int fcntl(int fildes, int cmd, ...); |
lypinator | 0:bb348c97df44 | 530 | int poll(struct pollfd fds[], nfds_t nfds, int timeout); |
lypinator | 0:bb348c97df44 | 531 | int close(int fildes); |
lypinator | 0:bb348c97df44 | 532 | int stat(const char *path, struct stat *st); |
lypinator | 0:bb348c97df44 | 533 | int statvfs(const char *path, struct statvfs *buf); |
lypinator | 0:bb348c97df44 | 534 | DIR *opendir(const char *); |
lypinator | 0:bb348c97df44 | 535 | struct dirent *readdir(DIR *); |
lypinator | 0:bb348c97df44 | 536 | int closedir(DIR *); |
lypinator | 0:bb348c97df44 | 537 | void rewinddir(DIR *); |
lypinator | 0:bb348c97df44 | 538 | long telldir(DIR *); |
lypinator | 0:bb348c97df44 | 539 | void seekdir(DIR *, long); |
lypinator | 0:bb348c97df44 | 540 | int mkdir(const char *name, mode_t n); |
lypinator | 0:bb348c97df44 | 541 | #if __cplusplus |
lypinator | 0:bb348c97df44 | 542 | }; // extern "C" |
lypinator | 0:bb348c97df44 | 543 | |
lypinator | 0:bb348c97df44 | 544 | namespace mbed { |
lypinator | 0:bb348c97df44 | 545 | |
lypinator | 0:bb348c97df44 | 546 | /** This call is an analogue to POSIX fdopen(). |
lypinator | 0:bb348c97df44 | 547 | * |
lypinator | 0:bb348c97df44 | 548 | * It associates a C stream to an already-opened FileHandle, to allow you to |
lypinator | 0:bb348c97df44 | 549 | * use C printf/scanf/fwrite etc. The provided FileHandle must remain open - |
lypinator | 0:bb348c97df44 | 550 | * it will be closed by the C library when fclose(FILE) is called. |
lypinator | 0:bb348c97df44 | 551 | * |
lypinator | 0:bb348c97df44 | 552 | * The net effect is fdopen(bind_to_fd(fh), mode), with error handling. |
lypinator | 0:bb348c97df44 | 553 | * |
lypinator | 0:bb348c97df44 | 554 | * @param fh a pointer to an opened FileHandle |
lypinator | 0:bb348c97df44 | 555 | * @param mode operation upon the file descriptor, e.g., "w+" |
lypinator | 0:bb348c97df44 | 556 | * |
lypinator | 0:bb348c97df44 | 557 | * @returns a pointer to FILE |
lypinator | 0:bb348c97df44 | 558 | */ |
lypinator | 0:bb348c97df44 | 559 | std::FILE *fdopen(mbed::FileHandle *fh, const char *mode); |
lypinator | 0:bb348c97df44 | 560 | |
lypinator | 0:bb348c97df44 | 561 | /** Bind an mbed FileHandle to a POSIX file descriptor |
lypinator | 0:bb348c97df44 | 562 | * |
lypinator | 0:bb348c97df44 | 563 | * This is similar to fdopen, but only operating at the POSIX layer - it |
lypinator | 0:bb348c97df44 | 564 | * associates a POSIX integer file descriptor with a FileHandle, to allow you |
lypinator | 0:bb348c97df44 | 565 | * to use POSIX read/write calls etc. The provided FileHandle must remain open - |
lypinator | 0:bb348c97df44 | 566 | * it will be closed when close(int) is called. |
lypinator | 0:bb348c97df44 | 567 | * |
lypinator | 0:bb348c97df44 | 568 | * @param fh a pointer to an opened FileHandle |
lypinator | 0:bb348c97df44 | 569 | * |
lypinator | 0:bb348c97df44 | 570 | * @return an integer file descriptor, or negative if no descriptors available |
lypinator | 0:bb348c97df44 | 571 | */ |
lypinator | 0:bb348c97df44 | 572 | int bind_to_fd(mbed::FileHandle *fh); |
lypinator | 0:bb348c97df44 | 573 | |
lypinator | 0:bb348c97df44 | 574 | } // namespace mbed |
lypinator | 0:bb348c97df44 | 575 | |
lypinator | 0:bb348c97df44 | 576 | #endif // __cplusplus |
lypinator | 0:bb348c97df44 | 577 | |
lypinator | 0:bb348c97df44 | 578 | /**@}*/ |
lypinator | 0:bb348c97df44 | 579 | |
lypinator | 0:bb348c97df44 | 580 | /**@}*/ |
lypinator | 0:bb348c97df44 | 581 | |
lypinator | 0:bb348c97df44 | 582 | #endif /* RETARGET_H */ |