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