Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed_retarget.h
00001 /* 00002 * mbed Microcontroller Library 00003 * Copyright (c) 2006-2016 ARM Limited 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 */ 00018 00019 #ifndef RETARGET_H 00020 #define RETARGET_H 00021 00022 #if __cplusplus 00023 #include <cstdio> 00024 #else 00025 #include <stdio.h> 00026 #endif //__cplusplus 00027 #include <stdint.h> 00028 #include <stddef.h> 00029 00030 /* We can get the following standard types from sys/types for gcc, but we 00031 * need to define the types ourselves for the other compilers that normally 00032 * target embedded systems */ 00033 typedef signed int ssize_t; ///< Signed size type, usually encodes negative errors 00034 typedef signed long off_t; ///< Offset in a data stream 00035 typedef unsigned int nfds_t; ///< Number of file descriptors 00036 typedef unsigned long long fsblkcnt_t; ///< Count of file system blocks 00037 #if defined(__ARMCC_VERSION) || !defined(__GNUC__) 00038 typedef unsigned int mode_t; ///< Mode for opening files 00039 typedef unsigned int dev_t; ///< Device ID type 00040 typedef unsigned long ino_t; ///< File serial number 00041 typedef unsigned int nlink_t; ///< Number of links to a file 00042 typedef unsigned int uid_t; ///< User ID 00043 typedef unsigned int gid_t; ///< Group ID 00044 #endif 00045 00046 #define O_RDONLY 0 ///< Open for reading 00047 #define O_WRONLY 1 ///< Open for writing 00048 #define O_RDWR 2 ///< Open for reading and writing 00049 #define O_CREAT 0x0200 ///< Create file if it does not exist 00050 #define O_TRUNC 0x0400 ///< Truncate file to zero length 00051 #define O_EXCL 0x0800 ///< Fail if file exists 00052 #define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write 00053 #define O_BINARY 0x8000 ///< Open file in binary mode 00054 00055 #define NAME_MAX 255 ///< Maximum size of a name in a file path 00056 00057 #define STDIN_FILENO 0 00058 #define STDOUT_FILENO 1 00059 #define STDERR_FILENO 2 00060 00061 #include <time.h> 00062 00063 /** \addtogroup platform */ 00064 /** @{*/ 00065 /** 00066 * \defgroup platform_retarget Retarget functions 00067 * @{ 00068 */ 00069 00070 /* DIR declarations must also be here */ 00071 #if __cplusplus 00072 namespace mbed { 00073 00074 class FileHandle; 00075 class DirHandle; 00076 00077 /** Targets may implement this to change stdin, stdout, stderr. 00078 * 00079 * If the application hasn't provided mbed_override_console, this is called 00080 * to give the target a chance to specify a FileHandle for the console. 00081 * 00082 * If this is not provided or returns NULL, the console will be: 00083 * - UARTSerial if configuration option "platform.stdio-buffered-serial" is 00084 * true and the target has DEVICE_SERIAL; 00085 * - Raw HAL serial via serial_getc and serial_putc if 00086 * "platform.stdio-buffered-serial" is false and the target has DEVICE_SERIAL; 00087 * - stdout/stderr will be a sink and stdin will input a stream of 0s if the 00088 * target does not have DEVICE_SERIAL. 00089 * 00090 * @param fd file descriptor - STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO 00091 * @return pointer to FileHandle to override normal stream otherwise NULL 00092 */ 00093 FileHandle* mbed_target_override_console(int fd); 00094 00095 /** Applications may implement this to change stdin, stdout, stderr. 00096 * 00097 * This hook gives the application a chance to specify a custom FileHandle 00098 * for the console. 00099 * 00100 * If this is not provided or returns NULL, the console will be specified 00101 * by mbed_target_override_console, else will default to serial - see 00102 * mbed_target_override_console for more details. 00103 * 00104 * Example: 00105 * @code 00106 * FileHandle* mbed::mbed_override_console(int) { 00107 * static UARTSerial my_serial(D0, D1); 00108 * return &my_serial; 00109 * } 00110 * @endcode 00111 00112 * @param fd file descriptor - STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO 00113 * @return pointer to FileHandle to override normal stream otherwise NULL 00114 */ 00115 FileHandle* mbed_override_console(int fd); 00116 00117 } 00118 00119 typedef mbed::DirHandle DIR; 00120 #else 00121 typedef struct Dir DIR; 00122 #endif 00123 00124 /* The intent of this section is to unify the errno error values to match 00125 * the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is 00126 * necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some 00127 * symbol definitions used by the POSIX filesystem API to return errno codes. 00128 * Note also that ARMCC errno.h defines some symbol values differently from 00129 * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against 00130 * this and future changes by changing the symbol definition as shown below. 00131 */ 00132 #undef EPERM 00133 #define EPERM 1 /* Operation not permitted */ 00134 #undef ENOENT 00135 #define ENOENT 2 /* No such file or directory */ 00136 #undef ESRCH 00137 #define ESRCH 3 /* No such process */ 00138 #undef EINTR 00139 #define EINTR 4 /* Interrupted system call */ 00140 #undef EIO 00141 #define EIO 5 /* I/O error */ 00142 #undef ENXIO 00143 #define ENXIO 6 /* No such device or address */ 00144 #undef E2BIG 00145 #define E2BIG 7 /* Argument list too long */ 00146 #undef ENOEXEC 00147 #define ENOEXEC 8 /* Exec format error */ 00148 #undef EBADF 00149 #define EBADF 9 /* Bad file number */ 00150 #undef ECHILD 00151 #define ECHILD 10 /* No child processes */ 00152 #undef EAGAIN 00153 #define EAGAIN 11 /* Try again */ 00154 #undef ENOMEM 00155 #define ENOMEM 12 /* Out of memory */ 00156 #undef EACCES 00157 #define EACCES 13 /* Permission denied */ 00158 #undef EFAULT 00159 #define EFAULT 14 /* Bad address */ 00160 #undef ENOTBLK 00161 #define ENOTBLK 15 /* Block device required */ 00162 #undef EBUSY 00163 #define EBUSY 16 /* Device or resource busy */ 00164 #undef EEXIST 00165 #define EEXIST 17 /* File exists */ 00166 #undef EXDEV 00167 #define EXDEV 18 /* Cross-device link */ 00168 #undef ENODEV 00169 #define ENODEV 19 /* No such device */ 00170 #undef ENOTDIR 00171 #define ENOTDIR 20 /* Not a directory */ 00172 #undef EISDIR 00173 #define EISDIR 21 /* Is a directory */ 00174 #undef EINVAL 00175 #define EINVAL 22 /* Invalid argument */ 00176 #undef ENFILE 00177 #define ENFILE 23 /* File table overflow */ 00178 #undef EMFILE 00179 #define EMFILE 24 /* Too many open files */ 00180 #undef ENOTTY 00181 #define ENOTTY 25 /* Not a typewriter */ 00182 #undef ETXTBSY 00183 #define ETXTBSY 26 /* Text file busy */ 00184 #undef EFBIG 00185 #define EFBIG 27 /* File too large */ 00186 #undef ENOSPC 00187 #define ENOSPC 28 /* No space left on device */ 00188 #undef ESPIPE 00189 #define ESPIPE 29 /* Illegal seek */ 00190 #undef EROFS 00191 #define EROFS 30 /* Read-only file system */ 00192 #undef EMLINK 00193 #define EMLINK 31 /* Too many links */ 00194 #undef EPIPE 00195 #define EPIPE 32 /* Broken pipe */ 00196 #undef EDOM 00197 #define EDOM 33 /* Math argument out of domain of func */ 00198 #undef ERANGE 00199 #define ERANGE 34 /* Math result not representable */ 00200 #undef EDEADLK 00201 #define EDEADLK 35 /* Resource deadlock would occur */ 00202 #undef ENAMETOOLONG 00203 #define ENAMETOOLONG 36 /* File name too long */ 00204 #undef ENOLCK 00205 #define ENOLCK 37 /* No record locks available */ 00206 #undef ENOSYS 00207 #define ENOSYS 38 /* Function not implemented */ 00208 #undef ENOTEMPTY 00209 #define ENOTEMPTY 39 /* Directory not empty */ 00210 #undef ELOOP 00211 #define ELOOP 40 /* Too many symbolic links encountered */ 00212 #undef EWOULDBLOCK 00213 #define EWOULDBLOCK EAGAIN /* Operation would block */ 00214 #undef ENOMSG 00215 #define ENOMSG 42 /* No message of desired type */ 00216 #undef EIDRM 00217 #define EIDRM 43 /* Identifier removed */ 00218 #undef ECHRNG 00219 #define ECHRNG 44 /* Channel number out of range */ 00220 #undef EL2NSYNC 00221 #define EL2NSYNC 45 /* Level 2 not synchronized */ 00222 #undef EL3HLT 00223 #define EL3HLT 46 /* Level 3 halted */ 00224 #undef EL3RST 00225 #define EL3RST 47 /* Level 3 reset */ 00226 #undef ELNRNG 00227 #define ELNRNG 48 /* Link number out of range */ 00228 #undef EUNATCH 00229 #define EUNATCH 49 /* Protocol driver not attached */ 00230 #undef ENOCSI 00231 #define ENOCSI 50 /* No CSI structure available */ 00232 #undef EL2HLT 00233 #define EL2HLT 51 /* Level 2 halted */ 00234 #undef EBADE 00235 #define EBADE 52 /* Invalid exchange */ 00236 #undef EBADR 00237 #define EBADR 53 /* Invalid request descriptor */ 00238 #undef EXFULL 00239 #define EXFULL 54 /* Exchange full */ 00240 #undef ENOANO 00241 #define ENOANO 55 /* No anode */ 00242 #undef EBADRQC 00243 #define EBADRQC 56 /* Invalid request code */ 00244 #undef EBADSLT 00245 #define EBADSLT 57 /* Invalid slot */ 00246 #undef EDEADLOCK 00247 #define EDEADLOCK EDEADLK /* Resource deadlock would occur */ 00248 #undef EBFONT 00249 #define EBFONT 59 /* Bad font file format */ 00250 #undef ENOSTR 00251 #define ENOSTR 60 /* Device not a stream */ 00252 #undef ENODATA 00253 #define ENODATA 61 /* No data available */ 00254 #undef ETIME 00255 #define ETIME 62 /* Timer expired */ 00256 #undef ENOSR 00257 #define ENOSR 63 /* Out of streams resources */ 00258 #undef ENONET 00259 #define ENONET 64 /* Machine is not on the network */ 00260 #undef ENOPKG 00261 #define ENOPKG 65 /* Package not installed */ 00262 #undef EREMOTE 00263 #define EREMOTE 66 /* Object is remote */ 00264 #undef ENOLINK 00265 #define ENOLINK 67 /* Link has been severed */ 00266 #undef EADV 00267 #define EADV 68 /* Advertise error */ 00268 #undef ESRMNT 00269 #define ESRMNT 69 /* Srmount error */ 00270 #undef ECOMM 00271 #define ECOMM 70 /* Communication error on send */ 00272 #undef EPROTO 00273 #define EPROTO 71 /* Protocol error */ 00274 #undef EMULTIHOP 00275 #define EMULTIHOP 72 /* Multihop attempted */ 00276 #undef EDOTDOT 00277 #define EDOTDOT 73 /* RFS specific error */ 00278 #undef EBADMSG 00279 #define EBADMSG 74 /* Not a data message */ 00280 #undef EOVERFLOW 00281 #define EOVERFLOW 75 /* Value too large for defined data type */ 00282 #undef ENOTUNIQ 00283 #define ENOTUNIQ 76 /* Name not unique on network */ 00284 #undef EBADFD 00285 #define EBADFD 77 /* File descriptor in bad state */ 00286 #undef EREMCHG 00287 #define EREMCHG 78 /* Remote address changed */ 00288 #undef ELIBACC 00289 #define ELIBACC 79 /* Can not access a needed shared library */ 00290 #undef ELIBBAD 00291 #define ELIBBAD 80 /* Accessing a corrupted shared library */ 00292 #undef ELIBSCN 00293 #define ELIBSCN 81 /* .lib section in a.out corrupted */ 00294 #undef ELIBMAX 00295 #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ 00296 #undef ELIBEXEC 00297 #define ELIBEXEC 83 /* Cannot exec a shared library directly */ 00298 #undef EILSEQ 00299 #define EILSEQ 84 /* Illegal byte sequence */ 00300 #undef ERESTART 00301 #define ERESTART 85 /* Interrupted system call should be restarted */ 00302 #undef ESTRPIPE 00303 #define ESTRPIPE 86 /* Streams pipe error */ 00304 #undef EUSERS 00305 #define EUSERS 87 /* Too many users */ 00306 #undef ENOTSOCK 00307 #define ENOTSOCK 88 /* Socket operation on non-socket */ 00308 #undef EDESTADDRREQ 00309 #define EDESTADDRREQ 89 /* Destination address required */ 00310 #undef EMSGSIZE 00311 #define EMSGSIZE 90 /* Message too long */ 00312 #undef EPROTOTYPE 00313 #define EPROTOTYPE 91 /* Protocol wrong type for socket */ 00314 #undef ENOPROTOOPT 00315 #define ENOPROTOOPT 92 /* Protocol not available */ 00316 #undef EPROTONOSUPPORT 00317 #define EPROTONOSUPPORT 93 /* Protocol not supported */ 00318 #undef ESOCKTNOSUPPORT 00319 #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ 00320 #undef EOPNOTSUPP 00321 #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 00322 #undef EPFNOSUPPORT 00323 #define EPFNOSUPPORT 96 /* Protocol family not supported */ 00324 #undef EAFNOSUPPORT 00325 #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ 00326 #undef EADDRINUSE 00327 #define EADDRINUSE 98 /* Address already in use */ 00328 #undef EADDRNOTAVAIL 00329 #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ 00330 #undef ENETDOWN 00331 #define ENETDOWN 100 /* Network is down */ 00332 #undef ENETUNREACH 00333 #define ENETUNREACH 101 /* Network is unreachable */ 00334 #undef ENETRESET 00335 #define ENETRESET 102 /* Network dropped connection because of reset */ 00336 #undef ECONNABORTED 00337 #define ECONNABORTED 103 /* Software caused connection abort */ 00338 #undef ECONNRESET 00339 #define ECONNRESET 104 /* Connection reset by peer */ 00340 #undef ENOBUFS 00341 #define ENOBUFS 105 /* No buffer space available */ 00342 #undef EISCONN 00343 #define EISCONN 106 /* Transport endpoint is already connected */ 00344 #undef ENOTCONN 00345 #define ENOTCONN 107 /* Transport endpoint is not connected */ 00346 #undef ESHUTDOWN 00347 #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ 00348 #undef ETOOMANYREFS 00349 #define ETOOMANYREFS 109 /* Too many references: cannot splice */ 00350 #undef ETIMEDOUT 00351 #define ETIMEDOUT 110 /* Connection timed out */ 00352 #undef ECONNREFUSED 00353 #define ECONNREFUSED 111 /* Connection refused */ 00354 #undef EHOSTDOWN 00355 #define EHOSTDOWN 112 /* Host is down */ 00356 #undef EHOSTUNREACH 00357 #define EHOSTUNREACH 113 /* No route to host */ 00358 #undef EALREADY 00359 #define EALREADY 114 /* Operation already in progress */ 00360 #undef EINPROGRESS 00361 #define EINPROGRESS 115 /* Operation now in progress */ 00362 #undef ESTALE 00363 #define ESTALE 116 /* Stale NFS file handle */ 00364 #undef EUCLEAN 00365 #define EUCLEAN 117 /* Structure needs cleaning */ 00366 #undef ENOTNAM 00367 #define ENOTNAM 118 /* Not a XENIX named type file */ 00368 #undef ENAVAIL 00369 #define ENAVAIL 119 /* No XENIX semaphores available */ 00370 #undef EISNAM 00371 #define EISNAM 120 /* Is a named type file */ 00372 #undef EREMOTEIO 00373 #define EREMOTEIO 121 /* Remote I/O error */ 00374 #undef EDQUOT 00375 #define EDQUOT 122 /* Quota exceeded */ 00376 #undef ENOMEDIUM 00377 #define ENOMEDIUM 123 /* No medium found */ 00378 #undef EMEDIUMTYPE 00379 #define EMEDIUMTYPE 124 /* Wrong medium type */ 00380 #undef ECANCELED 00381 #define ECANCELED 125 /* Operation Canceled */ 00382 #undef ENOKEY 00383 #define ENOKEY 126 /* Required key not available */ 00384 #undef EKEYEXPIRED 00385 #define EKEYEXPIRED 127 /* Key has expired */ 00386 #undef EKEYREVOKED 00387 #define EKEYREVOKED 128 /* Key has been revoked */ 00388 #undef EKEYREJECTED 00389 #define EKEYREJECTED 129 /* Key was rejected by service */ 00390 #undef EOWNERDEAD 00391 #define EOWNERDEAD 130 /* Owner died */ 00392 #undef ENOTRECOVERABLE 00393 #define ENOTRECOVERABLE 131 /* State not recoverable */ 00394 00395 /* Missing stat.h defines. 00396 * The following are sys/stat.h definitions not currently present in the ARMCC 00397 * errno.h. Note, ARMCC errno.h defines some symbol values differing from 00398 * GCC_ARM/IAR/standard POSIX definitions. Guard against this and future 00399 * changes by changing the symbol definition for filesystem use. 00400 */ 00401 #define _IFMT 0170000 //< type of file 00402 #define _IFSOCK 0140000 //< socket 00403 #define _IFLNK 0120000 //< symbolic link 00404 #define _IFREG 0100000 //< regular 00405 #define _IFBLK 0060000 //< block special 00406 #define _IFDIR 0040000 //< directory 00407 #define _IFCHR 0020000 //< character special 00408 #define _IFIFO 0010000 //< fifo special 00409 00410 #define S_IFMT _IFMT //< type of file 00411 #define S_IFSOCK _IFSOCK //< socket 00412 #define S_IFLNK _IFLNK //< symbolic link 00413 #define S_IFREG _IFREG //< regular 00414 #define S_IFBLK _IFBLK //< block special 00415 #define S_IFDIR _IFDIR //< directory 00416 #define S_IFCHR _IFCHR //< character special 00417 #define S_IFIFO _IFIFO //< fifo special 00418 00419 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) 00420 #define S_IRUSR 0000400 ///< read permission, owner 00421 #define S_IWUSR 0000200 ///< write permission, owner 00422 #define S_IXUSR 0000100 ///< execute/search permission, owner 00423 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) 00424 #define S_IRGRP 0000040 ///< read permission, group 00425 #define S_IWGRP 0000020 ///< write permission, group 00426 #define S_IXGRP 0000010 ///< execute/search permission, group 00427 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) 00428 #define S_IROTH 0000004 ///< read permission, other 00429 #define S_IWOTH 0000002 ///< write permission, other 00430 #define S_IXOTH 0000001 ///< execute/search permission, other 00431 00432 /* Refer to sys/stat standard 00433 * Note: Not all fields may be supported by the underlying filesystem 00434 */ 00435 struct stat { 00436 dev_t st_dev; ///< Device ID containing file 00437 ino_t st_ino; ///< File serial number 00438 mode_t st_mode; ///< Mode of file 00439 nlink_t st_nlink; ///< Number of links to file 00440 00441 uid_t st_uid; ///< User ID 00442 gid_t st_gid; ///< Group ID 00443 00444 off_t st_size; ///< Size of file in bytes 00445 00446 time_t st_atime; ///< Time of last access 00447 time_t st_mtime; ///< Time of last data modification 00448 time_t st_ctime; ///< Time of last status change 00449 }; 00450 00451 struct statvfs { 00452 unsigned long f_bsize; ///< Filesystem block size 00453 unsigned long f_frsize; ///< Fragment size (block size) 00454 00455 fsblkcnt_t f_blocks; ///< Number of blocks 00456 fsblkcnt_t f_bfree; ///< Number of free blocks 00457 fsblkcnt_t f_bavail; ///< Number of free blocks for unprivileged users 00458 00459 unsigned long f_fsid; ///< Filesystem ID 00460 00461 unsigned long f_namemax; ///< Maximum filename length 00462 }; 00463 00464 /* The following are dirent.h definitions are declared here to guarantee 00465 * consistency where structure may be different with different toolchains 00466 */ 00467 struct dirent { 00468 char d_name[NAME_MAX+1]; ///< Name of file 00469 uint8_t d_type; ///< Type of file 00470 }; 00471 00472 enum { 00473 DT_UNKNOWN, ///< The file type could not be determined. 00474 DT_FIFO, ///< This is a named pipe (FIFO). 00475 DT_CHR, ///< This is a character device. 00476 DT_DIR, ///< This is a directory. 00477 DT_BLK, ///< This is a block device. 00478 DT_REG, ///< This is a regular file. 00479 DT_LNK, ///< This is a symbolic link. 00480 DT_SOCK, ///< This is a UNIX domain socket. 00481 }; 00482 00483 struct pollfd { 00484 int fd; 00485 short events; 00486 short revents; 00487 }; 00488 00489 /* POSIX-compatible I/O functions */ 00490 #if __cplusplus 00491 extern "C" { 00492 #endif 00493 int open(const char *path, int oflag, ...); 00494 #ifndef __IAR_SYSTEMS_ICC__ /* IAR provides fdopen itself */ 00495 #if __cplusplus 00496 std::FILE* fdopen(int fildes, const char *mode); 00497 #else 00498 FILE* fdopen(int fildes, const char *mode); 00499 #endif 00500 #endif 00501 ssize_t write(int fildes, const void *buf, size_t nbyte); 00502 ssize_t read(int fildes, void *buf, size_t nbyte); 00503 off_t lseek(int fildes, off_t offset, int whence); 00504 int isatty(int fildes); 00505 int fsync(int fildes); 00506 int fstat(int fh, struct stat *st); 00507 int poll(struct pollfd fds[], nfds_t nfds, int timeout); 00508 int close(int fildes); 00509 int stat(const char *path, struct stat *st); 00510 int statvfs(const char *path, struct statvfs *buf); 00511 DIR *opendir(const char*); 00512 struct dirent *readdir(DIR *); 00513 int closedir(DIR*); 00514 void rewinddir(DIR*); 00515 long telldir(DIR*); 00516 void seekdir(DIR*, long); 00517 int mkdir(const char *name, mode_t n); 00518 #if __cplusplus 00519 }; // extern "C" 00520 00521 namespace mbed { 00522 00523 /** This call is an analogue to POSIX fdopen(). 00524 * 00525 * It associates a C stream to an already-opened FileHandle, to allow you to 00526 * use C printf/scanf/fwrite etc. The provided FileHandle must remain open - 00527 * it will be closed by the C library when fclose(FILE) is called. 00528 * 00529 * The net effect is fdopen(bind_to_fd(fh), mode), with error handling. 00530 * 00531 * @param fh a pointer to an opened FileHandle 00532 * @param mode operation upon the file descriptor, e.g., "w+" 00533 * 00534 * @returns a pointer to FILE 00535 */ 00536 std::FILE* fdopen(mbed::FileHandle *fh, const char *mode); 00537 00538 /** Bind an mbed FileHandle to a POSIX file descriptor 00539 * 00540 * This is similar to fdopen, but only operating at the POSIX layer - it 00541 * associates a POSIX integer file descriptor with a FileHandle, to allow you 00542 * to use POSIX read/write calls etc. The provided FileHandle must remain open - 00543 * it will be closed when close(int) is called. 00544 * 00545 * @param fh a pointer to an opened FileHandle 00546 * 00547 * @return an integer file descriptor, or negative if no descriptors available 00548 */ 00549 int bind_to_fd(mbed::FileHandle *fh); 00550 00551 } // namespace mbed 00552 00553 #endif // __cplusplus 00554 00555 /**@}*/ 00556 00557 /**@}*/ 00558 00559 #endif /* RETARGET_H */
Generated on Tue Jul 12 2022 12:22:11 by
