libc: Move xtensa reentrant syscall impl to common libc-hooks

The xcc specific reentrant syscall implementations are actually useful
for xtensa in general.  So move that code from being specific to
intel_s1000 / xcc into generic newlib/libc-hooks.c.  This is in prep
for the Zephyr SDK dropping -DMISSING_SYSCALL_NAMES which will make
its version of newlib on xtensa match behavior with xcc.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-02-03 05:08:04 -06:00 committed by Kumar Gala
commit 9897c3b0dd
2 changed files with 85 additions and 91 deletions

View file

@ -270,3 +270,88 @@ __weak int *__errno(void)
{
return z_errno();
}
#if CONFIG_XTENSA
/* The Newlib in xtensa toolchain has a few missing functions for the
* reentrant versions of the syscalls.
*/
#ifndef CONFIG_POSIX_API
_ssize_t _read_r(struct _reent *r, int fd, void *buf, size_t nbytes)
{
ARG_UNUSED(r);
return _read(fd, (char *)buf, nbytes);
}
_ssize_t _write_r(struct _reent *r, int fd, const void *buf, size_t nbytes)
{
ARG_UNUSED(r);
return _write(fd, buf, nbytes);
}
int _open_r(struct _reent *r, const char *name, int flags, int mode)
{
ARG_UNUSED(r);
ARG_UNUSED(flags);
return _open(name, mode);
}
int _close_r(struct _reent *r, int file)
{
ARG_UNUSED(r);
return _close(file);
}
_off_t _lseek_r(struct _reent *r, int file, _off_t ptr, int dir)
{
ARG_UNUSED(r);
return _lseek(file, ptr, dir);
}
#endif
int _isatty_r(struct _reent *r, int file)
{
ARG_UNUSED(r);
return _isatty(file);
}
int _kill_r(struct _reent *r, int i, int j)
{
ARG_UNUSED(r);
return _kill(i, j);
}
int _getpid_r(struct _reent *r)
{
ARG_UNUSED(r);
return _getpid();
}
int _fstat_r(struct _reent *r, int file, struct stat *st)
{
ARG_UNUSED(r);
return _fstat(file, st);
}
void _exit_r(struct _reent *r, int status)
{
ARG_UNUSED(r);
_exit(status);
}
void *_sbrk_r(struct _reent *r, int count)
{
ARG_UNUSED(r);
return _sbrk(count);
}
#endif /* CONFIG_XTENSA */

View file

@ -12,97 +12,6 @@
#include <reent.h>
/* these externs are from lib/libc/newlib/libc-hooks.c */
extern int _read(int fd, char *buf, int nbytes);
extern int _write(int fd, const void *buf, int nbytes);
extern int _open(const char *name, int mode);
extern int _close(int file);
extern int _lseek(int file, int ptr, int dir);
extern int _isatty(int file);
extern int _kill(int i, int j);
extern int _getpid(void);
extern int _fstat(int file, struct stat *st);
extern void _exit(int status);
extern void *_sbrk(int count);
_ssize_t _read_r(struct _reent *r, int fd, void *buf, size_t nbytes)
{
ARG_UNUSED(r);
return _read(fd, (char *)buf, nbytes);
}
_ssize_t _write_r(struct _reent *r, int fd, const void *buf, size_t nbytes)
{
ARG_UNUSED(r);
return _write(fd, buf, nbytes);
}
int _open_r(struct _reent *r, const char *name, int flags, int mode)
{
ARG_UNUSED(r);
ARG_UNUSED(flags);
return _open(name, mode);
}
int _close_r(struct _reent *r, int file)
{
ARG_UNUSED(r);
return _close(file);
}
_off_t _lseek_r(struct _reent *r, int file, _off_t ptr, int dir)
{
ARG_UNUSED(r);
return _lseek(file, ptr, dir);
}
int _isatty_r(struct _reent *r, int file)
{
ARG_UNUSED(r);
return _isatty(file);
}
int _kill_r(struct _reent *r, int i, int j)
{
ARG_UNUSED(r);
return _kill(i, j);
}
int _getpid_r(struct _reent *r)
{
ARG_UNUSED(r);
return _getpid();
}
int _fstat_r(struct _reent *r, int file, struct stat *st)
{
ARG_UNUSED(r);
return _fstat(file, st);
}
void _exit_r(struct _reent *r, int status)
{
ARG_UNUSED(r);
_exit(status);
}
void *_sbrk_r(struct _reent *r, int count)
{
ARG_UNUSED(r);
return _sbrk(count);
}
int _gettimeofday_r(struct _reent *r, struct timeval *__tp, void *__tzp)
{
ARG_UNUSED(r);