qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

syscall-fallbacks.c (3005B)


      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 struct timeval;
     26 #endif
     27 
     28 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
     29 
     30 __attribute__((weak, used)) int _open_r(struct _reent *r, const char *path, int flag, int m) {
     31     __errno_r(r) = ENOENT;
     32     return -1;
     33 }
     34 
     35 __attribute__((weak, used)) int _lseek_r(struct _reent *r, int file, int ptr, int dir) {
     36     __errno_r(r) = EBADF;
     37     return -1;
     38 }
     39 
     40 __attribute__((weak, used)) int _read_r(struct _reent *r, int file, char *ptr, int len) {
     41     __errno_r(r) = EBADF;
     42     return -1;
     43 }
     44 
     45 __attribute__((weak, used)) int _write_r(struct _reent *r, int file, char *ptr, int len) {
     46     __errno_r(r) = EBADF;
     47     return -1;
     48 }
     49 
     50 __attribute__((weak, used)) int _close_r(struct _reent *r, int file) {
     51     __errno_r(r) = EBADF;
     52     return -1;
     53 }
     54 
     55 __attribute__((weak, used)) int _link_r(struct _reent *r, const char *oldpath, const char *newpath) {
     56     __errno_r(r) = EPERM;
     57     return -1;
     58 }
     59 
     60 __attribute__((weak, used)) int _unlink_r(struct _reent *r, const char *path) {
     61     __errno_r(r) = EPERM;
     62     return -1;
     63 }
     64 
     65 __attribute__((weak, used)) clock_t _times_r(struct _reent *r, void *t) {
     66     __errno_r(r) = EFAULT;
     67     return -1;
     68 }
     69 
     70 __attribute__((weak, used)) int _fstat_r(struct _reent *r, int file, struct stat *st) {
     71     __errno_r(r) = EBADF;
     72     return -1;
     73 }
     74 
     75 __attribute__((weak, used)) int _isatty_r(struct _reent *r, int fd) {
     76     __errno_r(r) = EBADF;
     77     return 0;
     78 }
     79 
     80 __attribute__((weak, used)) caddr_t _sbrk_r(struct _reent *r, int incr) {
     81     __errno_r(r) = ENOMEM;
     82     return (caddr_t)-1;
     83 }
     84 
     85 __attribute__((weak, used)) int _kill(int pid, int sig) {
     86     errno = EPERM;
     87     return -1;
     88 }
     89 
     90 __attribute__((weak, used)) pid_t _getpid(void) {
     91     return 1;
     92 }
     93 
     94 __attribute__((weak, used)) void _fini(void) {
     95     return;
     96 }
     97 
     98 __attribute__((weak, used, noreturn)) void _exit(int i) {
     99     while (1)
    100         ;
    101 }
    102 
    103 __attribute__((weak, used)) int _gettimeofday_r(struct _reent *r, struct timeval *t, void *tzp) {
    104     __errno_r(r) = EPERM;
    105     return -1;
    106 }
    107 
    108 __attribute__((weak, used)) void *__dso_handle;
    109 
    110 __attribute__((weak, used)) void __cxa_pure_virtual(void) {
    111     while (1)
    112         ;
    113 }
    114 
    115 #pragma GCC diagnostic pop