mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
Diff: platform/mbed_retarget.h
- Revision:
- 186:707f6e361f3e
- Parent:
- 184:08ed48f1de7f
diff -r 08ed48f1de7f -r 707f6e361f3e platform/mbed_retarget.h --- a/platform/mbed_retarget.h Thu Apr 19 17:12:19 2018 +0100 +++ b/platform/mbed_retarget.h Fri Jun 22 16:45:37 2018 +0100 @@ -27,6 +27,18 @@ #include <stdint.h> #include <stddef.h> +/* Include logic for errno so we can get errno defined but not bring in error_t, + * including errno here prevents an include later, which would redefine our + * error codes + */ +#ifndef __error_t_defined +#define __error_t_defined 1 +#include <errno.h> +#undef __error_t_defined +#else +#include <errno.h> +#endif + /* We can get the following standard types from sys/types for gcc, but we * need to define the types ourselves for the other compilers that normally * target embedded systems */ @@ -43,14 +55,20 @@ typedef unsigned int gid_t; ///< Group ID #endif -#define O_RDONLY 0 ///< Open for reading -#define O_WRONLY 1 ///< Open for writing -#define O_RDWR 2 ///< Open for reading and writing -#define O_CREAT 0x0200 ///< Create file if it does not exist -#define O_TRUNC 0x0400 ///< Truncate file to zero length -#define O_EXCL 0x0800 ///< Fail if file exists -#define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write -#define O_BINARY 0x8000 ///< Open file in binary mode +/* Flags for open() and fcntl(GETFL/SETFL) + * At present, fcntl only supports reading and writing O_NONBLOCK + */ +#define O_RDONLY 0 ///< Open for reading +#define O_WRONLY 1 ///< Open for writing +#define O_RDWR 2 ///< Open for reading and writing +#define O_NONBLOCK 0x0004 ///< Non-blocking mode +#define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write +#define O_CREAT 0x0200 ///< Create file if it does not exist +#define O_TRUNC 0x0400 ///< Truncate file to zero length +#define O_EXCL 0x0800 ///< Fail if file exists +#define O_BINARY 0x8000 ///< Open file in binary mode + +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) #define NAME_MAX 255 ///< Maximum size of a name in a file path @@ -480,6 +498,10 @@ DT_SOCK, ///< This is a UNIX domain socket. }; +/* fcntl.h defines */ +#define F_GETFL 3 +#define F_SETFL 4 + struct pollfd { int fd; short events; @@ -503,7 +525,8 @@ off_t lseek(int fildes, off_t offset, int whence); int isatty(int fildes); int fsync(int fildes); - int fstat(int fh, struct stat *st); + int fstat(int fildes, struct stat *st); + int fcntl(int fildes, int cmd, ...); int poll(struct pollfd fds[], nfds_t nfds, int timeout); int close(int fildes); int stat(const char *path, struct stat *st);