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