Fix code style and warnings in syscalls.c

This commit is contained in:
Mario Hüttel 2020-02-12 21:15:25 +01:00
parent 09507b5734
commit d095e26c9e
1 changed files with 46 additions and 23 deletions

View File

@ -1,6 +1,7 @@
#include <stm-periph/uart.h> #include <stm-periph/uart.h>
char* _sbrk(int incr) { char* _sbrk(int incr)
{
extern char heap_low; // Defined by the linker extern char heap_low; // Defined by the linker
extern char heap_top; extern char heap_top;
static char *heap_end; static char *heap_end;
@ -9,6 +10,7 @@ char* _sbrk(int incr) {
if (heap_end == 0) { if (heap_end == 0) {
heap_end = &heap_low; heap_end = &heap_low;
} }
prev_heap_end = heap_end; prev_heap_end = heap_end;
if (heap_end + incr > &heap_top) { if (heap_end + incr > &heap_top) {
return 0; return 0;
@ -17,25 +19,46 @@ char* _sbrk(int incr) {
heap_end += incr; heap_end += incr;
return (char*) prev_heap_end; return (char*) prev_heap_end;
} }
int _isatty(int fd) {
int _isatty(int fd)
{
(void)fd;
return 1; return 1;
} }
int _close(int fd) {
int _close(int fd)
{
(void)fd;
return 0; return 0;
} }
int _open(int fd) {
int _open(int fd)
{
(void)fd;
return 0; return 0;
} }
int _fstat(void) {
int _fstat(void)
{
return 0; return 0;
} }
int _lseek(void) {
int _lseek(void)
{
return 0; return 0;
} }
int _read(void) {
int _read(void)
{
return 0; return 0;
} }
int _write(int fd, const void *buf, int count) {
int _write(int fd, const void *buf, int count)
{
if (fd == 1)
uart_send_array((char*)buf, count); uart_send_array((char*)buf, count);
return count; return count;
} }