syscall-fallbacks.c 2.8 KB

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