#ifndef SYS_LINUX_SYSCALL_SUPPORT_H
#define SYS_LINUX_SYSCALL_SUPPORT_H
#if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \
defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \
defined(__aarch64__) || defined(__s390__) || defined(__e2k__) || \
(defined(__riscv) && __riscv_xlen == 64) || defined(__loongarch_lp64)) \
&& (defined(__linux) || defined(__ANDROID__))
#ifndef SYS_CPLUSPLUS
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <sys/ptrace.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <linux/unistd.h>
#include <endian.h>
#ifdef __mips__
#ifdef __ANDROID__
#include <asm/sgidefs.h>
#else
#include <sgidefs.h>
#endif
#endif
#endif
#pragma push_macro("stat64")
#pragma push_macro("fstat64")
#pragma push_macro("lstat64")
#pragma push_macro("pread64")
#pragma push_macro("pwrite64")
#pragma push_macro("getdents64")
#undef stat64
#undef fstat64
#undef lstat64
#undef pread64
#undef pwrite64
#undef getdents64
#if defined(__ANDROID__) && defined(__x86_64__)
# undef __NR_getdents
# undef __NR_dup2
# undef __NR_fork
# undef __NR_getpgrp
# undef __NR_open
# undef __NR_poll
# undef __NR_readlink
# undef __NR_stat
# undef __NR_unlink
# undef __NR_pipe
#endif
#if defined(__ANDROID__)
# undef __NR_waitpid
#endif
struct kernel_dirent64 { … };
#if !defined(__NR_getdents)
#define kernel_dirent …
#else
struct kernel_dirent { … };
#endif
struct kernel_iovec { … };
struct kernel_msghdr { … };
struct kernel_pollfd { … };
struct kernel_rlimit { … };
struct kernel_timespec { … };
struct kernel_timeval { … };
struct kernel_itimerval { … };
struct kernel_rusage { … };
#if defined(__i386__) || defined(__ARM_EABI__) || defined(__ARM_ARCH_3__) \
|| defined(__PPC__) || (defined(__s390__) && !defined(__s390x__)) \
|| defined(__e2k__)
struct kernel_old_sigaction {
union {
void (*sa_handler_)(int);
void (*sa_sigaction_)(int, siginfo_t *, void *);
};
unsigned long sa_mask;
unsigned long sa_flags;
void (*sa_restorer)(void);
} __attribute__((packed,aligned(4)));
#elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32)
#define kernel_old_sigaction …
#elif defined(__aarch64__) || defined(__riscv) || defined(__loongarch_lp64)
#endif
#ifdef __mips__
#define KERNEL_NSIG …
#else
#define KERNEL_NSIG …
#endif
struct kernel_sigset_t { … };
struct kernel_sigaction { … };
struct kernel_sockaddr { … };
#ifdef __mips__
#if _MIPS_SIM == _MIPS_SIM_ABI64
typedef unsigned long long kernel_blkcnt_t;
typedef unsigned kernel_blksize_t;
typedef unsigned kernel_dev_t;
typedef unsigned kernel_gid_t;
typedef unsigned long long kernel_ino_t;
typedef unsigned kernel_mode_t;
typedef unsigned kernel_nlink_t;
typedef long long kernel_off_t;
typedef unsigned kernel_time_t;
typedef unsigned kernel_uid_t;
struct kernel_stat {
#else
struct kernel_stat64 {
#endif
unsigned st_dev;
unsigned __pad0[3];
unsigned long long st_ino;
unsigned st_mode;
unsigned st_nlink;
unsigned st_uid;
unsigned st_gid;
unsigned st_rdev;
unsigned __pad1[3];
long long st_size;
unsigned st_atime_;
unsigned st_atime_nsec_;
unsigned st_mtime_;
unsigned st_mtime_nsec_;
unsigned st_ctime_;
unsigned st_ctime_nsec_;
unsigned st_blksize;
unsigned __pad2;
unsigned long long st_blocks;
};
#elif defined __PPC__
struct kernel_stat64 {
unsigned long long st_dev;
unsigned long long st_ino;
unsigned st_mode;
unsigned st_nlink;
unsigned st_uid;
unsigned st_gid;
unsigned long long st_rdev;
unsigned short int __pad2;
long long st_size;
long st_blksize;
long long st_blocks;
long st_atime_;
unsigned long st_atime_nsec_;
long st_mtime_;
unsigned long st_mtime_nsec_;
long st_ctime_;
unsigned long st_ctime_nsec_;
unsigned long __unused4;
unsigned long __unused5;
};
#elif defined(__e2k__)
struct kernel_stat64 {
unsigned long long st_dev;
unsigned long long st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned int st_uid;
unsigned int st_gid;
unsigned long long st_rdev;
long long st_size;
int st_blksize;
int __pad2;
unsigned long long st_blocks;
int st_atime_;
unsigned int st_atime_nsec_;
int st_mtime_;
unsigned int st_mtime_nsec_;
int st_ctime_;
unsigned int st_ctime_nsec_;
unsigned int __unused4;
unsigned int __unused5;
};
#else
struct kernel_stat64 { … };
#endif
#if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__)
typedef unsigned kernel_blkcnt_t;
typedef unsigned kernel_blksize_t;
typedef unsigned short kernel_dev_t;
typedef unsigned short kernel_gid_t;
typedef unsigned kernel_ino_t;
typedef unsigned short kernel_mode_t;
typedef unsigned short kernel_nlink_t;
typedef unsigned kernel_off_t;
typedef unsigned kernel_time_t;
typedef unsigned short kernel_uid_t;
struct kernel_stat {
kernel_dev_t st_dev;
short pad1;
kernel_ino_t st_ino;
kernel_mode_t st_mode;
kernel_nlink_t st_nlink;
kernel_uid_t st_uid;
kernel_gid_t st_gid;
kernel_dev_t st_rdev;
short pad2;
kernel_off_t st_size;
kernel_blksize_t st_blksize;
kernel_blkcnt_t st_blocks;
kernel_time_t st_atime_;
unsigned st_atime_nsec_;
kernel_time_t st_mtime_;
unsigned st_mtime_nsec_;
kernel_time_t st_ctime_;
unsigned st_ctime_nsec_;
unsigned __unused4;
unsigned __unused5;
};
#elif defined(__x86_64__)
kernel_blkcnt_t;
kernel_blksize_t;
kernel_dev_t;
kernel_gid_t;
kernel_ino_t;
kernel_mode_t;
kernel_nlink_t;
kernel_off_t;
kernel_time_t;
kernel_uid_t;
struct kernel_stat { … };
#elif defined(__PPC__)
typedef unsigned long kernel_blkcnt_t;
typedef unsigned long kernel_blksize_t;
typedef unsigned kernel_dev_t;
typedef unsigned kernel_gid_t;
typedef unsigned long kernel_ino_t;
typedef unsigned long kernel_mode_t;
typedef unsigned short kernel_nlink_t;
typedef long kernel_off_t;
typedef unsigned long kernel_time_t;
typedef unsigned kernel_uid_t;
struct kernel_stat {
kernel_dev_t st_dev;
kernel_ino_t st_ino;
kernel_mode_t st_mode;
kernel_nlink_t st_nlink;
kernel_gid_t st_uid;
kernel_uid_t st_gid;
kernel_dev_t st_rdev;
kernel_off_t st_size;
kernel_blksize_t st_blksize;
kernel_blkcnt_t st_blocks;
kernel_time_t st_atime_;
unsigned long st_atime_nsec_;
kernel_time_t st_mtime_;
unsigned long st_mtime_nsec_;
kernel_time_t st_ctime_;
unsigned long st_ctime_nsec_;
unsigned long __unused4;
unsigned long __unused5;
};
#elif (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64)
typedef int kernel_blkcnt_t;
typedef int kernel_blksize_t;
typedef unsigned kernel_dev_t;
typedef unsigned kernel_gid_t;
typedef unsigned kernel_ino_t;
typedef unsigned kernel_mode_t;
typedef unsigned kernel_nlink_t;
typedef long kernel_off_t;
typedef long kernel_time_t;
typedef unsigned kernel_uid_t;
struct kernel_stat {
kernel_dev_t st_dev;
int st_pad1[3];
kernel_ino_t st_ino;
kernel_mode_t st_mode;
kernel_nlink_t st_nlink;
kernel_uid_t st_uid;
kernel_gid_t st_gid;
kernel_dev_t st_rdev;
int st_pad2[2];
kernel_off_t st_size;
int st_pad3;
kernel_time_t st_atime_;
long st_atime_nsec_;
kernel_time_t st_mtime_;
long st_mtime_nsec_;
kernel_time_t st_ctime_;
long st_ctime_nsec_;
kernel_blksize_t st_blksize;
kernel_blkcnt_t st_blocks;
int st_pad4[14];
};
#elif defined(__aarch64__) || defined(__riscv) || defined(__loongarch_lp64)
typedef long kernel_blkcnt_t;
typedef int kernel_blksize_t;
typedef unsigned long kernel_dev_t;
typedef unsigned int kernel_gid_t;
typedef unsigned long kernel_ino_t;
typedef unsigned int kernel_mode_t;
typedef unsigned int kernel_nlink_t;
typedef long kernel_off_t;
typedef long kernel_time_t;
typedef unsigned int kernel_uid_t;
struct kernel_stat {
kernel_dev_t st_dev;
kernel_ino_t st_ino;
kernel_mode_t st_mode;
kernel_nlink_t st_nlink;
kernel_uid_t st_uid;
kernel_gid_t st_gid;
kernel_dev_t st_rdev;
unsigned long __pad1;
kernel_off_t st_size;
kernel_blksize_t st_blksize;
int __pad2;
kernel_blkcnt_t st_blocks;
kernel_time_t st_atime_;
unsigned long st_atime_nsec_;
kernel_time_t st_mtime_;
unsigned long st_mtime_nsec_;
kernel_time_t st_ctime_;
unsigned long st_ctime_nsec_;
unsigned int __unused4;
unsigned int __unused5;
};
#elif defined(__s390x__)
typedef long kernel_blkcnt_t;
typedef unsigned long kernel_blksize_t;
typedef unsigned long kernel_dev_t;
typedef unsigned int kernel_gid_t;
typedef unsigned long kernel_ino_t;
typedef unsigned int kernel_mode_t;
typedef unsigned long kernel_nlink_t;
typedef unsigned long kernel_off_t;
typedef unsigned long kernel_time_t;
typedef unsigned int kernel_uid_t;
struct kernel_stat {
kernel_dev_t st_dev;
kernel_ino_t st_ino;
kernel_nlink_t st_nlink;
kernel_mode_t st_mode;
kernel_uid_t st_uid;
kernel_gid_t st_gid;
unsigned int __pad1;
kernel_dev_t st_rdev;
kernel_off_t st_size;
kernel_time_t st_atime_;
unsigned long st_atime_nsec_;
kernel_time_t st_mtime_;
unsigned long st_mtime_nsec_;
kernel_time_t st_ctime_;
unsigned long st_ctime_nsec_;
kernel_blksize_t st_blksize;
kernel_blkcnt_t st_blocks;
unsigned long __unused[3];
};
#elif defined(__s390__)
typedef unsigned long kernel_blkcnt_t;
typedef unsigned long kernel_blksize_t;
typedef unsigned short kernel_dev_t;
typedef unsigned short kernel_gid_t;
typedef unsigned long kernel_ino_t;
typedef unsigned short kernel_mode_t;
typedef unsigned short kernel_nlink_t;
typedef unsigned long kernel_off_t;
typedef unsigned long kernel_time_t;
typedef unsigned short kernel_uid_t;
struct kernel_stat {
kernel_dev_t st_dev;
unsigned short __pad1;
kernel_ino_t st_ino;
kernel_mode_t st_mode;
kernel_nlink_t st_nlink;
kernel_uid_t st_uid;
kernel_gid_t st_gid;
kernel_dev_t st_rdev;
unsigned short __pad2;
kernel_off_t st_size;
kernel_blksize_t st_blksize;
kernel_blkcnt_t st_blocks;
kernel_time_t st_atime_;
unsigned long st_atime_nsec_;
kernel_time_t st_mtime_;
unsigned long st_mtime_nsec_;
kernel_time_t st_ctime_;
unsigned long st_ctime_nsec_;
unsigned long __unused4;
unsigned long __unused5;
};
#elif defined(__e2k__)
typedef unsigned long kernel_blkcnt_t;
typedef unsigned long kernel_blksize_t;
typedef unsigned long kernel_dev_t;
typedef unsigned int kernel_gid_t;
typedef unsigned long kernel_ino_t;
typedef unsigned int kernel_mode_t;
typedef unsigned long kernel_nlink_t;
typedef unsigned long kernel_off_t;
typedef unsigned long kernel_time_t;
typedef unsigned int kernel_uid_t;
struct kernel_stat {
kernel_dev_t st_dev;
kernel_ino_t st_ino;
kernel_mode_t st_mode;
kernel_nlink_t st_nlink;
kernel_uid_t st_uid;
kernel_gid_t st_gid;
kernel_dev_t st_rdev;
kernel_off_t st_size;
kernel_blksize_t st_blksize;
kernel_blkcnt_t st_blocks;
kernel_time_t st_atime_;
unsigned long st_atime_nsec_;
kernel_time_t st_mtime_;
unsigned long st_mtime_nsec_;
kernel_time_t st_ctime_;
unsigned long st_ctime_nsec_;
};
#endif
#ifdef __mips__
#if _MIPS_SIM != _MIPS_SIM_ABI64
struct kernel_statfs64 {
unsigned long f_type;
unsigned long f_bsize;
unsigned long f_frsize;
unsigned long __pad;
unsigned long long f_blocks;
unsigned long long f_bfree;
unsigned long long f_files;
unsigned long long f_ffree;
unsigned long long f_bavail;
struct { int val[2]; } f_fsid;
unsigned long f_namelen;
unsigned long f_spare[6];
};
#endif
#elif defined(__s390__)
struct kernel_statfs64 {
unsigned int f_type;
unsigned int f_bsize;
unsigned long long f_blocks;
unsigned long long f_bfree;
unsigned long long f_bavail;
unsigned long long f_files;
unsigned long long f_ffree;
struct { int val[2]; } f_fsid;
unsigned int f_namelen;
unsigned int f_frsize;
unsigned int f_flags;
unsigned int f_spare[4];
};
#elif !defined(__x86_64__)
struct kernel_statfs64 {
unsigned long f_type;
unsigned long f_bsize;
unsigned long long f_blocks;
unsigned long long f_bfree;
unsigned long long f_bavail;
unsigned long long f_files;
unsigned long long f_ffree;
struct { int val[2]; } f_fsid;
unsigned long f_namelen;
unsigned long f_frsize;
unsigned long f_spare[5];
};
#endif
#ifdef __mips__
struct kernel_statfs {
long f_type;
long f_bsize;
long f_frsize;
long f_blocks;
long f_bfree;
long f_files;
long f_ffree;
long f_bavail;
struct { int val[2]; } f_fsid;
long f_namelen;
long f_spare[6];
};
#elif defined(__x86_64__)
struct kernel_statfs { … };
#elif defined(__s390__)
struct kernel_statfs {
unsigned int f_type;
unsigned int f_bsize;
unsigned long f_blocks;
unsigned long f_bfree;
unsigned long f_bavail;
unsigned long f_files;
unsigned long f_ffree;
struct { int val[2]; } f_fsid;
unsigned int f_namelen;
unsigned int f_frsize;
unsigned int f_flags;
unsigned int f_spare[4];
};
#else
struct kernel_statfs {
unsigned long f_type;
unsigned long f_bsize;
unsigned long f_blocks;
unsigned long f_bfree;
unsigned long f_bavail;
unsigned long f_files;
unsigned long f_ffree;
struct { int val[2]; } f_fsid;
unsigned long f_namelen;
unsigned long f_frsize;
unsigned long f_spare[5];
};
#endif
struct kernel_statx_timestamp { … };
struct kernel_statx { … };
#ifndef O_DIRECTORY
#if defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || defined(__aarch64__)
#define O_DIRECTORY …
#else
#define O_DIRECTORY …
#endif
#endif
#ifndef NT_PRXFPREG
#define NT_PRXFPREG …
#endif
#ifndef PTRACE_GETFPXREGS
#define PTRACE_GETFPXREGS …
#endif
#ifndef PR_GET_DUMPABLE
#define PR_GET_DUMPABLE …
#endif
#ifndef PR_SET_DUMPABLE
#define PR_SET_DUMPABLE …
#endif
#ifndef PR_GET_SECCOMP
#define PR_GET_SECCOMP …
#endif
#ifndef PR_SET_SECCOMP
#define PR_SET_SECCOMP …
#endif
#ifndef AT_FDCWD
#define AT_FDCWD …
#endif
#ifndef AT_SYMLINK_NOFOLLOW
#define AT_SYMLINK_NOFOLLOW …
#endif
#ifndef AT_REMOVEDIR
#define AT_REMOVEDIR …
#endif
#ifndef AT_NO_AUTOMOUNT
#define AT_NO_AUTOMOUNT …
#endif
#ifndef AT_EMPTY_PATH
#define AT_EMPTY_PATH …
#endif
#ifndef STATX_BASIC_STATS
#define STATX_BASIC_STATS …
#endif
#ifndef AT_STATX_SYNC_AS_STAT
#define AT_STATX_SYNC_AS_STAT …
#endif
#ifndef MREMAP_FIXED
#define MREMAP_FIXED …
#endif
#ifndef SA_RESTORER
#define SA_RESTORER …
#endif
#ifndef CPUCLOCK_PROF
#define CPUCLOCK_PROF …
#endif
#ifndef CPUCLOCK_VIRT
#define CPUCLOCK_VIRT …
#endif
#ifndef CPUCLOCK_SCHED
#define CPUCLOCK_SCHED …
#endif
#ifndef CPUCLOCK_PERTHREAD_MASK
#define CPUCLOCK_PERTHREAD_MASK …
#endif
#ifndef MAKE_PROCESS_CPUCLOCK
#define MAKE_PROCESS_CPUCLOCK(pid, clock) …
#endif
#ifndef MAKE_THREAD_CPUCLOCK
#define MAKE_THREAD_CPUCLOCK(tid, clock) …
#endif
#ifndef FUTEX_WAIT
#define FUTEX_WAIT …
#endif
#ifndef FUTEX_WAKE
#define FUTEX_WAKE …
#endif
#ifndef FUTEX_FD
#define FUTEX_FD …
#endif
#ifndef FUTEX_REQUEUE
#define FUTEX_REQUEUE …
#endif
#ifndef FUTEX_CMP_REQUEUE
#define FUTEX_CMP_REQUEUE …
#endif
#ifndef FUTEX_WAKE_OP
#define FUTEX_WAKE_OP …
#endif
#ifndef FUTEX_LOCK_PI
#define FUTEX_LOCK_PI …
#endif
#ifndef FUTEX_UNLOCK_PI
#define FUTEX_UNLOCK_PI …
#endif
#ifndef FUTEX_TRYLOCK_PI
#define FUTEX_TRYLOCK_PI …
#endif
#ifndef FUTEX_PRIVATE_FLAG
#define FUTEX_PRIVATE_FLAG …
#endif
#ifndef FUTEX_CMD_MASK
#define FUTEX_CMD_MASK …
#endif
#ifndef FUTEX_WAIT_PRIVATE
#define FUTEX_WAIT_PRIVATE …
#endif
#ifndef FUTEX_WAKE_PRIVATE
#define FUTEX_WAKE_PRIVATE …
#endif
#ifndef FUTEX_REQUEUE_PRIVATE
#define FUTEX_REQUEUE_PRIVATE …
#endif
#ifndef FUTEX_CMP_REQUEUE_PRIVATE
#define FUTEX_CMP_REQUEUE_PRIVATE …
#endif
#ifndef FUTEX_WAKE_OP_PRIVATE
#define FUTEX_WAKE_OP_PRIVATE …
#endif
#ifndef FUTEX_LOCK_PI_PRIVATE
#define FUTEX_LOCK_PI_PRIVATE …
#endif
#ifndef FUTEX_UNLOCK_PI_PRIVATE
#define FUTEX_UNLOCK_PI_PRIVATE …
#endif
#ifndef FUTEX_TRYLOCK_PI_PRIVATE
#define FUTEX_TRYLOCK_PI_PRIVATE …
#endif
#if defined(__x86_64__)
#ifndef ARCH_SET_GS
#define ARCH_SET_GS …
#endif
#ifndef ARCH_GET_GS
#define ARCH_GET_GS …
#endif
#endif
#if defined(__i386__)
#ifndef __NR_quotactl
#define __NR_quotactl …
#endif
#ifndef __NR_setresuid
#define __NR_setresuid …
#define __NR_getresuid …
#define __NR_setresgid …
#define __NR_getresgid …
#endif
#ifndef __NR_rt_sigaction
#define __NR_rt_sigreturn …
#define __NR_rt_sigaction …
#define __NR_rt_sigprocmask …
#define __NR_rt_sigpending …
#define __NR_rt_sigsuspend …
#endif
#ifndef __NR_pread64
#define __NR_pread64 …
#endif
#ifndef __NR_pwrite64
#define __NR_pwrite64 …
#endif
#ifndef __NR_ugetrlimit
#define __NR_ugetrlimit …
#endif
#ifndef __NR_stat64
#define __NR_stat64 …
#endif
#ifndef __NR_fstat64
#define __NR_fstat64 …
#endif
#ifndef __NR_setresuid32
#define __NR_setresuid32 …
#define __NR_getresuid32 …
#define __NR_setresgid32 …
#define __NR_getresgid32 …
#endif
#ifndef __NR_setfsuid32
#define __NR_setfsuid32 …
#define __NR_setfsgid32 …
#endif
#ifndef __NR_getdents64
#define __NR_getdents64 …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_statfs64
#define __NR_statfs64 …
#endif
#ifndef __NR_fstatfs64
#define __NR_fstatfs64 …
#endif
#ifndef __NR_fadvise64_64
#define __NR_fadvise64_64 …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#ifndef __NR_openat
#define __NR_openat …
#endif
#ifndef __NR_fstatat64
#define __NR_fstatat64 …
#endif
#ifndef __NR_unlinkat
#define __NR_unlinkat …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_getcpu
#define __NR_getcpu …
#endif
#ifndef __NR_fallocate
#define __NR_fallocate …
#endif
#ifndef __NR_getrandom
#define __NR_getrandom …
#endif
#elif defined(__ARM_ARCH_3__) || defined(__ARM_EABI__)
#ifndef __NR_setresuid
#define __NR_setresuid …
#define __NR_getresuid …
#define __NR_setresgid …
#define __NR_getresgid …
#endif
#ifndef __NR_rt_sigaction
#define __NR_rt_sigreturn …
#define __NR_rt_sigaction …
#define __NR_rt_sigprocmask …
#define __NR_rt_sigpending …
#define __NR_rt_sigsuspend …
#endif
#ifndef __NR_pread64
#define __NR_pread64 …
#endif
#ifndef __NR_pwrite64
#define __NR_pwrite64 …
#endif
#ifndef __NR_ugetrlimit
#define __NR_ugetrlimit …
#endif
#ifndef __NR_stat64
#define __NR_stat64 …
#endif
#ifndef __NR_fstat64
#define __NR_fstat64 …
#endif
#ifndef __NR_setresuid32
#define __NR_setresuid32 …
#define __NR_getresuid32 …
#define __NR_setresgid32 …
#define __NR_getresgid32 …
#endif
#ifndef __NR_setfsuid32
#define __NR_setfsuid32 …
#define __NR_setfsgid32 …
#endif
#ifndef __NR_getdents64
#define __NR_getdents64 …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_statfs64
#define __NR_statfs64 …
#endif
#ifndef __NR_fstatfs64
#define __NR_fstatfs64 …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#ifndef __NR_fstatat64
#define __NR_fstatat64 …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_getcpu
#define __NR_getcpu …
#endif
#ifndef __NR_getrandom
#define __NR_getrandom …
#endif
#elif defined(__aarch64__) || defined(__riscv) || defined(__loongarch_lp64)
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#ifndef __NR_unlinkat
#define __NR_unlinkat …
#endif
#ifndef __NR_fallocate
#define __NR_fallocate …
#endif
#ifndef __NR_openat
#define __NR_openat …
#endif
#ifndef __NR_quotactl
#define __NR_quotactl …
#endif
#ifndef __NR_getdents64
#define __NR_getdents64 …
#endif
#ifndef __NR_getdents
#define __NR_getdents …
#endif
#ifndef __NR_pread64
#define __NR_pread64 …
#endif
#ifndef __NR_pwrite64
#define __NR_pwrite64 …
#endif
#ifndef __NR_ppoll
#define __NR_ppoll …
#endif
#ifndef __NR_readlinkat
#define __NR_readlinkat …
#endif
#if !defined(__loongarch_lp64)
#ifndef __NR_newfstatat
#define __NR_newfstatat …
#endif
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_setresuid
#define __NR_setresuid …
#define __NR_getresuid …
#define __NR_setresgid …
#define __NR_getresgid …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_fadvise64
#define __NR_fadvise64 …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_getrandom
#define __NR_getrandom …
#endif
#ifndef __NR_statx
#define __NR_statx …
#endif
#elif defined(__x86_64__)
#ifndef __NR_pread64
#define __NR_pread64 …
#endif
#ifndef __NR_pwrite64
#define __NR_pwrite64 …
#endif
#ifndef __NR_setresuid
#define __NR_setresuid …
#define __NR_getresuid …
#define __NR_setresgid …
#define __NR_getresgid …
#endif
#ifndef __NR_quotactl
#define __NR_quotactl …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_getdents64
#define __NR_getdents64 …
#endif
#ifndef __NR_getdents
#define __NR_getdents …
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_fadvise64
#define __NR_fadvise64 …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#ifndef __NR_openat
#define __NR_openat …
#endif
#ifndef __NR_newfstatat
#define __NR_newfstatat …
#endif
#ifndef __NR_unlinkat
#define __NR_unlinkat …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_fallocate
#define __NR_fallocate …
#endif
#ifndef __NR_getrandom
#define __NR_getrandom …
#endif
#elif defined(__mips__)
#if _MIPS_SIM == _MIPS_SIM_ABI32
#ifndef __NR_setresuid
#define __NR_setresuid …
#define __NR_getresuid …
#define __NR_setresgid …
#define __NR_getresgid …
#endif
#ifndef __NR_rt_sigaction
#define __NR_rt_sigreturn …
#define __NR_rt_sigaction …
#define __NR_rt_sigprocmask …
#define __NR_rt_sigpending …
#define __NR_rt_sigsuspend …
#endif
#ifndef __NR_pread64
#define __NR_pread64 …
#endif
#ifndef __NR_pwrite64
#define __NR_pwrite64 …
#endif
#ifndef __NR_stat64
#define __NR_stat64 …
#endif
#ifndef __NR_fstat64
#define __NR_fstat64 …
#endif
#ifndef __NR_getdents64
#define __NR_getdents64 …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_statfs64
#define __NR_statfs64 …
#endif
#ifndef __NR_fstatfs64
#define __NR_fstatfs64 …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_openat
#define __NR_openat …
#endif
#ifndef __NR_fstatat
#define __NR_fstatat …
#endif
#ifndef __NR_unlinkat
#define __NR_unlinkat …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_getcpu
#define __NR_getcpu …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#ifndef __NR_getrandom
#define __NR_getrandom …
#endif
#elif _MIPS_SIM == _MIPS_SIM_ABI64
#ifndef __NR_pread64
#define __NR_pread64 …
#endif
#ifndef __NR_pwrite64
#define __NR_pwrite64 …
#endif
#ifndef __NR_setresuid
#define __NR_setresuid …
#define __NR_getresuid …
#define __NR_setresgid …
#define __NR_getresgid …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_openat
#define __NR_openat …
#endif
#ifndef __NR_fstatat
#define __NR_fstatat …
#endif
#ifndef __NR_unlinkat
#define __NR_unlinkat …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_getcpu
#define __NR_getcpu …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#ifndef __NR_getrandom
#define __NR_getrandom …
#endif
#else
#ifndef __NR_setresuid
#define __NR_setresuid …
#define __NR_getresuid …
#define __NR_setresgid …
#define __NR_getresgid …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_statfs64
#define __NR_statfs64 …
#endif
#ifndef __NR_fstatfs64
#define __NR_fstatfs64 …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_openat
#define __NR_openat …
#endif
#ifndef __NR_fstatat
#define __NR_fstatat …
#endif
#ifndef __NR_unlinkat
#define __NR_unlinkat …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_getcpu
#define __NR_getcpu …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#endif
#elif defined(__PPC__)
#ifndef __NR_setfsuid
#define __NR_setfsuid …
#define __NR_setfsgid …
#endif
#ifndef __NR_setresuid
#define __NR_setresuid …
#define __NR_getresuid …
#define __NR_setresgid …
#define __NR_getresgid …
#endif
#ifndef __NR_rt_sigaction
#define __NR_rt_sigreturn …
#define __NR_rt_sigaction …
#define __NR_rt_sigprocmask …
#define __NR_rt_sigpending …
#define __NR_rt_sigsuspend …
#endif
#ifndef __NR_pread64
#define __NR_pread64 …
#endif
#ifndef __NR_pwrite64
#define __NR_pwrite64 …
#endif
#ifndef __NR_ugetrlimit
#define __NR_ugetrlimit …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_stat64
#define __NR_stat64 …
#endif
#ifndef __NR_fstat64
#define __NR_fstat64 …
#endif
#ifndef __NR_getdents64
#define __NR_getdents64 …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_statfs64
#define __NR_statfs64 …
#endif
#ifndef __NR_fstatfs64
#define __NR_fstatfs64 …
#endif
#ifndef __NR_fadvise64_64
#define __NR_fadvise64_64 …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#ifndef __NR_openat
#define __NR_openat …
#endif
#ifndef __NR_fstatat64
#define __NR_fstatat64 …
#endif
#ifndef __NR_unlinkat
#define __NR_unlinkat …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_getcpu
#define __NR_getcpu …
#endif
#elif defined(__s390__)
#ifndef __NR_quotactl
#define __NR_quotactl …
#endif
#ifndef __NR_rt_sigreturn
#define __NR_rt_sigreturn …
#endif
#ifndef __NR_rt_sigaction
#define __NR_rt_sigaction …
#endif
#ifndef __NR_rt_sigprocmask
#define __NR_rt_sigprocmask …
#endif
#ifndef __NR_rt_sigpending
#define __NR_rt_sigpending …
#endif
#ifndef __NR_rt_sigsuspend
#define __NR_rt_sigsuspend …
#endif
#ifndef __NR_pread64
#define __NR_pread64 …
#endif
#ifndef __NR_pwrite64
#define __NR_pwrite64 …
#endif
#ifndef __NR_getdents64
#define __NR_getdents64 …
#endif
#ifndef __NR_readahead
#define __NR_readahead …
#endif
#ifndef __NR_setxattr
#define __NR_setxattr …
#endif
#ifndef __NR_lsetxattr
#define __NR_lsetxattr …
#endif
#ifndef __NR_getxattr
#define __NR_getxattr …
#endif
#ifndef __NR_lgetxattr
#define __NR_lgetxattr …
#endif
#ifndef __NR_listxattr
#define __NR_listxattr …
#endif
#ifndef __NR_llistxattr
#define __NR_llistxattr …
#endif
#ifndef __NR_gettid
#define __NR_gettid …
#endif
#ifndef __NR_tkill
#define __NR_tkill …
#endif
#ifndef __NR_futex
#define __NR_futex …
#endif
#ifndef __NR_sched_setaffinity
#define __NR_sched_setaffinity …
#endif
#ifndef __NR_sched_getaffinity
#define __NR_sched_getaffinity …
#endif
#ifndef __NR_set_tid_address
#define __NR_set_tid_address …
#endif
#ifndef __NR_clock_gettime
#define __NR_clock_gettime …
#endif
#ifndef __NR_clock_getres
#define __NR_clock_getres …
#endif
#ifndef __NR_statfs64
#define __NR_statfs64 …
#endif
#ifndef __NR_fstatfs64
#define __NR_fstatfs64 …
#endif
#ifndef __NR_ioprio_set
#define __NR_ioprio_set …
#endif
#ifndef __NR_ioprio_get
#define __NR_ioprio_get …
#endif
#ifndef __NR_openat
#define __NR_openat …
#endif
#ifndef __NR_unlinkat
#define __NR_unlinkat …
#endif
#ifndef __NR_move_pages
#define __NR_move_pages …
#endif
#ifndef __NR_getcpu
#define __NR_getcpu …
#endif
#ifndef __NR_fallocate
#define __NR_fallocate …
#endif
#ifdef __s390x__
# ifndef __NR_getrlimit
#define __NR_getrlimit …
# endif
# ifndef __NR_setresuid
#define __NR_setresuid …
# endif
# ifndef __NR_getresuid
#define __NR_getresuid …
# endif
# ifndef __NR_setresgid
#define __NR_setresgid …
# endif
# ifndef __NR_getresgid
#define __NR_getresgid …
# endif
# ifndef __NR_setfsuid
#define __NR_setfsuid …
# endif
# ifndef __NR_setfsgid
#define __NR_setfsgid …
# endif
# ifndef __NR_fadvise64
#define __NR_fadvise64 …
# endif
# ifndef __NR_newfstatat
#define __NR_newfstatat …
# endif
#else
# ifndef __NR_getrlimit
#define __NR_getrlimit …
# endif
# ifndef __NR_setfsuid
#define __NR_setfsuid …
# endif
# ifndef __NR_setfsgid
#define __NR_setfsgid …
# endif
# ifndef __NR_setresuid
#define __NR_setresuid …
# endif
# ifndef __NR_getresuid
#define __NR_getresuid …
# endif
# ifndef __NR_setresgid
#define __NR_setresgid …
# endif
# ifndef __NR_getresgid
#define __NR_getresgid …
# endif
# ifndef __NR_ugetrlimit
#define __NR_ugetrlimit …
# endif
# ifndef __NR_mmap2
#define __NR_mmap2 …
# endif
# ifndef __NR_setresuid32
#define __NR_setresuid32 …
# endif
# ifndef __NR_getresuid32
#define __NR_getresuid32 …
# endif
# ifndef __NR_setresgid32
#define __NR_setresgid32 …
# endif
# ifndef __NR_getresgid32
#define __NR_getresgid32 …
# endif
# ifndef __NR_setfsuid32
#define __NR_setfsuid32 …
# endif
# ifndef __NR_setfsgid32
#define __NR_setfsgid32 …
# endif
# ifndef __NR_fadvise64_64
#define __NR_fadvise64_64 …
# endif
# ifndef __NR_fstatat64
#define __NR_fstatat64 …
# endif
#endif
#endif
#if defined(__BOUNDED_POINTERS__)
#error "Need to port invocations of syscalls for bounded ptrs"
#else
#undef LSS_ERRNO
#ifdef SYS_ERRNO
#define LSS_ERRNO …
#else
#define LSS_ERRNO …
#endif
#undef LSS_INLINE
#ifdef SYS_INLINE
#define LSS_INLINE …
#else
#define LSS_INLINE …
#endif
#undef LSS_NAME
#ifndef SYS_PREFIX
#define LSS_NAME(name) …
#elif defined(SYS_PREFIX) && SYS_PREFIX < 0
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 0
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 1
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 2
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 3
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 4
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 5
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 6
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 7
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 8
#define LSS_NAME …
#elif defined(SYS_PREFIX) && SYS_PREFIX == 9
#define LSS_NAME …
#endif
#undef LSS_RETURN
#if defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \
|| defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__) \
|| defined(__e2k__) || defined(__riscv) || defined(__loongarch_lp64)
#define LSS_RETURN(type, res) …
#elif defined(__mips__)
#define LSS_RETURN …
#elif defined(__PPC__)
#define LSS_RETURN …
#endif
#if defined(__i386__)
#undef LSS_ENTRYPOINT
#ifdef SYS_SYSCALL_ENTRYPOINT
static inline void (**LSS_NAME(get_syscall_entrypoint)(void))(void) {
void (**entrypoint)(void);
asm volatile(".bss\n"
".align 8\n"
".globl " SYS_SYSCALL_ENTRYPOINT "\n"
".common " SYS_SYSCALL_ENTRYPOINT ",8,8\n"
".previous\n"
"call 0f\n"
"0:pop %0\n"
"add $_GLOBAL_OFFSET_TABLE_+[.-0b], %0\n"
"mov " SYS_SYSCALL_ENTRYPOINT "@GOT(%0), %0\n"
: "=r"(entrypoint));
return entrypoint;
}
#define LSS_ENTRYPOINT …
#else
#define LSS_ENTRYPOINT …
#endif
#undef LSS_BODY
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
long __res;
__asm__ __volatile__(
"movl %3,%%ecx\n"
"jecxz 1f\n"
"movl %4,%%ecx\n"
"jecxz 1f\n"
"andl $-16,%%ecx\n"
"subl $20,%%ecx\n"
"movl %6,%%eax\n"
"movl %%eax,4(%%ecx)\n"
"movl %3,%%eax\n"
"movl %%eax,(%%ecx)\n"
"movl %8,%%esi\n"
"movl %7,%%edx\n"
"movl %5,%%eax\n"
"movl %9,%%edi\n"
"pushl %%ebx\n"
"movl %%eax,%%ebx\n"
"movl %2,%%eax\n"
LSS_ENTRYPOINT
"popl %%ebx\n"
"test %%eax,%%eax\n"
"jnz 1f\n"
"movl $0,%%ebp\n"
"call *%%ebx\n"
"movl %%eax,%%ebx\n"
"movl $1,%%eax\n"
LSS_ENTRYPOINT
"1:\n"
: "=a" (__res)
: "0"(-EINVAL), "i"(__NR_clone),
"m"(fn), "m"(child_stack), "m"(flags), "m"(arg),
"m"(parent_tidptr), "m"(newtls), "m"(child_tidptr)
: "memory", "ecx", "edx", "esi", "edi");
LSS_RETURN(int, __res);
}
LSS_INLINE _syscall1(int, set_thread_area, void *, u)
LSS_INLINE _syscall1(int, get_thread_area, void *, u)
LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) {
void (*res)(void);
__asm__ __volatile__("call 2f\n"
"0:.align 16\n"
"1:movl %1,%%eax\n"
LSS_ENTRYPOINT
"2:popl %0\n"
"addl $(1b-0b),%0\n"
: "=a" (res)
: "i" (__NR_rt_sigreturn));
return res;
}
LSS_INLINE void (*LSS_NAME(restore)(void))(void) {
void (*res)(void);
__asm__ __volatile__("call 2f\n"
"0:.align 16\n"
"1:pop %%eax\n"
"movl %1,%%eax\n"
LSS_ENTRYPOINT
"2:popl %0\n"
"addl $(1b-0b),%0\n"
: "=a" (res)
: "i" (__NR_sigreturn));
return res;
}
#elif defined(__x86_64__)
#undef LSS_ENTRYPOINT
#ifdef SYS_SYSCALL_ENTRYPOINT
static inline void (**LSS_NAME(get_syscall_entrypoint)(void))(void) {
void (**entrypoint)(void);
asm volatile(".bss\n"
".align 8\n"
".globl " SYS_SYSCALL_ENTRYPOINT "\n"
".common " SYS_SYSCALL_ENTRYPOINT ",8,8\n"
".previous\n"
"mov " SYS_SYSCALL_ENTRYPOINT "@GOTPCREL(%%rip), %0\n"
: "=r"(entrypoint));
return entrypoint;
}
#define LSS_ENTRYPOINT …
#else
#define LSS_ENTRYPOINT …
#endif
#undef LSS_SYSCALL_ARG
#define LSS_SYSCALL_ARG(a) …
#undef _LSS_RETURN
#define _LSS_RETURN(type, res, cast) …
#undef LSS_RETURN
#define LSS_RETURN(type, res) …
#undef _LSS_BODY
#define _LSS_BODY(nr, type, name, cast, ...) …
#undef LSS_BODY
#define LSS_BODY(nr, type, name, args...) …
#undef LSS_BODY_ASM0
#undef LSS_BODY_ASM1
#undef LSS_BODY_ASM2
#undef LSS_BODY_ASM3
#undef LSS_BODY_ASM4
#undef LSS_BODY_ASM5
#undef LSS_BODY_ASM6
#define LSS_BODY_ASM0
#define LSS_BODY_ASM1 …
#define LSS_BODY_ASM2 …
#define LSS_BODY_ASM3 …
#define LSS_BODY_ASM4 …
#define LSS_BODY_ASM5 …
#define LSS_BODY_ASM6 …
#undef LSS_BODY_CLOBBER0
#undef LSS_BODY_CLOBBER1
#undef LSS_BODY_CLOBBER2
#undef LSS_BODY_CLOBBER3
#undef LSS_BODY_CLOBBER4
#undef LSS_BODY_CLOBBER5
#undef LSS_BODY_CLOBBER6
#define LSS_BODY_CLOBBER0
#define LSS_BODY_CLOBBER1 …
#define LSS_BODY_CLOBBER2 …
#define LSS_BODY_CLOBBER3 …
#define LSS_BODY_CLOBBER4 …
#define LSS_BODY_CLOBBER5 …
#define LSS_BODY_CLOBBER6 …
#undef LSS_BODY_ARG0
#undef LSS_BODY_ARG1
#undef LSS_BODY_ARG2
#undef LSS_BODY_ARG3
#undef LSS_BODY_ARG4
#undef LSS_BODY_ARG5
#undef LSS_BODY_ARG6
#define LSS_BODY_ARG0() …
#define LSS_BODY_ARG1(arg1) …
#define LSS_BODY_ARG2(arg1, arg2) …
#define LSS_BODY_ARG3(arg1, arg2, arg3) …
#define LSS_BODY_ARG4(arg1, arg2, arg3, arg4) …
#define LSS_BODY_ARG5(arg1, arg2, arg3, arg4, arg5) …
#define LSS_BODY_ARG6(arg1, arg2, arg3, arg4, arg5, arg6) …
#undef _syscall0
#define _syscall0(type,name) …
#undef _syscall1
#define _syscall1(type,name,type1,arg1) …
#undef _syscall2
#define _syscall2(type,name,type1,arg1,type2,arg2) …
#undef _syscall3
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) …
#undef _syscall4
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) …
#undef _syscall5
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5) …
#undef _syscall6
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5,type6,arg6) …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) { … }
LSS_INLINE _syscall2(int, arch_prctl, int, c, void *, a)
LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { … }
#elif defined(__ARM_ARCH_3__)
#undef LSS_REG
#define LSS_REG …
#undef LSS_BODY
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
long __res;
{
register int __flags __asm__("r0") = flags;
register void *__stack __asm__("r1") = child_stack;
register void *__ptid __asm__("r2") = parent_tidptr;
register void *__tls __asm__("r3") = newtls;
register int *__ctid __asm__("r4") = child_tidptr;
__asm__ __volatile__(
"cmp %2,#0\n"
"cmpne %3,#0\n"
"moveq %0,%1\n"
"beq 1f\n"
"str %5,[%3,#-4]!\n"
"str %2,[%3,#-4]!\n"
__syscall(clone)"\n"
"movs %0,r0\n"
"bne 1f\n"
"ldr r0,[sp, #4]\n"
"mov lr,pc\n"
"ldr pc,[sp]\n"
__syscall(exit)"\n"
"1:\n"
: "=r" (__res)
: "i"(-EINVAL),
"r"(fn), "r"(__stack), "r"(__flags), "r"(arg),
"r"(__ptid), "r"(__tls), "r"(__ctid)
: "cc", "lr", "memory");
}
LSS_RETURN(int, __res);
}
#elif defined(__ARM_EABI__)
#undef LSS_REG
#define LSS_REG …
#undef LSS_BODY
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
long __res;
if (fn == NULL || child_stack == NULL) {
__res = -EINVAL;
LSS_RETURN(int, __res);
}
{
uintptr_t* cstack = (uintptr_t*)child_stack - 2;
cstack[0] = (uintptr_t)fn;
cstack[1] = (uintptr_t)arg;
child_stack = cstack;
}
{
register int __flags __asm__("r0") = flags;
register void *__stack __asm__("r1") = child_stack;
register void *__ptid __asm__("r2") = parent_tidptr;
register void *__tls __asm__("r3") = newtls;
register int *__ctid __asm__("r4") = child_tidptr;
__asm__ __volatile__(
#ifdef __thumb2__
"push {r7}\n"
#endif
"mov r7, %6\n"
"swi 0x0\n"
"cmp r0, #0\n"
"bne 1f\n"
"ldr r0,[sp, #4]\n"
"ldr lr,[sp]\n"
"blx lr\n"
"mov r7, %7\n"
"swi 0x0\n"
"bkpt #0\n"
"1:\n"
#ifdef __thumb2__
"pop {r7}\n"
#endif
"movs %0,r0\n"
: "=r"(__res)
: "r"(__stack), "r"(__flags), "r"(__ptid), "r"(__tls), "r"(__ctid),
"i"(__NR_clone), "i"(__NR_exit)
: "cc", "lr", "memory"
#ifndef __thumb2__
, "r7"
#endif
);
}
LSS_RETURN(int, __res);
}
#elif defined(__aarch64__)
#undef LSS_REG
#define LSS_REG …
#undef LSS_BODY
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
int64_t __res;
{
register uint64_t __flags __asm__("x0") = (uint64_t)flags;
register void *__stack __asm__("x1") = child_stack;
register void *__ptid __asm__("x2") = parent_tidptr;
register void *__tls __asm__("x3") = newtls;
register int *__ctid __asm__("x4") = child_tidptr;
__asm__ __volatile__(
"stp %1, %4, [%2, #-16]!\n"
"mov x8, %8\n"
"svc 0x0\n"
"mov %0, x0\n"
"cbnz x0, 1f\n"
"ldp x1, x0, [sp], #16\n"
"blr x1\n"
"mov x8, %9\n"
"svc 0x0\n"
"1:\n"
: "=r" (__res)
: "r"(fn), "r"(__stack), "r"(__flags), "r"(arg),
"r"(__ptid), "r"(__tls), "r"(__ctid),
"i"(__NR_clone), "i"(__NR_exit)
: "cc", "x8", "memory");
}
LSS_RETURN(int, __res);
}
#elif defined(__mips__)
#undef LSS_REG
#define LSS_REG …
#undef LSS_BODY
#undef LSS_SYSCALL_CLOBBERS
#if _MIPS_SIM == _MIPS_SIM_ABI32
#define LSS_SYSCALL_CLOBBERS …
#else
#define LSS_SYSCALL_CLOBBERS …
#endif
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#if _MIPS_SIM == _MIPS_SIM_ABI32
#define _syscall5 …
#else
#define _syscall5 …
#endif
#undef _syscall6
#if _MIPS_SIM == _MIPS_SIM_ABI32
#define _syscall6 …
#else
#define _syscall6 …
#endif
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
register unsigned long __v0 __asm__("$2") = -EINVAL;
register unsigned long __r7 __asm__("$7") = (unsigned long)newtls;
{
register int __flags __asm__("$4") = flags;
register void *__stack __asm__("$5") = child_stack;
register void *__ptid __asm__("$6") = parent_tidptr;
register int *__ctid __asm__("$8") = child_tidptr;
__asm__ __volatile__(
#if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32
"subu $29,24\n"
#elif _MIPS_SIM == _MIPS_SIM_NABI32
"sub $29,16\n"
#else
"dsubu $29,16\n"
#endif
"beqz %4,1f\n"
"beqz %5,1f\n"
#if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32
"subu %5,32\n"
"sw %4,0(%5)\n"
"sw %7,4(%5)\n"
#elif _MIPS_SIM == _MIPS_SIM_NABI32
"sub %5,32\n"
"sw %4,0(%5)\n"
"sw %7,8(%5)\n"
#else
"dsubu %5,32\n"
"sd %4,0(%5)\n"
"sd %7,8(%5)\n"
#endif
"li $2,%2\n"
"syscall\n"
"bnez $7,1f\n"
"bnez $2,1f\n"
#if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32
"lw $25,0($29)\n"
"lw $4,4($29)\n"
#elif _MIPS_SIM == _MIPS_SIM_NABI32
"lw $25,0($29)\n"
"lw $4,8($29)\n"
#else
"ld $25,0($29)\n"
"ld $4,8($29)\n"
#endif
"jalr $25\n"
"move $4,$2\n"
"li $2,%3\n"
"syscall\n"
"1:\n"
#if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32
"addu $29, 24\n"
#elif _MIPS_SIM == _MIPS_SIM_NABI32
"add $29, 16\n"
#else
"daddu $29,16\n"
#endif
: "+r" (__v0), "+r" (__r7)
: "i"(__NR_clone), "i"(__NR_exit), "r"(fn),
"r"(__stack), "r"(__flags), "r"(arg),
"r"(__ptid), "r"(__ctid)
: "$9", "$10", "$11", "$12", "$13", "$14", "$15",
"$24", "$25", "memory");
}
LSS_RETURN(int, __v0, __r7);
}
#elif defined (__PPC__)
#undef LSS_LOADARGS_0
#define LSS_LOADARGS_0 …
#undef LSS_LOADARGS_1
#define LSS_LOADARGS_1 …
#undef LSS_LOADARGS_2
#define LSS_LOADARGS_2 …
#undef LSS_LOADARGS_3
#define LSS_LOADARGS_3 …
#undef LSS_LOADARGS_4
#define LSS_LOADARGS_4 …
#undef LSS_LOADARGS_5
#define LSS_LOADARGS_5 …
#undef LSS_LOADARGS_6
#define LSS_LOADARGS_6 …
#undef LSS_ASMINPUT_0
#define LSS_ASMINPUT_0 …
#undef LSS_ASMINPUT_1
#define LSS_ASMINPUT_1 …
#undef LSS_ASMINPUT_2
#define LSS_ASMINPUT_2 …
#undef LSS_ASMINPUT_3
#define LSS_ASMINPUT_3 …
#undef LSS_ASMINPUT_4
#define LSS_ASMINPUT_4 …
#undef LSS_ASMINPUT_5
#define LSS_ASMINPUT_5 …
#undef LSS_ASMINPUT_6
#define LSS_ASMINPUT_6 …
#undef LSS_BODY
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
long __ret, __err;
{
register int (*__fn)(void *) __asm__ ("r8") = fn;
register void *__cstack __asm__ ("r4") = child_stack;
register int __flags __asm__ ("r3") = flags;
register void * __arg __asm__ ("r9") = arg;
register int * __ptidptr __asm__ ("r5") = parent_tidptr;
register void * __newtls __asm__ ("r6") = newtls;
register int * __ctidptr __asm__ ("r7") = child_tidptr;
__asm__ __volatile__(
"cmpwi cr0, %6, 0\n\t"
"cmpwi cr1, %7, 0\n\t"
"cror cr0*4+eq, cr1*4+eq, cr0*4+eq\n\t"
"beq- cr0, 1f\n\t"
"clrrwi %7, %7, 4\n\t"
"li 0, 0\n\t"
"stwu 0, -16(%7)\n\t"
"mr 28, %6\n\t"
"mr 29, %7\n\t"
"mr 27, %9\n\t"
"li 0, %4\n\t"
"sc\n\t"
"cmpwi cr1, 3, 0\n\t"
"crandc cr1*4+eq, cr1*4+eq, cr0*4+so\n\t"
"bne- cr1, 1f\n\t"
"mtctr 28\n\t"
"mr 3, 27\n\t"
"bctrl\n\t"
"li 0, %5\n\t"
"sc\n\t"
"1:\n"
"mfcr %1\n\t"
"mr %0, 3\n\t"
: "=r" (__ret), "=r" (__err)
: "0" (-1), "1" (EINVAL),
"i" (__NR_clone), "i" (__NR_exit),
"r" (__fn), "r" (__cstack), "r" (__flags),
"r" (__arg), "r" (__ptidptr), "r" (__newtls),
"r" (__ctidptr)
: "cr0", "cr1", "memory", "ctr",
"r0", "r29", "r27", "r28");
}
LSS_RETURN(int, __ret, __err);
}
#elif defined(__s390__)
#undef LSS_REG
#define LSS_REG …
#undef LSS_BODY
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
long __ret;
{
register int (*__fn)(void *) __asm__ ("r1") = fn;
register void *__cstack __asm__ ("r2") = child_stack;
register int __flags __asm__ ("r3") = flags;
register void *__arg __asm__ ("r0") = arg;
register int *__ptidptr __asm__ ("r4") = parent_tidptr;
register void *__newtls __asm__ ("r6") = newtls;
register int *__ctidptr __asm__ ("r5") = child_tidptr;
__asm__ __volatile__ (
#ifndef __s390x__
"ltr %4, %4\n\t"
"jz 1f\n\t"
"ltr %5, %5\n\t"
"jz 1f\n\t"
"svc %2\n\t"
"ltr %0,%%r2\n\t"
"jnz 1f\n\t"
"lr %%r2, %7\n\t"
"ahi %%r15, -96\n\t"
"xc 0(4,%%r15), 0(%%r15)\n\t"
"basr %%r14, %4\n\t"
"svc %3\n"
"1:\n"
#else
"ltgr %4, %4\n\t"
"jz 1f\n\t"
"ltgr %5, %5\n\t"
"jz 1f\n\t"
"svc %2\n\t"
"ltgr %0, %%r2\n\t"
"jnz 1f\n\t"
"lgr %%r2, %7\n\t"
"aghi %%r15, -160\n\t"
"xc 0(8,%%r15), 0(%%r15)\n\t"
"basr %%r14, %4\n\t"
"svc %3\n"
"1:\n"
#endif
: "=r" (__ret)
: "0" (-EINVAL), "i" (__NR_clone), "i" (__NR_exit),
"d" (__fn), "d" (__cstack), "d" (__flags), "d" (__arg),
"d" (__ptidptr), "d" (__newtls), "d" (__ctidptr)
: "cc", "r14", "memory"
);
}
LSS_RETURN(int, __ret);
}
#elif defined(__riscv) && __riscv_xlen == 64
#undef LSS_REG
#define LSS_REG …
#undef LSS_BODY
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
int64_t __res;
{
register int64_t __res_a0 __asm__("a0");
register uint64_t __flags __asm__("a0") = flags;
register void *__stack __asm__("a1") = child_stack;
register void *__ptid __asm__("a2") = parent_tidptr;
register void *__tls __asm__("a3") = newtls;
register int *__ctid __asm__("a4") = child_tidptr;
__asm__ __volatile__(
"addi %2,%2,-16\n"
"sd %1, 0(%2)\n"
"sd %4, 8(%2)\n"
"li a7, %8\n"
"scall\n"
"bnez %0, 1f\n"
"ld a1, 0(sp)\n"
"ld a0, 8(sp)\n"
"jalr a1\n"
"li a7, %9\n"
"scall\n"
"1:\n"
: "=r" (__res_a0)
: "r"(fn), "r"(__stack), "r"(__flags), "r"(arg),
"r"(__ptid), "r"(__tls), "r"(__ctid),
"i"(__NR_clone), "i"(__NR_exit)
: "cc", "memory");
__res = __res_a0;
}
LSS_RETURN(int, __res);
}
#elif defined(__e2k__)
#undef _LSS_BODY
#define _LSS_BODY …
#undef LSS_BODY
#define LSS_BODY …
#undef LSS_BODY_ASM0
#undef LSS_BODY_ASM1
#undef LSS_BODY_ASM2
#undef LSS_BODY_ASM3
#undef LSS_BODY_ASM4
#undef LSS_BODY_ASM5
#undef LSS_BODY_ASM6
#define LSS_BODY_ASM0
#define LSS_BODY_ASM1 …
#define LSS_BODY_ASM2 …
#define LSS_BODY_ASM3 …
#define LSS_BODY_ASM4 …
#define LSS_BODY_ASM5 …
#define LSS_BODY_ASM6 …
#undef LSS_SYSCALL_ARG
#define LSS_SYSCALL_ARG …
#undef LSS_BODY_ARG0
#undef LSS_BODY_ARG1
#undef LSS_BODY_ARG2
#undef LSS_BODY_ARG3
#undef LSS_BODY_ARG4
#undef LSS_BODY_ARG5
#undef LSS_BODY_ARG6
#define LSS_BODY_ARG0 …
#define LSS_BODY_ARG1 …
#define LSS_BODY_ARG2 …
#define LSS_BODY_ARG3 …
#define LSS_BODY_ARG4 …
#define LSS_BODY_ARG5 …
#define LSS_BODY_ARG6 …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
unsigned long long __res;
__asm__ __volatile__ (
"{\n\t"
" addd,s 0x0, %[nr_clone], %%b[0]\n\t"
" addd,s 0x0, %[flags], %%db[1]\n\t"
" addd,s 0x0, %[child_stack], %%db[2]\n\t"
" addd,s 0x0, %[parent_tidptr], %%db[3]\n\t"
" addd,s 0x0, %[child_tidptr], %%db[4]\n\t"
" addd,s 0x0, %[newtls], %%db[5]\n\t"
"}\n\t"
"{\n\t"
" disp %%ctpr1, .L1\n\t"
"}\n\t"
"{\n\t"
" cmpesb,s 0x0, %[fn], %%pred0\n\t"
"}\n\t"
"{\n\t"
" ct %%ctpr1 ? %%pred0\n\t"
"}\n\t"
"{\n\t"
" cmpesb,s 0x0, %%db[2], %%pred0\n\t"
"}\n\t"
"{\n\t"
" ct %%ctpr1 ? %%pred0\n\t"
"}\n\t"
"{\n\t"
" sdisp %%ctpr1, 0x3\n\t"
"}\n\t"
"{\n\t"
" call %%ctpr1, wbs = %#\n\t"
"}\n\t"
"{\n\t"
" disp %%ctpr1, .L2\n\t"
" cmpesb,s 0x0, %%b[0], %%pred0\n\t"
"}\n\t"
"{\n\t"
" ct %%ctpr1 ? ~%%pred0\n\t"
"}\n\t"
"{\n\t"
" movtd,s %[fn], %%ctpr1\n\t"
"}\n\t"
"{\n\t"
" addd,s 0x0, %[arg], %%db[0]\n\t"
"}\n\t"
"{\n\t"
" call %%ctpr1, wbs = %#\n\t"
"}\n\t"
"{\n\t"
" sdisp %%ctpr1, 0x3\n\t"
" addd,s 0x0, %%b[0], %%b[1]\n\t"
"}\n\t"
"{\n\t"
" addd,s 0x0, %[nr_exit], %%b[0]\n\t"
"}\n\t"
"{\n\t"
" call %%ctpr1, wbs = %#\n\t"
"}\n\t"
"{\n\t"
" disp %%ctpr1, .L2\n\t"
" adds,s 0x0, 0x0, %%b[0]\n\t"
"}\n\t"
"{\n\t"
" ct %%ctpr1\n\t"
"}\n\t"
".L1:\n\t"
"{\n\t"
" addd,s 0x0, %[einval], %%b[0]\n\t"
"}\n\t"
".L2:\n\t"
"{\n\t"
" addd,s 0x0, %%b[0], %[res]\n\t"
"}\n\t"
: [res] "=r" LSS_SYSCALL_ARG(__res)
: [nr_clone] "ri" LSS_SYSCALL_ARG(__NR_clone)
[arg] "ri" LSS_SYSCALL_ARG(arg)
[nr_exit] "ri" LSS_SYSCALL_ARG(__NR_exit)
[flags] "ri" LSS_SYSCALL_ARG(flags)
[child_stack] "ri" LSS_SYSCALL_ARG(child_stack)
[parent_tidptr] "ri"
LSS_SYSCALL_ARG(parent_tidptr)
[newtls] "ri" LSS_SYSCALL_ARG(newtls)
[child_tidptr] "ri"
LSS_SYSCALL_ARG(child_tidptr)
[fn] "ri" LSS_SYSCALL_ARG(fn)
[einval] "ri" LSS_SYSCALL_ARG(-EINVAL)
: "ctpr1", "b[0]", "b[1]", "b[2]", "b[3]",
"b[4]", "b[5]", "pred0");
LSS_RETURN(int, __res);
}
#elif defined(__loongarch_lp64)
#undef LSS_REG
#define LSS_REG …
#define LSS_SYSCALL_CLOBBERS …
#undef LSS_BODY
#define LSS_BODY …
#undef _syscall0
#define _syscall0 …
#undef _syscall1
#define _syscall1 …
#undef _syscall2
#define _syscall2 …
#undef _syscall3
#define _syscall3 …
#undef _syscall4
#define _syscall4 …
#undef _syscall5
#define _syscall5 …
#undef _syscall6
#define _syscall6 …
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
int64_t __res;
{
register int64_t __res_a0 __asm__("a0");
register uint64_t __flags __asm__("a0") = flags;
register void *__stack __asm__("a1") = child_stack;
register void *__ptid __asm__("a2") = parent_tidptr;
register void *__tls __asm__("a3") = newtls;
register int *__ctid __asm__("a4") = child_tidptr;
__asm__ __volatile__(
"addi.d %2, %2, -16\n"
"st.d %1, %2, 8\n"
"st.d %4, %2, 0\n"
"li.d $a7, %8\n"
"syscall 0x0\n"
"bnez $a0, 1f\n"
"ld.d $a0, $sp, 0\n"
"ld.d $a1, $sp, 8\n"
"addi.d $sp, $sp, 16\n"
"jirl $ra, $a1, 0\n"
"li.d $a7, %9\n"
"syscall 0x0\n"
"1:\n"
: "=r" (__res_a0)
: "r"(fn), "r"(__stack), "r"(__flags), "r"(arg),
"r"(__ptid), "r"(__tls), "r"(__ctid),
"i"(__NR_clone), "i"(__NR_exit)
: LSS_SYSCALL_CLOBBERS);
__res = __res_a0;
}
LSS_RETURN(int, __res);
}
#endif
#define __NR__exit …
#define __NR__gettid …
#define __NR__mremap …
LSS_INLINE _syscall1(void *, brk, void *, e)
LSS_INLINE _syscall1(int, chdir, const char *,p)
LSS_INLINE _syscall1(int, close, int, f)
LSS_INLINE _syscall2(int, clock_getres, int, c,
struct kernel_timespec*, t)
LSS_INLINE _syscall2(int, clock_gettime, int, c,
struct kernel_timespec*, t)
LSS_INLINE _syscall1(int, dup, int, f)
#if defined(__NR_dup2)
LSS_INLINE _syscall2(int, dup2, int, s,
int, d)
#endif
#if defined(__NR_dup3)
LSS_INLINE _syscall3(int, dup3, int, s, int, d, int, f)
#endif
LSS_INLINE _syscall3(int, execve, const char*, f,
const char*const*,a,const char*const*, e)
LSS_INLINE _syscall1(int, _exit, int, e)
LSS_INLINE _syscall1(int, exit_group, int, e)
LSS_INLINE _syscall3(int, fcntl, int, f,
int, c, long, a)
#if defined(__NR_fork)
LSS_INLINE _syscall0(…)
#endif
#if defined(__NR_fstat)
LSS_INLINE _syscall2(int, fstat, int, f,
struct kernel_stat*, b)
#endif
LSS_INLINE _syscall2(int, fstatfs, int, f,
struct kernel_statfs*, b)
#if defined(__x86_64__)
LSS_INLINE int LSS_NAME(ftruncate)(int f, off_t l) { … }
#else
LSS_INLINE _syscall2(int, ftruncate, int, f,
off_t, l)
#endif
LSS_INLINE _syscall6(int, futex, int*, u,
int, o, int, v,
struct kernel_timespec*, t,
int*, u2, int, v2)
LSS_INLINE _syscall3(int, getdents, int, f,
struct kernel_dirent*, d, int, c)
LSS_INLINE _syscall3(int, getdents64, int, f,
struct kernel_dirent64*, d, int, c)
LSS_INLINE _syscall0(…)
LSS_INLINE _syscall0(…)
LSS_INLINE _syscall2(int, getitimer, int, w,
struct kernel_itimerval*, c)
#if defined(__NR_getpgrp)
LSS_INLINE _syscall0(…)
#endif
LSS_INLINE _syscall0(…)
LSS_INLINE _syscall0(…)
LSS_INLINE _syscall2(int, getpriority, int, a,
int, b)
LSS_INLINE _syscall3(int, getresgid, gid_t *, r,
gid_t *, e, gid_t *, s)
LSS_INLINE _syscall3(int, getresuid, uid_t *, r,
uid_t *, e, uid_t *, s)
#if defined(__NR_getrlimit)
LSS_INLINE _syscall2(int, getrlimit, int, r,
struct kernel_rlimit*, l)
#endif
LSS_INLINE _syscall1(…)
LSS_INLINE _syscall0(…)
LSS_INLINE _syscall2(pid_t, gettimeofday, struct kernel_timeval*, t,
void*, tz)
LSS_INLINE _syscall5(int, setxattr, const char *,p,
const char *, n, const void *,v,
size_t, s, int, f)
LSS_INLINE _syscall5(int, lsetxattr, const char *,p,
const char *, n, const void *,v,
size_t, s, int, f)
LSS_INLINE _syscall4(ssize_t, getxattr, const char *,p,
const char *, n, void *, v, size_t, s)
LSS_INLINE _syscall4(ssize_t, lgetxattr, const char *,p,
const char *, n, void *, v, size_t, s)
LSS_INLINE _syscall3(ssize_t, listxattr, const char *,p,
char *, l, size_t, s)
LSS_INLINE _syscall3(ssize_t, llistxattr, const char *,p,
char *, l, size_t, s)
LSS_INLINE _syscall3(int, ioctl, int, d,
int, r, void *, a)
LSS_INLINE _syscall2(int, ioprio_get, int, which,
int, who)
LSS_INLINE _syscall3(int, ioprio_set, int, which,
int, who, int, ioprio)
LSS_INLINE _syscall2(int, kill, pid_t, p,
int, s)
#if defined(__x86_64__)
LSS_INLINE off_t LSS_NAME(lseek)(int f, off_t o, int w) { … }
#else
LSS_INLINE _syscall3(off_t, lseek, int, f,
off_t, o, int, w)
#endif
LSS_INLINE _syscall2(int, munmap, void*, s,
size_t, l)
LSS_INLINE _syscall6(long, move_pages, pid_t, p,
unsigned long, n, void **,g, int *, d,
int *, s, int, f)
LSS_INLINE _syscall3(int, mprotect, const void *,a,
size_t, l, int, p)
LSS_INLINE _syscall5(void*, _mremap, void*, o,
size_t, os, size_t, ns,
unsigned long, f, void *, a)
#if defined(__NR_open)
LSS_INLINE _syscall3(int, open, const char*, p,
int, f, int, m)
#endif
#if defined(__NR_poll)
LSS_INLINE _syscall3(int, poll, struct kernel_pollfd*, u,
unsigned int, n, int, t)
#endif
#if defined(__NR_ppoll)
LSS_INLINE _syscall5(int, ppoll, struct kernel_pollfd *, u,
unsigned int, n, const struct kernel_timespec *, t,
const struct kernel_sigset_t *, sigmask, size_t, s)
#endif
LSS_INLINE _syscall5(int, prctl, int, option,
unsigned long, arg2,
unsigned long, arg3,
unsigned long, arg4,
unsigned long, arg5)
LSS_INLINE _syscall4(long, ptrace, int, r,
pid_t, p, void *, a, void *, d)
#if defined(__NR_quotactl)
LSS_INLINE _syscall4(int, quotactl, int, cmd, const char *, special,
int, id, caddr_t, addr)
#endif
LSS_INLINE _syscall3(ssize_t, read, int, f,
void *, b, size_t, c)
#if defined(__NR_readlink)
LSS_INLINE _syscall3(int, readlink, const char*, p,
char*, b, size_t, s)
#endif
#if defined(__NR_readlinkat)
LSS_INLINE _syscall4(int, readlinkat, int, d, const char *, p, char *, b,
size_t, s)
#endif
LSS_INLINE _syscall4(int, rt_sigaction, int, s,
const struct kernel_sigaction*, a,
struct kernel_sigaction*, o, size_t, c)
LSS_INLINE _syscall2(int, rt_sigpending, struct kernel_sigset_t *, s,
size_t, c)
LSS_INLINE _syscall4(int, rt_sigprocmask, int, h,
const struct kernel_sigset_t*, s,
struct kernel_sigset_t*, o, size_t, c)
LSS_INLINE _syscall2(int, rt_sigsuspend,
const struct kernel_sigset_t*, s, size_t, c)
LSS_INLINE _syscall4(int, rt_sigtimedwait, const struct kernel_sigset_t*, s,
siginfo_t*, i, const struct timespec*, t, size_t, c)
LSS_INLINE _syscall3(int, sched_getaffinity,pid_t, p,
unsigned int, l, unsigned long *, m)
LSS_INLINE _syscall3(int, sched_setaffinity,pid_t, p,
unsigned int, l, unsigned long *, m)
LSS_INLINE _syscall0(…)
LSS_INLINE _syscall1(long, set_tid_address, int *, t)
LSS_INLINE _syscall1(…)
LSS_INLINE _syscall1(…)
LSS_INLINE _syscall1(…)
LSS_INLINE _syscall1(…)
LSS_INLINE _syscall3(int, setitimer, int, w,
const struct kernel_itimerval*, n,
struct kernel_itimerval*, o)
LSS_INLINE _syscall2(…)
LSS_INLINE _syscall3(int, setpriority, int, a,
int, b, int, p)
LSS_INLINE _syscall3(…)
LSS_INLINE _syscall3(…)
#if defined(__NR_setrlimit)
LSS_INLINE _syscall2(int, setrlimit, int, r,
const struct kernel_rlimit*, l)
#endif
LSS_INLINE _syscall0(…)
LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s,
const stack_t*, o)
#if defined(__NR_sigreturn)
LSS_INLINE _syscall1(int, sigreturn, unsigned long, u)
#endif
#if defined(__NR_stat)
LSS_INLINE _syscall2(int, stat, const char*, f,
struct kernel_stat*, b)
#endif
#if defined(__NR_lstat)
LSS_INLINE _syscall2(int, lstat, const char*, f,
struct kernel_stat*, b)
#endif
LSS_INLINE _syscall2(int, statfs, const char*, f,
struct kernel_statfs*, b)
LSS_INLINE _syscall3(int, tgkill, pid_t, p,
pid_t, t, int, s)
LSS_INLINE _syscall2(int, tkill, pid_t, p,
int, s)
#if defined(__NR_unlink)
LSS_INLINE _syscall1(int, unlink, const char*, f)
#endif
LSS_INLINE _syscall3(ssize_t, write, int, f,
const void *, b, size_t, c)
LSS_INLINE _syscall3(ssize_t, writev, int, f,
const struct kernel_iovec*, v, size_t, c)
#if defined(__NR_getcpu)
LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu,
unsigned *, node, void *, unused)
#endif
#if defined(__NR_fadvise64)
#if defined(__x86_64__)
LSS_INLINE int LSS_NAME(fadvise64)(int fd, loff_t offset, loff_t len,
int advice) { … }
#else
LSS_INLINE _syscall4(int, fadvise64,
int, fd, loff_t, offset, loff_t, len, int, advice)
#endif
#elif defined(__i386__)
#define __NR__fadvise64_64 …
LSS_INLINE _syscall6(int, _fadvise64_64, int, fd,
unsigned, offset_lo, unsigned, offset_hi,
unsigned, len_lo, unsigned, len_hi,
int, advice)
LSS_INLINE int LSS_NAME(fadvise64)(int fd, loff_t offset,
loff_t len, int advice) {
return LSS_NAME(_fadvise64_64)(fd,
(unsigned)offset, (unsigned)(offset >>32),
(unsigned)len, (unsigned)(len >> 32),
advice);
}
#elif defined(__s390__) && !defined(__s390x__)
#define __NR__fadvise64_64 …
struct kernel_fadvise64_64_args {
int fd;
long long offset;
long long len;
int advice;
};
LSS_INLINE _syscall1(int, _fadvise64_64,
struct kernel_fadvise64_64_args *args)
LSS_INLINE int LSS_NAME(fadvise64)(int fd, loff_t offset,
loff_t len, int advice) {
struct kernel_fadvise64_64_args args = { fd, offset, len, advice };
return LSS_NAME(_fadvise64_64)(&args);
}
#endif
#if defined(__NR_fallocate)
#if defined(__x86_64__)
LSS_INLINE int LSS_NAME(fallocate)(int f, int mode, loff_t offset,
loff_t len) { … }
#elif (defined(__i386__) || (defined(__s390__) && !defined(__s390x__)) \
|| defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) \
|| (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) \
|| defined(__PPC__))
#define __NR__fallocate …
LSS_INLINE _syscall6(int, _fallocate, int, fd,
int, mode,
unsigned, offset_lo, unsigned, offset_hi,
unsigned, len_lo, unsigned, len_hi)
LSS_INLINE int LSS_NAME(fallocate)(int fd, int mode,
loff_t offset, loff_t len) {
union { loff_t off; unsigned w[2]; } o = { offset }, l = { len };
return LSS_NAME(_fallocate)(fd, mode, o.w[0], o.w[1], l.w[0], l.w[1]);
}
#else
LSS_INLINE _syscall4(int, fallocate,
int, f, int, mode, loff_t, offset, loff_t, len)
#endif
#endif
#if defined(__NR_getrandom)
LSS_INLINE _syscall3(ssize_t, getrandom, void*, buffer, size_t, length,
unsigned int, flags)
#endif
#if defined(__NR_newfstatat)
LSS_INLINE _syscall4(int, newfstatat, int, d,
const char *, p,
struct kernel_stat*, b, int, f)
#endif
#if defined(__NR_statx)
LSS_INLINE _syscall5(int, statx, int, d,
const char *, p,
int, f, int, m,
struct kernel_statx*, b)
#endif
#if defined(__x86_64__) || defined(__s390x__)
LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid,
gid_t *egid,
gid_t *sgid) { … }
LSS_INLINE int LSS_NAME(getresuid32)(uid_t *ruid,
uid_t *euid,
uid_t *suid) { … }
LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { … }
LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { … }
LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { … }
LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { … }
LSS_INLINE int LSS_NAME(sigaction)(int signum,
const struct kernel_sigaction *act,
struct kernel_sigaction *oldact) { … }
LSS_INLINE int LSS_NAME(sigpending)(struct kernel_sigset_t *set) { … }
LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { … }
#endif
#if defined(__NR_rt_sigprocmask)
LSS_INLINE int LSS_NAME(sigprocmask)(int how,
const struct kernel_sigset_t *set,
struct kernel_sigset_t *oldset) { … }
#endif
#if defined(__NR_rt_sigtimedwait)
LSS_INLINE int LSS_NAME(sigtimedwait)(const struct kernel_sigset_t *set,
siginfo_t *info,
const struct timespec *timeout) { … }
#endif
#if defined(__NR_wait4)
LSS_INLINE _syscall4(pid_t, wait4, pid_t, p,
int*, s, int, o,
struct kernel_rusage*, r)
#endif
#if defined(__NR_openat)
LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m)
#endif
#if defined(__NR_unlinkat)
LSS_INLINE _syscall3(int, unlinkat, int, d, const char *, p, int, f)
#endif
#if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || \
(defined(__s390__) && !defined(__s390x__))
#define __NR__getresgid32 …
#define __NR__getresuid32 …
#define __NR__setfsgid32 …
#define __NR__setfsuid32 …
#define __NR__setresgid32 …
#define __NR__setresuid32 …
#if defined(__ARM_EABI__)
LSS_INLINE _syscall2(int, ugetrlimit, int, r,
struct kernel_rlimit*, l)
#endif
LSS_INLINE _syscall3(int, _getresgid32, gid_t *, r,
gid_t *, e, gid_t *, s)
LSS_INLINE _syscall3(int, _getresuid32, uid_t *, r,
uid_t *, e, uid_t *, s)
LSS_INLINE _syscall1(int, _setfsgid32, gid_t, f)
LSS_INLINE _syscall1(int, _setfsuid32, uid_t, f)
LSS_INLINE _syscall3(int, _setresgid32, gid_t, r,
gid_t, e, gid_t, s)
LSS_INLINE _syscall3(int, _setresuid32, uid_t, r,
uid_t, e, uid_t, s)
LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid,
gid_t *egid,
gid_t *sgid) {
int rc;
if ((rc = LSS_NAME(_getresgid32)(rgid, egid, sgid)) < 0 &&
LSS_ERRNO == ENOSYS) {
if ((rgid == NULL) || (egid == NULL) || (sgid == NULL)) {
return EFAULT;
}
*rgid = *egid = *sgid = 0;
rc = LSS_NAME(getresgid)(rgid, egid, sgid);
}
return rc;
}
LSS_INLINE int LSS_NAME(getresuid32)(uid_t *ruid,
uid_t *euid,
uid_t *suid) {
int rc;
if ((rc = LSS_NAME(_getresuid32)(ruid, euid, suid)) < 0 &&
LSS_ERRNO == ENOSYS) {
if ((ruid == NULL) || (euid == NULL) || (suid == NULL)) {
return EFAULT;
}
*ruid = *euid = *suid = 0;
rc = LSS_NAME(getresuid)(ruid, euid, suid);
}
return rc;
}
LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) {
int rc;
if ((rc = LSS_NAME(_setfsgid32)(gid)) < 0 &&
LSS_ERRNO == ENOSYS) {
if ((unsigned int)gid & ~0xFFFFu) {
rc = EINVAL;
} else {
rc = LSS_NAME(setfsgid)(gid);
}
}
return rc;
}
LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) {
int rc;
if ((rc = LSS_NAME(_setfsuid32)(uid)) < 0 &&
LSS_ERRNO == ENOSYS) {
if ((unsigned int)uid & ~0xFFFFu) {
rc = EINVAL;
} else {
rc = LSS_NAME(setfsuid)(uid);
}
}
return rc;
}
LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) {
int rc;
if ((rc = LSS_NAME(_setresgid32)(rgid, egid, sgid)) < 0 &&
LSS_ERRNO == ENOSYS) {
if ((unsigned int)rgid & ~0xFFFFu ||
(unsigned int)egid & ~0xFFFFu ||
(unsigned int)sgid & ~0xFFFFu) {
rc = EINVAL;
} else {
rc = LSS_NAME(setresgid)(rgid, egid, sgid);
}
}
return rc;
}
LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) {
int rc;
if ((rc = LSS_NAME(_setresuid32)(ruid, euid, suid)) < 0 &&
LSS_ERRNO == ENOSYS) {
if ((unsigned int)ruid & ~0xFFFFu ||
(unsigned int)euid & ~0xFFFFu ||
(unsigned int)suid & ~0xFFFFu) {
rc = EINVAL;
} else {
rc = LSS_NAME(setresuid)(ruid, euid, suid);
}
}
return rc;
}
#endif
LSS_INLINE int LSS_NAME(sigemptyset)(struct kernel_sigset_t *set) { … }
LSS_INLINE int LSS_NAME(sigfillset)(struct kernel_sigset_t *set) { … }
LSS_INLINE int LSS_NAME(sigaddset)(struct kernel_sigset_t *set,
int signum) { … }
LSS_INLINE int LSS_NAME(sigdelset)(struct kernel_sigset_t *set,
int signum) { … }
LSS_INLINE int LSS_NAME(sigismember)(struct kernel_sigset_t *set,
int signum) { … }
#if defined(__i386__) || \
defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || \
(defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \
defined(__PPC__) || \
(defined(__s390__) && !defined(__s390x__)) || defined(__e2k__)
#define __NR__sigaction …
#define __NR__sigpending …
#define __NR__sigsuspend …
#define __NR__socketcall …
LSS_INLINE _syscall2(int, fstat64, int, f,
struct kernel_stat64 *, b)
LSS_INLINE _syscall5(int, _llseek, uint, fd,
unsigned long, hi, unsigned long, lo,
loff_t *, res, uint, wh)
#if defined(__s390__) && !defined(__s390x__)
LSS_INLINE void* LSS_NAME(_mmap2)(void *s, size_t l, int p, int f, int d,
off_t o) {
unsigned long buf[6] = { (unsigned long) s, (unsigned long) l,
(unsigned long) p, (unsigned long) f,
(unsigned long) d, (unsigned long) o };
LSS_REG(2, buf);
LSS_BODY(void*, mmap2, "0"(__r2));
}
#else
#define __NR__mmap2 …
LSS_INLINE _syscall6(void*, _mmap2, void*, s,
size_t, l, int, p,
int, f, int, d,
off_t, o)
#endif
LSS_INLINE _syscall3(int, _sigaction, int, s,
const struct kernel_old_sigaction*, a,
struct kernel_old_sigaction*, o)
LSS_INLINE _syscall1(int, _sigpending, unsigned long*, s)
#ifdef __PPC__
LSS_INLINE _syscall1(int, _sigsuspend, unsigned long, s)
#else
LSS_INLINE _syscall3(int, _sigsuspend, const void*, a,
int, b,
unsigned long, s)
#endif
LSS_INLINE _syscall2(int, stat64, const char *, p,
struct kernel_stat64 *, b)
LSS_INLINE int LSS_NAME(sigaction)(int signum,
const struct kernel_sigaction *act,
struct kernel_sigaction *oldact) {
int old_errno = LSS_ERRNO;
int rc;
struct kernel_sigaction a;
if (act != NULL) {
a = *act;
#ifdef __i386__
if (!(a.sa_flags & SA_RESTORER)) {
a.sa_flags |= SA_RESTORER;
a.sa_restorer = (a.sa_flags & SA_SIGINFO)
? LSS_NAME(restore_rt)() : LSS_NAME(restore)();
}
#endif
}
rc = LSS_NAME(rt_sigaction)(signum, act ? &a : act, oldact,
(KERNEL_NSIG+7)/8);
if (rc < 0 && LSS_ERRNO == ENOSYS) {
struct kernel_old_sigaction oa, ooa, *ptr_a = &oa, *ptr_oa = &ooa;
if (!act) {
ptr_a = NULL;
} else {
oa.sa_handler_ = act->sa_handler_;
memcpy(&oa.sa_mask, &act->sa_mask, sizeof(oa.sa_mask));
#ifndef __mips__
oa.sa_restorer = act->sa_restorer;
#endif
oa.sa_flags = act->sa_flags;
}
if (!oldact) {
ptr_oa = NULL;
}
LSS_ERRNO = old_errno;
rc = LSS_NAME(_sigaction)(signum, ptr_a, ptr_oa);
if (rc == 0 && oldact) {
if (act) {
memcpy(oldact, act, sizeof(*act));
} else {
memset(oldact, 0, sizeof(*oldact));
}
oldact->sa_handler_ = ptr_oa->sa_handler_;
oldact->sa_flags = ptr_oa->sa_flags;
memcpy(&oldact->sa_mask, &ptr_oa->sa_mask, sizeof(ptr_oa->sa_mask));
#ifndef __mips__
oldact->sa_restorer = ptr_oa->sa_restorer;
#endif
}
}
return rc;
}
LSS_INLINE int LSS_NAME(sigpending)(struct kernel_sigset_t *set) {
int old_errno = LSS_ERRNO;
int rc = LSS_NAME(rt_sigpending)(set, (KERNEL_NSIG+7)/8);
if (rc < 0 && LSS_ERRNO == ENOSYS) {
LSS_ERRNO = old_errno;
LSS_NAME(sigemptyset)(set);
rc = LSS_NAME(_sigpending)(&set->sig[0]);
}
return rc;
}
LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) {
int olderrno = LSS_ERRNO;
int rc = LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8);
if (rc < 0 && LSS_ERRNO == ENOSYS) {
LSS_ERRNO = olderrno;
rc = LSS_NAME(_sigsuspend)(
#ifndef __PPC__
set, 0,
#endif
set->sig[0]);
}
return rc;
}
#endif
#if defined(__i386__) || \
defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || \
(defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \
defined(__PPC__) || \
(defined(__s390__) && !defined(__s390x__))
LSS_INLINE void* LSS_NAME(mmap)(void *s, size_t l, int p, int f, int d,
int64_t o) {
if (o % 4096) {
LSS_ERRNO = EINVAL;
return (void *) -1;
}
return LSS_NAME(_mmap2)(s, l, p, f, d, (o / 4096));
}
#elif defined(__s390x__)
LSS_INLINE void* LSS_NAME(mmap)(void *s, size_t l, int p, int f, int d,
int64_t o) {
unsigned long buf[6] = { (unsigned long) s, (unsigned long) l,
(unsigned long) p, (unsigned long) f,
(unsigned long) d, (unsigned long) o };
LSS_REG(2, buf);
LSS_BODY(void*, mmap, "0"(__r2));
}
#elif defined(__x86_64__)
LSS_INLINE void* LSS_NAME(mmap)(void *s, size_t l, int p, int f, int d,
int64_t o) { … }
#else
LSS_INLINE _syscall6(void*, mmap, void*, addr, size_t, length, int, prot,
int, flags, int, fd, int64_t, offset)
#endif
#if defined(__PPC__)
#undef LSS_SC_LOADARGS_0
#define LSS_SC_LOADARGS_0 …
#undef LSS_SC_LOADARGS_1
#define LSS_SC_LOADARGS_1 …
#undef LSS_SC_LOADARGS_2
#define LSS_SC_LOADARGS_2 …
#undef LSS_SC_LOADARGS_3
#define LSS_SC_LOADARGS_3 …
#undef LSS_SC_LOADARGS_4
#define LSS_SC_LOADARGS_4 …
#undef LSS_SC_LOADARGS_5
#define LSS_SC_LOADARGS_5 …
#undef LSS_SC_BODY
#define LSS_SC_BODY …
LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg,
int flags){
LSS_SC_BODY(3, ssize_t, 17, s, msg, flags);
}
LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s,
const struct kernel_msghdr *msg,
int flags) {
LSS_SC_BODY(3, ssize_t, 16, s, msg, flags);
}
#if 0
LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len,
int flags,
const struct kernel_sockaddr *to,
unsigned int tolen) {
LSS_BODY(6, ssize_t, 11, s, buf, len, flags, to, tolen);
}
#endif
LSS_INLINE int LSS_NAME(shutdown)(int s, int how) {
LSS_SC_BODY(2, int, 13, s, how);
}
LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) {
LSS_SC_BODY(3, int, 1, domain, type, protocol);
}
LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol,
int sv[2]) {
LSS_SC_BODY(4, int, 8, d, type, protocol, sv);
}
#endif
#if defined(__NR_recvmsg)
LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg,
int, flags)
#endif
#if defined(__NR_sendmsg)
LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*,
msg, int, flags)
#endif
#if defined(__NR_sendto)
LSS_INLINE _syscall6(ssize_t, sendto, int, s, const void*, buf, size_t,len,
int, flags, const struct kernel_sockaddr*, to,
unsigned int, tolen)
#endif
#if defined(__NR_shutdown)
LSS_INLINE _syscall2(int, shutdown, int, s, int, how)
#endif
#if defined(__NR_socket)
LSS_INLINE _syscall3(int, socket, int, domain, int, type, int, protocol)
#endif
#if defined(__NR_socketpair)
LSS_INLINE _syscall4(int, socketpair, int, d, int, type, int, protocol,
int*, sv)
#endif
#if defined(__NR_socketcall)
LSS_INLINE _syscall2(int, _socketcall, int, c,
va_list, a)
LSS_INLINE int LSS_NAME(socketcall)(int op, ...) {
int rc;
va_list ap;
va_start(ap, op);
rc = LSS_NAME(_socketcall)(op, ap);
va_end(ap);
return rc;
}
# if !defined(__NR_recvmsg)
LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg,
int flags){
return (ssize_t)LSS_NAME(socketcall)(17, s, msg, flags);
}
# endif
# if !defined(__NR_sendmsg)
LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s,
const struct kernel_msghdr *msg,
int flags) {
return (ssize_t)LSS_NAME(socketcall)(16, s, msg, flags);
}
# endif
# if !defined(__NR_sendto)
LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len,
int flags,
const struct kernel_sockaddr *to,
unsigned int tolen) {
return (ssize_t)LSS_NAME(socketcall)(11, s, buf, len, flags, to, tolen);
}
# endif
# if !defined(__NR_shutdown)
LSS_INLINE int LSS_NAME(shutdown)(int s, int how) {
return LSS_NAME(socketcall)(13, s, how);
}
# endif
# if !defined(__NR_socket)
LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) {
return LSS_NAME(socketcall)(1, domain, type, protocol);
}
# endif
# if !defined(__NR_socketpair)
LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol,
int sv[2]) {
return LSS_NAME(socketcall)(8, d, type, protocol, sv);
}
# endif
#endif
#if defined(__NR_fstatat64)
LSS_INLINE _syscall4(int, fstatat64, int, d,
const char *, p,
struct kernel_stat64 *, b, int, f)
#endif
#if defined(__NR_waitpid)
LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p,
int*, s, int, o)
#endif
#if defined(__mips__)
LSS_INLINE int LSS_NAME(pipe)(int *p) {
register unsigned long __v0 __asm__("$2") = __NR_pipe;
register unsigned long __v1 __asm__("$3");
register unsigned long __r7 __asm__("$7");
__asm__ __volatile__ ("syscall\n"
: "=r"(__v0), "=r"(__v1), "=r" (__r7)
: "0"(__v0)
: "$8", "$9", "$10", "$11", "$12",
"$13", "$14", "$15", "$24", "$25", "memory");
if (__r7) {
unsigned long __errnovalue = __v0;
LSS_ERRNO = __errnovalue;
return -1;
} else {
p[0] = __v0;
p[1] = __v1;
return 0;
}
}
#elif defined(__NR_pipe)
LSS_INLINE _syscall1(int, pipe, int *, p)
#endif
#if defined(__NR_pipe2)
LSS_INLINE _syscall2(int, pipe2, int *, pipefd, int, flags)
#endif
#if defined(__i386__) || defined(__ARM_ARCH_3__) || \
defined(__ARM_EABI__) || \
(defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) || \
(defined(__s390__) && !defined(__s390x__))
#define __NR__statfs64 …
#define __NR__fstatfs64 …
LSS_INLINE _syscall3(int, _statfs64, const char*, p,
size_t, s,struct kernel_statfs64*, b)
LSS_INLINE _syscall3(int, _fstatfs64, int, f,
size_t, s,struct kernel_statfs64*, b)
LSS_INLINE int LSS_NAME(statfs64)(const char *p,
struct kernel_statfs64 *b) {
return LSS_NAME(_statfs64)(p, sizeof(*b), b);
}
LSS_INLINE int LSS_NAME(fstatfs64)(int f,struct kernel_statfs64 *b) {
return LSS_NAME(_fstatfs64)(f, sizeof(*b), b);
}
#endif
LSS_INLINE int LSS_NAME(execv)(const char *path, const char *const argv[]) { … }
LSS_INLINE pid_t LSS_NAME(gettid)(void) { … }
LSS_INLINE void *LSS_NAME(mremap)(void *old_address, size_t old_size,
size_t new_size, int flags, ...) { … }
LSS_INLINE long LSS_NAME(ptrace_detach)(pid_t pid) { … }
LSS_INLINE int LSS_NAME(raise)(int sig) { … }
LSS_INLINE int LSS_NAME(setpgrp)(void) { … }
#if defined(__x86_64__)
LSS_INLINE ssize_t LSS_NAME(pread64)(int f, void *b, size_t c, loff_t o) { … }
LSS_INLINE ssize_t LSS_NAME(pwrite64)(int f, const void *b, size_t c,
loff_t o) { … }
LSS_INLINE int LSS_NAME(readahead)(int f, loff_t o, size_t c) { … }
#elif defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64
LSS_INLINE _syscall4(ssize_t, pread64, int, f,
void *, b, size_t, c,
loff_t, o)
LSS_INLINE _syscall4(ssize_t, pwrite64, int, f,
const void *, b, size_t, c,
loff_t, o)
LSS_INLINE _syscall3(int, readahead, int, f,
loff_t, o, unsigned, c)
#else
#define __NR__pread64 …
#define __NR__pwrite64 …
#define __NR__readahead …
#if defined(__ARM_EABI__) || defined(__mips__)
#define LSS_LLARG_PAD …
LSS_INLINE _syscall6(ssize_t, _pread64, int, f,
void *, b, size_t, c,
unsigned, skip, unsigned, o1, unsigned, o2)
LSS_INLINE _syscall6(ssize_t, _pwrite64, int, f,
const void *, b, size_t, c,
unsigned, skip, unsigned, o1, unsigned, o2)
LSS_INLINE _syscall5(int, _readahead, int, f,
unsigned, skip,
unsigned, o1, unsigned, o2, size_t, c)
#else
#define LSS_LLARG_PAD
LSS_INLINE _syscall5(ssize_t, _pread64, int, f,
void *, b, size_t, c, unsigned, o1,
unsigned, o2)
LSS_INLINE _syscall5(ssize_t, _pwrite64, int, f,
const void *, b, size_t, c, unsigned, o1,
unsigned, o2)
LSS_INLINE _syscall4(int, _readahead, int, f,
unsigned, o1, unsigned, o2, size_t, c)
#endif
LSS_INLINE ssize_t LSS_NAME(pread64)(int fd, void *buf, size_t count,
loff_t off) {
union { loff_t off; unsigned arg[2]; } o = { off };
return LSS_NAME(_pread64)(fd, buf, count,
LSS_LLARG_PAD o.arg[0], o.arg[1]);
}
LSS_INLINE ssize_t LSS_NAME(pwrite64)(int fd, const void *buf,
size_t count, loff_t off) {
union { loff_t off; unsigned arg[2]; } o = { off };
return LSS_NAME(_pwrite64)(fd, buf, count,
LSS_LLARG_PAD o.arg[0], o.arg[1]);
}
LSS_INLINE int LSS_NAME(readahead)(int fd, loff_t off, size_t count) {
union { loff_t off; unsigned arg[2]; } o = { off };
return LSS_NAME(_readahead)(fd, LSS_LLARG_PAD o.arg[0], o.arg[1], count);
}
#endif
#endif
#if !defined(__NR_dup2)
LSS_INLINE int LSS_NAME(dup2)(int s, int d) {
return LSS_NAME(dup3)(s, d, 0);
}
#endif
#if !defined(__NR_open)
LSS_INLINE int LSS_NAME(open)(const char *pathname, int flags, int mode) {
return LSS_NAME(openat)(AT_FDCWD, pathname, flags, mode);
}
#endif
#if !defined(__NR_unlink)
LSS_INLINE int LSS_NAME(unlink)(const char *pathname) {
return LSS_NAME(unlinkat)(AT_FDCWD, pathname, 0);
}
#endif
#if !defined(__NR_readlink)
LSS_INLINE int LSS_NAME(readlink)(const char *pathname, char *buffer,
size_t size) {
return LSS_NAME(readlinkat)(AT_FDCWD, pathname, buffer, size);
}
#endif
#if !defined(__NR_pipe)
LSS_INLINE int LSS_NAME(pipe)(int *pipefd) {
return LSS_NAME(pipe2)(pipefd, 0);
}
#endif
#if !defined(__NR_poll)
LSS_INLINE int LSS_NAME(poll)(struct kernel_pollfd *fds, unsigned int nfds,
int timeout) {
struct kernel_timespec timeout_ts;
struct kernel_timespec *timeout_ts_p = NULL;
if (timeout >= 0) {
timeout_ts.tv_sec = timeout / 1000;
timeout_ts.tv_nsec = (timeout % 1000) * 1000000;
timeout_ts_p = &timeout_ts;
}
return LSS_NAME(ppoll)(fds, nfds, timeout_ts_p, NULL, 0);
}
#endif
#if defined(__NR_statx)
LSS_INLINE void LSS_NAME(cp_stat_statx)(struct kernel_stat *to,
struct kernel_statx *from) { … }
#endif
#if !defined(__NR_fstat)
LSS_INLINE int LSS_NAME(fstat)(int fd,
struct kernel_stat *buf) {
#if defined(__NR_newfstatat)
return LSS_NAME(newfstatat)(fd, "", buf, AT_EMPTY_PATH);
#elif defined(__NR_statx)
struct kernel_statx stx;
int flags = AT_NO_AUTOMOUNT | AT_EMPTY_PATH;
int mask = STATX_BASIC_STATS;
int res = LSS_NAME(statx)(fd, "", flags, mask, &stx);
LSS_NAME(cp_stat_statx)(buf, &stx);
return res;
#endif
}
#endif
#if !defined(__NR_stat)
LSS_INLINE int LSS_NAME(stat)(const char *pathname,
struct kernel_stat *buf) {
#if defined(__NR_newfstatat)
return LSS_NAME(newfstatat)(AT_FDCWD, pathname, buf, 0);
#elif defined(__NR_statx)
struct kernel_statx stx;
int flags = AT_NO_AUTOMOUNT | AT_STATX_SYNC_AS_STAT;
int mask = STATX_BASIC_STATS;
int res = LSS_NAME(statx)(AT_FDCWD, pathname, flags, mask, &stx);
LSS_NAME(cp_stat_statx)(buf, &stx);
return res;
#endif
}
#endif
#if !defined(__NR_lstat)
LSS_INLINE int LSS_NAME(lstat)(const char *pathname,
struct kernel_stat *buf) {
#if defined(__NR_newfstatat)
return LSS_NAME(newfstatat)(AT_FDCWD, pathname, buf, AT_SYMLINK_NOFOLLOW);
#elif defined(__NR_statx)
struct kernel_statx stx;
int flags = AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW;
int mask = STATX_BASIC_STATS;
int res = LSS_NAME(statx)(AT_FDCWD, pathname, flags, mask, &stx);
LSS_NAME(cp_stat_statx)(buf, &stx);
return res;
#endif
}
#endif
#if !defined(__NR_waitpid)
LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options) { … }
#endif
#if !defined(__NR_fork)
# if defined(__aarch64__) || defined(__riscv) || defined(__loongarch_lp64)
LSS_INLINE pid_t LSS_NAME(fork)(void) {
int flags = SIGCHLD;
void *child_stack = NULL;
void *parent_tidptr = NULL;
void *newtls = NULL;
void *child_tidptr = NULL;
LSS_REG(0, flags);
LSS_REG(1, child_stack);
LSS_REG(2, parent_tidptr);
LSS_REG(3, newtls);
LSS_REG(4, child_tidptr);
LSS_BODY(pid_t, clone, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3),
"r"(__r4));
}
# elif defined(__x86_64__)
LSS_INLINE pid_t LSS_NAME(fork)(void) {
int flags = SIGCHLD;
void *child_stack = NULL;
void *parent_tidptr = NULL;
void *newtls = NULL;
void *child_tidptr = NULL;
LSS_BODY(5, pid_t, clone, LSS_SYSCALL_ARG(flags),
LSS_SYSCALL_ARG(child_stack), LSS_SYSCALL_ARG(parent_tidptr),
LSS_SYSCALL_ARG(newtls), LSS_SYSCALL_ARG(child_tidptr));
}
# else
# error missing fork polyfill for this architecture
# endif
#endif
#pragma pop_macro("stat64")
#pragma pop_macro("fstat64")
#pragma pop_macro("lstat64")
#pragma pop_macro("pread64")
#pragma pop_macro("pwrite64")
#pragma pop_macro("getdents64")
#if defined(__cplusplus) && !defined(SYS_CPLUSPLUS)
}
#endif
#endif
#endif