From caad7b91b94e7fa8aa24c1d8ab81b46de2beb64c Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 2 Jan 2022 10:21:27 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15309 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- .../various/SB-CLIENT-256k-08180000-128k-20060000/Makefile | 1 - .../various/SB-CLIENT-256k-081C0000-128k-20080000/Makefile | 1 - demos/various/SB-CLIENT-32k-08070000-4k-2001E000/Makefile | 1 - demos/various/SB-CLIENT-32k-08078000-4k-2001F000/Makefile | 1 - os/sb/user/lib/libdir.c | 6 ++++-- os/sb/user/lib/syscalls.c | 7 ++++--- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/demos/various/SB-CLIENT-256k-08180000-128k-20060000/Makefile b/demos/various/SB-CLIENT-256k-08180000-128k-20060000/Makefile index 4bb368270..ee349f962 100644 --- a/demos/various/SB-CLIENT-256k-08180000-128k-20060000/Makefile +++ b/demos/various/SB-CLIENT-256k-08180000-128k-20060000/Makefile @@ -123,7 +123,6 @@ LDSCRIPT= ./sandbox.ld # setting. CSRC = $(ALLCSRC) \ $(TESTSRC) \ - $(CHIBIOS)/os/sb/various/syscalls.c \ main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global diff --git a/demos/various/SB-CLIENT-256k-081C0000-128k-20080000/Makefile b/demos/various/SB-CLIENT-256k-081C0000-128k-20080000/Makefile index 4bb368270..ee349f962 100644 --- a/demos/various/SB-CLIENT-256k-081C0000-128k-20080000/Makefile +++ b/demos/various/SB-CLIENT-256k-081C0000-128k-20080000/Makefile @@ -123,7 +123,6 @@ LDSCRIPT= ./sandbox.ld # setting. CSRC = $(ALLCSRC) \ $(TESTSRC) \ - $(CHIBIOS)/os/sb/various/syscalls.c \ main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global diff --git a/demos/various/SB-CLIENT-32k-08070000-4k-2001E000/Makefile b/demos/various/SB-CLIENT-32k-08070000-4k-2001E000/Makefile index 4bb368270..ee349f962 100644 --- a/demos/various/SB-CLIENT-32k-08070000-4k-2001E000/Makefile +++ b/demos/various/SB-CLIENT-32k-08070000-4k-2001E000/Makefile @@ -123,7 +123,6 @@ LDSCRIPT= ./sandbox.ld # setting. CSRC = $(ALLCSRC) \ $(TESTSRC) \ - $(CHIBIOS)/os/sb/various/syscalls.c \ main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global diff --git a/demos/various/SB-CLIENT-32k-08078000-4k-2001F000/Makefile b/demos/various/SB-CLIENT-32k-08078000-4k-2001F000/Makefile index 4bb368270..ee349f962 100644 --- a/demos/various/SB-CLIENT-32k-08078000-4k-2001F000/Makefile +++ b/demos/various/SB-CLIENT-32k-08078000-4k-2001F000/Makefile @@ -123,7 +123,6 @@ LDSCRIPT= ./sandbox.ld # setting. CSRC = $(ALLCSRC) \ $(TESTSRC) \ - $(CHIBIOS)/os/sb/various/syscalls.c \ main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global diff --git a/os/sb/user/lib/libdir.c b/os/sb/user/lib/libdir.c index cbf9076bf..8b4d26585 100644 --- a/os/sb/user/lib/libdir.c +++ b/os/sb/user/lib/libdir.c @@ -20,6 +20,8 @@ #include #include +#include + DIR *fdopendir(int fd) { DIR *dirp; @@ -53,13 +55,13 @@ int closedir (DIR *dirp) { } struct dirent *readdir (DIR *dirp) { - extern int getdents(int fd, void *dp, int count); + extern int _getdents_r(struct _reent *r, int fd, void *dp, int count); while (true) { struct dirent *dep; if (dirp->next == 0) { - dirp->size = getdents(dirp->fd, dirp->buf, DIR_BUF_SIZE); + dirp->size = _getdents_r(_REENT, dirp->fd, dirp->buf, DIR_BUF_SIZE); } if (dirp->size <= 0) { diff --git a/os/sb/user/lib/syscalls.c b/os/sb/user/lib/syscalls.c index 6a9c4924f..d77b18e23 100644 --- a/os/sb/user/lib/syscalls.c +++ b/os/sb/user/lib/syscalls.c @@ -134,7 +134,7 @@ caddr_t _sbrk_r(struct _reent *r, int incr) { prevp = p; if ((p + incr > &__heap_end__) || (p + incr < &__heap_base__)) { - __errno_r(r) = ENOMEM; + __errno_r(r) = ENOMEM; return (caddr_t)-1; } @@ -142,12 +142,13 @@ caddr_t _sbrk_r(struct _reent *r, int incr) { return (caddr_t)prevp; } -int getdents(int fd, void *dp, int count) { +__attribute__((used)) +int _getdents_r(struct _reent *r, int fd, void *dp, int count) { ssize_t n; n = sbPosixGetdents(fd, dp, count); if (CH_RET_IS_ERROR(n)) { - errno = CH_DECODE_ERROR(n); + __errno_r(r) = CH_DECODE_ERROR(n); return -1; }