diff options
| -rw-r--r-- | tmk_core/common/chibios/syscall-fallbacks.c | 85 |
1 files changed, 49 insertions, 36 deletions
diff --git a/tmk_core/common/chibios/syscall-fallbacks.c b/tmk_core/common/chibios/syscall-fallbacks.c index 5d232a755..739017ae1 100644 --- a/tmk_core/common/chibios/syscall-fallbacks.c +++ b/tmk_core/common/chibios/syscall-fallbacks.c | |||
| @@ -14,76 +14,89 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include <errno.h> | ||
| 17 | #include <sys/stat.h> | 18 | #include <sys/stat.h> |
| 18 | #include <sys/types.h> | 19 | #include <sys/types.h> |
| 19 | 20 | ||
| 20 | #pragma GCC diagnostic ignored "-Wmissing-prototypes" | 21 | #pragma GCC diagnostic ignored "-Wmissing-prototypes" |
| 21 | 22 | ||
| 22 | __attribute__((weak, used)) int _read_r(struct _reent *r, int file, char *ptr, int len) { | 23 | __attribute__((weak, used)) int _open_r(struct _reent *r, const char *path, int flag, int m) { |
| 23 | (void)r; | 24 | __errno_r(r) = ENOENT; |
| 24 | (void)file; | ||
| 25 | (void)ptr; | ||
| 26 | (void)len; | ||
| 27 | return -1; | 25 | return -1; |
| 28 | } | 26 | } |
| 29 | 27 | ||
| 30 | __attribute__((weak, used)) int _lseek_r(struct _reent *r, int file, int ptr, int dir) { | 28 | __attribute__((weak, used)) int _lseek_r(struct _reent *r, int file, int ptr, int dir) { |
| 31 | (void)r; | 29 | __errno_r(r) = EBADF; |
| 32 | (void)file; | 30 | return -1; |
| 33 | (void)ptr; | 31 | } |
| 34 | (void)dir; | 32 | |
| 35 | return 0; | 33 | __attribute__((weak, used)) int _read_r(struct _reent *r, int file, char *ptr, int len) { |
| 34 | __errno_r(r) = EBADF; | ||
| 35 | return -1; | ||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | __attribute__((weak, used)) int _write_r(struct _reent *r, int file, char *ptr, int len) { | 38 | __attribute__((weak, used)) int _write_r(struct _reent *r, int file, char *ptr, int len) { |
| 39 | (void)r; | 39 | __errno_r(r) = EBADF; |
| 40 | (void)file; | 40 | return -1; |
| 41 | (void)ptr; | ||
| 42 | return len; | ||
| 43 | } | 41 | } |
| 44 | 42 | ||
| 45 | __attribute__((weak, used)) int _close_r(struct _reent *r, int file) { | 43 | __attribute__((weak, used)) int _close_r(struct _reent *r, int file) { |
| 46 | (void)r; | 44 | __errno_r(r) = EBADF; |
| 47 | (void)file; | 45 | return -1; |
| 48 | return 0; | ||
| 49 | } | 46 | } |
| 50 | 47 | ||
| 51 | __attribute__((weak, used)) caddr_t _sbrk_r(struct _reent *r, int incr) { | 48 | __attribute__((weak, used)) int _link_r(struct _reent *r, const char *oldpath, const char *newpath) { |
| 52 | (void)r; | 49 | __errno_r(r) = EPERM; |
| 53 | (void)incr; | 50 | return -1; |
| 54 | return (caddr_t)-1; | 51 | } |
| 52 | |||
| 53 | __attribute__((weak, used)) int _unlink_r(struct _reent *r, const char *path) { | ||
| 54 | __errno_r(r) = EPERM; | ||
| 55 | return -1; | ||
| 56 | } | ||
| 57 | |||
| 58 | __attribute__((weak, used)) clock_t _times_r(struct _reent *r, void *t) { | ||
| 59 | __errno_r(r) = EFAULT; | ||
| 60 | return -1; | ||
| 55 | } | 61 | } |
| 56 | 62 | ||
| 57 | __attribute__((weak, used)) int _fstat_r(struct _reent *r, int file, struct stat *st) { | 63 | __attribute__((weak, used)) int _fstat_r(struct _reent *r, int file, struct stat *st) { |
| 58 | (void)r; | 64 | __errno_r(r) = EBADF; |
| 59 | (void)file; | 65 | return -1; |
| 60 | (void)st; | ||
| 61 | return 0; | ||
| 62 | } | 66 | } |
| 63 | 67 | ||
| 64 | __attribute__((weak, used)) int _isatty_r(struct _reent *r, int fd) { | 68 | __attribute__((weak, used)) int _isatty_r(struct _reent *r, int fd) { |
| 65 | (void)r; | 69 | __errno_r(r) = EBADF; |
| 66 | (void)fd; | 70 | return 0; |
| 67 | return 1; | ||
| 68 | } | 71 | } |
| 69 | 72 | ||
| 70 | __attribute__((weak, used)) void _fini(void) { return; } | 73 | __attribute__((weak, used)) caddr_t _sbrk_r(struct _reent *r, int incr) { |
| 74 | __errno_r(r) = ENOMEM; | ||
| 75 | return (caddr_t)-1; | ||
| 76 | } | ||
| 77 | |||
| 78 | __attribute__((weak, used)) int _kill(int pid, int sig) { | ||
| 79 | errno = EPERM; | ||
| 80 | return -1; | ||
| 81 | } | ||
| 71 | 82 | ||
| 72 | __attribute__((weak, used)) pid_t _getpid(void) { return 1; } | 83 | __attribute__((weak, used)) pid_t _getpid(void) { return 1; } |
| 73 | 84 | ||
| 74 | __attribute__((weak, noreturn)) void _exit(int i) { | 85 | __attribute__((weak, used)) void _fini(void) { return; } |
| 75 | (void)i; | 86 | |
| 87 | __attribute__((weak, used, noreturn)) void _exit(int i) { | ||
| 76 | while (1) | 88 | while (1) |
| 77 | ; | 89 | ; |
| 78 | } | 90 | } |
| 79 | 91 | ||
| 80 | __attribute__((weak)) void _kill(void) {} | 92 | __attribute__((weak, used)) int _gettimeofday_r(struct _reent *r, struct timeval *t, void *tzp) { |
| 81 | 93 | __errno_r(r) = EPERM; | |
| 82 | __attribute__((weak)) void *__dso_handle; | 94 | return -1; |
| 95 | } | ||
| 83 | 96 | ||
| 84 | void __cxa_pure_virtual(void); | 97 | __attribute__((weak, used)) void *__dso_handle; |
| 85 | 98 | ||
| 86 | __attribute__((weak)) void __cxa_pure_virtual() { | 99 | __attribute__((weak, used)) void __cxa_pure_virtual(void) { |
| 87 | while (1) | 100 | while (1) |
| 88 | ; | 101 | ; |
| 89 | } | 102 | } |
