Source: purelibc
Severity: normal
X-Debbugs-Cc: wuruil...@loongson.cn

Dear Maintainer,

purelibc failed to compile on loongarch, upstream has added support for 
loongarch, 
please refer to the attached patch or upgrade the software version to solve the 
problem. 
The link to the upstream commit code is as follows: 
https://github.com/virtualsquare/purelibc/commit/6df6bd54f40205e4a79115f49ad01dd080d5886c
https://github.com/virtualsquare/purelibc/commit/4d22452b569b5aa47ec44d8f66d1e36c8e0fcd45
https://github.com/virtualsquare/purelibc/commit/278dac7ea75df7df561daaec4c2ad746cbed901c

wuruilong

-- System Information:
Debian Release: trixie/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: loong64 (loongarch64)

Kernel: Linux 5.10.0-60.96.0.126.oe2203.loongarch64 (SMP w/32 CPU threads)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect
>From 6df6bd54f40205e4a79115f49ad01dd080d5886c Mon Sep 17 00:00:00 2001
From: Renzo Davoli <re...@cs.unibo.it>
Date: Tue, 3 Oct 2023 11:58:04 +0200
Subject: [PATCH 1/3] syscall: support archs without fstat

---
 syscalls.c | 42 ++++++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/syscalls.c b/syscalls.c
index cf5e4c7..fea7463 100644
--- a/syscalls.c
+++ b/syscalls.c
@@ -213,13 +213,19 @@ int dup3(int oldfd, int newfd, int flags){
 
 #if __WORDSIZE == 64 || defined(__ILP32__)
 # if defined(__NR_FSTATAT64) && ! defined(__NR_stat)
-#  define __USE_FSTATAT64
+#  define __USE_NEWSTAT64_STAT
+# endif
+# if defined(__NR_FSTATAT64) && ! defined(__NR_fstat)
+#  define __USE_NEWSTAT64_FSTAT
 # endif
 #      define arch_stat64 stat
 #      define IFNOT64(x)
 #else
 # if defined(__NR_FSTATAT64) && ! defined(__NR_stat64)
-#  define __USE_FSTATAT64
+#  define __USE_NEWSTAT64_STAT
+# endif
+# if defined(__NR_FSTATAT64) && ! defined(__NR_fstat64)
+#  define __USE_NEWSTAT64_FSTAT
 # endif
 #      define arch_stat64 stat64
 #      define IFNOT64(x) x
@@ -256,7 +262,7 @@ int stat(const char* pathname, struct stat* buf_stat)
        IFNOT64(struct stat64 *buf_stat64 = alloca(sizeof(struct stat64)));
                int rv;
 
-#ifdef __USE_FSTATAT64
+#ifdef __USE_NEWSTAT64_STAT
        rv = _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, MAKE_NAME(buf_, 
arch_stat64), 0);
 #else
        rv = _pure_syscall(MAKE_NAME(__NR_, arch_stat64), pathname, 
MAKE_NAME(buf_, arch_stat64));
@@ -272,7 +278,7 @@ int lstat(const char* pathname, struct stat* buf_stat)
        IFNOT64(struct stat64 *buf_stat64 = alloca(sizeof(struct stat64)));
                int rv;
 
-#ifdef __USE_FSTATAT64
+#ifdef __USE_NEWSTAT64_STAT
        rv = _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, MAKE_NAME(buf_, 
arch_stat64), AT_SYMLINK_NOFOLLOW);
 #else
        rv = _pure_syscall(MAKE_NAME(__NR_l, arch_stat64), pathname, 
MAKE_NAME(buf_, arch_stat64));
@@ -287,7 +293,11 @@ int fstat(int fildes, struct stat* buf_stat)
 {
        IFNOT64(struct stat64 *buf_stat64 = alloca(sizeof(struct stat64)));
                int rv;
+#ifdef __USE_NEWSTAT64_FSTAT
+       rv = _pure_syscall(__NR_FSTATAT64, fildes, "", MAKE_NAME(buf_, 
arch_stat64), AT_EMPTY_PATH);
+#else
        rv = _pure_syscall(MAKE_NAME(__NR_f, arch_stat64), fildes, 
MAKE_NAME(buf_, arch_stat64));
+#endif
        if (rv >= 0)
                arch_stat64_2_stat(MAKE_NAME(buf_, arch_stat64), buf_stat);
 
@@ -295,7 +305,7 @@ int fstat(int fildes, struct stat* buf_stat)
 }
 
 int stat64(const char* pathname,struct stat64* buf){
-#ifdef __USE_FSTATAT64
+#ifdef __USE_NEWSTAT64_STAT
        return _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, buf, 0);
 #else
        return _pure_syscall(MAKE_NAME(__NR_, arch_stat64), pathname, buf);
