/*
* POSIX entry points on top of the reentrant newlib system calls. This
* newlib build has no "supplied syscalls" layer (libxenon normally provides
* it), so libstdc++ and application code calling read(), stat() etc. need
* these wrappers.
*/
#include <reent.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
/* Normally from crtbegin.o: identifies this module for __cxa_atexit. */
void *__dso_handle = &__dso_handle;
int open(const char *path, int flags, ...)
{
int mode = 0;
if (flags & O_CREAT) {
va_list ap;
va_start(ap, flags);
mode = va_arg(ap, int);
va_end(ap);
}
return _open_r(_REENT, path, flags, mode);
}
int close(int fd) { return _close_r(_REENT, fd); }
ssize_t read(int fd, void *buf, size_t len) { return _read_r(_REENT, fd, buf, len); }
ssize_t write(int fd, const void *buf, size_t len) { return _write_r(_REENT, fd, buf, len); }
off_t lseek(int fd, off_t off, int whence) { return _lseek_r(_REENT, fd, off, whence); }
int fstat(int fd, struct stat *st) { return _fstat_r(_REENT, fd, st); }
int stat(const char *path, struct stat *st) { return _stat_r(_REENT, path, st); }
int unlink(const char *path) { return _unlink_r(_REENT, path); }
int isatty(int fd) { return _isatty_r(_REENT, fd); }
int gettimeofday(struct timeval *tv, void *tz) { return _gettimeofday_r(_REENT, tv, tz); }