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