@@ -303,7 +313,7 @@ int stat64(const char* pathname,struct stat64* buf){
 }
 
 int lstat64(const char* pathname,struct stat64* buf){
-#ifdef __USE_FSTATAT64
+#ifdef __USE_NEWSTAT64_STAT
   return _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, buf, 
AT_SYMLINK_NOFOLLOW);
 #else
   return _pure_syscall(MAKE_NAME(__NR_l, arch_stat64), pathname, buf);
@@ -311,7 +321,11 @@ int lstat64(const char* pathname,struct stat64* buf){
 }
 
 int fstat64 (int fildes, struct stat64 *buf){
+#ifdef __USE_NEWSTAT64_FTAT
+  return _pure_syscall(__NR_FSTATAT64, fildes, "", buf, AT_EMPTY_PATH);
+#else
   return _pure_syscall(MAKE_NAME(__NR_f, arch_stat64), fildes, buf);
+#endif
 }
 
 int mknod(const char *pathname, mode_t mode, dev_t dev) {
@@ -331,7 +345,7 @@ int __xstat(int ver, const char* pathname, struct stat* 
buf_stat)
        switch(ver)
        {
                case _STAT_VER_LINUX:
-#ifdef __USE_FSTATAT64
+#ifdef __USE_NEWSTAT64_STAT
                        rv = _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, 
MAKE_NAME(buf_, arch_stat64), 0);
 #else
                        rv = _pure_syscall(MAKE_NAME(__NR_, arch_stat64), 
pathname, MAKE_NAME(buf_, arch_stat64));
@@ -357,7 +371,7 @@ int __lxstat(int ver, const char* pathname, struct stat* 
buf_stat)
        switch(ver)
        {
                case _STAT_VER_LINUX:
-#ifdef __USE_FSTATAT64
+#ifdef __USE_NEWSTAT64_STAT
                        rv = _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, 
MAKE_NAME(buf_, arch_stat64), AT_SYMLINK_NOFOLLOW);
 #else
                        rv = _pure_syscall(MAKE_NAME(__NR_l, arch_stat64), 
pathname, MAKE_NAME(buf_, arch_stat64));
@@ -382,7 +396,11 @@ int __fxstat(int ver, int fildes, struct stat* buf_stat)
        switch(ver)
        {
                case _STAT_VER_LINUX:
+#ifdef __USE_NEWSTAT64_FSTAT
+                       rv = _pure_syscall(__NR_FSTATAT64, fildes, "", 
MAKE_NAME(buf_, arch_stat64), AT_EMPTY_PATH);
+#else
                        rv = _pure_syscall(MAKE_NAME(__NR_f, arch_stat64), 
fildes, MAKE_NAME(buf_, arch_stat64));
+#endif
                        break;
 
                default:
@@ -396,7 +414,7 @@ int __fxstat(int ver, int fildes, struct stat* buf_stat)
 }
 
 int __xstat64(int ver,const char* pathname,struct stat64* buf){
-#ifdef __USE_FSTATAT64
+#ifdef __USE_NEWSTAT64_STAT
        return _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, buf, 0);
 #else
        return _pure_syscall(MAKE_NAME(__NR_, arch_stat64), pathname, buf);
@@ -404,7 +422,7 @@ int __xstat64(int ver,const char* pathname,struct stat64* 
buf){
 }
 
 int __lxstat64(int ver,const char* pathname,struct stat64* buf){
-#ifdef __USE_FSTATAT64
+#ifdef __USE_NEWSTAT64_STAT
        return _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, buf,   
AT_SYMLINK_NOFOLLOW);
 #else
        return _pure_syscall(MAKE_NAME(__NR_l, arch_stat64), pathname, buf);
@@ -412,7 +430,11 @@ int __lxstat64(int ver,const char* pathname,struct stat64* 
buf){
 }
 
 int __fxstat64 (int ver, int fildes, struct stat64 *buf){
+#ifdef __USE_NEWSTAT64_FSTAT
+       return _pure_syscall(__NR_FSTATAT64, fildes, "", buf,   AT_EMPTY_PATH);
+#else
        return _pure_syscall(MAKE_NAME(__NR_f, arch_stat64), fildes, buf);
+#endif
 }
 
 #ifdef __NR_FSTATAT64
-- 
2.43.0

>From 4d22452b569b5aa47ec44d8f66d1e36c8e0fcd45 Mon Sep 17 00:00:00 2001
From: Renzo Davoli <re...@cs.unibo.it>
Date: Tue, 3 Oct 2023 12:20:09 +0200
Subject: [PATCH 2/3] syscall: support for archs using statx for all
 stat/lstat/fstat etc.

---
 syscalls.c | 76 ++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 54 insertions(+), 22 deletions(-)

diff --git a/syscalls.c b/syscalls.c
index fea7463..8e979b1 100644
--- a/syscalls.c
+++ b/syscalls.c
@@ -45,6 +45,7 @@
 #include <sys/timeb.h>
 #include <sys/mman.h>
 #include <sys/epoll.h>
+#include <sys/sysmacros.h>
 #include <bits/wordsize.h>
 #include <utime.h>
 #include <stdarg.h>
@@ -211,6 +212,37 @@ int dup3(int oldfd, int newfd, int flags){
 #define __NR_FSTATAT64 __NR_newfstatat
 #endif
 
+#if defined(__NR_statx) && ! defined(__NR_FSTATAT64)
+       #define __NR_FSTATAT64 __NR_statx
+int __purelibc_newstat64(int dirfd, const char *restrict pathname,
+               struct stat *restrict statbuf, int flags) {
+  struct statx buf[1];
+  int rv = _pure_syscall(__NR_statx, dirfd, pathname, flags, 
STATX_BASIC_STATS, buf);
+  if (rv == 0) {
+    statbuf->st_dev = makedev(buf->stx_dev_major, buf->stx_dev_minor);
+    statbuf->st_ino = buf->stx_ino;
+    statbuf->st_mode = buf->stx_mode;
+    statbuf->st_nlink = buf->stx_nlink;
+    statbuf->st_uid = buf->stx_uid;
+    statbuf->st_gid = buf->stx_gid;
+    statbuf->st_rdev = makedev(buf->stx_rdev_major, buf->stx_rdev_minor);
+    statbuf->st_size = buf->stx_size;
+    statbuf->st_blksize = buf->stx_blksize;
+    statbuf->st_blocks = buf->stx_blocks;
+    statbuf->st_atim.tv_sec = buf->stx_atime.tv_sec;
+    statbuf->st_atim.tv_nsec = buf->stx_atime.tv_nsec;
+    statbuf->st_mtim.tv_sec = buf->stx_mtime.tv_sec;
+    statbuf->st_mtim.tv_nsec = buf->stx_mtime.tv_nsec;
+    statbuf->st_ctim.tv_sec = buf->stx_ctime.tv_sec;
+    statbuf->st_ctim.tv_nsec = buf->stx_ctime.tv_nsec;
+  }
+  return rv;
+}
+#else
+       #define __purelibc_newstat64(dirfd, pathname, statbuf, flags) \
+               _pure_syscall(__NR_FSTATAT64, (dirfd), (pathname), (statbuf), 
(flags))
+#endif
+
 #if __WORDSIZE == 64 || defined(__ILP32__)
 # if defined(__NR_FSTATAT64) && ! defined(__NR_stat)
 #  define __USE_NEWSTAT64_STAT
@@ -263,7 +295,7 @@ int stat(const char* pathname, struct stat* buf_stat)
                int rv;
 
 #ifdef __USE_NEWSTAT64_STAT
-       rv = _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, MAKE_NAME(buf_, 
arch_stat64), 0);
+       rv = __purelibc_newstat64(AT_FDCWD, pathname, MAKE_NAME(buf_, 
arch_stat64), 0);
 #else
        rv = _pure_syscall(MAKE_NAME(__NR_, arch_stat64), pathname, 
MAKE_NAME(buf_, arch_stat64));
 #endif
@@ -279,7 +311,7 @@ int lstat(const char* pathname, struct stat* buf_stat)
                int rv;
 
 #ifdef __USE_NEWSTAT64_STAT
-       rv = _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, MAKE_NAME(buf_, 
arch_stat64), AT_SYMLINK_NOFOLLOW);
+       rv = __purelibc_newstat64(AT_FDCWD, pathname, MAKE_NAME(buf_, 
arch_stat64), AT_SYMLINK_NOFOLLOW);
 #else
        rv = _pure_syscall(MAKE_NAME(__NR_l, arch_stat64), pathname, 
MAKE_NAME(buf_, arch_stat64));
 #endif
