diff options
author | Joel Challis <git@zvecr.com> | 2021-11-19 18:41:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 10:41:02 -0800 |
commit | 2728603fe6d73e805a539d337fd01051c46ca806 (patch) | |
tree | 5c83ffc7efa112da870bd5d8502a9d91d4792f35 /platforms/chibios/syscall-fallbacks.c | |
parent | 43b9e23bae12916d5161f03700c9bfe46737324b (diff) | |
download | qmk_firmware-2728603fe6d73e805a539d337fd01051c46ca806.tar.gz qmk_firmware-2728603fe6d73e805a539d337fd01051c46ca806.zip |
Move tmk_core/common/<plat> (#13918)
Diffstat (limited to 'platforms/chibios/syscall-fallbacks.c')
-rw-r--r-- | platforms/chibios/syscall-fallbacks.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/platforms/chibios/syscall-fallbacks.c b/platforms/chibios/syscall-fallbacks.c new file mode 100644 index 000000000..4569879c7 --- /dev/null +++ b/platforms/chibios/syscall-fallbacks.c | |||
@@ -0,0 +1,110 @@ | |||
1 | /* Copyright 2021 Nick Brassel, QMK | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <errno.h> | ||
18 | #include <sys/stat.h> | ||
19 | #include <sys/types.h> | ||
20 | |||
21 | /* To compile the ChibiOS syscall stubs with picolibc | ||
22 | * the _reent struct has to be defined. */ | ||
23 | #if defined(USE_PICOLIBC) | ||
24 | struct _reent; | ||
25 | #endif | ||
26 | |||
27 | #pragma GCC diagnostic ignored "-Wmissing-prototypes" | ||
28 | |||
29 | __attribute__((weak, used)) int _open_r(struct _reent *r, const char *path, int flag, int m) { | ||
30 | __errno_r(r) = ENOENT; | ||
31 | return -1; | ||
32 | } | ||
33 | |||
34 | __attribute__((weak, used)) int _lseek_r(struct _reent *r, int file, int ptr, int dir) { | ||
35 | __errno_r(r) = EBADF; | ||
36 | return -1; | ||
37 | } | ||
38 | |||
39 | __attribute__((weak, used)) int _read_r(struct _reent *r, int file, char *ptr, int len) { | ||
40 | __errno_r(r) = EBADF; | ||
41 | return -1; | ||
42 | } | ||
43 | |||
44 | __attribute__((weak, used)) int _write_r(struct _reent *r, int file, char *ptr, int len) { | ||
45 | __errno_r(r) = EBADF; | ||
46 | return -1; | ||
47 | } | ||
48 | |||
49 | __attribute__((weak, used)) int _close_r(struct _reent *r, int file) { | ||
50 | __errno_r(r) = EBADF; | ||
51 | return -1; | ||
52 | } | ||
53 | |||
54 | __attribute__((weak, used)) int _link_r(struct _reent *r, const char *oldpath, const char *newpath) { | ||
55 | __errno_r(r) = EPERM; | ||
56 | return -1; | ||
57 | } | ||
58 | |||
59 | __attribute__((weak, used)) int _unlink_r(struct _reent *r, const char *path) { | ||
60 | __errno_r(r) = EPERM; | ||
61 | return -1; | ||
62 | } | ||
63 | |||
64 | __attribute__((weak, used)) clock_t _times_r(struct _reent *r, void *t) { | ||
65 | __errno_r(r) = EFAULT; | ||
66 | return -1; | ||
67 | } | ||
68 | |||
69 | __attribute__((weak, used)) int _fstat_r(struct _reent *r, int file, struct stat *st) { | ||
70 | __errno_r(r) = EBADF; | ||
71 | return -1; | ||
72 | } | ||
73 | |||
74 | __attribute__((weak, used)) int _isatty_r(struct _reent *r, int fd) { | ||
75 | __errno_r(r) = EBADF; | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | __attribute__((weak, used)) caddr_t _sbrk_r(struct _reent *r, int incr) { | ||
80 | __errno_r(r) = ENOMEM; | ||
81 | return (caddr_t)-1; | ||
82 | } | ||
83 | |||
84 | __attribute__((weak, used)) int _kill(int pid, int sig) { | ||
85 | errno = EPERM; | ||
86 | return -1; | ||
87 | } | ||
88 | |||
89 | __attribute__((weak, used)) pid_t _getpid(void) { return 1; } | ||
90 | |||
91 | __attribute__((weak, used)) void _fini(void) { return; } | ||
92 | |||
93 | __attribute__((weak, used, noreturn)) void _exit(int i) { | ||
94 | while (1) | ||
95 | ; | ||
96 | } | ||
97 | |||
98 | __attribute__((weak, used)) int _gettimeofday_r(struct _reent *r, struct timeval *t, void *tzp) { | ||
99 | __errno_r(r) = EPERM; | ||
100 | return -1; | ||
101 | } | ||
102 | |||
103 | __attribute__((weak, used)) void *__dso_handle; | ||
104 | |||
105 | __attribute__((weak, used)) void __cxa_pure_virtual(void) { | ||
106 | while (1) | ||
107 | ; | ||
108 | } | ||
109 | |||
110 | #pragma GCC diagnostic pop | ||