Merge pull request #164 from fjtrujy/newlib4.4.0-Improvements

New glue functions needed after toolchain upgrade
This commit is contained in:
Francisco Javier Trujillo Mata
2024-01-24 14:24:28 +01:00
committed by GitHub
2 changed files with 111 additions and 11 deletions

View File

@@ -27,8 +27,9 @@ FDMAN_OBJS = __descriptor_data_pool.o __descriptormap.o __fdman_init.o __fdman_g
GLUE_OBJS = __dummy_passwd.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wait.o _open.o _close.o _read.o \
_write.o _fstat.o _stat.o lstat.o access.o _fcntl.o _lseek.o chdir.o mkdir.o rmdir.o getdents.o _link.o _unlink.o \
_rename.o _getpid.o _kill.o _sbrk.o _gettimeofday.o _times.o ftime.o clock_getres.o clock_gettime.o clock_settime.o \
_isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o getentropy.o getpwuid.o \
fsync.o getpwnam.o getuid.o geteuid.o basename.o statvfs.o
_isatty.o symlink.o truncate.o chmod.o fchmod.o pathconf.o readlink.o utime.o fchown.o _getentropy.o getpwuid.o \
fsync.o getpwnam.o getuid.o geteuid.o basename.o statvfs.o \
openat.o renameat.o fchmodat.o fstatat.o mkdirat.o faccessat.o fchownat.o linkat.o readlinkat.o unlinkat.o
INIT_OBJS = __libpthreadglue_init.o __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o

View File

@@ -886,13 +886,6 @@ int fchmod(int fd, mode_t mode)
}
#endif
#ifdef F_fchmodat
int fchmodat(int fd, const char *path, mode_t mode, int flag)
{
return chmod(path, mode);
}
#endif
#ifdef F_pathconf
long int pathconf(const char *path, int name) {
errno = ENOSYS;
@@ -956,8 +949,8 @@ int fchown(int fd, uid_t owner, gid_t group)
}
#endif
#ifdef F_getentropy
int getentropy(void *buffer, size_t length) {
#ifdef F__getentropy
int _getentropy(void *buffer, size_t length) {
size_t i;
SceKernelUtilsMt19937Context ctx;
sceKernelUtilsMt19937Init(&ctx, time(NULL));
@@ -1058,3 +1051,109 @@ int statvfs (const char *__path, struct statvfs *__buf)
__buf->f_namemax = MAXNAMLEN;
}
#endif /* F_statvfs */
/* ATFILE functions */
#ifdef F_openat
int openat(int dirfd, const char *pathname, int flags, ...)
{
// TODO: Do better implementation following https://linux.die.net/man/2/openat
// for now use the same as open
// Extract mode from variable arguments
va_list args;
va_start(args, flags);
// Get the mode argument
int mode = va_arg(args, int);
// Clean up the va_list
va_end(args);
return _open(pathname, flags, mode);
}
#endif /* F_openat */
#ifdef F_renameat
int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath)
{
// TODO: Do better implementation following https://linux.die.net/man/2/renameat
// for now use the same as rename
return _rename(oldpath, newpath);
}
#endif /* F_renameat */
#ifdef F_fchmodat
int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
{
// TODO: Do better implementation following https://linux.die.net/man/2/fchmodat
// for now use the same as chmod
return chmod(pathname, mode);
}
#endif /* F_fchmodat */
#ifdef F_fstatat
int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags)
{
// TODO: Do better implementation following https://linux.die.net/man/2/fstatat
// for now use the same as stat
return _stat(pathname, buf);
}
#endif /* F_fstatat */
#ifdef F_mkdirat
int mkdirat(int dirfd, const char *pathname, mode_t mode)
{
// TODO: Do better implementation following https://linux.die.net/man/2/mkdirat
// for now use the same as mkdir
return mkdir(pathname, mode);
}
#endif /* F_mkdirat */
#ifdef F_faccessat
int faccessat(int dirfd, const char *pathname, int mode, int flags)
{
// TODO: Do better implementation following https://linux.die.net/man/2/faccessat
// for now use the same as access
return access(pathname, mode);
}
#endif /* F_faccessat */
#ifdef F_fchownat
int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags)
{
// TODO: Do better implementation following https://linux.die.net/man/2/fchownat
// for now use the same as chown
return chown(pathname, owner, group);
}
#endif /* F_fchownat */
#ifdef F_linkat
int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) {
// TODO: Do better implementation following https://linux.die.net/man/2/linkat
// for now use the same as link
return link(oldpath, newpath);
}
#endif /* F_linkat */
#ifdef F_readlinkat
int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz)
{
// TODO: Do better implementation following https://linux.die.net/man/2/linkat
// for now use the same as readlink
return readlink(pathname, buf, bufsiz);
}
#endif /* F_readlinkat */
#ifdef F_unlinkat
int unlinkat(int dirfd, const char *pathname, int flags)
{
// If flags contains AT_REMOVEDIR, then the path refers to a directory.
// Otherwise, the path refers to a file.
if (flags & AT_REMOVEDIR) {
return rmdir(pathname);
}
else {
return unlink(pathname);
}
}
#endif /* F_unlinkat */