@@ -294,7 +326,7 @@ int fstat(int fildes, struct stat* buf_stat)
        IFNOT64(struct stat64 *buf_stat64 = alloca(sizeof(struct stat64)));
                int rv;
 #ifdef __USE_NEWSTAT64_FSTAT
-       rv = _pure_syscall(__NR_FSTATAT64, fildes, "", MAKE_NAME(buf_, 
arch_stat64), AT_EMPTY_PATH);
+       rv = __purelibc_newstat64(fildes, "", MAKE_NAME(buf_, arch_stat64), 
AT_EMPTY_PATH);
 #else
        rv = _pure_syscall(MAKE_NAME(__NR_f, arch_stat64), fildes, 
MAKE_NAME(buf_, arch_stat64));
 #endif
@@ -306,7 +338,7 @@ int fstat(int fildes, struct stat* buf_stat)
 
 int stat64(const char* pathname,struct stat64* buf){
 #ifdef __USE_NEWSTAT64_STAT
-       return _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, buf, 0);
+       return __purelibc_newstat64(AT_FDCWD, pathname, buf, 0);
 #else
        return _pure_syscall(MAKE_NAME(__NR_, arch_stat64), pathname, buf);
 #endif
@@ -314,15 +346,15 @@ int stat64(const char* pathname,struct stat64* buf){
 
 int lstat64(const char* pathname,struct stat64* buf){
 #ifdef __USE_NEWSTAT64_STAT
-  return _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, buf, 
AT_SYMLINK_NOFOLLOW);
+  return __purelibc_newstat64(AT_FDCWD, pathname, buf, AT_SYMLINK_NOFOLLOW);
 #else
   return _pure_syscall(MAKE_NAME(__NR_l, arch_stat64), pathname, buf);
 #endif
 }
 
 int fstat64 (int fildes, struct stat64 *buf){
-#ifdef __USE_NEWSTAT64_FTAT
-  return _pure_syscall(__NR_FSTATAT64, fildes, "", buf, AT_EMPTY_PATH);
+#ifdef __USE_NEWSTAT64_FSTAT
+  return __purelibc_newstat64(fildes, "", buf, AT_EMPTY_PATH);
 #else
   return _pure_syscall(MAKE_NAME(__NR_f, arch_stat64), fildes, buf);
 #endif
@@ -346,7 +378,7 @@ int __xstat(int ver, const char* pathname, struct stat* 
buf_stat)
        {
                case _STAT_VER_LINUX:
 #ifdef __USE_NEWSTAT64_STAT
-                       rv = _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, 
MAKE_NAME(buf_, arch_stat64), 0);
+                       rv = __purelibc_newstat64(AT_FDCWD, pathname, 
MAKE_NAME(buf_, arch_stat64), 0);
 #else
                        rv = _pure_syscall(MAKE_NAME(__NR_, arch_stat64), 
pathname, MAKE_NAME(buf_, arch_stat64));
 #endif
@@ -372,7 +404,7 @@ int __lxstat(int ver, const char* pathname, struct stat* 
buf_stat)
        {
                case _STAT_VER_LINUX:
 #ifdef __USE_NEWSTAT64_STAT
-                       rv = _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, 
MAKE_NAME(buf_, arch_stat64), AT_SYMLINK_NOFOLLOW);
+                       rv = __purelibc_newstat64(AT_FDCWD, pathname, 
MAKE_NAME(buf_, arch_stat64), AT_SYMLINK_NOFOLLOW);
 #else
                        rv = _pure_syscall(MAKE_NAME(__NR_l, arch_stat64), 
pathname, MAKE_NAME(buf_, arch_stat64));
 #endif
@@ -397,7 +429,7 @@ int __fxstat(int ver, int fildes, struct stat* buf_stat)
        {
                case _STAT_VER_LINUX:
 #ifdef __USE_NEWSTAT64_FSTAT
-                       rv = _pure_syscall(__NR_FSTATAT64, fildes, "", 
MAKE_NAME(buf_, arch_stat64), AT_EMPTY_PATH);
+                       rv = __purelibc_newstat64(fildes, "", MAKE_NAME(buf_, 
arch_stat64), AT_EMPTY_PATH);
 #else
                        rv = _pure_syscall(MAKE_NAME(__NR_f, arch_stat64), 
fildes, MAKE_NAME(buf_, arch_stat64));
 #endif
@@ -415,7 +447,7 @@ int __fxstat(int ver, int fildes, struct stat* buf_stat)
 
 int __xstat64(int ver,const char* pathname,struct stat64* buf){
 #ifdef __USE_NEWSTAT64_STAT
-       return _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, buf, 0);
+       return __purelibc_newstat64(AT_FDCWD, pathname, buf, 0);
 #else
        return _pure_syscall(MAKE_NAME(__NR_, arch_stat64), pathname, buf);
 #endif
@@ -423,7 +455,7 @@ int __xstat64(int ver,const char* pathname,struct stat64* 
buf){
 
 int __lxstat64(int ver,const char* pathname,struct stat64* buf){
 #ifdef __USE_NEWSTAT64_STAT
-       return _pure_syscall(__NR_FSTATAT64, AT_FDCWD, pathname, buf,   
AT_SYMLINK_NOFOLLOW);
+       return __purelibc_newstat64(AT_FDCWD, pathname, buf,    
AT_SYMLINK_NOFOLLOW);
 #else
        return _pure_syscall(MAKE_NAME(__NR_l, arch_stat64), pathname, buf);
 #endif
@@ -431,7 +463,7 @@ int __lxstat64(int ver,const char* pathname,struct stat64* 
buf){
 
 int __fxstat64 (int ver, int fildes, struct stat64 *buf){
 #ifdef __USE_NEWSTAT64_FSTAT
-       return _pure_syscall(__NR_FSTATAT64, fildes, "", buf,   AT_EMPTY_PATH);
+       return __purelibc_newstat64(fildes, "", buf,    AT_EMPTY_PATH);
 #else
        return _pure_syscall(MAKE_NAME(__NR_f, arch_stat64), fildes, buf);
 #endif
@@ -439,7 +471,7 @@ int __fxstat64 (int ver, int fildes, struct stat64 *buf){
 
 #ifdef __NR_FSTATAT64
 int __fxstatat64 (int ver, int dirfd, const char *pathname, struct stat64 
*buf, int flags){
-       return _pure_syscall(__NR_FSTATAT64,dirfd,pathname,buf,flags);
+       return __purelibc_newstat64(dirfd,pathname,buf,flags);
 }
 int __fxstatat(int ver, int fildes, const char *pathname, struct stat* 
buf_stat,int flags)
 {
@@ -448,7 +480,7 @@ int __fxstatat(int ver, int fildes, const char *pathname, 
struct stat* buf_stat,
        switch(ver)
        {
                case _STAT_VER_LINUX:
-                       rv = _pure_syscall(__NR_FSTATAT64, fildes, pathname, 
MAKE_NAME(buf_, arch_stat64), flags);
+                       rv = __purelibc_newstat64(fildes, pathname, 
MAKE_NAME(buf_, arch_stat64), flags);
                        break;
 
                default:
@@ -474,7 +506,7 @@ int __xmknod (int ver, const char *path, mode_t mode, dev_t 
*dev) {
 
 #ifdef __NR_FSTATAT64
 int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags) {
-       return _pure_syscall(__NR_FSTATAT64,dirfd,pathname,buf,flags);
+       return __purelibc_newstat64(dirfd,pathname,buf,flags);
 }
 #endif
 
@@ -634,7 +666,7 @@ ssize_t pread64(int fs,void* buf, size_t count, __off64_t 
offset){
 #if defined(__powerpc__) || defined(__arm__)
                        0,
 #endif
-                       __LONG_LONG_PAIR( 
(__off_t)(offset>>32),(__off_t)(offset&0xffffffff)));
+                       
__LONG_LONG_PAIR((__off_t)(offset>>32),(__off_t)(offset&0xffffffff)));
 }
 ssize_t pread(int fs,void* buf, size_t count, __off_t offset){
        return pread64(fs,buf,count,(__off64_t)offset);
@@ -647,7 +679,7 @@ ssize_t pwrite64(int fs,const void* buf, size_t count, 
__off64_t offset){
 #if defined(__powerpc__) || defined(__arm__)
                        0,
 #endif
-                       __LONG_LONG_PAIR( 
(__off_t)(offset>>32),(__off_t)(offset&0xffffffff)));
+                       
__LONG_LONG_PAIR((__off_t)(offset>>32),(__off_t)(offset&0xffffffff)));
 }
 ssize_t pwrite(int fs,const void* buf, size_t count, __off_t offset){
        return pwrite64(fs,buf,count,(__off64_t)offset);
@@ -661,7 +693,7 @@ ssize_t preadv64(int fs,const struct iovec *iov, int 
iovcnt, __off64_t offset){
 #if defined(__powerpc__) || defined(__arm__)
                        0,
 #endif
-                       __LONG_LONG_PAIR( 
(__off_t)(offset>>32),(__off_t)(offset&0xffffffff))
+                       
__LONG_LONG_PAIR((__off_t)(offset>>32),(__off_t)(offset&0xffffffff))
 #else
                        offset
 #endif
@@ -700,7 +732,7 @@ ssize_t pwritev64(int fs,const struct iovec *iov, int 
iovcnt, __off64_t offset){
 #if defined(__powerpc__) || defined(__arm__)
                        0,
 #endif
-                       __LONG_LONG_PAIR( 
(__off_t)(offset>>32),(__off_t)(offset&0xffffffff))
+                       
__LONG_LONG_PAIR((__off_t)(offset>>32),(__off_t)(offset&0xffffffff))
 #else
                        offset
 #endif
@@ -1284,7 +1316,7 @@ int truncate64(const char *path, __off64_t length){
 #if defined(__powerpc__)
                        0,
 #endif
-                       __LONG_LONG_PAIR( 
(__off_t)(length>>32),(__off_t)(length&0xffffffff)));
+                       
__LONG_LONG_PAIR((__off_t)(length>>32),(__off_t)(length&0xffffffff)));
 }
 #endif
 
@@ -1294,7 +1326,7 @@ int ftruncate64(int fd, __off64_t length){
 #if defined(__powerpc__)
                        0,
 #endif
-                       __LONG_LONG_PAIR( 
(__off_t)(length>>32),(__off_t)(length&0xffffffff)));
+                       
__LONG_LONG_PAIR((__off_t)(length>>32),(__off_t)(length&0xffffffff)));
 }
 #endif
 
-- 
2.43.0

>From 278dac7ea75df7df561daaec4c2ad746cbed901c Mon Sep 17 00:00:00 2001
From: Renzo Davoli <re...@cs.unibo.it>
Date: Wed, 4 Oct 2023 10:28:30 +0200
Subject: [PATCH 3/3] syscall: loongarch compatibility

---
 syscalls.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/syscalls.c b/syscalls.c
index 8e979b1..9027867 100644
--- a/syscalls.c
+++ b/syscalls.c
@@ -1070,7 +1070,7 @@ pid_t fork(void){
                return -1;
        else
                return child_tid;
-#elif defined(__aarch64__) || defined(__riscv) && __riscv_xlen==64
+#elif defined(__aarch64__) || (defined(__riscv) && __riscv_xlen==64) || 
defined(__loongarch__)
        int child_tid;
        if (_pure_syscall(__NR_clone, NULL, 
CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, &child_tid) < 0)
                return -1;
@@ -1120,7 +1120,8 @@ int nice(int inc){
        defined(__alpha__) || defined(__s390x__) || \
        (defined(__mips__) && defined(__LP64__)) || \
        defined(__aarch64__) || \
-       (defined(__riscv) && __riscv_xlen==64)
+       (defined(__riscv) && __riscv_xlen==64) || \
+       defined(__loongarch__)
        int nice = _pure_syscall(__NR_getpriority,PRIO_PROCESS,0);
        return _pure_syscall(__NR_setpriority,PRIO_PROCESS,0,nice + inc);
 #else
@@ -1249,7 +1250,7 @@ int select(int n, fd_set *readfds, fd_set *writefds, 
fd_set *exceptfds, struct t
 #if defined(__x86_64__) || defined(__s390x__) || \
        defined(__alpha__) || defined(__ia64__)
        return _pure_syscall(__NR_select,n,readfds,writefds,exceptfds,timeout);
-#elif defined(__aarch64__) || defined(__riscv) && __riscv_xlen==64
+#elif defined(__aarch64__) || (defined(__riscv) && __riscv_xlen==64) || 
defined(__loongarch__)
        if (timeout == NULL)
                return pselect(n,readfds,writefds,exceptfds,NULL,NULL);
        else {
-- 
2.43.0

Reply via email to