You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.9 KiB

  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. #include <errno.h>
  17. #include <sys/stat.h>
  18. #include <sys/types.h>
  19. /* To compile the ChibiOS syscall stubs with picolibc
  20. * the _reent struct has to be defined. */
  21. #if defined(USE_PICOLIBC)
  22. struct _reent;
  23. struct timeval;
  24. #endif
  25. #pragma GCC diagnostic ignored "-Wmissing-prototypes"
  26. __attribute__((weak, used)) int _open_r(struct _reent *r, const char *path, int flag, int m) {
  27. __errno_r(r) = ENOENT;
  28. return -1;
  29. }
  30. __attribute__((weak, used)) int _lseek_r(struct _reent *r, int file, int ptr, int dir) {
  31. __errno_r(r) = EBADF;
  32. return -1;
  33. }
  34. __attribute__((weak, used)) int _read_r(struct _reent *r, int file, char *ptr, int len) {
  35. __errno_r(r) = EBADF;
  36. return -1;
  37. }
  38. __attribute__((weak, used)) int _write_r(struct _reent *r, int file, char *ptr, int len) {
  39. __errno_r(r) = EBADF;
  40. return -1;
  41. }
  42. __attribute__((weak, used)) int _close_r(struct _reent *r, int file) {
  43. __errno_r(r) = EBADF;
  44. return -1;
  45. }
  46. __attribute__((weak, used)) int _link_r(struct _reent *r, const char *oldpath, const char *newpath) {
  47. __errno_r(r) = EPERM;
  48. return -1;
  49. }
  50. __attribute__((weak, used)) int _unlink_r(struct _reent *r, const char *path) {
  51. __errno_r(r) = EPERM;
  52. return -1;
  53. }
  54. __attribute__((weak, used)) clock_t _times_r(struct _reent *r, void *t) {
  55. __errno_r(r) = EFAULT;
  56. return -1;
  57. }
  58. __attribute__((weak, used)) int _fstat_r(struct _reent *r, int file, struct stat *st) {
  59. __errno_r(r) = EBADF;
  60. return -1;
  61. }
  62. __attribute__((weak, used)) int _isatty_r(struct _reent *r, int fd) {
  63. __errno_r(r) = EBADF;
  64. return 0;
  65. }
  66. __attribute__((weak, used)) caddr_t _sbrk_r(struct _reent *r, int incr) {
  67. __errno_r(r) = ENOMEM;
  68. return (caddr_t)-1;
  69. }
  70. __attribute__((weak, used)) int _kill(int pid, int sig) {
  71. errno = EPERM;
  72. return -1;
  73. }
  74. __attribute__((weak, used)) pid_t _getpid(void) { return 1; }
  75. __attribute__((weak, used)) void _fini(void) { return; }
  76. __attribute__((weak, used, noreturn)) void _exit(int i) {
  77. while (1)
  78. ;
  79. }
  80. __attribute__((weak, used)) int _gettimeofday_r(struct _reent *r, struct timeval *t, void *tzp) {
  81. __errno_r(r) = EPERM;
  82. return -1;
  83. }
  84. __attribute__((weak, used)) void *__dso_handle;
  85. __attribute__((weak, used)) void __cxa_pure_virtual(void) {
  86. while (1)
  87. ;
  88. }
  89. #pragma GCC diagnostic pop