82 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H 83 #define SYS_LINUX_SYSCALL_SUPPORT_H 88 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ 89 defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__)) \ 90 && (defined(__linux) || defined(__ANDROID__)) 107 #include <sys/ptrace.h> 108 #include <sys/resource.h> 109 #include <sys/time.h> 110 #include <sys/types.h> 111 #include <sys/syscall.h> 113 #include <linux/unistd.h> 127 # pragma push_macro("stat64") 128 # pragma push_macro("fstat64") 129 # pragma push_macro("lstat64") 165 struct kernel_dirent64 {
166 unsigned long long d_ino;
168 unsigned short d_reclen;
169 unsigned char d_type;
174 struct kernel_dirent {
177 unsigned short d_reclen;
182 struct kernel_iovec {
184 unsigned long iov_len;
188 struct kernel_msghdr {
191 struct kernel_iovec*msg_iov;
192 unsigned long msg_iovlen;
194 unsigned long msg_controllen;
199 struct kernel_pollfd {
206 struct kernel_rlimit {
207 unsigned long rlim_cur;
208 unsigned long rlim_max;
212 struct kernel_timespec {
218 struct kernel_timeval {
224 struct kernel_rusage {
225 struct kernel_timeval ru_utime;
226 struct kernel_timeval ru_stime;
244 #if defined(__i386__) || defined(__ARM_EABI__) || defined(__ARM_ARCH_3__) \ 248 struct kernel_old_sigaction {
250 void (*sa_handler_)(
int);
251 void (*sa_sigaction_)(
int,
struct siginfo *,
void *);
253 unsigned long sa_mask;
254 unsigned long sa_flags;
255 void (*sa_restorer)(void);
256 } __attribute__((packed,aligned(4)));
257 #elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) 258 #define kernel_old_sigaction kernel_sigaction 271 #define KERNEL_NSIG 128 273 #define KERNEL_NSIG 64 277 struct kernel_sigset_t {
278 unsigned long sig[(KERNEL_NSIG + 8*
sizeof(
unsigned long) - 1)/
279 (8*
sizeof(
unsigned long))];
283 struct kernel_sigaction {
285 unsigned long sa_flags;
287 void (*sa_handler_)(
int);
288 void (*sa_sigaction_)(
int,
struct siginfo *,
void *);
290 struct kernel_sigset_t sa_mask;
293 void (*sa_handler_)(
int);
294 void (*sa_sigaction_)(
int,
struct siginfo *,
void *);
296 unsigned long sa_flags;
297 void (*sa_restorer)(void);
298 struct kernel_sigset_t sa_mask;
303 struct kernel_sockaddr {
304 unsigned short sa_family;
310 #if _MIPS_SIM == _MIPS_SIM_ABI64 313 struct kernel_stat64 {
317 unsigned long long st_ino;
326 unsigned st_atime_nsec_;
328 unsigned st_mtime_nsec_;
330 unsigned st_ctime_nsec_;
333 unsigned long long st_blocks;
335 #elif defined __PPC__ 336 struct kernel_stat64 {
337 unsigned long long st_dev;
338 unsigned long long st_ino;
343 unsigned long long st_rdev;
344 unsigned short int __pad2;
349 unsigned long st_atime_nsec_;
351 unsigned long st_mtime_nsec_;
353 unsigned long st_ctime_nsec_;
354 unsigned long __unused4;
355 unsigned long __unused5;
358 struct kernel_stat64 {
359 unsigned long long st_dev;
360 unsigned char __pad0[4];
366 unsigned long long st_rdev;
367 unsigned char __pad3[4];
370 unsigned long long st_blocks;
372 unsigned st_atime_nsec_;
374 unsigned st_mtime_nsec_;
376 unsigned st_ctime_nsec_;
377 unsigned long long st_ino;
382 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) 389 unsigned short st_dev;
392 unsigned short st_mode;
393 unsigned short st_nlink;
394 unsigned short st_uid;
395 unsigned short st_gid;
396 unsigned short st_rdev;
402 unsigned st_atime_nsec_;
404 unsigned st_mtime_nsec_;
406 unsigned st_ctime_nsec_;
410 #elif defined(__x86_64__) 412 unsigned long st_dev;
413 unsigned long st_ino;
414 unsigned long st_nlink;
419 unsigned long st_rdev;
423 unsigned long st_atime_;
424 unsigned long st_atime_nsec_;
425 unsigned long st_mtime_;
426 unsigned long st_mtime_nsec_;
427 unsigned long st_ctime_;
428 unsigned long st_ctime_nsec_;
431 #elif defined(__PPC__) 434 unsigned long st_ino;
435 unsigned long st_mode;
436 unsigned short st_nlink;
441 unsigned long st_blksize;
442 unsigned long st_blocks;
443 unsigned long st_atime_;
444 unsigned long st_atime_nsec_;
445 unsigned long st_mtime_;
446 unsigned long st_mtime_nsec_;
447 unsigned long st_ctime_;
448 unsigned long st_ctime_nsec_;
449 unsigned long __unused4;
450 unsigned long __unused5;
452 #elif (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) 479 #if _MIPS_SIM != _MIPS_SIM_ABI64 480 struct kernel_statfs64 {
481 unsigned long f_type;
482 unsigned long f_bsize;
483 unsigned long f_frsize;
485 unsigned long long f_blocks;
486 unsigned long long f_bfree;
487 unsigned long long f_files;
488 unsigned long long f_ffree;
489 unsigned long long f_bavail;
490 struct {
int val[2]; } f_fsid;
491 unsigned long f_namelen;
492 unsigned long f_spare[6];
495 #elif !defined(__x86_64__) 496 struct kernel_statfs64 {
497 unsigned long f_type;
498 unsigned long f_bsize;
499 unsigned long long f_blocks;
500 unsigned long long f_bfree;
501 unsigned long long f_bavail;
502 unsigned long long f_files;
503 unsigned long long f_ffree;
504 struct {
int val[2]; } f_fsid;
505 unsigned long f_namelen;
506 unsigned long f_frsize;
507 unsigned long f_spare[5];
513 struct kernel_statfs {
522 struct {
int val[2]; } f_fsid;
527 struct kernel_statfs {
531 unsigned long f_type;
532 unsigned long f_bsize;
533 unsigned long f_blocks;
534 unsigned long f_bfree;
535 unsigned long f_bavail;
536 unsigned long f_files;
537 unsigned long f_ffree;
538 struct {
int val[2]; } f_fsid;
539 unsigned long f_namelen;
540 unsigned long f_frsize;
541 unsigned long f_spare[5];
548 #if defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) 549 #define O_DIRECTORY 0040000 551 #define O_DIRECTORY 0200000 555 #define NT_PRXFPREG 0x46e62b7f 557 #ifndef PTRACE_GETFPXREGS 558 #define PTRACE_GETFPXREGS ((enum __ptrace_request)18) 560 #ifndef PR_GET_DUMPABLE 561 #define PR_GET_DUMPABLE 3 563 #ifndef PR_SET_DUMPABLE 564 #define PR_SET_DUMPABLE 4 566 #ifndef PR_GET_SECCOMP 567 #define PR_GET_SECCOMP 21 569 #ifndef PR_SET_SECCOMP 570 #define PR_SET_SECCOMP 22 573 #define AT_FDCWD (-100) 575 #ifndef AT_SYMLINK_NOFOLLOW 576 #define AT_SYMLINK_NOFOLLOW 0x100 579 #define AT_REMOVEDIR 0x200 582 #define MREMAP_FIXED 2 585 #define SA_RESTORER 0x04000000 587 #ifndef CPUCLOCK_PROF 588 #define CPUCLOCK_PROF 0 590 #ifndef CPUCLOCK_VIRT 591 #define CPUCLOCK_VIRT 1 593 #ifndef CPUCLOCK_SCHED 594 #define CPUCLOCK_SCHED 2 596 #ifndef CPUCLOCK_PERTHREAD_MASK 597 #define CPUCLOCK_PERTHREAD_MASK 4 599 #ifndef MAKE_PROCESS_CPUCLOCK 600 #define MAKE_PROCESS_CPUCLOCK(pid, clock) \ 601 ((~(int)(pid) << 3) | (int)(clock)) 603 #ifndef MAKE_THREAD_CPUCLOCK 604 #define MAKE_THREAD_CPUCLOCK(tid, clock) \ 605 ((~(int)(tid) << 3) | (int)((clock) | CPUCLOCK_PERTHREAD_MASK)) 617 #ifndef FUTEX_REQUEUE 618 #define FUTEX_REQUEUE 3 620 #ifndef FUTEX_CMP_REQUEUE 621 #define FUTEX_CMP_REQUEUE 4 623 #ifndef FUTEX_WAKE_OP 624 #define FUTEX_WAKE_OP 5 626 #ifndef FUTEX_LOCK_PI 627 #define FUTEX_LOCK_PI 6 629 #ifndef FUTEX_UNLOCK_PI 630 #define FUTEX_UNLOCK_PI 7 632 #ifndef FUTEX_TRYLOCK_PI 633 #define FUTEX_TRYLOCK_PI 8 635 #ifndef FUTEX_PRIVATE_FLAG 636 #define FUTEX_PRIVATE_FLAG 128 638 #ifndef FUTEX_CMD_MASK 639 #define FUTEX_CMD_MASK ~FUTEX_PRIVATE_FLAG 641 #ifndef FUTEX_WAIT_PRIVATE 642 #define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG) 644 #ifndef FUTEX_WAKE_PRIVATE 645 #define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG) 647 #ifndef FUTEX_REQUEUE_PRIVATE 648 #define FUTEX_REQUEUE_PRIVATE (FUTEX_REQUEUE | FUTEX_PRIVATE_FLAG) 650 #ifndef FUTEX_CMP_REQUEUE_PRIVATE 651 #define FUTEX_CMP_REQUEUE_PRIVATE (FUTEX_CMP_REQUEUE | FUTEX_PRIVATE_FLAG) 653 #ifndef FUTEX_WAKE_OP_PRIVATE 654 #define FUTEX_WAKE_OP_PRIVATE (FUTEX_WAKE_OP | FUTEX_PRIVATE_FLAG) 656 #ifndef FUTEX_LOCK_PI_PRIVATE 657 #define FUTEX_LOCK_PI_PRIVATE (FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG) 659 #ifndef FUTEX_UNLOCK_PI_PRIVATE 660 #define FUTEX_UNLOCK_PI_PRIVATE (FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG) 662 #ifndef FUTEX_TRYLOCK_PI_PRIVATE 663 #define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG) 667 #if defined(__x86_64__) 669 #define ARCH_SET_GS 0x1001 672 #define ARCH_GET_GS 0x1004 676 #if defined(__i386__) 677 #ifndef __NR_quotactl 678 #define __NR_quotactl 131 680 #ifndef __NR_setresuid 681 #define __NR_setresuid 164 682 #define __NR_getresuid 165 683 #define __NR_setresgid 170 684 #define __NR_getresgid 171 686 #ifndef __NR_rt_sigaction 687 #define __NR_rt_sigreturn 173 688 #define __NR_rt_sigaction 174 689 #define __NR_rt_sigprocmask 175 690 #define __NR_rt_sigpending 176 691 #define __NR_rt_sigsuspend 179 694 #define __NR_pread64 180 696 #ifndef __NR_pwrite64 697 #define __NR_pwrite64 181 699 #ifndef __NR_ugetrlimit 700 #define __NR_ugetrlimit 191 703 #define __NR_stat64 195 706 #define __NR_fstat64 197 708 #ifndef __NR_setresuid32 709 #define __NR_setresuid32 208 710 #define __NR_getresuid32 209 711 #define __NR_setresgid32 210 712 #define __NR_getresgid32 211 714 #ifndef __NR_setfsuid32 715 #define __NR_setfsuid32 215 716 #define __NR_setfsgid32 216 718 #ifndef __NR_getdents64 719 #define __NR_getdents64 220 722 #define __NR_gettid 224 724 #ifndef __NR_readahead 725 #define __NR_readahead 225 727 #ifndef __NR_setxattr 728 #define __NR_setxattr 226 730 #ifndef __NR_lsetxattr 731 #define __NR_lsetxattr 227 733 #ifndef __NR_getxattr 734 #define __NR_getxattr 229 736 #ifndef __NR_lgetxattr 737 #define __NR_lgetxattr 230 739 #ifndef __NR_listxattr 740 #define __NR_listxattr 232 742 #ifndef __NR_llistxattr 743 #define __NR_llistxattr 233 746 #define __NR_tkill 238 749 #define __NR_futex 240 751 #ifndef __NR_sched_setaffinity 752 #define __NR_sched_setaffinity 241 753 #define __NR_sched_getaffinity 242 755 #ifndef __NR_set_tid_address 756 #define __NR_set_tid_address 258 758 #ifndef __NR_clock_gettime 759 #define __NR_clock_gettime 265 761 #ifndef __NR_clock_getres 762 #define __NR_clock_getres 266 764 #ifndef __NR_statfs64 765 #define __NR_statfs64 268 767 #ifndef __NR_fstatfs64 768 #define __NR_fstatfs64 269 770 #ifndef __NR_fadvise64_64 771 #define __NR_fadvise64_64 272 773 #ifndef __NR_ioprio_set 774 #define __NR_ioprio_set 289 776 #ifndef __NR_ioprio_get 777 #define __NR_ioprio_get 290 780 #define __NR_openat 295 782 #ifndef __NR_fstatat64 783 #define __NR_fstatat64 300 785 #ifndef __NR_unlinkat 786 #define __NR_unlinkat 301 788 #ifndef __NR_move_pages 789 #define __NR_move_pages 317 792 #define __NR_getcpu 318 794 #ifndef __NR_fallocate 795 #define __NR_fallocate 324 798 #elif defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) 799 #ifndef __NR_setresuid 800 #define __NR_setresuid (__NR_SYSCALL_BASE + 164) 801 #define __NR_getresuid (__NR_SYSCALL_BASE + 165) 802 #define __NR_setresgid (__NR_SYSCALL_BASE + 170) 803 #define __NR_getresgid (__NR_SYSCALL_BASE + 171) 805 #ifndef __NR_rt_sigaction 806 #define __NR_rt_sigreturn (__NR_SYSCALL_BASE + 173) 807 #define __NR_rt_sigaction (__NR_SYSCALL_BASE + 174) 808 #define __NR_rt_sigprocmask (__NR_SYSCALL_BASE + 175) 809 #define __NR_rt_sigpending (__NR_SYSCALL_BASE + 176) 810 #define __NR_rt_sigsuspend (__NR_SYSCALL_BASE + 179) 813 #define __NR_pread64 (__NR_SYSCALL_BASE + 180) 815 #ifndef __NR_pwrite64 816 #define __NR_pwrite64 (__NR_SYSCALL_BASE + 181) 818 #ifndef __NR_ugetrlimit 819 #define __NR_ugetrlimit (__NR_SYSCALL_BASE + 191) 822 #define __NR_stat64 (__NR_SYSCALL_BASE + 195) 825 #define __NR_fstat64 (__NR_SYSCALL_BASE + 197) 827 #ifndef __NR_setresuid32 828 #define __NR_setresuid32 (__NR_SYSCALL_BASE + 208) 829 #define __NR_getresuid32 (__NR_SYSCALL_BASE + 209) 830 #define __NR_setresgid32 (__NR_SYSCALL_BASE + 210) 831 #define __NR_getresgid32 (__NR_SYSCALL_BASE + 211) 833 #ifndef __NR_setfsuid32 834 #define __NR_setfsuid32 (__NR_SYSCALL_BASE + 215) 835 #define __NR_setfsgid32 (__NR_SYSCALL_BASE + 216) 837 #ifndef __NR_getdents64 838 #define __NR_getdents64 (__NR_SYSCALL_BASE + 217) 841 #define __NR_gettid (__NR_SYSCALL_BASE + 224) 843 #ifndef __NR_readahead 844 #define __NR_readahead (__NR_SYSCALL_BASE + 225) 846 #ifndef __NR_setxattr 847 #define __NR_setxattr (__NR_SYSCALL_BASE + 226) 849 #ifndef __NR_lsetxattr 850 #define __NR_lsetxattr (__NR_SYSCALL_BASE + 227) 852 #ifndef __NR_getxattr 853 #define __NR_getxattr (__NR_SYSCALL_BASE + 229) 855 #ifndef __NR_lgetxattr 856 #define __NR_lgetxattr (__NR_SYSCALL_BASE + 230) 858 #ifndef __NR_listxattr 859 #define __NR_listxattr (__NR_SYSCALL_BASE + 232) 861 #ifndef __NR_llistxattr 862 #define __NR_llistxattr (__NR_SYSCALL_BASE + 233) 865 #define __NR_tkill (__NR_SYSCALL_BASE + 238) 868 #define __NR_futex (__NR_SYSCALL_BASE + 240) 870 #ifndef __NR_sched_setaffinity 871 #define __NR_sched_setaffinity (__NR_SYSCALL_BASE + 241) 872 #define __NR_sched_getaffinity (__NR_SYSCALL_BASE + 242) 874 #ifndef __NR_set_tid_address 875 #define __NR_set_tid_address (__NR_SYSCALL_BASE + 256) 877 #ifndef __NR_clock_gettime 878 #define __NR_clock_gettime (__NR_SYSCALL_BASE + 263) 880 #ifndef __NR_clock_getres 881 #define __NR_clock_getres (__NR_SYSCALL_BASE + 264) 883 #ifndef __NR_statfs64 884 #define __NR_statfs64 (__NR_SYSCALL_BASE + 266) 886 #ifndef __NR_fstatfs64 887 #define __NR_fstatfs64 (__NR_SYSCALL_BASE + 267) 889 #ifndef __NR_ioprio_set 890 #define __NR_ioprio_set (__NR_SYSCALL_BASE + 314) 892 #ifndef __NR_ioprio_get 893 #define __NR_ioprio_get (__NR_SYSCALL_BASE + 315) 895 #ifndef __NR_move_pages 896 #define __NR_move_pages (__NR_SYSCALL_BASE + 344) 899 #define __NR_getcpu (__NR_SYSCALL_BASE + 345) 902 #elif defined(__x86_64__) 904 #define __NR_pread64 17 906 #ifndef __NR_pwrite64 907 #define __NR_pwrite64 18 909 #ifndef __NR_setresuid 910 #define __NR_setresuid 117 911 #define __NR_getresuid 118 912 #define __NR_setresgid 119 913 #define __NR_getresgid 120 915 #ifndef __NR_quotactl 916 #define __NR_quotactl 179 919 #define __NR_gettid 186 921 #ifndef __NR_readahead 922 #define __NR_readahead 187 924 #ifndef __NR_setxattr 925 #define __NR_setxattr 188 927 #ifndef __NR_lsetxattr 928 #define __NR_lsetxattr 189 930 #ifndef __NR_getxattr 931 #define __NR_getxattr 191 933 #ifndef __NR_lgetxattr 934 #define __NR_lgetxattr 192 936 #ifndef __NR_listxattr 937 #define __NR_listxattr 194 939 #ifndef __NR_llistxattr 940 #define __NR_llistxattr 195 943 #define __NR_tkill 200 946 #define __NR_futex 202 948 #ifndef __NR_sched_setaffinity 949 #define __NR_sched_setaffinity 203 950 #define __NR_sched_getaffinity 204 952 #ifndef __NR_getdents64 953 #define __NR_getdents64 217 955 #ifndef __NR_set_tid_address 956 #define __NR_set_tid_address 218 958 #ifndef __NR_fadvise64 959 #define __NR_fadvise64 221 961 #ifndef __NR_clock_gettime 962 #define __NR_clock_gettime 228 964 #ifndef __NR_clock_getres 965 #define __NR_clock_getres 229 967 #ifndef __NR_ioprio_set 968 #define __NR_ioprio_set 251 970 #ifndef __NR_ioprio_get 971 #define __NR_ioprio_get 252 974 #define __NR_openat 257 976 #ifndef __NR_newfstatat 977 #define __NR_newfstatat 262 979 #ifndef __NR_unlinkat 980 #define __NR_unlinkat 263 982 #ifndef __NR_move_pages 983 #define __NR_move_pages 279 985 #ifndef __NR_fallocate 986 #define __NR_fallocate 285 989 #elif defined(__mips__) 990 #if _MIPS_SIM == _MIPS_SIM_ABI32 991 #ifndef __NR_setresuid 992 #define __NR_setresuid (__NR_Linux + 185) 993 #define __NR_getresuid (__NR_Linux + 186) 994 #define __NR_setresgid (__NR_Linux + 190) 995 #define __NR_getresgid (__NR_Linux + 191) 997 #ifndef __NR_rt_sigaction 998 #define __NR_rt_sigreturn (__NR_Linux + 193) 999 #define __NR_rt_sigaction (__NR_Linux + 194) 1000 #define __NR_rt_sigprocmask (__NR_Linux + 195) 1001 #define __NR_rt_sigpending (__NR_Linux + 196) 1002 #define __NR_rt_sigsuspend (__NR_Linux + 199) 1004 #ifndef __NR_pread64 1005 #define __NR_pread64 (__NR_Linux + 200) 1007 #ifndef __NR_pwrite64 1008 #define __NR_pwrite64 (__NR_Linux + 201) 1011 #define __NR_stat64 (__NR_Linux + 213) 1013 #ifndef __NR_fstat64 1014 #define __NR_fstat64 (__NR_Linux + 215) 1016 #ifndef __NR_getdents64 1017 #define __NR_getdents64 (__NR_Linux + 219) 1020 #define __NR_gettid (__NR_Linux + 222) 1022 #ifndef __NR_readahead 1023 #define __NR_readahead (__NR_Linux + 223) 1025 #ifndef __NR_setxattr 1026 #define __NR_setxattr (__NR_Linux + 224) 1028 #ifndef __NR_lsetxattr 1029 #define __NR_lsetxattr (__NR_Linux + 225) 1031 #ifndef __NR_getxattr 1032 #define __NR_getxattr (__NR_Linux + 227) 1034 #ifndef __NR_lgetxattr 1035 #define __NR_lgetxattr (__NR_Linux + 228) 1037 #ifndef __NR_listxattr 1038 #define __NR_listxattr (__NR_Linux + 230) 1040 #ifndef __NR_llistxattr 1041 #define __NR_llistxattr (__NR_Linux + 231) 1044 #define __NR_tkill (__NR_Linux + 236) 1047 #define __NR_futex (__NR_Linux + 238) 1049 #ifndef __NR_sched_setaffinity 1050 #define __NR_sched_setaffinity (__NR_Linux + 239) 1051 #define __NR_sched_getaffinity (__NR_Linux + 240) 1053 #ifndef __NR_set_tid_address 1054 #define __NR_set_tid_address (__NR_Linux + 252) 1056 #ifndef __NR_statfs64 1057 #define __NR_statfs64 (__NR_Linux + 255) 1059 #ifndef __NR_fstatfs64 1060 #define __NR_fstatfs64 (__NR_Linux + 256) 1062 #ifndef __NR_clock_gettime 1063 #define __NR_clock_gettime (__NR_Linux + 263) 1065 #ifndef __NR_clock_getres 1066 #define __NR_clock_getres (__NR_Linux + 264) 1069 #define __NR_openat (__NR_Linux + 288) 1071 #ifndef __NR_fstatat 1072 #define __NR_fstatat (__NR_Linux + 293) 1074 #ifndef __NR_unlinkat 1075 #define __NR_unlinkat (__NR_Linux + 294) 1077 #ifndef __NR_move_pages 1078 #define __NR_move_pages (__NR_Linux + 308) 1081 #define __NR_getcpu (__NR_Linux + 312) 1083 #ifndef __NR_ioprio_set 1084 #define __NR_ioprio_set (__NR_Linux + 314) 1086 #ifndef __NR_ioprio_get 1087 #define __NR_ioprio_get (__NR_Linux + 315) 1090 #elif _MIPS_SIM == _MIPS_SIM_ABI64 1091 #ifndef __NR_pread64 1092 #define __NR_pread64 (__NR_Linux + 16) 1094 #ifndef __NR_pwrite64 1095 #define __NR_pwrite64 (__NR_Linux + 17) 1097 #ifndef __NR_setresuid 1098 #define __NR_setresuid (__NR_Linux + 115) 1099 #define __NR_getresuid (__NR_Linux + 116) 1100 #define __NR_setresgid (__NR_Linux + 117) 1101 #define __NR_getresgid (__NR_Linux + 118) 1104 #define __NR_gettid (__NR_Linux + 178) 1106 #ifndef __NR_readahead 1107 #define __NR_readahead (__NR_Linux + 179) 1109 #ifndef __NR_setxattr 1110 #define __NR_setxattr (__NR_Linux + 180) 1112 #ifndef __NR_lsetxattr 1113 #define __NR_lsetxattr (__NR_Linux + 181) 1115 #ifndef __NR_getxattr 1116 #define __NR_getxattr (__NR_Linux + 183) 1118 #ifndef __NR_lgetxattr 1119 #define __NR_lgetxattr (__NR_Linux + 184) 1121 #ifndef __NR_listxattr 1122 #define __NR_listxattr (__NR_Linux + 186) 1124 #ifndef __NR_llistxattr 1125 #define __NR_llistxattr (__NR_Linux + 187) 1128 #define __NR_tkill (__NR_Linux + 192) 1131 #define __NR_futex (__NR_Linux + 194) 1133 #ifndef __NR_sched_setaffinity 1134 #define __NR_sched_setaffinity (__NR_Linux + 195) 1135 #define __NR_sched_getaffinity (__NR_Linux + 196) 1137 #ifndef __NR_set_tid_address 1138 #define __NR_set_tid_address (__NR_Linux + 212) 1140 #ifndef __NR_clock_gettime 1141 #define __NR_clock_gettime (__NR_Linux + 222) 1143 #ifndef __NR_clock_getres 1144 #define __NR_clock_getres (__NR_Linux + 223) 1147 #define __NR_openat (__NR_Linux + 247) 1149 #ifndef __NR_fstatat 1150 #define __NR_fstatat (__NR_Linux + 252) 1152 #ifndef __NR_unlinkat 1153 #define __NR_unlinkat (__NR_Linux + 253) 1155 #ifndef __NR_move_pages 1156 #define __NR_move_pages (__NR_Linux + 267) 1159 #define __NR_getcpu (__NR_Linux + 271) 1161 #ifndef __NR_ioprio_set 1162 #define __NR_ioprio_set (__NR_Linux + 273) 1164 #ifndef __NR_ioprio_get 1165 #define __NR_ioprio_get (__NR_Linux + 274) 1169 #ifndef __NR_setresuid 1170 #define __NR_setresuid (__NR_Linux + 115) 1171 #define __NR_getresuid (__NR_Linux + 116) 1172 #define __NR_setresgid (__NR_Linux + 117) 1173 #define __NR_getresgid (__NR_Linux + 118) 1176 #define __NR_gettid (__NR_Linux + 178) 1178 #ifndef __NR_readahead 1179 #define __NR_readahead (__NR_Linux + 179) 1181 #ifndef __NR_setxattr 1182 #define __NR_setxattr (__NR_Linux + 180) 1184 #ifndef __NR_lsetxattr 1185 #define __NR_lsetxattr (__NR_Linux + 181) 1187 #ifndef __NR_getxattr 1188 #define __NR_getxattr (__NR_Linux + 183) 1190 #ifndef __NR_lgetxattr 1191 #define __NR_lgetxattr (__NR_Linux + 184) 1193 #ifndef __NR_listxattr 1194 #define __NR_listxattr (__NR_Linux + 186) 1196 #ifndef __NR_llistxattr 1197 #define __NR_llistxattr (__NR_Linux + 187) 1200 #define __NR_tkill (__NR_Linux + 192) 1203 #define __NR_futex (__NR_Linux + 194) 1205 #ifndef __NR_sched_setaffinity 1206 #define __NR_sched_setaffinity (__NR_Linux + 195) 1207 #define __NR_sched_getaffinity (__NR_Linux + 196) 1209 #ifndef __NR_set_tid_address 1210 #define __NR_set_tid_address (__NR_Linux + 213) 1212 #ifndef __NR_statfs64 1213 #define __NR_statfs64 (__NR_Linux + 217) 1215 #ifndef __NR_fstatfs64 1216 #define __NR_fstatfs64 (__NR_Linux + 218) 1218 #ifndef __NR_clock_gettime 1219 #define __NR_clock_gettime (__NR_Linux + 226) 1221 #ifndef __NR_clock_getres 1222 #define __NR_clock_getres (__NR_Linux + 227) 1225 #define __NR_openat (__NR_Linux + 251) 1227 #ifndef __NR_fstatat 1228 #define __NR_fstatat (__NR_Linux + 256) 1230 #ifndef __NR_unlinkat 1231 #define __NR_unlinkat (__NR_Linux + 257) 1233 #ifndef __NR_move_pages 1234 #define __NR_move_pages (__NR_Linux + 271) 1237 #define __NR_getcpu (__NR_Linux + 275) 1239 #ifndef __NR_ioprio_set 1240 #define __NR_ioprio_set (__NR_Linux + 277) 1242 #ifndef __NR_ioprio_get 1243 #define __NR_ioprio_get (__NR_Linux + 278) 1248 #elif defined(__PPC__) 1249 #ifndef __NR_setfsuid 1250 #define __NR_setfsuid 138 1251 #define __NR_setfsgid 139 1253 #ifndef __NR_setresuid 1254 #define __NR_setresuid 164 1255 #define __NR_getresuid 165 1256 #define __NR_setresgid 169 1257 #define __NR_getresgid 170 1259 #ifndef __NR_rt_sigaction 1260 #define __NR_rt_sigreturn 172 1261 #define __NR_rt_sigaction 173 1262 #define __NR_rt_sigprocmask 174 1263 #define __NR_rt_sigpending 175 1264 #define __NR_rt_sigsuspend 178 1266 #ifndef __NR_pread64 1267 #define __NR_pread64 179 1269 #ifndef __NR_pwrite64 1270 #define __NR_pwrite64 180 1272 #ifndef __NR_ugetrlimit 1273 #define __NR_ugetrlimit 190 1275 #ifndef __NR_readahead 1276 #define __NR_readahead 191 1279 #define __NR_stat64 195 1281 #ifndef __NR_fstat64 1282 #define __NR_fstat64 197 1284 #ifndef __NR_getdents64 1285 #define __NR_getdents64 202 1288 #define __NR_gettid 207 1291 #define __NR_tkill 208 1293 #ifndef __NR_setxattr 1294 #define __NR_setxattr 209 1296 #ifndef __NR_lsetxattr 1297 #define __NR_lsetxattr 210 1299 #ifndef __NR_getxattr 1300 #define __NR_getxattr 212 1302 #ifndef __NR_lgetxattr 1303 #define __NR_lgetxattr 213 1305 #ifndef __NR_listxattr 1306 #define __NR_listxattr 215 1308 #ifndef __NR_llistxattr 1309 #define __NR_llistxattr 216 1312 #define __NR_futex 221 1314 #ifndef __NR_sched_setaffinity 1315 #define __NR_sched_setaffinity 222 1316 #define __NR_sched_getaffinity 223 1318 #ifndef __NR_set_tid_address 1319 #define __NR_set_tid_address 232 1321 #ifndef __NR_clock_gettime 1322 #define __NR_clock_gettime 246 1324 #ifndef __NR_clock_getres 1325 #define __NR_clock_getres 247 1327 #ifndef __NR_statfs64 1328 #define __NR_statfs64 252 1330 #ifndef __NR_fstatfs64 1331 #define __NR_fstatfs64 253 1333 #ifndef __NR_fadvise64_64 1334 #define __NR_fadvise64_64 254 1336 #ifndef __NR_ioprio_set 1337 #define __NR_ioprio_set 273 1339 #ifndef __NR_ioprio_get 1340 #define __NR_ioprio_get 274 1343 #define __NR_openat 286 1345 #ifndef __NR_fstatat64 1346 #define __NR_fstatat64 291 1348 #ifndef __NR_unlinkat 1349 #define __NR_unlinkat 292 1351 #ifndef __NR_move_pages 1352 #define __NR_move_pages 301 1355 #define __NR_getcpu 302 1362 #if defined(__BOUNDED_POINTERS__) 1363 #error "Need to port invocations of syscalls for bounded ptrs" 1377 #define LSS_ERRNO SYS_ERRNO 1379 #define LSS_ERRNO errno 1384 #define LSS_INLINE SYS_INLINE 1386 #define LSS_INLINE static inline 1394 #define LSS_NAME(name) sys_##name 1395 #elif defined(SYS_PREFIX) && SYS_PREFIX < 0 1396 #define LSS_NAME(name) name 1397 #elif defined(SYS_PREFIX) && SYS_PREFIX == 0 1398 #define LSS_NAME(name) sys0_##name 1399 #elif defined(SYS_PREFIX) && SYS_PREFIX == 1 1400 #define LSS_NAME(name) sys1_##name 1401 #elif defined(SYS_PREFIX) && SYS_PREFIX == 2 1402 #define LSS_NAME(name) sys2_##name 1403 #elif defined(SYS_PREFIX) && SYS_PREFIX == 3 1404 #define LSS_NAME(name) sys3_##name 1405 #elif defined(SYS_PREFIX) && SYS_PREFIX == 4 1406 #define LSS_NAME(name) sys4_##name 1407 #elif defined(SYS_PREFIX) && SYS_PREFIX == 5 1408 #define LSS_NAME(name) sys5_##name 1409 #elif defined(SYS_PREFIX) && SYS_PREFIX == 6 1410 #define LSS_NAME(name) sys6_##name 1411 #elif defined(SYS_PREFIX) && SYS_PREFIX == 7 1412 #define LSS_NAME(name) sys7_##name 1413 #elif defined(SYS_PREFIX) && SYS_PREFIX == 8 1414 #define LSS_NAME(name) sys8_##name 1415 #elif defined(SYS_PREFIX) && SYS_PREFIX == 9 1416 #define LSS_NAME(name) sys9_##name 1420 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ 1421 || defined(__ARM_EABI__)) 1425 #define LSS_RETURN(type, res) \ 1427 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ 1428 LSS_ERRNO = -(res); \ 1431 return (type) (res); \ 1433 #elif defined(__mips__) 1437 #define LSS_RETURN(type, res, err) \ 1440 unsigned long __errnovalue = (res); \ 1441 LSS_ERRNO = __errnovalue; \ 1444 return (type) (res); \ 1446 #elif defined(__PPC__) 1450 #define LSS_RETURN(type, res, err) \ 1452 if (err & 0x10000000 ) { \ 1453 LSS_ERRNO = (res); \ 1456 return (type) (res); \ 1459 #if defined(__i386__) 1468 #undef LSS_ENTRYPOINT 1469 #ifdef SYS_SYSCALL_ENTRYPOINT 1470 static inline void (**LSS_NAME(get_syscall_entrypoint)(
void))(void) {
1471 void (**entrypoint)(void);
1472 asm volatile(
".bss\n" 1474 ".globl "SYS_SYSCALL_ENTRYPOINT
"\n" 1475 ".common "SYS_SYSCALL_ENTRYPOINT
",8,8\n" 1480 "add $_GLOBAL_OFFSET_TABLE_+[.-0b], %0\n" 1481 "mov "SYS_SYSCALL_ENTRYPOINT
"@GOT(%0), %0\n" 1482 :
"=r"(entrypoint));
1486 #define LSS_ENTRYPOINT ".bss\n" \ 1488 ".globl "SYS_SYSCALL_ENTRYPOINT"\n" \ 1489 ".common "SYS_SYSCALL_ENTRYPOINT",8,8\n" \ 1494 "10000:pop %%eax\n" \ 1495 "add $_GLOBAL_OFFSET_TABLE_+[.-10000b], %%eax\n" \ 1496 "mov "SYS_SYSCALL_ENTRYPOINT"@GOT(%%eax), %%eax\n"\ 1497 "mov 0(%%eax), %%eax\n" \ 1498 "test %%eax, %%eax\n" \ 1502 "10001:pop %%eax\n" \ 1503 "add $(10003f-10001b), %%eax\n" \ 1504 "xchg 4(%%esp), %%eax\n" \ 1506 "10002:pop %%eax\n" \ 1510 #define LSS_ENTRYPOINT "int $0x80\n" 1513 #define LSS_BODY(type,args...) \ 1515 __asm__ __volatile__("push %%ebx\n" \ 1520 : "esp", "memory"); \ 1521 LSS_RETURN(type,__res) 1523 #define _syscall0(type,name) \ 1524 type LSS_NAME(name)(void) { \ 1526 __asm__ volatile(LSS_ENTRYPOINT \ 1528 : "0" (__NR_##name) \ 1529 : "esp", "memory"); \ 1530 LSS_RETURN(type,__res); \ 1533 #define _syscall1(type,name,type1,arg1) \ 1534 type LSS_NAME(name)(type1 arg1) { \ 1537 : "0" (__NR_##name), "ri" ((long)(arg1))); \ 1540 #define _syscall2(type,name,type1,arg1,type2,arg2) \ 1541 type LSS_NAME(name)(type1 arg1,type2 arg2) { \ 1544 : "0" (__NR_##name),"ri" ((long)(arg1)), "c" ((long)(arg2))); \ 1547 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ 1548 type LSS_NAME(name)(type1 arg1,type2 arg2,type3 arg3) { \ 1551 : "0" (__NR_##name), "ri" ((long)(arg1)), "c" ((long)(arg2)), \ 1552 "d" ((long)(arg3))); \ 1555 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ 1556 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ 1559 : "0" (__NR_##name), "ri" ((long)(arg1)), "c" ((long)(arg2)), \ 1560 "d" ((long)(arg3)),"S" ((long)(arg4))); \ 1563 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1565 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1568 __asm__ __volatile__("push %%ebx\n" \ 1574 : "i" (__NR_##name), "ri" ((long)(arg1)), \ 1575 "c" ((long)(arg2)), "d" ((long)(arg3)), \ 1576 "S" ((long)(arg4)), "D" ((long)(arg5)) \ 1577 : "esp", "memory"); \ 1578 LSS_RETURN(type,__res); \ 1581 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1582 type5,arg5,type6,arg6) \ 1583 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1584 type5 arg5, type6 arg6) { \ 1586 struct { long __a1; long __a6; } __s = { (long)arg1, (long) arg6 }; \ 1587 __asm__ __volatile__("push %%ebp\n" \ 1589 "movl 4(%2),%%ebp\n" \ 1590 "movl 0(%2), %%ebx\n" \ 1596 : "i" (__NR_##name), "0" ((long)(&__s)), \ 1597 "c" ((long)(arg2)), "d" ((long)(arg3)), \ 1598 "S" ((long)(arg4)), "D" ((long)(arg5)) \ 1599 : "esp", "memory"); \ 1600 LSS_RETURN(type,__res); \ 1602 LSS_INLINE
int LSS_NAME(clone)(
int (*fn)(
void *),
void *child_stack,
1603 int flags,
void *arg,
int *parent_tidptr,
1604 void *newtls,
int *child_tidptr) {
1606 __asm__ __volatile__(
1628 "movl %%eax,4(%%ecx)\n" 1630 "movl %%eax,(%%ecx)\n" 1646 "movl %%eax,%%ebx\n" 1658 "test %%eax,%%eax\n" 1674 "movl %%eax,%%ebx\n" 1682 :
"0"(-EINVAL),
"i"(__NR_clone),
1683 "m"(fn),
"m"(child_stack),
"m"(flags),
"m"(arg),
1684 "m"(parent_tidptr),
"m"(newtls),
"m"(child_tidptr)
1685 :
"esp",
"memory",
"ecx",
"edx",
"esi",
"edi");
1686 LSS_RETURN(
int, __res);
1689 #define __NR__fadvise64_64 __NR_fadvise64_64 1690 LSS_INLINE _syscall6(
int, _fadvise64_64,
int, fd,
1691 unsigned, offset_lo,
unsigned, offset_hi,
1692 unsigned, len_lo,
unsigned, len_hi,
1695 LSS_INLINE
int LSS_NAME(fadvise64)(
int fd, loff_t offset,
1696 loff_t len,
int advice) {
1697 return LSS_NAME(_fadvise64_64)(fd,
1698 (
unsigned)offset, (
unsigned)(offset >>32),
1699 (
unsigned)len, (
unsigned)(len >> 32),
1703 #define __NR__fallocate __NR_fallocate 1704 LSS_INLINE _syscall6(
int, _fallocate,
int, fd,
1706 unsigned, offset_lo,
unsigned, offset_hi,
1707 unsigned, len_lo,
unsigned, len_hi)
1709 LSS_INLINE
int LSS_NAME(fallocate)(
int fd,
int mode,
1710 loff_t offset, loff_t len) {
1711 union { loff_t off;
unsigned w[2]; } o = { offset }, l = { len };
1712 return LSS_NAME(_fallocate)(fd, mode, o.w[0], o.w[1], l.w[0], l.w[1]);
1715 LSS_INLINE _syscall1(
int, set_thread_area,
void *, u)
1716 LSS_INLINE _syscall1(
int, get_thread_area,
void *, u)
1718 LSS_INLINE
void (*LSS_NAME(restore_rt)(
void))(
void) {
1726 __asm__ __volatile__(
"call 2f\n" 1731 "addl $(1b-0b),%0\n" 1733 :
"i" (__NR_rt_sigreturn));
1736 LSS_INLINE void (*LSS_NAME(restore)(
void))(void) {
1744 __asm__ __volatile__(
"call 2f\n" 1750 "addl $(1b-0b),%0\n" 1752 :
"i" (__NR_sigreturn));
1755 #elif defined(__x86_64__) 1762 #undef LSS_ENTRYPOINT 1763 #ifdef SYS_SYSCALL_ENTRYPOINT 1764 static inline void (**LSS_NAME(get_syscall_entrypoint)(
void))(void) {
1765 void (**entrypoint)(void);
1766 asm volatile(
".bss\n" 1768 ".globl "SYS_SYSCALL_ENTRYPOINT
"\n" 1769 ".common "SYS_SYSCALL_ENTRYPOINT
",8,8\n" 1771 "mov "SYS_SYSCALL_ENTRYPOINT
"@GOTPCREL(%%rip), %0\n" 1772 :
"=r"(entrypoint));
1776 #define LSS_ENTRYPOINT \ 1779 ".globl "SYS_SYSCALL_ENTRYPOINT"\n" \ 1780 ".common "SYS_SYSCALL_ENTRYPOINT",8,8\n" \ 1782 "mov "SYS_SYSCALL_ENTRYPOINT"@GOTPCREL(%%rip), %%rcx\n" \ 1783 "mov 0(%%rcx), %%rcx\n" \ 1784 "test %%rcx, %%rcx\n" \ 1792 #define LSS_ENTRYPOINT "syscall\n" 1795 #define LSS_BODY(type,name, ...) \ 1797 __asm__ __volatile__(LSS_ENTRYPOINT \ 1798 : "=a" (__res) : "0" (__NR_##name), \ 1799 ##__VA_ARGS__ : "r11", "rcx", "memory"); \ 1800 LSS_RETURN(type, __res) 1802 #define _syscall0(type,name) \ 1803 type LSS_NAME(name)() { \ 1804 LSS_BODY(type, name); \ 1807 #define _syscall1(type,name,type1,arg1) \ 1808 type LSS_NAME(name)(type1 arg1) { \ 1809 LSS_BODY(type, name, "D" ((long)(arg1))); \ 1812 #define _syscall2(type,name,type1,arg1,type2,arg2) \ 1813 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ 1814 LSS_BODY(type, name, "D" ((long)(arg1)), "S" ((long)(arg2))); \ 1817 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ 1818 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ 1819 LSS_BODY(type, name, "D" ((long)(arg1)), "S" ((long)(arg2)), \ 1820 "d" ((long)(arg3))); \ 1823 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ 1824 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ 1826 __asm__ __volatile__("movq %5,%%r10;" LSS_ENTRYPOINT : \ 1827 "=a" (__res) : "0" (__NR_##name), \ 1828 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ 1829 "r" ((long)(arg4)) : "r10", "r11", "rcx", "memory"); \ 1830 LSS_RETURN(type, __res); \ 1833 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1835 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1838 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8;" LSS_ENTRYPOINT :\ 1839 "=a" (__res) : "0" (__NR_##name), \ 1840 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ 1841 "r" ((long)(arg4)), "r" ((long)(arg5)) : \ 1842 "r8", "r10", "r11", "rcx", "memory"); \ 1843 LSS_RETURN(type, __res); \ 1846 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1847 type5,arg5,type6,arg6) \ 1848 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1849 type5 arg5, type6 arg6) { \ 1851 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; movq %7,%%r9;" \ 1853 "=a" (__res) : "0" (__NR_##name), \ 1854 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ 1855 "r" ((long)(arg4)), "r" ((long)(arg5)), "r" ((long)(arg6)) : \ 1856 "r8", "r9", "r10", "r11", "rcx", "memory"); \ 1857 LSS_RETURN(type, __res); \ 1859 LSS_INLINE
int LSS_NAME(clone)(int (*fn)(
void *),
void *child_stack,
1860 int flags,
void *arg,
int *parent_tidptr,
1861 void *newtls,
int *child_tidptr) {
1864 __asm__ __volatile__(
1901 "testq %%rax,%%rax\n" 1906 "xorq %%rbp,%%rbp\n" 1916 "movq %%rax,%%rdi\n" 1924 :
"0"(-EINVAL),
"i"(__NR_clone),
"i"(__NR_exit),
1925 "r"(fn),
"S"(child_stack),
"D"(flags),
"r"(arg),
1926 "d"(parent_tidptr),
"r"(newtls),
1928 :
"rsp",
"memory",
"r8",
"r10",
"r11",
"rcx");
1930 LSS_RETURN(
int, __res);
1932 LSS_INLINE _syscall2(
int, arch_prctl,
int, c,
void *, a)
1933 LSS_INLINE _syscall4(
int, fadvise64,
int, fd, loff_t, offset, loff_t, len,
1936 LSS_INLINE
void (*LSS_NAME(restore_rt)(
void))(
void) {
1944 __asm__ __volatile__(
"call 2f\n" 1949 "addq $(1b-0b),%0\n" 1951 :
"i" (__NR_rt_sigreturn));
1954 #elif defined(__ARM_ARCH_3__) 1961 #define LSS_REG(r,a) register long __r##r __asm__("r"#r) = (long)a 1963 #define LSS_BODY(type,name,args...) \ 1964 register long __res_r0 __asm__("r0"); \ 1966 __asm__ __volatile__ (__syscall(name) \ 1967 : "=r"(__res_r0) : args : "lr", "memory"); \ 1969 LSS_RETURN(type, __res) 1971 #define _syscall0(type, name) \ 1972 type LSS_NAME(name)() { \ 1973 LSS_BODY(type, name); \ 1976 #define _syscall1(type, name, type1, arg1) \ 1977 type LSS_NAME(name)(type1 arg1) { \ 1978 LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ 1981 #define _syscall2(type, name, type1, arg1, type2, arg2) \ 1982 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ 1983 LSS_REG(0, arg1); LSS_REG(1, arg2); \ 1984 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ 1987 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 1988 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ 1989 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ 1990 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ 1993 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ 1994 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ 1995 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ 1997 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ 2000 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 2002 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2004 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ 2005 LSS_REG(3, arg4); LSS_REG(4, arg5); \ 2006 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ 2010 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 2011 type5,arg5,type6,arg6) \ 2012 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2013 type5 arg5, type6 arg6) { \ 2014 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ 2015 LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ 2016 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ 2017 "r"(__r4), "r"(__r5)); \ 2019 LSS_INLINE
int LSS_NAME(clone)(int (*fn)(
void *),
void *child_stack,
2020 int flags,
void *arg,
int *parent_tidptr,
2021 void *newtls,
int *child_tidptr) {
2024 register int __flags __asm__(
"r0") = flags;
2025 register void *__stack __asm__(
"r1") = child_stack;
2026 register void *__ptid __asm__(
"r2") = parent_tidptr;
2027 register void *__tls __asm__(
"r3") = newtls;
2028 register int *__ctid __asm__(
"r4") = child_tidptr;
2029 __asm__ __volatile__(
2040 "str %5,[%3,#-4]!\n" 2041 "str %2,[%3,#-4]!\n" 2049 __syscall(clone)
"\n" 2069 "r"(fn),
"r"(__stack),
"r"(__flags),
"r"(arg),
2070 "r"(__ptid),
"r"(__tls),
"r"(__ctid)
2071 :
"cc",
"lr",
"memory");
2073 LSS_RETURN(
int, __res);
2075 #elif defined(__ARM_EABI__) 2082 #define LSS_REG(r,a) register long __r##r __asm__("r"#r) = (long)a 2084 #define LSS_BODY(type,name,args...) \ 2085 register long __res_r0 __asm__("r0"); \ 2087 __asm__ __volatile__ ("push {r7}\n" \ 2092 : "i"(__NR_##name) , ## args \ 2093 : "lr", "memory"); \ 2095 LSS_RETURN(type, __res) 2097 #define _syscall0(type, name) \ 2098 type LSS_NAME(name)() { \ 2099 LSS_BODY(type, name); \ 2102 #define _syscall1(type, name, type1, arg1) \ 2103 type LSS_NAME(name)(type1 arg1) { \ 2104 LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ 2107 #define _syscall2(type, name, type1, arg1, type2, arg2) \ 2108 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ 2109 LSS_REG(0, arg1); LSS_REG(1, arg2); \ 2110 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ 2113 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 2114 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ 2115 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ 2116 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ 2119 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ 2120 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ 2121 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ 2123 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ 2126 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 2128 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2130 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ 2131 LSS_REG(3, arg4); LSS_REG(4, arg5); \ 2132 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ 2136 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 2137 type5,arg5,type6,arg6) \ 2138 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2139 type5 arg5, type6 arg6) { \ 2140 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ 2141 LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ 2142 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ 2143 "r"(__r4), "r"(__r5)); \ 2145 LSS_INLINE
int LSS_NAME(clone)(int (*fn)(
void *),
void *child_stack,
2146 int flags,
void *arg,
int *parent_tidptr,
2147 void *newtls,
int *child_tidptr) {
2150 register int __flags __asm__(
"r0") = flags;
2151 register void *__stack __asm__(
"r1") = child_stack;
2152 register void *__ptid __asm__(
"r2") = parent_tidptr;
2153 register void *__tls __asm__(
"r3") = newtls;
2154 register int *__ctid __asm__(
"r4") = child_tidptr;
2155 __asm__ __volatile__(
2168 "str %5,[%3,#-4]!\n" 2169 "str %2,[%3,#-4]!\n" 2215 "r"(fn),
"r"(__stack),
"r"(__flags),
"r"(arg),
2216 "r"(__ptid),
"r"(__tls),
"r"(__ctid),
2217 "i"(__NR_clone),
"i"(__NR_exit)
2218 :
"cc",
"r7",
"lr",
"memory");
2220 LSS_RETURN(
int, __res);
2222 #elif defined(__mips__) 2224 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \ 2227 #define LSS_BODY(type,name,r7,...) \ 2228 register unsigned long __v0 __asm__("$2") = __NR_##name; \ 2229 __asm__ __volatile__ ("syscall\n" \ 2230 : "+r"(__v0), r7 (__r7) \ 2231 : "0"(__v0), ##__VA_ARGS__ \ 2232 : "$8", "$9", "$10", "$11", "$12", \ 2233 "$13", "$14", "$15", "$24", "$25", \ 2235 LSS_RETURN(type, __v0, __r7) 2237 #define _syscall0(type, name) \ 2238 type LSS_NAME(name)() { \ 2239 register unsigned long __r7 __asm__("$7"); \ 2240 LSS_BODY(type, name, "=r"); \ 2243 #define _syscall1(type, name, type1, arg1) \ 2244 type LSS_NAME(name)(type1 arg1) { \ 2245 register unsigned long __r7 __asm__("$7"); \ 2246 LSS_REG(4, arg1); LSS_BODY(type, name, "=r", "r"(__r4)); \ 2249 #define _syscall2(type, name, type1, arg1, type2, arg2) \ 2250 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ 2251 register unsigned long __r7 __asm__("$7"); \ 2252 LSS_REG(4, arg1); LSS_REG(5, arg2); \ 2253 LSS_BODY(type, name, "=r", "r"(__r4), "r"(__r5)); \ 2256 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 2257 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ 2258 register unsigned long __r7 __asm__("$7"); \ 2259 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ 2260 LSS_BODY(type, name, "=r", "r"(__r4), "r"(__r5), "r"(__r6)); \ 2263 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ 2264 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ 2265 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ 2267 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6)); \ 2270 #if _MIPS_SIM == _MIPS_SIM_ABI32 2274 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 2276 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2278 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ 2280 register unsigned long __v0 __asm__("$2") = __NR_##name; \ 2281 __asm__ __volatile__ (".set noreorder\n" \ 2283 "sw %5, 16($29)\n" \ 2287 : "+r"(__v0), "+r" (__r7) \ 2288 : "r"(__r4), "r"(__r5), \ 2289 "r"(__r6), "r" ((unsigned long)arg5) \ 2290 : "$8", "$9", "$10", "$11", "$12", \ 2291 "$13", "$14", "$15", "$24", "$25", \ 2293 LSS_RETURN(type, __v0, __r7); \ 2296 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 2298 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2300 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ 2301 LSS_REG(7, arg4); LSS_REG(8, arg5); \ 2302 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ 2307 #if _MIPS_SIM == _MIPS_SIM_ABI32 2311 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 2312 type5,arg5,type6,arg6) \ 2313 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2314 type5 arg5, type6 arg6) { \ 2315 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ 2317 register unsigned long __v0 __asm__("$2") = __NR_##name; \ 2318 __asm__ __volatile__ (".set noreorder\n" \ 2320 "sw %5, 16($29)\n" \ 2321 "sw %6, 20($29)\n" \ 2325 : "+r"(__v0), "+r" (__r7) \ 2326 : "r"(__r4), "r"(__r5), \ 2327 "r"(__r6), "r" ((unsigned long)arg5), \ 2328 "r" ((unsigned long)arg6) \ 2329 : "$8", "$9", "$10", "$11", "$12", \ 2330 "$13", "$14", "$15", "$24", "$25", \ 2332 LSS_RETURN(type, __v0, __r7); \ 2335 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 2336 type5,arg5,type6,arg6) \ 2337 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2338 type5 arg5,type6 arg6) { \ 2339 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ 2340 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \ 2341 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ 2342 "r"(__r8), "r"(__r9)); \ 2345 LSS_INLINE
int LSS_NAME(clone)(int (*fn)(
void *),
void *child_stack,
2346 int flags,
void *arg,
int *parent_tidptr,
2347 void *newtls,
int *child_tidptr) {
2348 register unsigned long __v0 __asm__(
"$2");
2349 register unsigned long __r7 __asm__(
"$7") = (
unsigned long)newtls;
2351 register int __flags __asm__(
"$4") = flags;
2352 register void *__stack __asm__(
"$5") = child_stack;
2353 register void *__ptid __asm__(
"$6") = parent_tidptr;
2354 register int *__ctid __asm__(
"$8") = child_tidptr;
2355 __asm__ __volatile__(
2356 #
if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32
2358 #elif _MIPS_SIM == _MIPS_SIM_NABI32
2374 #
if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32
2378 #elif _MIPS_SIM == _MIPS_SIM_NABI32
2405 #
if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32
2408 #elif _MIPS_SIM == _MIPS_SIM_NABI32
2424 #
if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32
2426 #elif _MIPS_SIM == _MIPS_SIM_NABI32
2431 :
"=&r" (__v0),
"+r" (__r7)
2432 :
"i"(-EINVAL),
"i"(__NR_clone),
"i"(__NR_exit),
2433 "r"(fn),
"r"(__stack),
"r"(__flags),
"r"(arg),
2434 "r"(__ptid),
"r"(__r7),
"r"(__ctid)
2435 :
"$9",
"$10",
"$11",
"$12",
"$13",
"$14",
"$15",
2436 "$24",
"$25",
"memory");
2438 LSS_RETURN(
int, __v0, __r7);
2440 #elif defined (__PPC__) 2441 #undef LSS_LOADARGS_0 2442 #define LSS_LOADARGS_0(name, dummy...) \ 2443 __sc_0 = __NR_##name 2444 #undef LSS_LOADARGS_1 2445 #define LSS_LOADARGS_1(name, arg1) \ 2446 LSS_LOADARGS_0(name); \ 2447 __sc_3 = (unsigned long) (arg1) 2448 #undef LSS_LOADARGS_2 2449 #define LSS_LOADARGS_2(name, arg1, arg2) \ 2450 LSS_LOADARGS_1(name, arg1); \ 2451 __sc_4 = (unsigned long) (arg2) 2452 #undef LSS_LOADARGS_3 2453 #define LSS_LOADARGS_3(name, arg1, arg2, arg3) \ 2454 LSS_LOADARGS_2(name, arg1, arg2); \ 2455 __sc_5 = (unsigned long) (arg3) 2456 #undef LSS_LOADARGS_4 2457 #define LSS_LOADARGS_4(name, arg1, arg2, arg3, arg4) \ 2458 LSS_LOADARGS_3(name, arg1, arg2, arg3); \ 2459 __sc_6 = (unsigned long) (arg4) 2460 #undef LSS_LOADARGS_5 2461 #define LSS_LOADARGS_5(name, arg1, arg2, arg3, arg4, arg5) \ 2462 LSS_LOADARGS_4(name, arg1, arg2, arg3, arg4); \ 2463 __sc_7 = (unsigned long) (arg5) 2464 #undef LSS_LOADARGS_6 2465 #define LSS_LOADARGS_6(name, arg1, arg2, arg3, arg4, arg5, arg6) \ 2466 LSS_LOADARGS_5(name, arg1, arg2, arg3, arg4, arg5); \ 2467 __sc_8 = (unsigned long) (arg6) 2468 #undef LSS_ASMINPUT_0 2469 #define LSS_ASMINPUT_0 "0" (__sc_0) 2470 #undef LSS_ASMINPUT_1 2471 #define LSS_ASMINPUT_1 LSS_ASMINPUT_0, "1" (__sc_3) 2472 #undef LSS_ASMINPUT_2 2473 #define LSS_ASMINPUT_2 LSS_ASMINPUT_1, "2" (__sc_4) 2474 #undef LSS_ASMINPUT_3 2475 #define LSS_ASMINPUT_3 LSS_ASMINPUT_2, "3" (__sc_5) 2476 #undef LSS_ASMINPUT_4 2477 #define LSS_ASMINPUT_4 LSS_ASMINPUT_3, "4" (__sc_6) 2478 #undef LSS_ASMINPUT_5 2479 #define LSS_ASMINPUT_5 LSS_ASMINPUT_4, "5" (__sc_7) 2480 #undef LSS_ASMINPUT_6 2481 #define LSS_ASMINPUT_6 LSS_ASMINPUT_5, "6" (__sc_8) 2483 #define LSS_BODY(nr, type, name, args...) \ 2484 long __sc_ret, __sc_err; \ 2486 register unsigned long __sc_0 __asm__ ("r0"); \ 2487 register unsigned long __sc_3 __asm__ ("r3"); \ 2488 register unsigned long __sc_4 __asm__ ("r4"); \ 2489 register unsigned long __sc_5 __asm__ ("r5"); \ 2490 register unsigned long __sc_6 __asm__ ("r6"); \ 2491 register unsigned long __sc_7 __asm__ ("r7"); \ 2492 register unsigned long __sc_8 __asm__ ("r8"); \ 2494 LSS_LOADARGS_##nr(name, args); \ 2495 __asm__ __volatile__ \ 2499 "=&r" (__sc_3), "=&r" (__sc_4), \ 2500 "=&r" (__sc_5), "=&r" (__sc_6), \ 2501 "=&r" (__sc_7), "=&r" (__sc_8) \ 2502 : LSS_ASMINPUT_##nr \ 2503 : "cr0", "ctr", "memory", \ 2504 "r9", "r10", "r11", "r12"); \ 2505 __sc_ret = __sc_3; \ 2506 __sc_err = __sc_0; \ 2508 LSS_RETURN(type, __sc_ret, __sc_err) 2510 #define _syscall0(type, name) \ 2511 type LSS_NAME(name)(void) { \ 2512 LSS_BODY(0, type, name); \ 2515 #define _syscall1(type, name, type1, arg1) \ 2516 type LSS_NAME(name)(type1 arg1) { \ 2517 LSS_BODY(1, type, name, arg1); \ 2520 #define _syscall2(type, name, type1, arg1, type2, arg2) \ 2521 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ 2522 LSS_BODY(2, type, name, arg1, arg2); \ 2525 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 2526 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ 2527 LSS_BODY(3, type, name, arg1, arg2, arg3); \ 2530 #define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ 2532 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ 2533 LSS_BODY(4, type, name, arg1, arg2, arg3, arg4); \ 2536 #define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ 2537 type4, arg4, type5, arg5) \ 2538 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2540 LSS_BODY(5, type, name, arg1, arg2, arg3, arg4, arg5); \ 2543 #define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ 2544 type4, arg4, type5, arg5, type6, arg6) \ 2545 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 2546 type5 arg5, type6 arg6) { \ 2547 LSS_BODY(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6); \ 2553 LSS_INLINE
int LSS_NAME(clone)(int (*fn)(
void *),
void *child_stack,
2554 int flags,
void *arg,
int *parent_tidptr,
2555 void *newtls,
int *child_tidptr) {
2558 register int (*__fn)(
void *) __asm__ (
"r8") = fn;
2559 register void *__cstack __asm__ (
"r4") = child_stack;
2560 register int __flags __asm__ (
"r3") = flags;
2561 register void * __arg __asm__ (
"r9") = arg;
2562 register int * __ptidptr __asm__ (
"r5") = parent_tidptr;
2563 register void * __newtls __asm__ (
"r6") = newtls;
2564 register int * __ctidptr __asm__ (
"r7") = child_tidptr;
2565 __asm__ __volatile__(
2569 "cmpwi cr0, %6, 0\n\t" 2570 "cmpwi cr1, %7, 0\n\t" 2571 "cror cr0*4+eq, cr1*4+eq, cr0*4+eq\n\t" 2575 "clrrwi %7, %7, 4\n\t" 2577 "stwu 0, -16(%7)\n\t" 2595 "cmpwi cr1, 3, 0\n\t" 2596 "crandc cr1*4+eq, cr1*4+eq, cr0*4+so\n\t" 2612 :
"=r" (__ret),
"=r" (__err)
2613 :
"0" (-1),
"1" (EINVAL),
2614 "i" (__NR_clone),
"i" (__NR_exit),
2615 "r" (__fn),
"r" (__cstack),
"r" (__flags),
2616 "r" (__arg),
"r" (__ptidptr),
"r" (__newtls),
2618 :
"cr0",
"cr1",
"memory",
"ctr",
2619 "r0",
"r29",
"r27",
"r28");
2621 LSS_RETURN(
int, __ret, __err);
2624 #define __NR__exit __NR_exit 2625 #define __NR__gettid __NR_gettid 2626 #define __NR__mremap __NR_mremap 2627 LSS_INLINE _syscall1(
int, brk,
void *, e)
2628 LSS_INLINE _syscall1(
int, chdir, const
char *,p)
2629 LSS_INLINE _syscall1(
int, close,
int, f)
2630 LSS_INLINE _syscall2(
int, clock_getres,
int, c,
2631 struct kernel_timespec*, t)
2632 LSS_INLINE _syscall2(
int, clock_gettime,
int, c,
2633 struct kernel_timespec*, t)
2634 LSS_INLINE _syscall1(
int, dup,
int, f)
2635 LSS_INLINE _syscall2(
int, dup2,
int, s,
2637 LSS_INLINE _syscall3(
int, execve, const
char*, f,
2638 const
char*const*,a,const
char*const*, e)
2639 LSS_INLINE _syscall1(
int, _exit,
int, e)
2640 LSS_INLINE _syscall1(
int, exit_group,
int, e)
2641 LSS_INLINE _syscall3(
int, fcntl,
int, f,
2643 LSS_INLINE _syscall0(pid_t, fork)
2644 LSS_INLINE _syscall2(
int, fstat,
int, f,
2645 struct kernel_stat*, b)
2646 LSS_INLINE _syscall2(
int, fstatfs,
int, f,
2647 struct kernel_statfs*, b)
2648 LSS_INLINE _syscall2(
int, ftruncate,
int, f,
2650 LSS_INLINE _syscall4(
int, futex,
int*, a,
2652 struct kernel_timespec*, t)
2653 LSS_INLINE _syscall3(
int, getdents,
int, f,
2654 struct kernel_dirent*, d,
int, c)
2655 LSS_INLINE _syscall3(
int, getdents64,
int, f,
2656 struct kernel_dirent64*, d,
int, c)
2657 LSS_INLINE _syscall0(gid_t, getegid)
2658 LSS_INLINE _syscall0(uid_t, geteuid)
2659 LSS_INLINE _syscall0(pid_t, getpgrp)
2660 LSS_INLINE _syscall0(pid_t, getpid)
2661 LSS_INLINE _syscall0(pid_t, getppid)
2662 LSS_INLINE _syscall2(
int, getpriority,
int, a,
2664 LSS_INLINE _syscall3(
int, getresgid, gid_t *, r,
2665 gid_t *, e, gid_t *, s)
2666 LSS_INLINE _syscall3(
int, getresuid, uid_t *, r,
2667 uid_t *, e, uid_t *, s)
2668 #if !defined(__ARM_EABI__) 2669 LSS_INLINE _syscall2(
int, getrlimit,
int, r,
2670 struct kernel_rlimit*, l)
2672 LSS_INLINE _syscall1(pid_t, getsid, pid_t, p)
2673 LSS_INLINE _syscall0(pid_t, _gettid)
2674 LSS_INLINE _syscall2(pid_t, gettimeofday, struct kernel_timeval*, t,
2676 LSS_INLINE _syscall5(
int, setxattr, const
char *,p,
2677 const
char *, n, const
void *,v,
2679 LSS_INLINE _syscall5(
int, lsetxattr, const
char *,p,
2680 const
char *, n, const
void *,v,
2682 LSS_INLINE _syscall4(ssize_t, getxattr, const
char *,p,
2683 const
char *, n,
void *, v,
size_t, s)
2684 LSS_INLINE _syscall4(ssize_t, lgetxattr, const
char *,p,
2685 const
char *, n,
void *, v,
size_t, s)
2686 LSS_INLINE _syscall3(ssize_t, listxattr, const
char *,p,
2687 char *, l,
size_t, s)
2688 LSS_INLINE _syscall3(ssize_t, llistxattr, const
char *,p,
2689 char *, l,
size_t, s)
2690 LSS_INLINE _syscall3(
int, ioctl,
int, d,
2692 LSS_INLINE _syscall2(
int, ioprio_get,
int, which,
2694 LSS_INLINE _syscall3(
int, ioprio_set,
int, which,
2695 int, who,
int, ioprio)
2696 LSS_INLINE _syscall2(
int, kill, pid_t, p,
2698 LSS_INLINE _syscall3(off_t, lseek,
int, f,
2700 LSS_INLINE _syscall2(
int, munmap,
void*, s,
2702 LSS_INLINE _syscall6(
long, move_pages, pid_t, p,
2703 unsigned long, n,
void **,g,
int *, d,
2705 LSS_INLINE _syscall3(
int, mprotect, const
void *,a,
2707 LSS_INLINE _syscall5(
void*, _mremap,
void*, o,
2708 size_t, os,
size_t, ns,
2709 unsigned long, f,
void *, a)
2710 LSS_INLINE _syscall3(
int, open, const
char*, p,
2712 LSS_INLINE _syscall3(
int, poll, struct kernel_pollfd*, u,
2713 unsigned int, n,
int, t)
2714 LSS_INLINE _syscall2(
int, prctl,
int, o,
2716 LSS_INLINE _syscall4(
long, ptrace,
int, r,
2717 pid_t, p,
void *, a,
void *, d)
2718 #if defined(__NR_quotactl) 2720 LSS_INLINE _syscall4(
int, quotactl,
int, cmd,
const char *, special,
2721 int,
id, caddr_t, addr)
2723 LSS_INLINE _syscall3(ssize_t, read,
int, f,
2724 void *, b,
size_t, c)
2725 LSS_INLINE _syscall3(
int, readlink, const
char*, p,
2726 char*, b,
size_t, s)
2727 LSS_INLINE _syscall4(
int, rt_sigaction,
int, s,
2728 const struct kernel_sigaction*, a,
2729 struct kernel_sigaction*, o,
size_t, c)
2730 LSS_INLINE _syscall2(
int, rt_sigpending, struct kernel_sigset_t *, s,
2732 LSS_INLINE _syscall4(
int, rt_sigprocmask,
int, h,
2733 const struct kernel_sigset_t*, s,
2734 struct kernel_sigset_t*, o,
size_t, c)
2735 LSS_INLINE _syscall2(
int, rt_sigsuspend,
2736 const struct kernel_sigset_t*, s,
size_t, c)
2737 LSS_INLINE _syscall3(
int, sched_getaffinity,pid_t, p,
2738 unsigned int, l,
unsigned long *, m)
2739 LSS_INLINE _syscall3(
int, sched_setaffinity,pid_t, p,
2740 unsigned int, l,
unsigned long *, m)
2741 LSS_INLINE _syscall0(
int, sched_yield)
2742 LSS_INLINE _syscall1(
long, set_tid_address,
int *, t)
2743 LSS_INLINE _syscall1(
int, setfsgid, gid_t, g)
2744 LSS_INLINE _syscall1(
int, setfsuid, uid_t, u)
2745 LSS_INLINE _syscall1(
int, setuid, uid_t, u)
2746 LSS_INLINE _syscall1(
int, setgid, gid_t, g)
2747 LSS_INLINE _syscall2(
int, setpgid, pid_t, p,
2749 LSS_INLINE _syscall3(
int, setpriority,
int, a,
2751 LSS_INLINE _syscall3(
int, setresgid, gid_t, r,
2753 LSS_INLINE _syscall3(
int, setresuid, uid_t, r,
2755 LSS_INLINE _syscall2(
int, setrlimit,
int, r,
2756 const struct kernel_rlimit*, l)
2757 LSS_INLINE _syscall0(pid_t, setsid)
2758 LSS_INLINE _syscall2(
int, sigaltstack, const stack_t*, s,
2760 #if defined(__NR_sigreturn) 2761 LSS_INLINE _syscall1(
int, sigreturn,
unsigned long, u)
2763 LSS_INLINE _syscall2(
int, stat,
const char*, f,
2764 struct kernel_stat*, b)
2765 LSS_INLINE _syscall2(
int, statfs, const
char*, f,
2766 struct kernel_statfs*, b)
2767 LSS_INLINE _syscall3(
int, tgkill, pid_t, p,
2769 LSS_INLINE _syscall2(
int, tkill, pid_t, p,
2771 LSS_INLINE _syscall1(
int, unlink, const
char*, f)
2772 LSS_INLINE _syscall3(ssize_t,
write,
int, f,
2773 const
void *, b,
size_t, c)
2774 LSS_INLINE _syscall3(ssize_t, writev,
int, f,
2775 const struct kernel_iovec*, v,
size_t, c)
2776 #if defined(__NR_getcpu) 2777 LSS_INLINE _syscall3(
long, getcpu,
unsigned *, cpu,
2778 unsigned *, node,
void *, unused)
2780 #if defined(__x86_64__) || \ 2781 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) 2782 LSS_INLINE _syscall3(
int, recvmsg,
int, s,
2783 struct kernel_msghdr*, m,
int, f)
2784 LSS_INLINE _syscall3(
int, sendmsg,
int, s,
2785 const struct kernel_msghdr*, m,
int, f)
2786 LSS_INLINE _syscall6(
int, sendto,
int, s,
2787 const
void*, m,
size_t, l,
2789 const struct kernel_sockaddr*, a,
int, t)
2790 LSS_INLINE _syscall2(
int, shutdown,
int, s,
2792 LSS_INLINE _syscall3(
int, socket,
int, d,
2794 LSS_INLINE _syscall4(
int, socketpair,
int, d,
2795 int, t,
int, p,
int*, s)
2797 #if defined(__x86_64__) 2798 LSS_INLINE _syscall4(
int, fallocate,
int, fd,
int, mode,
2799 loff_t, offset, loff_t, len)
2801 LSS_INLINE
int LSS_NAME(getresgid32)(gid_t *rgid,
2804 return LSS_NAME(getresgid)(rgid, egid, sgid);
2807 LSS_INLINE
int LSS_NAME(getresuid32)(uid_t *ruid,
2810 return LSS_NAME(getresuid)(ruid, euid, suid);
2813 LSS_INLINE _syscall6(
void*, mmap,
void*, s,
2818 LSS_INLINE _syscall4(
int, newfstatat,
int, d,
2820 struct kernel_stat*, b,
int, f)
2822 LSS_INLINE
int LSS_NAME(setfsgid32)(gid_t gid) {
2823 return LSS_NAME(setfsgid)(gid);
2826 LSS_INLINE
int LSS_NAME(setfsuid32)(uid_t uid) {
2827 return LSS_NAME(setfsuid)(uid);
2830 LSS_INLINE
int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) {
2831 return LSS_NAME(setresgid)(rgid, egid, sgid);
2834 LSS_INLINE
int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) {
2835 return LSS_NAME(setresuid)(ruid, euid, suid);
2838 LSS_INLINE
int LSS_NAME(sigaction)(
int signum,
2839 const struct kernel_sigaction *act,
2840 struct kernel_sigaction *oldact) {
2846 if (act != NULL && !(act->sa_flags & SA_RESTORER)) {
2847 struct kernel_sigaction a = *act;
2848 a.sa_flags |= SA_RESTORER;
2849 a.sa_restorer = LSS_NAME(restore_rt)();
2850 return LSS_NAME(rt_sigaction)(signum, &a, oldact,
2853 return LSS_NAME(rt_sigaction)(signum, act, oldact,
2858 LSS_INLINE
int LSS_NAME(sigpending)(
struct kernel_sigset_t *
set) {
2859 return LSS_NAME(rt_sigpending)(
set, (KERNEL_NSIG+7)/8);
2862 LSS_INLINE
int LSS_NAME(sigprocmask)(
int how,
2863 const struct kernel_sigset_t *
set,
2864 struct kernel_sigset_t *oldset) {
2865 return LSS_NAME(rt_sigprocmask)(how,
set, oldset, (KERNEL_NSIG+7)/8);
2868 LSS_INLINE
int LSS_NAME(sigsuspend)(
const struct kernel_sigset_t *
set) {
2869 return LSS_NAME(rt_sigsuspend)(
set, (KERNEL_NSIG+7)/8);
2872 #if defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ 2873 defined(__ARM_EABI__) || \ 2874 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) 2875 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p,
2877 struct kernel_rusage*, r)
2879 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid,
int *status,
int options){
2880 return LSS_NAME(wait4)(pid, status, options, 0);
2883 #if defined(__i386__) || defined(__x86_64__) 2884 LSS_INLINE _syscall4(
int, openat,
int, d,
const char *, p,
int, f,
int, m)
2885 LSS_INLINE _syscall3(
int, unlinkat,
int, d, const
char *, p,
int, f)
2887 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) 2888 #define __NR__getresgid32 __NR_getresgid32 2889 #define __NR__getresuid32 __NR_getresuid32 2890 #define __NR__setfsgid32 __NR_setfsgid32 2891 #define __NR__setfsuid32 __NR_setfsuid32 2892 #define __NR__setresgid32 __NR_setresgid32 2893 #define __NR__setresuid32 __NR_setresuid32 2894 #if defined(__ARM_EABI__) 2895 LSS_INLINE _syscall2(
int, ugetrlimit,
int, r,
2896 struct kernel_rlimit*, l)
2898 LSS_INLINE _syscall3(
int, _getresgid32, gid_t *, r,
2899 gid_t *, e, gid_t *, s)
2900 LSS_INLINE _syscall3(
int, _getresuid32, uid_t *, r,
2901 uid_t *, e, uid_t *, s)
2902 LSS_INLINE _syscall1(
int, _setfsgid32, gid_t, f)
2903 LSS_INLINE _syscall1(
int, _setfsuid32, uid_t, f)
2904 LSS_INLINE _syscall3(
int, _setresgid32, gid_t, r,
2906 LSS_INLINE _syscall3(
int, _setresuid32, uid_t, r,
2909 LSS_INLINE
int LSS_NAME(getresgid32)(gid_t *rgid,
2913 if ((rc = LSS_NAME(_getresgid32)(rgid, egid, sgid)) < 0 &&
2914 LSS_ERRNO == ENOSYS) {
2915 if ((rgid == NULL) || (egid == NULL) || (sgid == NULL)) {
2919 *rgid = *egid = *sgid = 0;
2920 rc = LSS_NAME(getresgid)(rgid, egid, sgid);
2925 LSS_INLINE
int LSS_NAME(getresuid32)(uid_t *ruid,
2929 if ((rc = LSS_NAME(_getresuid32)(ruid, euid, suid)) < 0 &&
2930 LSS_ERRNO == ENOSYS) {
2931 if ((ruid == NULL) || (euid == NULL) || (suid == NULL)) {
2935 *ruid = *euid = *suid = 0;
2936 rc = LSS_NAME(getresuid)(ruid, euid, suid);
2941 LSS_INLINE
int LSS_NAME(setfsgid32)(gid_t gid) {
2943 if ((rc = LSS_NAME(_setfsgid32)(gid)) < 0 &&
2944 LSS_ERRNO == ENOSYS) {
2945 if ((
unsigned int)gid & ~0xFFFFu) {
2948 rc = LSS_NAME(setfsgid)(gid);
2954 LSS_INLINE
int LSS_NAME(setfsuid32)(uid_t uid) {
2956 if ((rc = LSS_NAME(_setfsuid32)(uid)) < 0 &&
2957 LSS_ERRNO == ENOSYS) {
2958 if ((
unsigned int)uid & ~0xFFFFu) {
2961 rc = LSS_NAME(setfsuid)(uid);
2967 LSS_INLINE
int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) {
2969 if ((rc = LSS_NAME(_setresgid32)(rgid, egid, sgid)) < 0 &&
2970 LSS_ERRNO == ENOSYS) {
2971 if ((
unsigned int)rgid & ~0xFFFFu ||
2972 (
unsigned int)egid & ~0xFFFFu ||
2973 (
unsigned int)sgid & ~0xFFFFu) {
2976 rc = LSS_NAME(setresgid)(rgid, egid, sgid);
2982 LSS_INLINE
int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) {
2984 if ((rc = LSS_NAME(_setresuid32)(ruid, euid, suid)) < 0 &&
2985 LSS_ERRNO == ENOSYS) {
2986 if ((
unsigned int)ruid & ~0xFFFFu ||
2987 (
unsigned int)euid & ~0xFFFFu ||
2988 (
unsigned int)suid & ~0xFFFFu) {
2991 rc = LSS_NAME(setresuid)(ruid, euid, suid);
2997 LSS_INLINE
int LSS_NAME(sigemptyset)(
struct kernel_sigset_t *
set) {
2998 memset(&set->sig, 0,
sizeof(set->sig));
3002 LSS_INLINE
int LSS_NAME(sigfillset)(
struct kernel_sigset_t *
set) {
3003 memset(&set->sig, -1,
sizeof(set->sig));
3007 LSS_INLINE
int LSS_NAME(sigaddset)(
struct kernel_sigset_t *
set,
3009 if (signum < 1 || signum > (
int)(8*
sizeof(
set->sig))) {
3013 set->sig[(signum - 1)/(8*
sizeof(set->sig[0]))]
3014 |= 1UL << ((signum - 1) % (8*
sizeof(
set->sig[0])));
3019 LSS_INLINE
int LSS_NAME(sigdelset)(
struct kernel_sigset_t *
set,
3021 if (signum < 1 || signum > (
int)(8*
sizeof(
set->sig))) {
3025 set->sig[(signum - 1)/(8*
sizeof(set->sig[0]))]
3026 &= ~(1UL << ((signum - 1) % (8*
sizeof(
set->sig[0]))));
3031 LSS_INLINE
int LSS_NAME(sigismember)(
struct kernel_sigset_t *
set,
3033 if (signum < 1 || signum > (
int)(8*
sizeof(
set->sig))) {
3037 return !!(
set->sig[(signum - 1)/(8*
sizeof(set->sig[0]))] &
3038 (1UL << ((signum - 1) % (8*
sizeof(
set->sig[0])))));
3041 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ 3042 defined(__ARM_EABI__) || \ 3043 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) 3044 #define __NR__sigaction __NR_sigaction 3045 #define __NR__sigpending __NR_sigpending 3046 #define __NR__sigprocmask __NR_sigprocmask 3047 #define __NR__sigsuspend __NR_sigsuspend 3048 #define __NR__socketcall __NR_socketcall 3049 LSS_INLINE _syscall2(
int, fstat64,
int, f,
3050 struct kernel_stat64 *, b)
3051 LSS_INLINE _syscall5(
int, _llseek, uint, fd,
3052 unsigned long, hi,
unsigned long, lo,
3053 loff_t *, res, uint, wh)
3054 #if !defined(__ARM_EABI__) 3055 LSS_INLINE _syscall1(
void*, mmap,
void*, a)
3057 LSS_INLINE _syscall6(
void*, mmap2,
void*, s,
3061 LSS_INLINE _syscall3(
int, _sigaction,
int, s,
3062 const struct kernel_old_sigaction*, a,
3063 struct kernel_old_sigaction*, o)
3064 LSS_INLINE _syscall1(
int, _sigpending,
unsigned long*, s)
3065 LSS_INLINE _syscall3(
int, _sigprocmask,
int, h,
3066 const
unsigned long*, s,
3069 LSS_INLINE _syscall1(
int, _sigsuspend,
unsigned long, s)
3071 LSS_INLINE _syscall3(
int, _sigsuspend,
const void*, a,
3075 LSS_INLINE _syscall2(
int, stat64,
const char *, p,
3076 struct kernel_stat64 *, b)
3078 LSS_INLINE
int LSS_NAME(sigaction)(
int signum,
3079 const struct kernel_sigaction *act,
3080 struct kernel_sigaction *oldact) {
3081 int old_errno = LSS_ERRNO;
3083 struct kernel_sigaction a;
3097 if (!(a.sa_flags & SA_RESTORER)) {
3098 a.sa_flags |= SA_RESTORER;
3099 a.sa_restorer = (a.sa_flags & SA_SIGINFO)
3100 ? LSS_NAME(restore_rt)() : LSS_NAME(restore)();
3104 rc = LSS_NAME(rt_sigaction)(signum, act ? &a : act, oldact,
3106 if (rc < 0 && LSS_ERRNO == ENOSYS) {
3107 struct kernel_old_sigaction oa, ooa, *ptr_a = &oa, *ptr_oa = &ooa;
3111 oa.sa_handler_ = act->sa_handler_;
3112 memcpy(&oa.sa_mask, &act->sa_mask,
sizeof(oa.sa_mask));
3114 oa.sa_restorer = act->sa_restorer;
3116 oa.sa_flags = act->sa_flags;
3121 LSS_ERRNO = old_errno;
3122 rc = LSS_NAME(_sigaction)(signum, ptr_a, ptr_oa);
3123 if (rc == 0 && oldact) {
3125 memcpy(oldact, act,
sizeof(*act));
3127 memset(oldact, 0,
sizeof(*oldact));
3129 oldact->sa_handler_ = ptr_oa->sa_handler_;
3130 oldact->sa_flags = ptr_oa->sa_flags;
3131 memcpy(&oldact->sa_mask, &ptr_oa->sa_mask,
sizeof(ptr_oa->sa_mask));
3133 oldact->sa_restorer = ptr_oa->sa_restorer;
3140 LSS_INLINE
int LSS_NAME(sigpending)(
struct kernel_sigset_t *
set) {
3141 int old_errno = LSS_ERRNO;
3142 int rc = LSS_NAME(rt_sigpending)(
set, (KERNEL_NSIG+7)/8);
3143 if (rc < 0 && LSS_ERRNO == ENOSYS) {
3144 LSS_ERRNO = old_errno;
3145 LSS_NAME(sigemptyset)(
set);
3146 rc = LSS_NAME(_sigpending)(&
set->sig[0]);
3151 LSS_INLINE
int LSS_NAME(sigprocmask)(
int how,
3152 const struct kernel_sigset_t *
set,
3153 struct kernel_sigset_t *oldset) {
3154 int olderrno = LSS_ERRNO;
3155 int rc = LSS_NAME(rt_sigprocmask)(how,
set, oldset, (KERNEL_NSIG+7)/8);
3156 if (rc < 0 && LSS_ERRNO == ENOSYS) {
3157 LSS_ERRNO = olderrno;
3159 LSS_NAME(sigemptyset)(oldset);
3161 rc = LSS_NAME(_sigprocmask)(how,
3162 set ? &
set->sig[0] : NULL,
3163 oldset ? &oldset->sig[0] : NULL);
3168 LSS_INLINE
int LSS_NAME(sigsuspend)(
const struct kernel_sigset_t *
set) {
3169 int olderrno = LSS_ERRNO;
3170 int rc = LSS_NAME(rt_sigsuspend)(
set, (KERNEL_NSIG+7)/8);
3171 if (rc < 0 && LSS_ERRNO == ENOSYS) {
3172 LSS_ERRNO = olderrno;
3173 rc = LSS_NAME(_sigsuspend)(
3182 #if defined(__PPC__) 3183 #undef LSS_SC_LOADARGS_0 3184 #define LSS_SC_LOADARGS_0(dummy...) 3185 #undef LSS_SC_LOADARGS_1 3186 #define LSS_SC_LOADARGS_1(arg1) \ 3187 __sc_4 = (unsigned long) (arg1) 3188 #undef LSS_SC_LOADARGS_2 3189 #define LSS_SC_LOADARGS_2(arg1, arg2) \ 3190 LSS_SC_LOADARGS_1(arg1); \ 3191 __sc_5 = (unsigned long) (arg2) 3192 #undef LSS_SC_LOADARGS_3 3193 #define LSS_SC_LOADARGS_3(arg1, arg2, arg3) \ 3194 LSS_SC_LOADARGS_2(arg1, arg2); \ 3195 __sc_6 = (unsigned long) (arg3) 3196 #undef LSS_SC_LOADARGS_4 3197 #define LSS_SC_LOADARGS_4(arg1, arg2, arg3, arg4) \ 3198 LSS_SC_LOADARGS_3(arg1, arg2, arg3); \ 3199 __sc_7 = (unsigned long) (arg4) 3200 #undef LSS_SC_LOADARGS_5 3201 #define LSS_SC_LOADARGS_5(arg1, arg2, arg3, arg4, arg5) \ 3202 LSS_SC_LOADARGS_4(arg1, arg2, arg3, arg4); \ 3203 __sc_8 = (unsigned long) (arg5) 3205 #define LSS_SC_BODY(nr, type, opt, args...) \ 3206 long __sc_ret, __sc_err; \ 3208 register unsigned long __sc_0 __asm__ ("r0") = __NR_socketcall; \ 3209 register unsigned long __sc_3 __asm__ ("r3") = opt; \ 3210 register unsigned long __sc_4 __asm__ ("r4"); \ 3211 register unsigned long __sc_5 __asm__ ("r5"); \ 3212 register unsigned long __sc_6 __asm__ ("r6"); \ 3213 register unsigned long __sc_7 __asm__ ("r7"); \ 3214 register unsigned long __sc_8 __asm__ ("r8"); \ 3215 LSS_SC_LOADARGS_##nr(args); \ 3216 __asm__ __volatile__ \ 3217 ("stwu 1, -48(1)\n\t" \ 3218 "stw 4, 20(1)\n\t" \ 3219 "stw 5, 24(1)\n\t" \ 3220 "stw 6, 28(1)\n\t" \ 3221 "stw 7, 32(1)\n\t" \ 3222 "stw 8, 36(1)\n\t" \ 3223 "addi 4, 1, 20\n\t" \ 3227 "=&r" (__sc_3), "=&r" (__sc_4), \ 3228 "=&r" (__sc_5), "=&r" (__sc_6), \ 3229 "=&r" (__sc_7), "=&r" (__sc_8) \ 3230 : LSS_ASMINPUT_##nr \ 3231 : "cr0", "ctr", "memory"); \ 3232 __sc_ret = __sc_3; \ 3233 __sc_err = __sc_0; \ 3235 LSS_RETURN(type, __sc_ret, __sc_err) 3237 LSS_INLINE ssize_t LSS_NAME(recvmsg)(
int s,
struct kernel_msghdr *msg,
3239 LSS_SC_BODY(3, ssize_t, 17, s, msg, flags);
3242 LSS_INLINE ssize_t LSS_NAME(sendmsg)(
int s,
3243 const struct kernel_msghdr *msg,
3245 LSS_SC_BODY(3, ssize_t, 16, s, msg, flags);
3250 LSS_INLINE ssize_t LSS_NAME(sendto)(
int s,
const void *buf,
size_t len,
3252 const struct kernel_sockaddr *to,
3253 unsigned int tolen) {
3254 LSS_BODY(6, ssize_t, 11, s, buf, len, flags, to, tolen);
3258 LSS_INLINE
int LSS_NAME(shutdown)(
int s,
int how) {
3259 LSS_SC_BODY(2,
int, 13, s, how);
3262 LSS_INLINE
int LSS_NAME(socket)(
int domain,
int type,
int protocol) {
3263 LSS_SC_BODY(3,
int, 1, domain, type, protocol);
3266 LSS_INLINE
int LSS_NAME(socketpair)(
int d,
int type,
int protocol,
3268 LSS_SC_BODY(4,
int, 8, d, type, protocol, sv);
3271 #if defined(__ARM_EABI__) 3272 LSS_INLINE _syscall3(ssize_t, recvmsg,
int, s,
struct kernel_msghdr*, msg,
3274 LSS_INLINE _syscall3(ssize_t, sendmsg,
int, s, const struct kernel_msghdr*,
3276 LSS_INLINE _syscall6(ssize_t, sendto,
int, s, const
void*, buf,
size_t,len,
3277 int, flags, const struct kernel_sockaddr*, to,
3278 unsigned int, tolen)
3279 LSS_INLINE _syscall2(
int, shutdown,
int, s,
int, how)
3280 LSS_INLINE _syscall3(
int, socket,
int, domain,
int, type,
int, protocol)
3281 LSS_INLINE _syscall4(
int, socketpair,
int, d,
int, type,
int, protocol,
3284 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ 3285 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) 3286 #define __NR__socketcall __NR_socketcall 3287 LSS_INLINE _syscall2(
int, _socketcall,
int, c,
3289 LSS_INLINE
int LSS_NAME(socketcall)(
int op, ...) {
3293 rc = LSS_NAME(_socketcall)(op, ap);
3298 LSS_INLINE ssize_t LSS_NAME(recvmsg)(
int s,
struct kernel_msghdr *msg,
3300 return (ssize_t)LSS_NAME(socketcall)(17, s, msg, flags);
3303 LSS_INLINE ssize_t LSS_NAME(sendmsg)(
int s,
3304 const struct kernel_msghdr *msg,
3306 return (ssize_t)LSS_NAME(socketcall)(16, s, msg, flags);
3309 LSS_INLINE ssize_t LSS_NAME(sendto)(
int s,
const void *buf,
size_t len,
3311 const struct kernel_sockaddr *to,
3312 unsigned int tolen) {
3313 return (ssize_t)LSS_NAME(socketcall)(11, s, buf, len, flags, to, tolen);
3316 LSS_INLINE
int LSS_NAME(shutdown)(
int s,
int how) {
3317 return LSS_NAME(socketcall)(13, s, how);
3320 LSS_INLINE
int LSS_NAME(socket)(
int domain,
int type,
int protocol) {
3321 return LSS_NAME(socketcall)(1, domain, type, protocol);
3324 LSS_INLINE
int LSS_NAME(socketpair)(
int d,
int type,
int protocol,
3326 return LSS_NAME(socketcall)(8, d, type, protocol, sv);
3329 #if defined(__i386__) || defined(__PPC__) 3330 LSS_INLINE _syscall4(
int, fstatat64,
int, d,
3332 struct kernel_stat64 *, b,
int, f)
3334 #if defined(__i386__) || defined(__PPC__) || \ 3335 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) 3336 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p,
3339 #if defined(__mips__) 3343 LSS_INLINE
int LSS_NAME(pipe)(
int *p) {
3344 register unsigned long __v0 __asm__(
"$2") = __NR_pipe;
3345 register unsigned long __v1 __asm__(
"$3");
3346 register unsigned long __r7 __asm__(
"$7");
3347 __asm__ __volatile__ (
"syscall\n" 3348 :
"+r"(__v0),
"=r"(__v1),
"=r" (__r7)
3350 :
"$8",
"$9",
"$10",
"$11",
"$12",
3351 "$13",
"$14",
"$15",
"$24",
"$25",
"memory");
3353 unsigned long __errnovalue = __v0;
3354 LSS_ERRNO = __errnovalue;
3363 LSS_INLINE _syscall1(
int, pipe,
int *, p)
3366 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ 3367 defined(__ARM_EABI__) || \ 3368 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) 3369 #define __NR__statfs64 __NR_statfs64 3370 #define __NR__fstatfs64 __NR_fstatfs64 3371 LSS_INLINE _syscall3(
int, _statfs64,
const char*, p,
3372 size_t, s,
struct kernel_statfs64*, b)
3373 LSS_INLINE _syscall3(
int, _fstatfs64,
int, f,
3374 size_t, s,struct kernel_statfs64*, b)
3375 LSS_INLINE
int LSS_NAME(statfs64)(const
char *p,
3376 struct kernel_statfs64 *b) {
3377 return LSS_NAME(_statfs64)(p,
sizeof(*b), b);
3379 LSS_INLINE
int LSS_NAME(fstatfs64)(
int f,
struct kernel_statfs64 *b) {
3380 return LSS_NAME(_fstatfs64)(f,
sizeof(*b), b);
3384 LSS_INLINE
int LSS_NAME(execv)(
const char *path,
const char *
const argv[]) {
3385 extern char **environ;
3386 return LSS_NAME(execve)(path, argv, (
const char *
const *)environ);
3389 LSS_INLINE pid_t LSS_NAME(gettid)() {
3390 pid_t tid = LSS_NAME(_gettid)();
3394 return LSS_NAME(getpid)();
3397 LSS_INLINE
void *LSS_NAME(mremap)(
void *old_address,
size_t old_size,
3398 size_t new_size,
int flags, ...) {
3400 void *new_address, *rc;
3401 va_start(ap, flags);
3402 new_address = va_arg(ap,
void *);
3403 rc = LSS_NAME(_mremap)(old_address, old_size, new_size,
3404 flags, new_address);
3409 LSS_INLINE
int LSS_NAME(ptrace_detach)(pid_t pid) {
3421 LSS_NAME(sched_yield)();
3422 rc = LSS_NAME(ptrace)(PTRACE_DETACH, pid, (
void *)0, (
void *)0);
3424 LSS_NAME(tkill)(pid, SIGCONT);
3426 if (LSS_ERRNO == ENOSYS)
3427 LSS_NAME(kill)(pid, SIGCONT);
3432 LSS_INLINE
int LSS_NAME(
raise)(
int sig) {
3433 return LSS_NAME(kill)(LSS_NAME(getpid)(), sig);
3436 LSS_INLINE
int LSS_NAME(setpgrp)() {
3437 return LSS_NAME(setpgid)(0, 0);
3440 LSS_INLINE
int LSS_NAME(sysconf)(
int name) {
3441 extern int __getpagesize(
void);
3443 case _SC_OPEN_MAX: {
3444 struct kernel_rlimit limit;
3445 #if defined(__ARM_EABI__) 3446 return LSS_NAME(ugetrlimit)(RLIMIT_NOFILE, &limit) < 0
3447 ? 8192 : limit.rlim_cur;
3449 return LSS_NAME(getrlimit)(RLIMIT_NOFILE, &limit) < 0
3450 ? 8192 : limit.rlim_cur;
3454 return __getpagesize();
3460 #if defined(__x86_64__) || \ 3461 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64) 3462 LSS_INLINE _syscall4(ssize_t, pread64,
int, f,
3463 void *, b,
size_t, c,
3465 LSS_INLINE _syscall4(ssize_t, pwrite64,
int, f,
3466 const
void *, b,
size_t, c,
3468 LSS_INLINE _syscall3(
int, readahead,
int, f,
3469 loff_t, o,
unsigned, c)
3471 #define __NR__pread64 __NR_pread64 3472 #define __NR__pwrite64 __NR_pwrite64 3473 #define __NR__readahead __NR_readahead 3474 #if defined(__ARM_EABI__) 3479 #define LSS_LLARG_PAD 0, 3480 LSS_INLINE _syscall6(ssize_t, _pread64,
int, f,
3481 void *, b,
size_t, c,
3482 unsigned, skip,
unsigned, o1,
unsigned, o2)
3483 LSS_INLINE _syscall6(ssize_t, _pwrite64,
int, f,
3484 const
void *, b,
size_t, c,
3485 unsigned, skip,
unsigned, o1,
unsigned, o2)
3486 LSS_INLINE _syscall5(
int, _readahead,
int, f,
3488 unsigned, o1,
unsigned, o2,
size_t, c)
3490 #define LSS_LLARG_PAD 3491 LSS_INLINE _syscall5(ssize_t, _pread64,
int, f,
3492 void *, b,
size_t, c,
unsigned, o1,
3494 LSS_INLINE _syscall5(ssize_t, _pwrite64,
int, f,
3495 const
void *, b,
size_t, c,
unsigned, o1,
3497 LSS_INLINE _syscall4(
int, _readahead,
int, f,
3498 unsigned, o1,
unsigned, o2,
size_t, c)
3505 LSS_INLINE ssize_t LSS_NAME(pread64)(
int fd,
void *buf,
size_t count,
3507 union { loff_t off;
unsigned arg[2]; } o = { off };
3508 return LSS_NAME(_pread64)(fd, buf, count,
3509 LSS_LLARG_PAD o.arg[0], o.arg[1]);
3511 LSS_INLINE ssize_t LSS_NAME(pwrite64)(
int fd,
const void *buf,
3512 size_t count, loff_t off) {
3513 union { loff_t off;
unsigned arg[2]; } o = { off };
3514 return LSS_NAME(_pwrite64)(fd, buf, count,
3515 LSS_LLARG_PAD o.arg[0], o.arg[1]);
3517 LSS_INLINE
int LSS_NAME(readahead)(
int fd, loff_t off,
int len) {
3518 union { loff_t off;
unsigned arg[2]; } o = { off };
3519 return LSS_NAME(_readahead)(fd, LSS_LLARG_PAD o.arg[0], o.arg[1], len);
3527 # pragma pop_macro("stat64") 3528 # pragma pop_macro("fstat64") 3529 # pragma pop_macro("lstat64") 3532 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS)
int write(const char *buf, size_t nbytes)