Various fixes around Companion trainer mode (#7116)
[opentx.git] / radio / src / syscalls.c
blobb80ae58e995d7620282cdd3614f44ca83fee7664
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <errno.h>
26 #include "debug.h"
28 #undef errno
29 extern int errno;
30 extern int _end;
31 extern int _heap_end;
33 unsigned char * heap = (unsigned char *)&_end;
35 extern caddr_t _sbrk(int nbytes)
37 if (heap + nbytes < (unsigned char *)&_heap_end) {
38 unsigned char * prev_heap = heap;
39 heap += nbytes;
40 return (caddr_t)prev_heap;
42 else {
43 errno = ENOMEM;
44 return ((void *)-1);
48 #if !defined(SEMIHOSTING)
49 extern int _gettimeofday(void *p1, void *p2)
51 return 0;
54 extern int _link(char *old, char *nw)
56 return -1;
59 extern int _unlink(const char *path)
61 return -1;
64 extern int _open(const char *name, int flags, int mode)
66 return -1;
69 extern int _close(int file)
71 return -1;
74 extern int _fstat(int file, struct stat * st)
76 st->st_mode = S_IFCHR ;
77 return 0;
80 extern int _isatty(int file)
82 return 1;
85 extern int _lseek(int file, int ptr, int dir)
87 return 0;
90 extern int _read(int file, char *ptr, int len)
92 return 0;
95 extern int _write(int file, char *ptr, int len)
97 return 0;
100 extern void _exit(int status)
102 TRACE("_exit(%d)", status);
103 for (;;);
106 extern void _kill(int pid, int sig)
108 return ;
111 extern int _getpid()
113 return -1 ;
115 #endif