| OLD | NEW |
| 1 /* Copyright (c) 2005-2008, Google Inc. | 1 /* Copyright (c) 2005-2008, Google Inc. |
| 2 * All rights reserved. | 2 * All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 * | 62 * |
| 63 * SYS_PREFIX: | 63 * SYS_PREFIX: |
| 64 * New system calls will have a prefix of "sys_" unless overridden by | 64 * New system calls will have a prefix of "sys_" unless overridden by |
| 65 * the SYS_PREFIX macro. Valid values for this macro are [0..9] which | 65 * the SYS_PREFIX macro. Valid values for this macro are [0..9] which |
| 66 * results in prefixes "sys[0..9]_". It is also possible to set this | 66 * results in prefixes "sys[0..9]_". It is also possible to set this |
| 67 * macro to -1, which avoids all prefixes. | 67 * macro to -1, which avoids all prefixes. |
| 68 * | 68 * |
| 69 * This file defines a few internal symbols that all start with "LSS_". | 69 * This file defines a few internal symbols that all start with "LSS_". |
| 70 * Do not access these symbols from outside this file. They are not part | 70 * Do not access these symbols from outside this file. They are not part |
| 71 * of the supported API. | 71 * of the supported API. |
| 72 * |
| 73 * NOTE: This is a stripped down version of the official opensource |
| 74 * version of linux_syscall_support.h, which lives at |
| 75 * http://code.google.com/p/linux-syscall-support/ |
| 76 * It includes only the syscalls that are used in perftools, plus a |
| 77 * few extra. Here's the breakdown: |
| 78 * 1) Perftools uses these: grep -rho 'sys_[a-z0-9_A-Z]* *(' src | sort -u |
| 79 * sys__exit( |
| 80 * sys_clone( |
| 81 * sys_close( |
| 82 * sys_fcntl( |
| 83 * sys_fstat( |
| 84 * sys_futex( |
| 85 * sys_futex1( |
| 86 * sys_getcpu( |
| 87 * sys_getdents( |
| 88 * sys_getppid( |
| 89 * sys_gettid( |
| 90 * sys_lseek( |
| 91 * sys_mmap( |
| 92 * sys_mremap( |
| 93 * sys_munmap( |
| 94 * sys_open( |
| 95 * sys_pipe( |
| 96 * sys_prctl( |
| 97 * sys_ptrace( |
| 98 * sys_ptrace_detach( |
| 99 * sys_read( |
| 100 * sys_sched_yield( |
| 101 * sys_sigaction( |
| 102 * sys_sigaltstack( |
| 103 * sys_sigdelset( |
| 104 * sys_sigfillset( |
| 105 * sys_sigprocmask( |
| 106 * sys_socket( |
| 107 * sys_stat( |
| 108 * sys_waitpid( |
| 109 * 2) These are used as subroutines of the above: |
| 110 * sys_getpid -- gettid |
| 111 * sys_kill -- ptrace_detach |
| 112 * sys_restore -- sigaction |
| 113 * sys_restore_rt -- sigaction |
| 114 * sys_socketcall -- socket |
| 115 * sys_wait4 -- waitpid |
| 116 * 3) I left these in even though they're not used. They either |
| 117 * complement the above (write vs read) or are variants (rt_sigaction): |
| 118 * sys_fstat64 |
| 119 * sys_getdents64 |
| 120 * sys_llseek |
| 121 * sys_mmap2 |
| 122 * sys_openat |
| 123 * sys_rt_sigaction |
| 124 * sys_rt_sigprocmask |
| 125 * sys_sigaddset |
| 126 * sys_sigemptyset |
| 127 * sys_stat64 |
| 128 * sys_write |
| 72 */ | 129 */ |
| 73 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H | 130 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H |
| 74 #define SYS_LINUX_SYSCALL_SUPPORT_H | 131 #define SYS_LINUX_SYSCALL_SUPPORT_H |
| 75 | 132 |
| 76 /* We currently only support x86-32, x86-64, ARM, MIPS, and PPC on Linux. | 133 /* We currently only support x86-32, x86-64, ARM, MIPS, and PPC on Linux. |
| 77 * Porting to other related platforms should not be difficult. | 134 * Porting to other related platforms should not be difficult. |
| 78 */ | 135 */ |
| 79 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ | 136 #if (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ |
| 80 defined(__mips__) || defined(__PPC__)) && defined(__linux) | 137 defined(__mips__) || defined(__PPC__)) && defined(__linux) |
| 81 | 138 |
| 82 #ifndef SYS_CPLUSPLUS | 139 #ifndef SYS_CPLUSPLUS |
| 83 #ifdef __cplusplus | 140 #ifdef __cplusplus |
| 84 /* Some system header files in older versions of gcc neglect to properly | 141 /* Some system header files in older versions of gcc neglect to properly |
| 85 * handle being included from C++. As it appears to be harmless to have | 142 * handle being included from C++. As it appears to be harmless to have |
| 86 * multiple nested 'extern "C"' blocks, just add another one here. | 143 * multiple nested 'extern "C"' blocks, just add another one here. |
| 87 */ | 144 */ |
| 88 extern "C" { | 145 extern "C" { |
| 89 #endif | 146 #endif |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 }; | 204 }; |
| 148 | 205 |
| 149 /* include/linux/dirent.h */ | 206 /* include/linux/dirent.h */ |
| 150 struct kernel_dirent { | 207 struct kernel_dirent { |
| 151 long d_ino; | 208 long d_ino; |
| 152 long d_off; | 209 long d_off; |
| 153 unsigned short d_reclen; | 210 unsigned short d_reclen; |
| 154 char d_name[256]; | 211 char d_name[256]; |
| 155 }; | 212 }; |
| 156 | 213 |
| 157 /* include/linux/uio.h */ | |
| 158 struct kernel_iovec { | |
| 159 void *iov_base; | |
| 160 unsigned long iov_len; | |
| 161 }; | |
| 162 | |
| 163 /* include/linux/socket.h */ | |
| 164 struct kernel_msghdr { | |
| 165 void *msg_name; | |
| 166 int msg_namelen; | |
| 167 struct kernel_iovec*msg_iov; | |
| 168 unsigned long msg_iovlen; | |
| 169 void *msg_control; | |
| 170 unsigned long msg_controllen; | |
| 171 unsigned msg_flags; | |
| 172 }; | |
| 173 | |
| 174 /* include/asm-generic/poll.h */ | |
| 175 struct kernel_pollfd { | |
| 176 int fd; | |
| 177 short events; | |
| 178 short revents; | |
| 179 }; | |
| 180 | |
| 181 /* include/linux/resource.h */ | |
| 182 struct kernel_rlimit { | |
| 183 unsigned long rlim_cur; | |
| 184 unsigned long rlim_max; | |
| 185 }; | |
| 186 | |
| 187 /* include/linux/time.h */ | 214 /* include/linux/time.h */ |
| 188 struct kernel_timespec { | 215 struct kernel_timespec { |
| 189 long tv_sec; | 216 long tv_sec; |
| 190 long tv_nsec; | 217 long tv_nsec; |
| 191 }; | 218 }; |
| 192 | 219 |
| 193 /* include/linux/time.h */ | 220 /* include/linux/time.h */ |
| 194 struct kernel_timeval { | 221 struct kernel_timeval { |
| 195 long tv_sec; | 222 long tv_sec; |
| 196 long tv_usec; | 223 long tv_usec; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 210 long ru_inblock; | 237 long ru_inblock; |
| 211 long ru_oublock; | 238 long ru_oublock; |
| 212 long ru_msgsnd; | 239 long ru_msgsnd; |
| 213 long ru_msgrcv; | 240 long ru_msgrcv; |
| 214 long ru_nsignals; | 241 long ru_nsignals; |
| 215 long ru_nvcsw; | 242 long ru_nvcsw; |
| 216 long ru_nivcsw; | 243 long ru_nivcsw; |
| 217 }; | 244 }; |
| 218 | 245 |
| 219 struct siginfo; | 246 struct siginfo; |
| 220 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__PPC__) | 247 #if defined(__i386__) || defined(__arm__) || defined(__PPC__) |
| 221 | 248 |
| 222 /* include/asm-{arm,i386,mips,ppc}/signal.h */ | 249 /* include/asm-{arm,i386,mips,ppc}/signal.h */ |
| 223 struct kernel_old_sigaction { | 250 struct kernel_old_sigaction { |
| 224 union { | 251 union { |
| 225 void (*sa_handler_)(int); | 252 void (*sa_handler_)(int); |
| 226 void (*sa_sigaction_)(int, struct siginfo *, void *); | 253 void (*sa_sigaction_)(int, struct siginfo *, void *); |
| 227 }; | 254 }; |
| 228 unsigned long sa_mask; | 255 unsigned long sa_mask; |
| 229 unsigned long sa_flags; | 256 unsigned long sa_flags; |
| 230 void (*sa_restorer)(void); | 257 void (*sa_restorer)(void); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 union { | 294 union { |
| 268 void (*sa_handler_)(int); | 295 void (*sa_handler_)(int); |
| 269 void (*sa_sigaction_)(int, struct siginfo *, void *); | 296 void (*sa_sigaction_)(int, struct siginfo *, void *); |
| 270 }; | 297 }; |
| 271 unsigned long sa_flags; | 298 unsigned long sa_flags; |
| 272 void (*sa_restorer)(void); | 299 void (*sa_restorer)(void); |
| 273 struct kernel_sigset_t sa_mask; | 300 struct kernel_sigset_t sa_mask; |
| 274 #endif | 301 #endif |
| 275 }; | 302 }; |
| 276 | 303 |
| 277 /* include/linux/socket.h */ | |
| 278 struct kernel_sockaddr { | |
| 279 unsigned short sa_family; | |
| 280 char sa_data[14]; | |
| 281 }; | |
| 282 | |
| 283 /* include/asm-{arm,i386,mips,ppc}/stat.h */ | 304 /* include/asm-{arm,i386,mips,ppc}/stat.h */ |
| 284 #ifdef __mips__ | 305 #ifdef __mips__ |
| 285 #if _MIPS_SIM == _MIPS_SIM_ABI64 | 306 #if _MIPS_SIM == _MIPS_SIM_ABI64 |
| 286 struct kernel_stat { | 307 struct kernel_stat { |
| 287 #else | 308 #else |
| 288 struct kernel_stat64 { | 309 struct kernel_stat64 { |
| 289 #endif | 310 #endif |
| 290 unsigned st_dev; | 311 unsigned st_dev; |
| 291 unsigned __pad0[3]; | 312 unsigned __pad0[3]; |
| 292 unsigned long long st_ino; | 313 unsigned long long st_ino; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 unsigned st_atime_nsec_; | 368 unsigned st_atime_nsec_; |
| 348 unsigned st_mtime_; | 369 unsigned st_mtime_; |
| 349 unsigned st_mtime_nsec_; | 370 unsigned st_mtime_nsec_; |
| 350 unsigned st_ctime_; | 371 unsigned st_ctime_; |
| 351 unsigned st_ctime_nsec_; | 372 unsigned st_ctime_nsec_; |
| 352 unsigned long long st_ino; | 373 unsigned long long st_ino; |
| 353 }; | 374 }; |
| 354 #endif | 375 #endif |
| 355 | 376 |
| 356 /* include/asm-{arm,i386,mips,x86_64,ppc}/stat.h */ | 377 /* include/asm-{arm,i386,mips,x86_64,ppc}/stat.h */ |
| 357 #if defined(__i386__) || defined(__ARM_ARCH_3__) | 378 #if defined(__i386__) || defined(__arm__) |
| 358 struct kernel_stat { | 379 struct kernel_stat { |
| 359 /* The kernel headers suggest that st_dev and st_rdev should be 32bit | 380 /* The kernel headers suggest that st_dev and st_rdev should be 32bit |
| 360 * quantities encoding 12bit major and 20bit minor numbers in an interleaved | 381 * quantities encoding 12bit major and 20bit minor numbers in an interleaved |
| 361 * format. In reality, we do not see useful data in the top bits. So, | 382 * format. In reality, we do not see useful data in the top bits. So, |
| 362 * we'll leave the padding in here, until we find a better solution. | 383 * we'll leave the padding in here, until we find a better solution. |
| 363 */ | 384 */ |
| 364 unsigned short st_dev; | 385 unsigned short st_dev; |
| 365 short pad1; | 386 short pad1; |
| 366 unsigned st_ino; | 387 unsigned st_ino; |
| 367 unsigned short st_mode; | 388 unsigned short st_mode; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 long st_mtime_; | 463 long st_mtime_; |
| 443 long st_mtime_nsec_; | 464 long st_mtime_nsec_; |
| 444 long st_ctime_; | 465 long st_ctime_; |
| 445 long st_ctime_nsec_; | 466 long st_ctime_nsec_; |
| 446 int st_blksize; | 467 int st_blksize; |
| 447 int st_blocks; | 468 int st_blocks; |
| 448 int st_pad4[14]; | 469 int st_pad4[14]; |
| 449 }; | 470 }; |
| 450 #endif | 471 #endif |
| 451 | 472 |
| 452 /* include/asm-{arm,i386,mips,x86_64,ppc}/statfs.h */ | |
| 453 #ifdef __mips__ | |
| 454 #if _MIPS_SIM != _MIPS_SIM_ABI64 | |
| 455 struct kernel_statfs64 { | |
| 456 unsigned long f_type; | |
| 457 unsigned long f_bsize; | |
| 458 unsigned long f_frsize; | |
| 459 unsigned long __pad; | |
| 460 unsigned long long f_blocks; | |
| 461 unsigned long long f_bfree; | |
| 462 unsigned long long f_files; | |
| 463 unsigned long long f_ffree; | |
| 464 unsigned long long f_bavail; | |
| 465 struct { int val[2]; } f_fsid; | |
| 466 unsigned long f_namelen; | |
| 467 unsigned long f_spare[6]; | |
| 468 }; | |
| 469 #endif | |
| 470 #elif !defined(__x86_64__) | |
| 471 struct kernel_statfs64 { | |
| 472 unsigned long f_type; | |
| 473 unsigned long f_bsize; | |
| 474 unsigned long long f_blocks; | |
| 475 unsigned long long f_bfree; | |
| 476 unsigned long long f_bavail; | |
| 477 unsigned long long f_files; | |
| 478 unsigned long long f_ffree; | |
| 479 struct { int val[2]; } f_fsid; | |
| 480 unsigned long f_namelen; | |
| 481 unsigned long f_frsize; | |
| 482 unsigned long f_spare[5]; | |
| 483 }; | |
| 484 #endif | |
| 485 | |
| 486 /* include/asm-{arm,i386,mips,x86_64,ppc,generic}/statfs.h */ | |
| 487 #ifdef __mips__ | |
| 488 struct kernel_statfs { | |
| 489 long f_type; | |
| 490 long f_bsize; | |
| 491 long f_frsize; | |
| 492 long f_blocks; | |
| 493 long f_bfree; | |
| 494 long f_files; | |
| 495 long f_ffree; | |
| 496 long f_bavail; | |
| 497 struct { int val[2]; } f_fsid; | |
| 498 long f_namelen; | |
| 499 long f_spare[6]; | |
| 500 }; | |
| 501 #else | |
| 502 struct kernel_statfs { | |
| 503 /* x86_64 actually defines all these fields as signed, whereas all other */ | |
| 504 /* platforms define them as unsigned. Leaving them at unsigned should not */ | |
| 505 /* cause any problems. */ | |
| 506 unsigned long f_type; | |
| 507 unsigned long f_bsize; | |
| 508 unsigned long f_blocks; | |
| 509 unsigned long f_bfree; | |
| 510 unsigned long f_bavail; | |
| 511 unsigned long f_files; | |
| 512 unsigned long f_ffree; | |
| 513 struct { int val[2]; } f_fsid; | |
| 514 unsigned long f_namelen; | |
| 515 unsigned long f_frsize; | |
| 516 unsigned long f_spare[5]; | |
| 517 }; | |
| 518 #endif | |
| 519 | |
| 520 | 473 |
| 521 /* Definitions missing from the standard header files */ | 474 /* Definitions missing from the standard header files */ |
| 522 #ifndef O_DIRECTORY | 475 #ifndef O_DIRECTORY |
| 523 #if defined(__ARM_ARCH_3__) | 476 #if defined(__arm__) |
| 524 #define O_DIRECTORY 0040000 | 477 #define O_DIRECTORY 0040000 |
| 525 #else | 478 #else |
| 526 #define O_DIRECTORY 0200000 | 479 #define O_DIRECTORY 0200000 |
| 527 #endif | 480 #endif |
| 528 #endif | 481 #endif |
| 529 #ifndef NT_PRXFPREG | |
| 530 #define NT_PRXFPREG 0x46e62b7f | |
| 531 #endif | |
| 532 #ifndef PTRACE_GETFPXREGS | |
| 533 #define PTRACE_GETFPXREGS ((enum __ptrace_request)18) | |
| 534 #endif | |
| 535 #ifndef PR_GET_DUMPABLE | 482 #ifndef PR_GET_DUMPABLE |
| 536 #define PR_GET_DUMPABLE 3 | 483 #define PR_GET_DUMPABLE 3 |
| 537 #endif | 484 #endif |
| 538 #ifndef PR_SET_DUMPABLE | 485 #ifndef PR_SET_DUMPABLE |
| 539 #define PR_SET_DUMPABLE 4 | 486 #define PR_SET_DUMPABLE 4 |
| 540 #endif | 487 #endif |
| 541 #ifndef AT_FDCWD | 488 #ifndef AT_FDCWD |
| 542 #define AT_FDCWD (-100) | 489 #define AT_FDCWD (-100) |
| 543 #endif | 490 #endif |
| 544 #ifndef AT_SYMLINK_NOFOLLOW | 491 #ifndef AT_SYMLINK_NOFOLLOW |
| 545 #define AT_SYMLINK_NOFOLLOW 0x100 | 492 #define AT_SYMLINK_NOFOLLOW 0x100 |
| 546 #endif | 493 #endif |
| 547 #ifndef AT_REMOVEDIR | 494 #ifndef AT_REMOVEDIR |
| 548 #define AT_REMOVEDIR 0x200 | 495 #define AT_REMOVEDIR 0x200 |
| 549 #endif | 496 #endif |
| 550 #ifndef MREMAP_FIXED | 497 #ifndef MREMAP_FIXED |
| 551 #define MREMAP_FIXED 2 | 498 #define MREMAP_FIXED 2 |
| 552 #endif | 499 #endif |
| 553 #ifndef SA_RESTORER | 500 #ifndef SA_RESTORER |
| 554 #define SA_RESTORER 0x04000000 | 501 #define SA_RESTORER 0x04000000 |
| 555 #endif | 502 #endif |
| 556 #ifndef CPUCLOCK_PROF | |
| 557 #define CPUCLOCK_PROF 0 | |
| 558 #endif | |
| 559 #ifndef CPUCLOCK_VIRT | |
| 560 #define CPUCLOCK_VIRT 1 | |
| 561 #endif | |
| 562 #ifndef CPUCLOCK_SCHED | |
| 563 #define CPUCLOCK_SCHED 2 | |
| 564 #endif | |
| 565 #ifndef CPUCLOCK_PERTHREAD_MASK | |
| 566 #define CPUCLOCK_PERTHREAD_MASK 4 | |
| 567 #endif | |
| 568 #ifndef MAKE_PROCESS_CPUCLOCK | |
| 569 #define MAKE_PROCESS_CPUCLOCK(pid, clock) \ | |
| 570 ((~(int)(pid) << 3) | (int)(clock)) | |
| 571 #endif | |
| 572 #ifndef MAKE_THREAD_CPUCLOCK | |
| 573 #define MAKE_THREAD_CPUCLOCK(tid, clock) \ | |
| 574 ((~(int)(tid) << 3) | (int)((clock) | CPUCLOCK_PERTHREAD_MASK)) | |
| 575 #endif | |
| 576 | 503 |
| 577 #if defined(__i386__) | 504 #if defined(__i386__) |
| 578 #ifndef __NR_setresuid | |
| 579 #define __NR_setresuid 164 | |
| 580 #define __NR_setresgid 170 | |
| 581 #endif | |
| 582 #ifndef __NR_rt_sigaction | 505 #ifndef __NR_rt_sigaction |
| 583 #define __NR_rt_sigaction 174 | 506 #define __NR_rt_sigaction 174 |
| 584 #define __NR_rt_sigprocmask 175 | 507 #define __NR_rt_sigprocmask 175 |
| 585 #define __NR_rt_sigpending 176 | |
| 586 #define __NR_rt_sigsuspend 179 | |
| 587 #endif | |
| 588 #ifndef __NR_pread64 | |
| 589 #define __NR_pread64 180 | |
| 590 #endif | |
| 591 #ifndef __NR_pwrite64 | |
| 592 #define __NR_pwrite64 181 | |
| 593 #endif | |
| 594 #ifndef __NR_ugetrlimit | |
| 595 #define __NR_ugetrlimit 191 | |
| 596 #endif | 508 #endif |
| 597 #ifndef __NR_stat64 | 509 #ifndef __NR_stat64 |
| 598 #define __NR_stat64 195 | 510 #define __NR_stat64 195 |
| 599 #endif | 511 #endif |
| 600 #ifndef __NR_fstat64 | 512 #ifndef __NR_fstat64 |
| 601 #define __NR_fstat64 197 | 513 #define __NR_fstat64 197 |
| 602 #endif | 514 #endif |
| 603 #ifndef __NR_setresuid32 | |
| 604 #define __NR_setresuid32 208 | |
| 605 #define __NR_setresgid32 210 | |
| 606 #endif | |
| 607 #ifndef __NR_setfsuid32 | |
| 608 #define __NR_setfsuid32 215 | |
| 609 #define __NR_setfsgid32 216 | |
| 610 #endif | |
| 611 #ifndef __NR_getdents64 | 515 #ifndef __NR_getdents64 |
| 612 #define __NR_getdents64 220 | 516 #define __NR_getdents64 220 |
| 613 #endif | 517 #endif |
| 614 #ifndef __NR_gettid | 518 #ifndef __NR_gettid |
| 615 #define __NR_gettid 224 | 519 #define __NR_gettid 224 |
| 616 #endif | 520 #endif |
| 617 #ifndef __NR_readahead | |
| 618 #define __NR_readahead 225 | |
| 619 #endif | |
| 620 #ifndef __NR_setxattr | |
| 621 #define __NR_setxattr 226 | |
| 622 #endif | |
| 623 #ifndef __NR_lsetxattr | |
| 624 #define __NR_lsetxattr 227 | |
| 625 #endif | |
| 626 #ifndef __NR_getxattr | |
| 627 #define __NR_getxattr 229 | |
| 628 #endif | |
| 629 #ifndef __NR_lgetxattr | |
| 630 #define __NR_lgetxattr 230 | |
| 631 #endif | |
| 632 #ifndef __NR_listxattr | |
| 633 #define __NR_listxattr 232 | |
| 634 #endif | |
| 635 #ifndef __NR_llistxattr | |
| 636 #define __NR_llistxattr 233 | |
| 637 #endif | |
| 638 #ifndef __NR_futex | 521 #ifndef __NR_futex |
| 639 #define __NR_futex 240 | 522 #define __NR_futex 240 |
| 640 #endif | 523 #endif |
| 641 #ifndef __NR_sched_setaffinity | |
| 642 #define __NR_sched_setaffinity 241 | |
| 643 #define __NR_sched_getaffinity 242 | |
| 644 #endif | |
| 645 #ifndef __NR_set_tid_address | |
| 646 #define __NR_set_tid_address 258 | |
| 647 #endif | |
| 648 #ifndef __NR_clock_gettime | |
| 649 #define __NR_clock_gettime 265 | |
| 650 #endif | |
| 651 #ifndef __NR_clock_getres | |
| 652 #define __NR_clock_getres 266 | |
| 653 #endif | |
| 654 #ifndef __NR_statfs64 | |
| 655 #define __NR_statfs64 268 | |
| 656 #endif | |
| 657 #ifndef __NR_fstatfs64 | |
| 658 #define __NR_fstatfs64 269 | |
| 659 #endif | |
| 660 #ifndef __NR_fadvise64_64 | |
| 661 #define __NR_fadvise64_64 272 | |
| 662 #endif | |
| 663 #ifndef __NR_ioprio_set | |
| 664 #define __NR_ioprio_set 289 | |
| 665 #endif | |
| 666 #ifndef __NR_ioprio_get | |
| 667 #define __NR_ioprio_get 290 | |
| 668 #endif | |
| 669 #ifndef __NR_openat | 524 #ifndef __NR_openat |
| 670 #define __NR_openat 295 | 525 #define __NR_openat 295 |
| 671 #endif | 526 #endif |
| 672 #ifndef __NR_fstatat64 | |
| 673 #define __NR_fstatat64 300 | |
| 674 #endif | |
| 675 #ifndef __NR_unlinkat | |
| 676 #define __NR_unlinkat 301 | |
| 677 #endif | |
| 678 #ifndef __NR_move_pages | |
| 679 #define __NR_move_pages 317 | |
| 680 #endif | |
| 681 #ifndef __NR_getcpu | 527 #ifndef __NR_getcpu |
| 682 #define __NR_getcpu 318 | 528 #define __NR_getcpu 318 |
| 683 #endif | 529 #endif |
| 684 #ifndef __NR_fallocate | 530 /* End of i386 definitions */ |
| 685 #define __NR_fallocate 324 | 531 #elif defined(__arm__) |
| 532 #ifndef __syscall |
| 533 #if defined(__thumb__) || defined(__ARM_EABI__) |
| 534 #define __SYS_REG(name) register long __sysreg __asm__("r6") = __NR_##name; |
| 535 #define __SYS_REG_LIST(regs...) [sysreg] "r" (__sysreg) , ##regs |
| 536 #define __syscall(name) "swi\t0" |
| 537 #define __syscall_safe(name) \ |
| 538 "push {r7}\n" \ |
| 539 "mov r7,%[sysreg]\n" \ |
| 540 __syscall(name)"\n" \ |
| 541 "pop {r7}" |
| 542 #else |
| 543 #define __SYS_REG(name) |
| 544 #define __SYS_REG_LIST(regs...) regs |
| 545 #define __syscall(name) "swi\t" __sys1(__NR_##name) "" |
| 546 #define __syscall_safe(name) __syscall(name) |
| 686 #endif | 547 #endif |
| 687 /* End of i386 definitions */ | |
| 688 #elif defined(__ARM_ARCH_3__) | |
| 689 #ifndef __NR_setresuid | |
| 690 #define __NR_setresuid (__NR_SYSCALL_BASE + 164) | |
| 691 #define __NR_setresgid (__NR_SYSCALL_BASE + 170) | |
| 692 #endif | 548 #endif |
| 693 #ifndef __NR_rt_sigaction | 549 #ifndef __NR_rt_sigaction |
| 694 #define __NR_rt_sigaction (__NR_SYSCALL_BASE + 174) | 550 #define __NR_rt_sigaction (__NR_SYSCALL_BASE + 174) |
| 695 #define __NR_rt_sigprocmask (__NR_SYSCALL_BASE + 175) | 551 #define __NR_rt_sigprocmask (__NR_SYSCALL_BASE + 175) |
| 696 #define __NR_rt_sigpending (__NR_SYSCALL_BASE + 176) | |
| 697 #define __NR_rt_sigsuspend (__NR_SYSCALL_BASE + 179) | |
| 698 #endif | |
| 699 #ifndef __NR_pread64 | |
| 700 #define __NR_pread64 (__NR_SYSCALL_BASE + 180) | |
| 701 #endif | |
| 702 #ifndef __NR_pwrite64 | |
| 703 #define __NR_pwrite64 (__NR_SYSCALL_BASE + 181) | |
| 704 #endif | |
| 705 #ifndef __NR_ugetrlimit | |
| 706 #define __NR_ugetrlimit (__NR_SYSCALL_BASE + 191) | |
| 707 #endif | 552 #endif |
| 708 #ifndef __NR_stat64 | 553 #ifndef __NR_stat64 |
| 709 #define __NR_stat64 (__NR_SYSCALL_BASE + 195) | 554 #define __NR_stat64 (__NR_SYSCALL_BASE + 195) |
| 710 #endif | 555 #endif |
| 711 #ifndef __NR_fstat64 | 556 #ifndef __NR_fstat64 |
| 712 #define __NR_fstat64 (__NR_SYSCALL_BASE + 197) | 557 #define __NR_fstat64 (__NR_SYSCALL_BASE + 197) |
| 713 #endif | 558 #endif |
| 714 #ifndef __NR_setresuid32 | |
| 715 #define __NR_setresuid32 (__NR_SYSCALL_BASE + 208) | |
| 716 #define __NR_setresgid32 (__NR_SYSCALL_BASE + 210) | |
| 717 #endif | |
| 718 #ifndef __NR_setfsuid32 | |
| 719 #define __NR_setfsuid32 (__NR_SYSCALL_BASE + 215) | |
| 720 #define __NR_setfsgid32 (__NR_SYSCALL_BASE + 216) | |
| 721 #endif | |
| 722 #ifndef __NR_getdents64 | 559 #ifndef __NR_getdents64 |
| 723 #define __NR_getdents64 (__NR_SYSCALL_BASE + 217) | 560 #define __NR_getdents64 (__NR_SYSCALL_BASE + 217) |
| 724 #endif | 561 #endif |
| 725 #ifndef __NR_gettid | 562 #ifndef __NR_gettid |
| 726 #define __NR_gettid (__NR_SYSCALL_BASE + 224) | 563 #define __NR_gettid (__NR_SYSCALL_BASE + 224) |
| 727 #endif | 564 #endif |
| 728 #ifndef __NR_readahead | |
| 729 #define __NR_readahead (__NR_SYSCALL_BASE + 225) | |
| 730 #endif | |
| 731 #ifndef __NR_setxattr | |
| 732 #define __NR_setxattr (__NR_SYSCALL_BASE + 226) | |
| 733 #endif | |
| 734 #ifndef __NR_lsetxattr | |
| 735 #define __NR_lsetxattr (__NR_SYSCALL_BASE + 227) | |
| 736 #endif | |
| 737 #ifndef __NR_getxattr | |
| 738 #define __NR_getxattr (__NR_SYSCALL_BASE + 229) | |
| 739 #endif | |
| 740 #ifndef __NR_lgetxattr | |
| 741 #define __NR_lgetxattr (__NR_SYSCALL_BASE + 230) | |
| 742 #endif | |
| 743 #ifndef __NR_listxattr | |
| 744 #define __NR_listxattr (__NR_SYSCALL_BASE + 232) | |
| 745 #endif | |
| 746 #ifndef __NR_llistxattr | |
| 747 #define __NR_llistxattr (__NR_SYSCALL_BASE + 233) | |
| 748 #endif | |
| 749 #ifndef __NR_futex | 565 #ifndef __NR_futex |
| 750 #define __NR_futex (__NR_SYSCALL_BASE + 240) | 566 #define __NR_futex (__NR_SYSCALL_BASE + 240) |
| 751 #endif | 567 #endif |
| 752 #ifndef __NR_sched_setaffinity | 568 /* End of ARM definitions */ |
| 753 #define __NR_sched_setaffinity (__NR_SYSCALL_BASE + 241) | |
| 754 #define __NR_sched_getaffinity (__NR_SYSCALL_BASE + 242) | |
| 755 #endif | |
| 756 #ifndef __NR_set_tid_address | |
| 757 #define __NR_set_tid_address (__NR_SYSCALL_BASE + 256) | |
| 758 #endif | |
| 759 #ifndef __NR_clock_gettime | |
| 760 #define __NR_clock_gettime (__NR_SYSCALL_BASE + 263) | |
| 761 #endif | |
| 762 #ifndef __NR_clock_getres | |
| 763 #define __NR_clock_getres (__NR_SYSCALL_BASE + 264) | |
| 764 #endif | |
| 765 #ifndef __NR_statfs64 | |
| 766 #define __NR_statfs64 (__NR_SYSCALL_BASE + 266) | |
| 767 #endif | |
| 768 #ifndef __NR_fstatfs64 | |
| 769 #define __NR_fstatfs64 (__NR_SYSCALL_BASE + 267) | |
| 770 #endif | |
| 771 #ifndef __NR_ioprio_set | |
| 772 #define __NR_ioprio_set (__NR_SYSCALL_BASE + 314) | |
| 773 #endif | |
| 774 #ifndef __NR_ioprio_get | |
| 775 #define __NR_ioprio_get (__NR_SYSCALL_BASE + 315) | |
| 776 #endif | |
| 777 #ifndef __NR_move_pages | |
| 778 #define __NR_move_pages (__NR_SYSCALL_BASE + 344) | |
| 779 #endif | |
| 780 #ifndef __NR_getcpu | |
| 781 #define __NR_getcpu (__NR_SYSCALL_BASE + 345) | |
| 782 #endif | |
| 783 /* End of ARM 3 definitions */ | |
| 784 #elif defined(__x86_64__) | 569 #elif defined(__x86_64__) |
| 785 #ifndef __NR_pread64 | |
| 786 #define __NR_pread64 17 | |
| 787 #endif | |
| 788 #ifndef __NR_pwrite64 | |
| 789 #define __NR_pwrite64 18 | |
| 790 #endif | |
| 791 #ifndef __NR_setresuid | |
| 792 #define __NR_setresuid 117 | |
| 793 #define __NR_setresgid 119 | |
| 794 #endif | |
| 795 #ifndef __NR_gettid | 570 #ifndef __NR_gettid |
| 796 #define __NR_gettid 186 | 571 #define __NR_gettid 186 |
| 797 #endif | 572 #endif |
| 798 #ifndef __NR_readahead | |
| 799 #define __NR_readahead 187 | |
| 800 #endif | |
| 801 #ifndef __NR_setxattr | |
| 802 #define __NR_setxattr 188 | |
| 803 #endif | |
| 804 #ifndef __NR_lsetxattr | |
| 805 #define __NR_lsetxattr 189 | |
| 806 #endif | |
| 807 #ifndef __NR_getxattr | |
| 808 #define __NR_getxattr 191 | |
| 809 #endif | |
| 810 #ifndef __NR_lgetxattr | |
| 811 #define __NR_lgetxattr 192 | |
| 812 #endif | |
| 813 #ifndef __NR_listxattr | |
| 814 #define __NR_listxattr 194 | |
| 815 #endif | |
| 816 #ifndef __NR_llistxattr | |
| 817 #define __NR_llistxattr 195 | |
| 818 #endif | |
| 819 #ifndef __NR_futex | 573 #ifndef __NR_futex |
| 820 #define __NR_futex 202 | 574 #define __NR_futex 202 |
| 821 #endif | 575 #endif |
| 822 #ifndef __NR_sched_setaffinity | |
| 823 #define __NR_sched_setaffinity 203 | |
| 824 #define __NR_sched_getaffinity 204 | |
| 825 #endif | |
| 826 #ifndef __NR_getdents64 | 576 #ifndef __NR_getdents64 |
| 827 #define __NR_getdents64 217 | 577 #define __NR_getdents64 217 |
| 828 #endif | 578 #endif |
| 829 #ifndef __NR_set_tid_address | |
| 830 #define __NR_set_tid_address 218 | |
| 831 #endif | |
| 832 #ifndef __NR_fadvise64 | |
| 833 #define __NR_fadvise64 221 | |
| 834 #endif | |
| 835 #ifndef __NR_clock_gettime | |
| 836 #define __NR_clock_gettime 228 | |
| 837 #endif | |
| 838 #ifndef __NR_clock_getres | |
| 839 #define __NR_clock_getres 229 | |
| 840 #endif | |
| 841 #ifndef __NR_ioprio_set | |
| 842 #define __NR_ioprio_set 251 | |
| 843 #endif | |
| 844 #ifndef __NR_ioprio_get | |
| 845 #define __NR_ioprio_get 252 | |
| 846 #endif | |
| 847 #ifndef __NR_openat | 579 #ifndef __NR_openat |
| 848 #define __NR_openat 257 | 580 #define __NR_openat 257 |
| 849 #endif | 581 #endif |
| 850 #ifndef __NR_newfstatat | |
| 851 #define __NR_newfstatat 262 | |
| 852 #endif | |
| 853 #ifndef __NR_unlinkat | |
| 854 #define __NR_unlinkat 263 | |
| 855 #endif | |
| 856 #ifndef __NR_move_pages | |
| 857 #define __NR_move_pages 279 | |
| 858 #endif | |
| 859 #ifndef __NR_fallocate | |
| 860 #define __NR_fallocate 285 | |
| 861 #endif | |
| 862 /* End of x86-64 definitions */ | 582 /* End of x86-64 definitions */ |
| 863 #elif defined(__mips__) | 583 #elif defined(__mips__) |
| 864 #if _MIPS_SIM == _MIPS_SIM_ABI32 | 584 #if _MIPS_SIM == _MIPS_SIM_ABI32 |
| 865 #ifndef __NR_setresuid | |
| 866 #define __NR_setresuid (__NR_Linux + 185) | |
| 867 #define __NR_setresgid (__NR_Linux + 190) | |
| 868 #endif | |
| 869 #ifndef __NR_rt_sigaction | 585 #ifndef __NR_rt_sigaction |
| 870 #define __NR_rt_sigaction (__NR_Linux + 194) | 586 #define __NR_rt_sigaction (__NR_Linux + 194) |
| 871 #define __NR_rt_sigprocmask (__NR_Linux + 195) | 587 #define __NR_rt_sigprocmask (__NR_Linux + 195) |
| 872 #define __NR_rt_sigpending (__NR_Linux + 196) | |
| 873 #define __NR_rt_sigsuspend (__NR_Linux + 199) | |
| 874 #endif | |
| 875 #ifndef __NR_pread64 | |
| 876 #define __NR_pread64 (__NR_Linux + 200) | |
| 877 #endif | |
| 878 #ifndef __NR_pwrite64 | |
| 879 #define __NR_pwrite64 (__NR_Linux + 201) | |
| 880 #endif | 588 #endif |
| 881 #ifndef __NR_stat64 | 589 #ifndef __NR_stat64 |
| 882 #define __NR_stat64 (__NR_Linux + 213) | 590 #define __NR_stat64 (__NR_Linux + 213) |
| 883 #endif | 591 #endif |
| 884 #ifndef __NR_fstat64 | 592 #ifndef __NR_fstat64 |
| 885 #define __NR_fstat64 (__NR_Linux + 215) | 593 #define __NR_fstat64 (__NR_Linux + 215) |
| 886 #endif | 594 #endif |
| 887 #ifndef __NR_getdents64 | 595 #ifndef __NR_getdents64 |
| 888 #define __NR_getdents64 (__NR_Linux + 219) | 596 #define __NR_getdents64 (__NR_Linux + 219) |
| 889 #endif | 597 #endif |
| 890 #ifndef __NR_gettid | 598 #ifndef __NR_gettid |
| 891 #define __NR_gettid (__NR_Linux + 222) | 599 #define __NR_gettid (__NR_Linux + 222) |
| 892 #endif | 600 #endif |
| 893 #ifndef __NR_readahead | |
| 894 #define __NR_readahead (__NR_Linux + 223) | |
| 895 #endif | |
| 896 #ifndef __NR_setxattr | |
| 897 #define __NR_setxattr (__NR_Linux + 224) | |
| 898 #endif | |
| 899 #ifndef __NR_lsetxattr | |
| 900 #define __NR_lsetxattr (__NR_Linux + 225) | |
| 901 #endif | |
| 902 #ifndef __NR_getxattr | |
| 903 #define __NR_getxattr (__NR_Linux + 227) | |
| 904 #endif | |
| 905 #ifndef __NR_lgetxattr | |
| 906 #define __NR_lgetxattr (__NR_Linux + 228) | |
| 907 #endif | |
| 908 #ifndef __NR_listxattr | |
| 909 #define __NR_listxattr (__NR_Linux + 230) | |
| 910 #endif | |
| 911 #ifndef __NR_llistxattr | |
| 912 #define __NR_llistxattr (__NR_Linux + 231) | |
| 913 #endif | |
| 914 #ifndef __NR_futex | 601 #ifndef __NR_futex |
| 915 #define __NR_futex (__NR_Linux + 238) | 602 #define __NR_futex (__NR_Linux + 238) |
| 916 #endif | 603 #endif |
| 917 #ifndef __NR_sched_setaffinity | |
| 918 #define __NR_sched_setaffinity (__NR_Linux + 239) | |
| 919 #define __NR_sched_getaffinity (__NR_Linux + 240) | |
| 920 #endif | |
| 921 #ifndef __NR_set_tid_address | |
| 922 #define __NR_set_tid_address (__NR_Linux + 252) | |
| 923 #endif | |
| 924 #ifndef __NR_statfs64 | |
| 925 #define __NR_statfs64 (__NR_Linux + 255) | |
| 926 #endif | |
| 927 #ifndef __NR_fstatfs64 | |
| 928 #define __NR_fstatfs64 (__NR_Linux + 256) | |
| 929 #endif | |
| 930 #ifndef __NR_clock_gettime | |
| 931 #define __NR_clock_gettime (__NR_Linux + 263) | |
| 932 #endif | |
| 933 #ifndef __NR_clock_getres | |
| 934 #define __NR_clock_getres (__NR_Linux + 264) | |
| 935 #endif | |
| 936 #ifndef __NR_openat | 604 #ifndef __NR_openat |
| 937 #define __NR_openat (__NR_Linux + 288) | 605 #define __NR_openat (__NR_Linux + 288) |
| 938 #endif | 606 #endif |
| 939 #ifndef __NR_fstatat | 607 #ifndef __NR_fstatat |
| 940 #define __NR_fstatat (__NR_Linux + 293) | 608 #define __NR_fstatat (__NR_Linux + 293) |
| 941 #endif | 609 #endif |
| 942 #ifndef __NR_unlinkat | |
| 943 #define __NR_unlinkat (__NR_Linux + 294) | |
| 944 #endif | |
| 945 #ifndef __NR_move_pages | |
| 946 #define __NR_move_pages (__NR_Linux + 308) | |
| 947 #endif | |
| 948 #ifndef __NR_getcpu | 610 #ifndef __NR_getcpu |
| 949 #define __NR_getcpu (__NR_Linux + 312) | 611 #define __NR_getcpu (__NR_Linux + 312) |
| 950 #endif | 612 #endif |
| 951 #ifndef __NR_ioprio_set | |
| 952 #define __NR_ioprio_set (__NR_Linux + 314) | |
| 953 #endif | |
| 954 #ifndef __NR_ioprio_get | |
| 955 #define __NR_ioprio_get (__NR_Linux + 315) | |
| 956 #endif | |
| 957 /* End of MIPS (old 32bit API) definitions */ | 613 /* End of MIPS (old 32bit API) definitions */ |
| 958 #elif _MIPS_SIM == _MIPS_SIM_ABI64 | 614 #elif _MIPS_SIM == _MIPS_SIM_ABI64 |
| 959 #ifndef __NR_pread64 | |
| 960 #define __NR_pread64 (__NR_Linux + 16) | |
| 961 #endif | |
| 962 #ifndef __NR_pwrite64 | |
| 963 #define __NR_pwrite64 (__NR_Linux + 17) | |
| 964 #endif | |
| 965 #ifndef __NR_setresuid | |
| 966 #define __NR_setresuid (__NR_Linux + 115) | |
| 967 #define __NR_setresgid (__NR_Linux + 117) | |
| 968 #endif | |
| 969 #ifndef __NR_gettid | 615 #ifndef __NR_gettid |
| 970 #define __NR_gettid (__NR_Linux + 178) | 616 #define __NR_gettid (__NR_Linux + 178) |
| 971 #endif | 617 #endif |
| 972 #ifndef __NR_readahead | |
| 973 #define __NR_readahead (__NR_Linux + 179) | |
| 974 #endif | |
| 975 #ifndef __NR_setxattr | |
| 976 #define __NR_setxattr (__NR_Linux + 180) | |
| 977 #endif | |
| 978 #ifndef __NR_lsetxattr | |
| 979 #define __NR_lsetxattr (__NR_Linux + 181) | |
| 980 #endif | |
| 981 #ifndef __NR_getxattr | |
| 982 #define __NR_getxattr (__NR_Linux + 183) | |
| 983 #endif | |
| 984 #ifndef __NR_lgetxattr | |
| 985 #define __NR_lgetxattr (__NR_Linux + 184) | |
| 986 #endif | |
| 987 #ifndef __NR_listxattr | |
| 988 #define __NR_listxattr (__NR_Linux + 186) | |
| 989 #endif | |
| 990 #ifndef __NR_llistxattr | |
| 991 #define __NR_llistxattr (__NR_Linux + 187) | |
| 992 #endif | |
| 993 #ifndef __NR_futex | 618 #ifndef __NR_futex |
| 994 #define __NR_futex (__NR_Linux + 194) | 619 #define __NR_futex (__NR_Linux + 194) |
| 995 #endif | 620 #endif |
| 996 #ifndef __NR_sched_setaffinity | |
| 997 #define __NR_sched_setaffinity (__NR_Linux + 195) | |
| 998 #define __NR_sched_getaffinity (__NR_Linux + 196) | |
| 999 #endif | |
| 1000 #ifndef __NR_set_tid_address | |
| 1001 #define __NR_set_tid_address (__NR_Linux + 212) | |
| 1002 #endif | |
| 1003 #ifndef __NR_clock_gettime | |
| 1004 #define __NR_clock_gettime (__NR_Linux + 222) | |
| 1005 #endif | |
| 1006 #ifndef __NR_clock_getres | |
| 1007 #define __NR_clock_getres (__NR_Linux + 223) | |
| 1008 #endif | |
| 1009 #ifndef __NR_openat | 621 #ifndef __NR_openat |
| 1010 #define __NR_openat (__NR_Linux + 247) | 622 #define __NR_openat (__NR_Linux + 247) |
| 1011 #endif | 623 #endif |
| 1012 #ifndef __NR_fstatat | 624 #ifndef __NR_fstatat |
| 1013 #define __NR_fstatat (__NR_Linux + 252) | 625 #define __NR_fstatat (__NR_Linux + 252) |
| 1014 #endif | 626 #endif |
| 1015 #ifndef __NR_unlinkat | |
| 1016 #define __NR_unlinkat (__NR_Linux + 253) | |
| 1017 #endif | |
| 1018 #ifndef __NR_move_pages | |
| 1019 #define __NR_move_pages (__NR_Linux + 267) | |
| 1020 #endif | |
| 1021 #ifndef __NR_getcpu | 627 #ifndef __NR_getcpu |
| 1022 #define __NR_getcpu (__NR_Linux + 271) | 628 #define __NR_getcpu (__NR_Linux + 271) |
| 1023 #endif | 629 #endif |
| 1024 #ifndef __NR_ioprio_set | |
| 1025 #define __NR_ioprio_set (__NR_Linux + 273) | |
| 1026 #endif | |
| 1027 #ifndef __NR_ioprio_get | |
| 1028 #define __NR_ioprio_get (__NR_Linux + 274) | |
| 1029 #endif | |
| 1030 /* End of MIPS (64bit API) definitions */ | 630 /* End of MIPS (64bit API) definitions */ |
| 1031 #else | 631 #else |
| 1032 #ifndef __NR_setresuid | |
| 1033 #define __NR_setresuid (__NR_Linux + 115) | |
| 1034 #define __NR_setresgid (__NR_Linux + 117) | |
| 1035 #endif | |
| 1036 #ifndef __NR_gettid | 632 #ifndef __NR_gettid |
| 1037 #define __NR_gettid (__NR_Linux + 178) | 633 #define __NR_gettid (__NR_Linux + 178) |
| 1038 #endif | 634 #endif |
| 1039 #ifndef __NR_readahead | |
| 1040 #define __NR_readahead (__NR_Linux + 179) | |
| 1041 #endif | |
| 1042 #ifndef __NR_setxattr | |
| 1043 #define __NR_setxattr (__NR_Linux + 180) | |
| 1044 #endif | |
| 1045 #ifndef __NR_lsetxattr | |
| 1046 #define __NR_lsetxattr (__NR_Linux + 181) | |
| 1047 #endif | |
| 1048 #ifndef __NR_getxattr | |
| 1049 #define __NR_getxattr (__NR_Linux + 183) | |
| 1050 #endif | |
| 1051 #ifndef __NR_lgetxattr | |
| 1052 #define __NR_lgetxattr (__NR_Linux + 184) | |
| 1053 #endif | |
| 1054 #ifndef __NR_listxattr | |
| 1055 #define __NR_listxattr (__NR_Linux + 186) | |
| 1056 #endif | |
| 1057 #ifndef __NR_llistxattr | |
| 1058 #define __NR_llistxattr (__NR_Linux + 187) | |
| 1059 #endif | |
| 1060 #ifndef __NR_futex | 635 #ifndef __NR_futex |
| 1061 #define __NR_futex (__NR_Linux + 194) | 636 #define __NR_futex (__NR_Linux + 194) |
| 1062 #endif | 637 #endif |
| 1063 #ifndef __NR_sched_setaffinity | |
| 1064 #define __NR_sched_setaffinity (__NR_Linux + 195) | |
| 1065 #define __NR_sched_getaffinity (__NR_Linux + 196) | |
| 1066 #endif | |
| 1067 #ifndef __NR_set_tid_address | |
| 1068 #define __NR_set_tid_address (__NR_Linux + 213) | |
| 1069 #endif | |
| 1070 #ifndef __NR_statfs64 | |
| 1071 #define __NR_statfs64 (__NR_Linux + 217) | |
| 1072 #endif | |
| 1073 #ifndef __NR_fstatfs64 | |
| 1074 #define __NR_fstatfs64 (__NR_Linux + 218) | |
| 1075 #endif | |
| 1076 #ifndef __NR_clock_gettime | |
| 1077 #define __NR_clock_gettime (__NR_Linux + 226) | |
| 1078 #endif | |
| 1079 #ifndef __NR_clock_getres | |
| 1080 #define __NR_clock_getres (__NR_Linux + 227) | |
| 1081 #endif | |
| 1082 #ifndef __NR_openat | 638 #ifndef __NR_openat |
| 1083 #define __NR_openat (__NR_Linux + 251) | 639 #define __NR_openat (__NR_Linux + 251) |
| 1084 #endif | 640 #endif |
| 1085 #ifndef __NR_fstatat | 641 #ifndef __NR_fstatat |
| 1086 #define __NR_fstatat (__NR_Linux + 256) | 642 #define __NR_fstatat (__NR_Linux + 256) |
| 1087 #endif | 643 #endif |
| 1088 #ifndef __NR_unlinkat | |
| 1089 #define __NR_unlinkat (__NR_Linux + 257) | |
| 1090 #endif | |
| 1091 #ifndef __NR_move_pages | |
| 1092 #define __NR_move_pages (__NR_Linux + 271) | |
| 1093 #endif | |
| 1094 #ifndef __NR_getcpu | 644 #ifndef __NR_getcpu |
| 1095 #define __NR_getcpu (__NR_Linux + 275) | 645 #define __NR_getcpu (__NR_Linux + 275) |
| 1096 #endif | 646 #endif |
| 1097 #ifndef __NR_ioprio_set | |
| 1098 #define __NR_ioprio_set (__NR_Linux + 277) | |
| 1099 #endif | |
| 1100 #ifndef __NR_ioprio_get | |
| 1101 #define __NR_ioprio_get (__NR_Linux + 278) | |
| 1102 #endif | |
| 1103 /* End of MIPS (new 32bit API) definitions */ | 647 /* End of MIPS (new 32bit API) definitions */ |
| 1104 #endif | 648 #endif |
| 1105 /* End of MIPS definitions */ | 649 /* End of MIPS definitions */ |
| 1106 #elif defined(__PPC__) | 650 #elif defined(__PPC__) |
| 1107 #ifndef __NR_setfsuid | |
| 1108 #define __NR_setfsuid 138 | |
| 1109 #define __NR_setfsgid 139 | |
| 1110 #endif | |
| 1111 #ifndef __NR_setresuid | |
| 1112 #define __NR_setresuid 164 | |
| 1113 #define __NR_setresgid 169 | |
| 1114 #endif | |
| 1115 #ifndef __NR_rt_sigaction | 651 #ifndef __NR_rt_sigaction |
| 1116 #define __NR_rt_sigaction 173 | 652 #define __NR_rt_sigaction 173 |
| 1117 #define __NR_rt_sigprocmask 174 | 653 #define __NR_rt_sigprocmask 174 |
| 1118 #define __NR_rt_sigpending 175 | |
| 1119 #define __NR_rt_sigsuspend 178 | |
| 1120 #endif | |
| 1121 #ifndef __NR_pread64 | |
| 1122 #define __NR_pread64 179 | |
| 1123 #endif | |
| 1124 #ifndef __NR_pwrite64 | |
| 1125 #define __NR_pwrite64 180 | |
| 1126 #endif | |
| 1127 #ifndef __NR_ugetrlimit | |
| 1128 #define __NR_ugetrlimit 190 | |
| 1129 #endif | |
| 1130 #ifndef __NR_readahead | |
| 1131 #define __NR_readahead 191 | |
| 1132 #endif | 654 #endif |
| 1133 #ifndef __NR_stat64 | 655 #ifndef __NR_stat64 |
| 1134 #define __NR_stat64 195 | 656 #define __NR_stat64 195 |
| 1135 #endif | 657 #endif |
| 1136 #ifndef __NR_fstat64 | 658 #ifndef __NR_fstat64 |
| 1137 #define __NR_fstat64 197 | 659 #define __NR_fstat64 197 |
| 1138 #endif | 660 #endif |
| 1139 #ifndef __NR_getdents64 | 661 #ifndef __NR_getdents64 |
| 1140 #define __NR_getdents64 202 | 662 #define __NR_getdents64 202 |
| 1141 #endif | 663 #endif |
| 1142 #ifndef __NR_gettid | 664 #ifndef __NR_gettid |
| 1143 #define __NR_gettid 207 | 665 #define __NR_gettid 207 |
| 1144 #endif | 666 #endif |
| 1145 #ifndef __NR_setxattr | |
| 1146 #define __NR_setxattr 209 | |
| 1147 #endif | |
| 1148 #ifndef __NR_lsetxattr | |
| 1149 #define __NR_lsetxattr 210 | |
| 1150 #endif | |
| 1151 #ifndef __NR_getxattr | |
| 1152 #define __NR_getxattr 212 | |
| 1153 #endif | |
| 1154 #ifndef __NR_lgetxattr | |
| 1155 #define __NR_lgetxattr 213 | |
| 1156 #endif | |
| 1157 #ifndef __NR_listxattr | |
| 1158 #define __NR_listxattr 215 | |
| 1159 #endif | |
| 1160 #ifndef __NR_llistxattr | |
| 1161 #define __NR_llistxattr 216 | |
| 1162 #endif | |
| 1163 #ifndef __NR_futex | 667 #ifndef __NR_futex |
| 1164 #define __NR_futex 221 | 668 #define __NR_futex 221 |
| 1165 #endif | 669 #endif |
| 1166 #ifndef __NR_sched_setaffinity | |
| 1167 #define __NR_sched_setaffinity 222 | |
| 1168 #define __NR_sched_getaffinity 223 | |
| 1169 #endif | |
| 1170 #ifndef __NR_set_tid_address | |
| 1171 #define __NR_set_tid_address 232 | |
| 1172 #endif | |
| 1173 #ifndef __NR_clock_gettime | |
| 1174 #define __NR_clock_gettime 246 | |
| 1175 #endif | |
| 1176 #ifndef __NR_clock_getres | |
| 1177 #define __NR_clock_getres 247 | |
| 1178 #endif | |
| 1179 #ifndef __NR_statfs64 | |
| 1180 #define __NR_statfs64 252 | |
| 1181 #endif | |
| 1182 #ifndef __NR_fstatfs64 | |
| 1183 #define __NR_fstatfs64 253 | |
| 1184 #endif | |
| 1185 #ifndef __NR_fadvise64_64 | |
| 1186 #define __NR_fadvise64_64 254 | |
| 1187 #endif | |
| 1188 #ifndef __NR_ioprio_set | |
| 1189 #define __NR_ioprio_set 273 | |
| 1190 #endif | |
| 1191 #ifndef __NR_ioprio_get | |
| 1192 #define __NR_ioprio_get 274 | |
| 1193 #endif | |
| 1194 #ifndef __NR_openat | 670 #ifndef __NR_openat |
| 1195 #define __NR_openat 286 | 671 #define __NR_openat 286 |
| 1196 #endif | 672 #endif |
| 1197 #ifndef __NR_fstatat64 | |
| 1198 #define __NR_fstatat64 291 | |
| 1199 #endif | |
| 1200 #ifndef __NR_unlinkat | |
| 1201 #define __NR_unlinkat 292 | |
| 1202 #endif | |
| 1203 #ifndef __NR_move_pages | |
| 1204 #define __NR_move_pages 301 | |
| 1205 #endif | |
| 1206 #ifndef __NR_getcpu | 673 #ifndef __NR_getcpu |
| 1207 #define __NR_getcpu 302 | 674 #define __NR_getcpu 302 |
| 1208 #endif | 675 #endif |
| 1209 /* End of powerpc defininitions */ | 676 /* End of powerpc defininitions */ |
| 1210 #endif | 677 #endif |
| 1211 | 678 |
| 1212 | 679 |
| 1213 /* After forking, we must make sure to only call system calls. */ | 680 /* After forking, we must make sure to only call system calls. */ |
| 1214 #if __BOUNDED_POINTERS__ | 681 #if __BOUNDED_POINTERS__ |
| 1215 #error "Need to port invocations of syscalls for bounded ptrs" | 682 #error "Need to port invocations of syscalls for bounded ptrs" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 #define LSS_NAME(name) sys6_##name | 729 #define LSS_NAME(name) sys6_##name |
| 1263 #elif SYS_PREFIX == 7 | 730 #elif SYS_PREFIX == 7 |
| 1264 #define LSS_NAME(name) sys7_##name | 731 #define LSS_NAME(name) sys7_##name |
| 1265 #elif SYS_PREFIX == 8 | 732 #elif SYS_PREFIX == 8 |
| 1266 #define LSS_NAME(name) sys8_##name | 733 #define LSS_NAME(name) sys8_##name |
| 1267 #elif SYS_PREFIX == 9 | 734 #elif SYS_PREFIX == 9 |
| 1268 #define LSS_NAME(name) sys9_##name | 735 #define LSS_NAME(name) sys9_##name |
| 1269 #endif | 736 #endif |
| 1270 | 737 |
| 1271 #undef LSS_RETURN | 738 #undef LSS_RETURN |
| 1272 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__)) | 739 #if (defined(__i386__) || defined(__x86_64__) || defined(__arm__)) |
| 1273 /* Failing system calls return a negative result in the range of | 740 /* Failing system calls return a negative result in the range of |
| 1274 * -1..-4095. These are "errno" values with the sign inverted. | 741 * -1..-4095. These are "errno" values with the sign inverted. |
| 1275 */ | 742 */ |
| 1276 #define LSS_RETURN(type, res) \ | 743 #define LSS_RETURN(type, res) \ |
| 1277 do { \ | 744 do { \ |
| 1278 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ | 745 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ |
| 1279 LSS_ERRNO = -(res); \ | 746 LSS_ERRNO = -(res); \ |
| 1280 res = -1; \ | 747 res = -1; \ |
| 1281 } \ | 748 } \ |
| 1282 return (type) (res); \ | 749 return (type) (res); \ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1300 #define LSS_RETURN(type, res, err) \ | 767 #define LSS_RETURN(type, res, err) \ |
| 1301 do { \ | 768 do { \ |
| 1302 if (err & 0x10000000 ) { \ | 769 if (err & 0x10000000 ) { \ |
| 1303 LSS_ERRNO = (res); \ | 770 LSS_ERRNO = (res); \ |
| 1304 res = -1; \ | 771 res = -1; \ |
| 1305 } \ | 772 } \ |
| 1306 return (type) (res); \ | 773 return (type) (res); \ |
| 1307 } while (0) | 774 } while (0) |
| 1308 #endif | 775 #endif |
| 1309 #if defined(__i386__) | 776 #if defined(__i386__) |
| 777 #if defined(NO_FRAME_POINTER) && (100 * __GNUC__ + __GNUC_MINOR__ >= 404) |
| 778 /* This only works for GCC-4.4 and above -- the first version to use |
| 779 .cfi directives for dwarf unwind info. */ |
| 780 #define CFI_ADJUST_CFA_OFFSET(adjust) \ |
| 781 ".cfi_adjust_cfa_offset " #adjust "\n" |
| 782 #else |
| 783 #define CFI_ADJUST_CFA_OFFSET(adjust) /**/ |
| 784 #endif |
| 785 |
| 1310 /* In PIC mode (e.g. when building shared libraries), gcc for i386 | 786 /* In PIC mode (e.g. when building shared libraries), gcc for i386 |
| 1311 * reserves ebx. Unfortunately, most distribution ship with implementations | 787 * reserves ebx. Unfortunately, most distribution ship with implementations |
| 1312 * of _syscallX() which clobber ebx. | 788 * of _syscallX() which clobber ebx. |
| 1313 * Also, most definitions of _syscallX() neglect to mark "memory" as being | 789 * Also, most definitions of _syscallX() neglect to mark "memory" as being |
| 1314 * clobbered. This causes problems with compilers, that do a better job | 790 * clobbered. This causes problems with compilers, that do a better job |
| 1315 * at optimizing across __asm__ calls. | 791 * at optimizing across __asm__ calls. |
| 1316 * So, we just have to redefine all of the _syscallX() macros. | 792 * So, we just have to redefine all of the _syscallX() macros. |
| 1317 */ | 793 */ |
| 1318 #undef LSS_BODY | 794 #undef LSS_BODY |
| 1319 #define LSS_BODY(type,args...) \ | 795 #define LSS_BODY(type,args...) \ |
| 1320 long __res; \ | 796 long __res; \ |
| 1321 __asm__ __volatile__("push %%ebx\n" \ | 797 __asm__ __volatile__("push %%ebx\n" \ |
| 798 CFI_ADJUST_CFA_OFFSET(4) \ |
| 1322 "movl %2,%%ebx\n" \ | 799 "movl %2,%%ebx\n" \ |
| 1323 "int $0x80\n" \ | 800 "int $0x80\n" \ |
| 1324 "pop %%ebx" \ | 801 "pop %%ebx\n" \ |
| 802 CFI_ADJUST_CFA_OFFSET(-4) \ |
| 1325 args \ | 803 args \ |
| 1326 : "memory"); \ | 804 : "esp", "memory"); \ |
| 1327 LSS_RETURN(type,__res) | 805 LSS_RETURN(type,__res) |
| 1328 #undef _syscall0 | 806 #undef _syscall0 |
| 1329 #define _syscall0(type,name) \ | 807 #define _syscall0(type,name) \ |
| 1330 type LSS_NAME(name)(void) { \ | 808 type LSS_NAME(name)(void) { \ |
| 1331 long __res; \ | 809 long __res; \ |
| 1332 __asm__ volatile("int $0x80" \ | 810 __asm__ volatile("int $0x80" \ |
| 1333 : "=a" (__res) \ | 811 : "=a" (__res) \ |
| 1334 : "0" (__NR_##name) \ | 812 : "0" (__NR_##name) \ |
| 1335 : "memory"); \ | 813 : "memory"); \ |
| 1336 LSS_RETURN(type,__res); \ | 814 LSS_RETURN(type,__res); \ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 long __res; \ | 851 long __res; \ |
| 1374 __asm__ __volatile__("push %%ebx\n" \ | 852 __asm__ __volatile__("push %%ebx\n" \ |
| 1375 "movl %2,%%ebx\n" \ | 853 "movl %2,%%ebx\n" \ |
| 1376 "movl %1,%%eax\n" \ | 854 "movl %1,%%eax\n" \ |
| 1377 "int $0x80\n" \ | 855 "int $0x80\n" \ |
| 1378 "pop %%ebx" \ | 856 "pop %%ebx" \ |
| 1379 : "=a" (__res) \ | 857 : "=a" (__res) \ |
| 1380 : "i" (__NR_##name), "ri" ((long)(arg1)), \ | 858 : "i" (__NR_##name), "ri" ((long)(arg1)), \ |
| 1381 "c" ((long)(arg2)), "d" ((long)(arg3)), \ | 859 "c" ((long)(arg2)), "d" ((long)(arg3)), \ |
| 1382 "S" ((long)(arg4)), "D" ((long)(arg5)) \ | 860 "S" ((long)(arg4)), "D" ((long)(arg5)) \ |
| 1383 : "memory"); \ | 861 : "esp", "memory"); \ |
| 1384 LSS_RETURN(type,__res); \ | 862 LSS_RETURN(type,__res); \ |
| 1385 } | 863 } |
| 1386 #undef _syscall6 | 864 #undef _syscall6 |
| 1387 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 865 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 1388 type5,arg5,type6,arg6) \ | 866 type5,arg5,type6,arg6) \ |
| 1389 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 867 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 1390 type5 arg5, type6 arg6) { \ | 868 type5 arg5, type6 arg6) { \ |
| 1391 long __res; \ | 869 long __res; \ |
| 1392 struct { long __a1; long __a6; } __s = { (long)arg1, (long) arg6 }; \ | 870 struct { long __a1; long __a6; } __s = { (long)arg1, (long) arg6 }; \ |
| 1393 __asm__ __volatile__("push %%ebp\n" \ | 871 __asm__ __volatile__("push %%ebp\n" \ |
| 1394 "push %%ebx\n" \ | 872 "push %%ebx\n" \ |
| 1395 "movl 4(%2),%%ebp\n" \ | 873 "movl 4(%2),%%ebp\n" \ |
| 1396 "movl 0(%2), %%ebx\n" \ | 874 "movl 0(%2), %%ebx\n" \ |
| 1397 "movl %1,%%eax\n" \ | 875 "movl %1,%%eax\n" \ |
| 1398 "int $0x80\n" \ | 876 "int $0x80\n" \ |
| 1399 "pop %%ebx\n" \ | 877 "pop %%ebx\n" \ |
| 1400 "pop %%ebp" \ | 878 "pop %%ebp" \ |
| 1401 : "=a" (__res) \ | 879 : "=a" (__res) \ |
| 1402 : "i" (__NR_##name), "0" ((long)(&__s)), \ | 880 : "i" (__NR_##name), "0" ((long)(&__s)), \ |
| 1403 "c" ((long)(arg2)), "d" ((long)(arg3)), \ | 881 "c" ((long)(arg2)), "d" ((long)(arg3)), \ |
| 1404 "S" ((long)(arg4)), "D" ((long)(arg5)) \ | 882 "S" ((long)(arg4)), "D" ((long)(arg5)) \ |
| 1405 : "memory"); \ | 883 : "esp", "memory"); \ |
| 1406 LSS_RETURN(type,__res); \ | 884 LSS_RETURN(type,__res); \ |
| 1407 } | 885 } |
| 1408 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, | 886 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, |
| 1409 int flags, void *arg, int *parent_tidptr, | 887 int flags, void *arg, int *parent_tidptr, |
| 1410 void *newtls, int *child_tidptr) { | 888 void *newtls, int *child_tidptr) { |
| 1411 long __res; | 889 long __res; |
| 1412 __asm__ __volatile__(/* if (fn == NULL) | 890 __asm__ __volatile__(/* if (fn == NULL) |
| 1413 * return -EINVAL; | 891 * return -EINVAL; |
| 1414 */ | 892 */ |
| 1415 "movl %3,%%ecx\n" | 893 "movl %3,%%ecx\n" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 "movl $1,%%eax\n" | 959 "movl $1,%%eax\n" |
| 1482 "int $0x80\n" | 960 "int $0x80\n" |
| 1483 | 961 |
| 1484 /* Return to parent. | 962 /* Return to parent. |
| 1485 */ | 963 */ |
| 1486 "1:\n" | 964 "1:\n" |
| 1487 : "=a" (__res) | 965 : "=a" (__res) |
| 1488 : "0"(-EINVAL), "i"(__NR_clone), | 966 : "0"(-EINVAL), "i"(__NR_clone), |
| 1489 "m"(fn), "m"(child_stack), "m"(flags), "m"(arg), | 967 "m"(fn), "m"(child_stack), "m"(flags), "m"(arg), |
| 1490 "m"(parent_tidptr), "m"(newtls), "m"(child_tidptr) | 968 "m"(parent_tidptr), "m"(newtls), "m"(child_tidptr) |
| 1491 : "memory", "ecx", "edx", "esi", "edi"); | 969 : "esp", "memory", "ecx", "edx", "esi", "edi"); |
| 1492 LSS_RETURN(int, __res); | 970 LSS_RETURN(int, __res); |
| 1493 } | 971 } |
| 1494 | 972 |
| 1495 #define __NR__fadvise64_64 __NR_fadvise64_64 | |
| 1496 LSS_INLINE _syscall6(int, _fadvise64_64, int, fd, | |
| 1497 unsigned, offset_lo, unsigned, offset_hi, | |
| 1498 unsigned, len_lo, unsigned, len_hi, | |
| 1499 int, advice) | |
| 1500 | |
| 1501 LSS_INLINE int LSS_NAME(fadvise64)(int fd, loff_t offset, | |
| 1502 loff_t len, int advice) { | |
| 1503 return LSS_NAME(_fadvise64_64)(fd, | |
| 1504 (unsigned)offset, (unsigned)(offset >>32), | |
| 1505 (unsigned)len, (unsigned)(len >> 32), | |
| 1506 advice); | |
| 1507 } | |
| 1508 | |
| 1509 #define __NR__fallocate __NR_fallocate | |
| 1510 LSS_INLINE _syscall6(int, _fallocate, int, fd, | |
| 1511 int, mode, | |
| 1512 unsigned, offset_lo, unsigned, offset_hi, | |
| 1513 unsigned, len_lo, unsigned, len_hi) | |
| 1514 | |
| 1515 LSS_INLINE int LSS_NAME(fallocate)(int fd, int mode, | |
| 1516 loff_t offset, loff_t len) { | |
| 1517 union { loff_t off; unsigned w[2]; } o = { offset }, l = { len }; | |
| 1518 return LSS_NAME(_fallocate)(fd, mode, o.w[0], o.w[1], l.w[0], l.w[1]); | |
| 1519 } | |
| 1520 | |
| 1521 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { | 973 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { |
| 1522 /* On i386, the kernel does not know how to return from a signal | 974 /* On i386, the kernel does not know how to return from a signal |
| 1523 * handler. Instead, it relies on user space to provide a | 975 * handler. Instead, it relies on user space to provide a |
| 1524 * restorer function that calls the {rt_,}sigreturn() system call. | 976 * restorer function that calls the {rt_,}sigreturn() system call. |
| 1525 * Unfortunately, we cannot just reference the glibc version of this | 977 * Unfortunately, we cannot just reference the glibc version of this |
| 1526 * function, as glibc goes out of its way to make it inaccessible. | 978 * function, as glibc goes out of its way to make it inaccessible. |
| 1527 */ | 979 */ |
| 1528 void (*res)(void); | 980 void (*res)(void); |
| 1529 __asm__ __volatile__("call 2f\n" | 981 __asm__ __volatile__("call 2f\n" |
| 1530 "0:.align 16\n" | 982 "0:.align 16\n" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 LSS_BODY(type, name, "D" ((long)(arg1)), "S" ((long)(arg2)), \ | 1041 LSS_BODY(type, name, "D" ((long)(arg1)), "S" ((long)(arg2)), \ |
| 1590 "d" ((long)(arg3))); \ | 1042 "d" ((long)(arg3))); \ |
| 1591 } | 1043 } |
| 1592 #undef _syscall4 | 1044 #undef _syscall4 |
| 1593 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ | 1045 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ |
| 1594 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ | 1046 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ |
| 1595 long __res; \ | 1047 long __res; \ |
| 1596 __asm__ __volatile__("movq %5,%%r10; syscall" : \ | 1048 __asm__ __volatile__("movq %5,%%r10; syscall" : \ |
| 1597 "=a" (__res) : "0" (__NR_##name), \ | 1049 "=a" (__res) : "0" (__NR_##name), \ |
| 1598 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ | 1050 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ |
| 1599 "g" ((long)(arg4)) : "r10", "r11", "rcx", "memory"); \ | 1051 "r" ((long)(arg4)) : "r10", "r11", "rcx", "memory"); \ |
| 1600 LSS_RETURN(type, __res); \ | 1052 LSS_RETURN(type, __res); \ |
| 1601 } | 1053 } |
| 1602 #undef _syscall5 | 1054 #undef _syscall5 |
| 1603 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 1055 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 1604 type5,arg5) \ | 1056 type5,arg5) \ |
| 1605 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 1057 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 1606 type5 arg5) { \ | 1058 type5 arg5) { \ |
| 1607 long __res; \ | 1059 long __res; \ |
| 1608 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; syscall" : \ | 1060 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; syscall" : \ |
| 1609 "=a" (__res) : "0" (__NR_##name), \ | 1061 "=a" (__res) : "0" (__NR_##name), \ |
| 1610 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ | 1062 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ |
| 1611 "g" ((long)(arg4)), "g" ((long)(arg5)) : \ | 1063 "r" ((long)(arg4)), "r" ((long)(arg5)) : \ |
| 1612 "r8", "r10", "r11", "rcx", "memory"); \ | 1064 "r8", "r10", "r11", "rcx", "memory"); \ |
| 1613 LSS_RETURN(type, __res); \ | 1065 LSS_RETURN(type, __res); \ |
| 1614 } | 1066 } |
| 1615 #undef _syscall6 | 1067 #undef _syscall6 |
| 1616 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 1068 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 1617 type5,arg5,type6,arg6) \ | 1069 type5,arg5,type6,arg6) \ |
| 1618 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 1070 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 1619 type5 arg5, type6 arg6) { \ | 1071 type5 arg5, type6 arg6) { \ |
| 1620 long __res; \ | 1072 long __res; \ |
| 1621 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; movq %7,%%r9;" \ | 1073 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; movq %7,%%r9;" \ |
| 1622 "syscall" : \ | 1074 "syscall" : \ |
| 1623 "=a" (__res) : "0" (__NR_##name), \ | 1075 "=a" (__res) : "0" (__NR_##name), \ |
| 1624 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ | 1076 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ |
| 1625 "g" ((long)(arg4)), "g" ((long)(arg5)), "g" ((long)(arg6)) : \ | 1077 "r" ((long)(arg4)), "r" ((long)(arg5)), "r" ((long)(arg6)) : \ |
| 1626 "r8", "r9", "r10", "r11", "rcx", "memory"); \ | 1078 "r8", "r9", "r10", "r11", "rcx", "memory"); \ |
| 1627 LSS_RETURN(type, __res); \ | 1079 LSS_RETURN(type, __res); \ |
| 1628 } | 1080 } |
| 1629 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, | 1081 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, |
| 1630 int flags, void *arg, int *parent_tidptr, | 1082 int flags, void *arg, int *parent_tidptr, |
| 1631 void *newtls, int *child_tidptr) { | 1083 void *newtls, int *child_tidptr) { |
| 1632 long __res; | 1084 long __res; |
| 1633 { | 1085 { |
| 1634 register void *__tls __asm__("r8") = newtls; | |
| 1635 register int *__ctid __asm__("r10") = child_tidptr; | |
| 1636 __asm__ __volatile__(/* if (fn == NULL) | 1086 __asm__ __volatile__(/* if (fn == NULL) |
| 1637 * return -EINVAL; | 1087 * return -EINVAL; |
| 1638 */ | 1088 */ |
| 1639 "testq %4,%4\n" | 1089 "testq %4,%4\n" |
| 1640 "jz 1f\n" | 1090 "jz 1f\n" |
| 1641 | 1091 |
| 1642 /* if (child_stack == NULL) | 1092 /* if (child_stack == NULL) |
| 1643 * return -EINVAL; | 1093 * return -EINVAL; |
| 1644 */ | 1094 */ |
| 1645 "testq %5,%5\n" | 1095 "testq %5,%5\n" |
| 1646 "jz 1f\n" | 1096 "jz 1f\n" |
| 1647 | 1097 |
| 1648 /* childstack -= 2*sizeof(void *); | 1098 /* Set up alignment of the child stack: |
| 1099 * child_stack = (child_stack & ~0xF) - 16; |
| 1649 */ | 1100 */ |
| 1101 "andq $-16,%5\n" |
| 1650 "subq $16,%5\n" | 1102 "subq $16,%5\n" |
| 1651 | 1103 |
| 1652 /* Push "arg" and "fn" onto the stack that will be | 1104 /* Push "arg" and "fn" onto the stack that will be |
| 1653 * used by the child. | 1105 * used by the child. |
| 1654 */ | 1106 */ |
| 1655 "movq %7,8(%5)\n" | 1107 "movq %7,8(%5)\n" |
| 1656 "movq %4,0(%5)\n" | 1108 "movq %4,0(%5)\n" |
| 1657 | 1109 |
| 1658 /* %rax = syscall(%rax = __NR_clone, | 1110 /* %rax = syscall(%rax = __NR_clone, |
| 1659 * %rdi = flags, | 1111 * %rdi = flags, |
| 1660 * %rsi = child_stack, | 1112 * %rsi = child_stack, |
| 1661 * %rdx = parent_tidptr, | 1113 * %rdx = parent_tidptr, |
| 1662 * %r8 = new_tls, | 1114 * %r8 = new_tls, |
| 1663 * %r10 = child_tidptr) | 1115 * %r10 = child_tidptr) |
| 1664 */ | 1116 */ |
| 1665 "movq %2,%%rax\n" | 1117 "movq %2,%%rax\n" |
| 1118 "movq %9,%%r8\n" |
| 1119 "movq %10,%%r10\n" |
| 1666 "syscall\n" | 1120 "syscall\n" |
| 1667 | 1121 |
| 1668 /* if (%rax != 0) | 1122 /* if (%rax != 0) |
| 1669 * return; | 1123 * return; |
| 1670 */ | 1124 */ |
| 1671 "testq %%rax,%%rax\n" | 1125 "testq %%rax,%%rax\n" |
| 1672 "jnz 1f\n" | 1126 "jnz 1f\n" |
| 1673 | 1127 |
| 1674 /* In the child. Terminate frame pointer chain. | 1128 /* In the child. Terminate frame pointer chain. |
| 1675 */ | 1129 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1686 "movq %%rax,%%rdi\n" | 1140 "movq %%rax,%%rdi\n" |
| 1687 "movq %3,%%rax\n" | 1141 "movq %3,%%rax\n" |
| 1688 "syscall\n" | 1142 "syscall\n" |
| 1689 | 1143 |
| 1690 /* Return to parent. | 1144 /* Return to parent. |
| 1691 */ | 1145 */ |
| 1692 "1:\n" | 1146 "1:\n" |
| 1693 : "=a" (__res) | 1147 : "=a" (__res) |
| 1694 : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), | 1148 : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), |
| 1695 "r"(fn), "S"(child_stack), "D"(flags), "r"(arg), | 1149 "r"(fn), "S"(child_stack), "D"(flags), "r"(arg), |
| 1696 "d"(parent_tidptr), "r"(__tls), "r"(__ctid) | 1150 "d"(parent_tidptr), "g"(newtls), "g"(child_tidptr
) |
| 1697 : "memory", "r11", "rcx"); | 1151 : "rsp", "memory", "r8", "r10", "r11", "rcx"); |
| 1698 } | 1152 } |
| 1699 LSS_RETURN(int, __res); | 1153 LSS_RETURN(int, __res); |
| 1700 } | 1154 } |
| 1701 LSS_INLINE _syscall4(int, fadvise64, int, fd, loff_t, offset, loff_t, len, | |
| 1702 int, advice) | |
| 1703 | 1155 |
| 1704 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { | 1156 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { |
| 1705 /* On x86-64, the kernel does not know how to return from | 1157 /* On x86-64, the kernel does not know how to return from |
| 1706 * a signal handler. Instead, it relies on user space to provide a | 1158 * a signal handler. Instead, it relies on user space to provide a |
| 1707 * restorer function that calls the rt_sigreturn() system call. | 1159 * restorer function that calls the rt_sigreturn() system call. |
| 1708 * Unfortunately, we cannot just reference the glibc version of this | 1160 * Unfortunately, we cannot just reference the glibc version of this |
| 1709 * function, as glibc goes out of its way to make it inaccessible. | 1161 * function, as glibc goes out of its way to make it inaccessible. |
| 1710 */ | 1162 */ |
| 1711 void (*res)(void); | 1163 void (*res)(void); |
| 1712 __asm__ __volatile__("call 2f\n" | 1164 __asm__ __volatile__("call 2f\n" |
| 1713 "0:.align 16\n" | 1165 "0:.align 16\n" |
| 1714 "1:movq %1,%%rax\n" | 1166 "1:movq %1,%%rax\n" |
| 1715 "syscall\n" | 1167 "syscall\n" |
| 1716 "2:popq %0\n" | 1168 "2:popq %0\n" |
| 1717 "addq $(1b-0b),%0\n" | 1169 "addq $(1b-0b),%0\n" |
| 1718 : "=a" (res) | 1170 : "=a" (res) |
| 1719 : "i" (__NR_rt_sigreturn)); | 1171 : "i" (__NR_rt_sigreturn)); |
| 1720 return res; | 1172 return res; |
| 1721 } | 1173 } |
| 1722 #elif defined(__ARM_ARCH_3__) | 1174 #elif defined(__arm__) |
| 1723 /* Most definitions of _syscallX() neglect to mark "memory" as being | 1175 /* Most definitions of _syscallX() neglect to mark "memory" as being |
| 1724 * clobbered. This causes problems with compilers, that do a better job | 1176 * clobbered. This causes problems with compilers, that do a better job |
| 1725 * at optimizing across __asm__ calls. | 1177 * at optimizing across __asm__ calls. |
| 1726 * So, we just have to redefine all fo the _syscallX() macros. | 1178 * So, we just have to redefine all fo the _syscallX() macros. |
| 1727 */ | 1179 */ |
| 1728 #undef LSS_REG | 1180 #undef LSS_REG |
| 1729 #define LSS_REG(r,a) register long __r##r __asm__("r"#r) = (long)a | 1181 #define LSS_REG(r,a) register long __r##r __asm__("r"#r) = (long)a |
| 1182 |
| 1183 /* r0..r3 are scratch registers and not preserved across function |
| 1184 * calls. We need to first evaluate the first 4 syscall arguments |
| 1185 * and store them on stack. They must be loaded into r0..r3 after |
| 1186 * all function calls to avoid r0..r3 being clobbered. |
| 1187 */ |
| 1188 #undef LSS_SAVE_ARG |
| 1189 #define LSS_SAVE_ARG(r,a) long __tmp##r = (long)a |
| 1190 #undef LSS_LOAD_ARG |
| 1191 #define LSS_LOAD_ARG(r) register long __r##r __asm__("r"#r) = __tmp##r |
| 1192 |
| 1730 #undef LSS_BODY | 1193 #undef LSS_BODY |
| 1731 #define LSS_BODY(type,name,args...) \ | 1194 #define LSS_BODY(type, name, args...) \ |
| 1732 register long __res_r0 __asm__("r0"); \ | 1195 register long __res_r0 __asm__("r0"); \ |
| 1733 long __res; \ | 1196 long __res; \ |
| 1734 __asm__ __volatile__ (__syscall(name) \ | 1197 __SYS_REG(name) \ |
| 1735 : "=r"(__res_r0) : args : "lr", "memory"); \ | 1198 __asm__ __volatile__ (__syscall_safe(name) \ |
| 1199 : "=r"(__res_r0) \ |
| 1200 : __SYS_REG_LIST(args) \ |
| 1201 : "lr", "memory"); \ |
| 1736 __res = __res_r0; \ | 1202 __res = __res_r0; \ |
| 1737 LSS_RETURN(type, __res) | 1203 LSS_RETURN(type, __res) |
| 1738 #undef _syscall0 | 1204 #undef _syscall0 |
| 1739 #define _syscall0(type, name) \ | 1205 #define _syscall0(type, name) \ |
| 1740 type LSS_NAME(name)() { \ | 1206 type LSS_NAME(name)() { \ |
| 1741 LSS_BODY(type, name); \ | 1207 LSS_BODY(type, name); \ |
| 1742 } | 1208 } |
| 1743 #undef _syscall1 | 1209 #undef _syscall1 |
| 1744 #define _syscall1(type, name, type1, arg1) \ | 1210 #define _syscall1(type, name, type1, arg1) \ |
| 1745 type LSS_NAME(name)(type1 arg1) { \ | 1211 type LSS_NAME(name)(type1 arg1) { \ |
| 1746 LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ | 1212 /* There is no need for using a volatile temp. */ \ |
| 1213 LSS_REG(0, arg1); \ |
| 1214 LSS_BODY(type, name, "r"(__r0)); \ |
| 1747 } | 1215 } |
| 1748 #undef _syscall2 | 1216 #undef _syscall2 |
| 1749 #define _syscall2(type, name, type1, arg1, type2, arg2) \ | 1217 #define _syscall2(type, name, type1, arg1, type2, arg2) \ |
| 1750 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ | 1218 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ |
| 1751 LSS_REG(0, arg1); LSS_REG(1, arg2); \ | 1219 LSS_SAVE_ARG(0, arg1); \ |
| 1220 LSS_SAVE_ARG(1, arg2); \ |
| 1221 LSS_LOAD_ARG(0); \ |
| 1222 LSS_LOAD_ARG(1); \ |
| 1752 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ | 1223 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ |
| 1753 } | 1224 } |
| 1754 #undef _syscall3 | 1225 #undef _syscall3 |
| 1755 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ | 1226 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ |
| 1756 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ | 1227 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ |
| 1757 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ | 1228 LSS_SAVE_ARG(0, arg1); \ |
| 1229 LSS_SAVE_ARG(1, arg2); \ |
| 1230 LSS_SAVE_ARG(2, arg3); \ |
| 1231 LSS_LOAD_ARG(0); \ |
| 1232 LSS_LOAD_ARG(1); \ |
| 1233 LSS_LOAD_ARG(2); \ |
| 1758 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ | 1234 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ |
| 1759 } | 1235 } |
| 1760 #undef _syscall4 | 1236 #undef _syscall4 |
| 1761 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ | 1237 #define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ |
| 1238 type4, arg4) \ |
| 1762 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ | 1239 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ |
| 1763 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ | 1240 LSS_SAVE_ARG(0, arg1); \ |
| 1764 LSS_REG(3, arg4); \ | 1241 LSS_SAVE_ARG(1, arg2); \ |
| 1242 LSS_SAVE_ARG(2, arg3); \ |
| 1243 LSS_SAVE_ARG(3, arg4); \ |
| 1244 LSS_LOAD_ARG(0); \ |
| 1245 LSS_LOAD_ARG(1); \ |
| 1246 LSS_LOAD_ARG(2); \ |
| 1247 LSS_LOAD_ARG(3); \ |
| 1765 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ | 1248 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ |
| 1766 } | 1249 } |
| 1767 #undef _syscall5 | 1250 #undef _syscall5 |
| 1768 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 1251 #define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ |
| 1769 type5,arg5) \ | 1252 type4, arg4, type5, arg5) \ |
| 1770 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 1253 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 1771 type5 arg5) { \ | 1254 type5 arg5) { \ |
| 1772 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ | 1255 LSS_SAVE_ARG(0, arg1); \ |
| 1773 LSS_REG(3, arg4); LSS_REG(4, arg5); \ | 1256 LSS_SAVE_ARG(1, arg2); \ |
| 1257 LSS_SAVE_ARG(2, arg3); \ |
| 1258 LSS_SAVE_ARG(3, arg4); \ |
| 1259 LSS_REG(4, arg5); \ |
| 1260 LSS_LOAD_ARG(0); \ |
| 1261 LSS_LOAD_ARG(1); \ |
| 1262 LSS_LOAD_ARG(2); \ |
| 1263 LSS_LOAD_ARG(3); \ |
| 1774 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ | 1264 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ |
| 1775 "r"(__r4)); \ | 1265 "r"(__r4)); \ |
| 1776 } | 1266 } |
| 1777 #undef _syscall6 | 1267 #undef _syscall6 |
| 1778 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 1268 #define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ |
| 1779 type5,arg5,type6,arg6) \ | 1269 type4, arg4, type5, arg5, type6, arg6) \ |
| 1780 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 1270 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 1781 type5 arg5, type6 arg6) { \ | 1271 type5 arg5, type6 arg6) { \ |
| 1782 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ | 1272 LSS_SAVE_ARG(0, arg1); \ |
| 1783 LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ | 1273 LSS_SAVE_ARG(1, arg2); \ |
| 1274 LSS_SAVE_ARG(2, arg3); \ |
| 1275 LSS_SAVE_ARG(3, arg4); \ |
| 1276 LSS_REG(4, arg5); \ |
| 1277 LSS_REG(5, arg6); \ |
| 1278 LSS_LOAD_ARG(0); \ |
| 1279 LSS_LOAD_ARG(1); \ |
| 1280 LSS_LOAD_ARG(2); \ |
| 1281 LSS_LOAD_ARG(3); \ |
| 1784 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ | 1282 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ |
| 1785 "r"(__r4), "r"(__r5)); \ | 1283 "r"(__r4), "r"(__r5)); \ |
| 1786 } | 1284 } |
| 1787 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, | 1285 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, |
| 1788 int flags, void *arg, int *parent_tidptr, | 1286 int flags, void *arg, int *parent_tidptr, |
| 1789 void *newtls, int *child_tidptr) { | 1287 void *newtls, int *child_tidptr) { |
| 1790 long __res; | 1288 register long __res __asm__("r5"); |
| 1791 { | 1289 { |
| 1792 register int __flags __asm__("r0") = flags; | 1290 if (fn == NULL || child_stack == NULL) { |
| 1793 register void *__stack __asm__("r1") = child_stack; | 1291 __res = -EINVAL; |
| 1794 register void *__ptid __asm__("r2") = parent_tidptr; | 1292 goto clone_exit; |
| 1795 register void *__tls __asm__("r3") = newtls; | 1293 } |
| 1294 |
| 1295 /* stash first 4 arguments on stack first because we can only load |
| 1296 * them after all function calls. |
| 1297 */ |
| 1298 int tmp_flags = flags; |
| 1299 int * tmp_stack = (int*) child_stack; |
| 1300 void * tmp_ptid = parent_tidptr; |
| 1301 void * tmp_tls = newtls; |
| 1302 |
| 1796 register int *__ctid __asm__("r4") = child_tidptr; | 1303 register int *__ctid __asm__("r4") = child_tidptr; |
| 1797 __asm__ __volatile__(/* if (fn == NULL || child_stack == NULL) | |
| 1798 * return -EINVAL; | |
| 1799 */ | |
| 1800 "cmp %2,#0\n" | |
| 1801 "cmpne %3,#0\n" | |
| 1802 "moveq %0,%1\n" | |
| 1803 "beq 1f\n" | |
| 1804 | 1304 |
| 1805 /* Push "arg" and "fn" onto the stack that will be | 1305 /* Push "arg" and "fn" onto the stack that will be |
| 1806 * used by the child. | 1306 * used by the child. |
| 1807 */ | 1307 */ |
| 1808 "str %5,[%3,#-4]!\n" | 1308 *(--tmp_stack) = (int) arg; |
| 1809 "str %2,[%3,#-4]!\n" | 1309 *(--tmp_stack) = (int) fn; |
| 1810 | 1310 |
| 1811 /* %r0 = syscall(%r0 = flags, | 1311 /* We must load r0..r3 last after all possible function calls. */ |
| 1312 register int __flags __asm__("r0") = tmp_flags; |
| 1313 register void *__stack __asm__("r1") = tmp_stack; |
| 1314 register void *__ptid __asm__("r2") = tmp_ptid; |
| 1315 register void *__tls __asm__("r3") = tmp_tls; |
| 1316 |
| 1317 /* %r0 = syscall(%r0 = flags, |
| 1318 * %r1 = child_stack, |
| 1319 * %r2 = parent_tidptr, |
| 1320 * %r3 = newtls, |
| 1321 * %r4 = child_tidptr) |
| 1322 */ |
| 1323 __SYS_REG(clone) |
| 1324 __asm__ __volatile__(/* %r0 = syscall(%r0 = flags, |
| 1812 * %r1 = child_stack, | 1325 * %r1 = child_stack, |
| 1813 * %r2 = parent_tidptr, | 1326 * %r2 = parent_tidptr, |
| 1814 * %r3 = newtls, | 1327 * %r3 = newtls, |
| 1815 * %r4 = child_tidptr) | 1328 * %r4 = child_tidptr) |
| 1816 */ | 1329 */ |
| 1330 "push {r7}\n" |
| 1331 "mov r7,%1\n" |
| 1817 __syscall(clone)"\n" | 1332 __syscall(clone)"\n" |
| 1818 | 1333 |
| 1819 /* if (%r0 != 0) | 1334 /* if (%r0 != 0) |
| 1820 * return %r0; | 1335 * return %r0; |
| 1821 */ | 1336 */ |
| 1822 "movs %0,r0\n" | 1337 "movs %0,r0\n" |
| 1823 "bne 1f\n" | 1338 "bne 1f\n" |
| 1824 | 1339 |
| 1825 /* In the child, now. Call "fn(arg)". | 1340 /* In the child, now. Call "fn(arg)". |
| 1826 */ | 1341 */ |
| 1827 "ldr r0,[sp, #4]\n" | 1342 "ldr r0,[sp, #4]\n" |
| 1828 "mov lr,pc\n" | 1343 "mov lr,pc\n" |
| 1829 "ldr pc,[sp]\n" | 1344 "ldr pc,[sp]\n" |
| 1830 | 1345 |
| 1831 /* Call _exit(%r0). | 1346 /* Call _exit(%r0), which never returns. We only |
| 1347 * need to set r7 for EABI syscall ABI but we do |
| 1348 * this always to simplify code sharing between |
| 1349 * old and new syscall ABIs. |
| 1832 */ | 1350 */ |
| 1351 "mov r7,%2\n" |
| 1833 __syscall(exit)"\n" | 1352 __syscall(exit)"\n" |
| 1834 "1:\n" | 1353 |
| 1354 /* Pop r7 from the stack only in the parent. |
| 1355 */ |
| 1356 "1: pop {r7}\n" |
| 1835 : "=r" (__res) | 1357 : "=r" (__res) |
| 1836 : "i"(-EINVAL), | 1358 : "r"(__sysreg), |
| 1837 "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), | 1359 "i"(__NR_exit), "r"(__stack), "r"(__flags), |
| 1838 "r"(__ptid), "r"(__tls), "r"(__ctid) | 1360 "r"(__ptid), "r"(__tls), "r"(__ctid) |
| 1839 : "lr", "memory"); | 1361 : "cc", "lr", "memory"); |
| 1840 } | 1362 } |
| 1363 clone_exit: |
| 1841 LSS_RETURN(int, __res); | 1364 LSS_RETURN(int, __res); |
| 1842 } | 1365 } |
| 1843 #elif defined(__mips__) | 1366 #elif defined(__mips__) |
| 1844 #undef LSS_REG | 1367 #undef LSS_REG |
| 1845 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \ | 1368 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \ |
| 1846 (unsigned long)(a) | 1369 (unsigned long)(a) |
| 1370 |
| 1371 #if _MIPS_SIM == _MIPS_SIM_ABI32 |
| 1372 // See http://sources.redhat.com/ml/libc-alpha/2004-10/msg00050.html |
| 1373 // or http://www.linux-mips.org/archives/linux-mips/2004-10/msg00142.html |
| 1374 #define MIPS_SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12",\ |
| 1375 "$13", "$14", "$15", "$24", "$25", "memory" |
| 1376 #else |
| 1377 #define MIPS_SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \ |
| 1378 "$14", "$15", "$24", "$25", "memory" |
| 1379 #endif |
| 1380 |
| 1847 #undef LSS_BODY | 1381 #undef LSS_BODY |
| 1848 #define LSS_BODY(type,name,r7,...) \ | 1382 #define LSS_BODY(type,name,r7,...) \ |
| 1849 register unsigned long __v0 __asm__("$2") = __NR_##name; \ | 1383 register unsigned long __v0 __asm__("$2") = __NR_##name; \ |
| 1850 __asm__ __volatile__ ("syscall\n" \ | 1384 __asm__ __volatile__ ("syscall\n" \ |
| 1851 : "=&r"(__v0), r7 (__r7) \ | 1385 : "=&r"(__v0), r7 (__r7) \ |
| 1852 : "0"(__v0), ##__VA_ARGS__ \ | 1386 : "0"(__v0), ##__VA_ARGS__ \ |
| 1853 : "$8", "$9", "$10", "$11", "$12", \ | 1387 : MIPS_SYSCALL_CLOBBERS); \ |
| 1854 "$13", "$14", "$15", "$24", "memory"); \ | |
| 1855 LSS_RETURN(type, __v0, __r7) | 1388 LSS_RETURN(type, __v0, __r7) |
| 1856 #undef _syscall0 | 1389 #undef _syscall0 |
| 1857 #define _syscall0(type, name) \ | 1390 #define _syscall0(type, name) \ |
| 1858 type LSS_NAME(name)() { \ | 1391 type LSS_NAME(name)() { \ |
| 1859 register unsigned long __r7 __asm__("$7"); \ | 1392 register unsigned long __r7 __asm__("$7"); \ |
| 1860 LSS_BODY(type, name, "=r"); \ | 1393 LSS_BODY(type, name, "=r"); \ |
| 1861 } | 1394 } |
| 1862 #undef _syscall1 | 1395 #undef _syscall1 |
| 1863 #define _syscall1(type, name, type1, arg1) \ | 1396 #define _syscall1(type, name, type1, arg1) \ |
| 1864 type LSS_NAME(name)(type1 arg1) { \ | 1397 type LSS_NAME(name)(type1 arg1) { \ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 "lw $2, %6\n" \ | 1435 "lw $2, %6\n" \ |
| 1903 "subu $29, 32\n" \ | 1436 "subu $29, 32\n" \ |
| 1904 "sw $2, 16($29)\n" \ | 1437 "sw $2, 16($29)\n" \ |
| 1905 "li $2, %2\n" \ | 1438 "li $2, %2\n" \ |
| 1906 "syscall\n" \ | 1439 "syscall\n" \ |
| 1907 "addiu $29, 32\n" \ | 1440 "addiu $29, 32\n" \ |
| 1908 ".set reorder\n" \ | 1441 ".set reorder\n" \ |
| 1909 : "=&r"(__v0), "+r" (__r7) \ | 1442 : "=&r"(__v0), "+r" (__r7) \ |
| 1910 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ | 1443 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ |
| 1911 "r"(__r6), "m" ((unsigned long)arg5) \ | 1444 "r"(__r6), "m" ((unsigned long)arg5) \ |
| 1912 : "$8", "$9", "$10", "$11", "$12", \ | 1445 : MIPS_SYSCALL_CLOBBERS); \ |
| 1913 "$13", "$14", "$15", "$24", "memory"); \ | |
| 1914 LSS_RETURN(type, __v0, __r7); \ | 1446 LSS_RETURN(type, __v0, __r7); \ |
| 1915 } | 1447 } |
| 1916 #else | 1448 #else |
| 1917 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 1449 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 1918 type5,arg5) \ | 1450 type5,arg5) \ |
| 1919 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 1451 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 1920 type5 arg5) { \ | 1452 type5 arg5) { \ |
| 1921 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ | 1453 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ |
| 1922 LSS_REG(7, arg4); LSS_REG(8, arg5); \ | 1454 LSS_REG(7, arg4); LSS_REG(8, arg5); \ |
| 1923 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ | 1455 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1943 "sw $2, 16($29)\n" \ | 1475 "sw $2, 16($29)\n" \ |
| 1944 "sw $8, 20($29)\n" \ | 1476 "sw $8, 20($29)\n" \ |
| 1945 "li $2, %2\n" \ | 1477 "li $2, %2\n" \ |
| 1946 "syscall\n" \ | 1478 "syscall\n" \ |
| 1947 "addiu $29, 32\n" \ | 1479 "addiu $29, 32\n" \ |
| 1948 ".set reorder\n" \ | 1480 ".set reorder\n" \ |
| 1949 : "=&r"(__v0), "+r" (__r7) \ | 1481 : "=&r"(__v0), "+r" (__r7) \ |
| 1950 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ | 1482 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ |
| 1951 "r"(__r6), "r" ((unsigned long)arg5), \ | 1483 "r"(__r6), "r" ((unsigned long)arg5), \ |
| 1952 "r" ((unsigned long)arg6) \ | 1484 "r" ((unsigned long)arg6) \ |
| 1953 : "$8", "$9", "$10", "$11", "$12", \ | 1485 : MIPS_SYSCALL_CLOBBERS); \ |
| 1954 "$13", "$14", "$15", "$24", "memory"); \ | |
| 1955 LSS_RETURN(type, __v0, __r7); \ | 1486 LSS_RETURN(type, __v0, __r7); \ |
| 1956 } | 1487 } |
| 1957 #else | 1488 #else |
| 1958 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 1489 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 1959 type5,arg5,type6,arg6) \ | 1490 type5,arg5,type6,arg6) \ |
| 1960 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 1491 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 1961 type5 arg5,type6 arg6) { \ | 1492 type5 arg5,type6 arg6) { \ |
| 1962 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ | 1493 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ |
| 1963 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \ | 1494 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \ |
| 1964 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ | 1495 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2240 "r" (__ctidptr) | 1771 "r" (__ctidptr) |
| 2241 : "cr0", "cr1", "memory", "ctr", | 1772 : "cr0", "cr1", "memory", "ctr", |
| 2242 "r0", "r29", "r27", "r28"); | 1773 "r0", "r29", "r27", "r28"); |
| 2243 } | 1774 } |
| 2244 LSS_RETURN(int, __ret, __err); | 1775 LSS_RETURN(int, __ret, __err); |
| 2245 } | 1776 } |
| 2246 #endif | 1777 #endif |
| 2247 #define __NR__exit __NR_exit | 1778 #define __NR__exit __NR_exit |
| 2248 #define __NR__gettid __NR_gettid | 1779 #define __NR__gettid __NR_gettid |
| 2249 #define __NR__mremap __NR_mremap | 1780 #define __NR__mremap __NR_mremap |
| 2250 LSS_INLINE _syscall1(int, chdir, const char *,p) | |
| 2251 LSS_INLINE _syscall1(int, close, int, f) | 1781 LSS_INLINE _syscall1(int, close, int, f) |
| 2252 LSS_INLINE _syscall2(int, clock_getres, int, c, | |
| 2253 struct kernel_timespec*, t) | |
| 2254 LSS_INLINE _syscall2(int, clock_gettime, int, c, | |
| 2255 struct kernel_timespec*, t) | |
| 2256 LSS_INLINE _syscall1(int, dup, int, f) | |
| 2257 LSS_INLINE _syscall2(int, dup2, int, s, | |
| 2258 int, d) | |
| 2259 LSS_INLINE _syscall3(int, execve, const char*, f, | |
| 2260 const char*const*,a,const char*const*, e) | |
| 2261 LSS_INLINE _syscall1(int, _exit, int, e) | 1782 LSS_INLINE _syscall1(int, _exit, int, e) |
| 2262 LSS_INLINE _syscall3(int, fcntl, int, f, | 1783 LSS_INLINE _syscall3(int, fcntl, int, f, |
| 2263 int, c, long, a) | 1784 int, c, long, a) |
| 2264 LSS_INLINE _syscall0(pid_t, fork) | |
| 2265 LSS_INLINE _syscall2(int, fstat, int, f, | 1785 LSS_INLINE _syscall2(int, fstat, int, f, |
| 2266 struct kernel_stat*, b) | 1786 struct kernel_stat*, b) |
| 2267 LSS_INLINE _syscall2(int, fstatfs, int, f, | |
| 2268 struct kernel_statfs*, b) | |
| 2269 LSS_INLINE _syscall4(int, futex, int*, a, | 1787 LSS_INLINE _syscall4(int, futex, int*, a, |
| 2270 int, o, int, v, | 1788 int, o, int, v, |
| 2271 struct kernel_timespec*, t) | 1789 struct kernel_timespec*, t) |
| 2272 LSS_INLINE _syscall3(int, getdents, int, f, | 1790 LSS_INLINE _syscall3(int, getdents, int, f, |
| 2273 struct kernel_dirent*, d, int, c) | 1791 struct kernel_dirent*, d, int, c) |
| 1792 #ifdef __NR_getdents64 |
| 2274 LSS_INLINE _syscall3(int, getdents64, int, f, | 1793 LSS_INLINE _syscall3(int, getdents64, int, f, |
| 2275 struct kernel_dirent64*, d, int, c) | 1794 struct kernel_dirent64*, d, int, c) |
| 2276 LSS_INLINE _syscall0(gid_t, getegid) | 1795 #endif |
| 2277 LSS_INLINE _syscall0(uid_t, geteuid) | |
| 2278 LSS_INLINE _syscall0(pid_t, getpgrp) | |
| 2279 LSS_INLINE _syscall0(pid_t, getpid) | 1796 LSS_INLINE _syscall0(pid_t, getpid) |
| 2280 LSS_INLINE _syscall0(pid_t, getppid) | 1797 LSS_INLINE _syscall0(pid_t, getppid) |
| 2281 LSS_INLINE _syscall2(int, getpriority, int, a, | |
| 2282 int, b) | |
| 2283 LSS_INLINE _syscall2(int, getrlimit, int, r, | |
| 2284 struct kernel_rlimit*, l) | |
| 2285 LSS_INLINE _syscall1(pid_t, getsid, pid_t, p) | |
| 2286 LSS_INLINE _syscall0(pid_t, _gettid) | 1798 LSS_INLINE _syscall0(pid_t, _gettid) |
| 2287 LSS_INLINE _syscall5(int, setxattr, const char *,p, | |
| 2288 const char *, n, const void *,v, | |
| 2289 size_t, s, int, f) | |
| 2290 LSS_INLINE _syscall5(int, lsetxattr, const char *,p, | |
| 2291 const char *, n, const void *,v, | |
| 2292 size_t, s, int, f) | |
| 2293 LSS_INLINE _syscall4(ssize_t, getxattr, const char *,p, | |
| 2294 const char *, n, void *, v, size_t, s) | |
| 2295 LSS_INLINE _syscall4(ssize_t, lgetxattr, const char *,p, | |
| 2296 const char *, n, void *, v, size_t, s) | |
| 2297 LSS_INLINE _syscall3(ssize_t, listxattr, const char *,p, | |
| 2298 char *, l, size_t, s) | |
| 2299 LSS_INLINE _syscall3(ssize_t, llistxattr, const char *,p, | |
| 2300 char *, l, size_t, s) | |
| 2301 LSS_INLINE _syscall2(int, ioprio_get, int, which, | |
| 2302 int, who) | |
| 2303 LSS_INLINE _syscall3(int, ioprio_set, int, which, | |
| 2304 int, who, int, ioprio) | |
| 2305 LSS_INLINE _syscall2(int, kill, pid_t, p, | 1799 LSS_INLINE _syscall2(int, kill, pid_t, p, |
| 2306 int, s) | 1800 int, s) |
| 2307 LSS_INLINE _syscall3(off_t, lseek, int, f, | 1801 LSS_INLINE _syscall3(off_t, lseek, int, f, |
| 2308 off_t, o, int, w) | 1802 off_t, o, int, w) |
| 2309 LSS_INLINE _syscall2(int, munmap, void*, s, | 1803 LSS_INLINE _syscall2(int, munmap, void*, s, |
| 2310 size_t, l) | 1804 size_t, l) |
| 2311 LSS_INLINE _syscall6(long, move_pages, pid_t, p, | |
| 2312 unsigned long, n, void **,g, int *, d, | |
| 2313 int *, s, int, f) | |
| 2314 LSS_INLINE _syscall5(void*, _mremap, void*, o, | 1805 LSS_INLINE _syscall5(void*, _mremap, void*, o, |
| 2315 size_t, os, size_t, ns, | 1806 size_t, os, size_t, ns, |
| 2316 unsigned long, f, void *, a) | 1807 unsigned long, f, void *, a) |
| 2317 LSS_INLINE _syscall3(int, open, const char*, p, | 1808 LSS_INLINE _syscall3(int, open, const char*, p, |
| 2318 int, f, int, m) | 1809 int, f, int, m) |
| 2319 LSS_INLINE _syscall3(int, poll, struct kernel_pollfd*, u, | |
| 2320 unsigned int, n, int, t) | |
| 2321 LSS_INLINE _syscall2(int, prctl, int, o, | 1810 LSS_INLINE _syscall2(int, prctl, int, o, |
| 2322 long, a) | 1811 long, a) |
| 2323 LSS_INLINE _syscall4(long, ptrace, int, r, | 1812 LSS_INLINE _syscall4(long, ptrace, int, r, |
| 2324 pid_t, p, void *, a, void *, d) | 1813 pid_t, p, void *, a, void *, d) |
| 2325 LSS_INLINE _syscall3(ssize_t, read, int, f, | 1814 LSS_INLINE _syscall3(ssize_t, read, int, f, |
| 2326 void *, b, size_t, c) | 1815 void *, b, size_t, c) |
| 2327 LSS_INLINE _syscall3(int, readlink, const char*, p, | |
| 2328 char*, b, size_t, s) | |
| 2329 LSS_INLINE _syscall4(int, rt_sigaction, int, s, | 1816 LSS_INLINE _syscall4(int, rt_sigaction, int, s, |
| 2330 const struct kernel_sigaction*, a, | 1817 const struct kernel_sigaction*, a, |
| 2331 struct kernel_sigaction*, o, size_t, c) | 1818 struct kernel_sigaction*, o, size_t, c) |
| 2332 LSS_INLINE _syscall2(int, rt_sigpending, struct kernel_sigset_t *, s, | |
| 2333 size_t, c) | |
| 2334 LSS_INLINE _syscall4(int, rt_sigprocmask, int, h, | 1819 LSS_INLINE _syscall4(int, rt_sigprocmask, int, h, |
| 2335 const struct kernel_sigset_t*, s, | 1820 const struct kernel_sigset_t*, s, |
| 2336 struct kernel_sigset_t*, o, size_t, c); | 1821 struct kernel_sigset_t*, o, size_t, c); |
| 2337 LSS_INLINE _syscall2(int, rt_sigsuspend, | |
| 2338 const struct kernel_sigset_t*, s, size_t, c); | |
| 2339 LSS_INLINE _syscall3(int, sched_getaffinity,pid_t, p, | |
| 2340 unsigned int, l, unsigned long *, m) | |
| 2341 LSS_INLINE _syscall3(int, sched_setaffinity,pid_t, p, | |
| 2342 unsigned int, l, unsigned long *, m) | |
| 2343 LSS_INLINE _syscall0(int, sched_yield) | 1822 LSS_INLINE _syscall0(int, sched_yield) |
| 2344 LSS_INLINE _syscall1(long, set_tid_address, int *, t) | |
| 2345 LSS_INLINE _syscall1(int, setfsgid, gid_t, g) | |
| 2346 LSS_INLINE _syscall1(int, setfsuid, uid_t, u) | |
| 2347 LSS_INLINE _syscall1(int, setuid, uid_t, u) | |
| 2348 LSS_INLINE _syscall1(int, setgid, gid_t, g) | |
| 2349 LSS_INLINE _syscall2(int, setpgid, pid_t, p, | |
| 2350 pid_t, g) | |
| 2351 LSS_INLINE _syscall3(int, setpriority, int, a, | |
| 2352 int, b, int, p) | |
| 2353 LSS_INLINE _syscall3(int, setresgid, gid_t, r, | |
| 2354 gid_t, e, gid_t, s) | |
| 2355 LSS_INLINE _syscall3(int, setresuid, uid_t, r, | |
| 2356 uid_t, e, uid_t, s) | |
| 2357 LSS_INLINE _syscall2(int, setrlimit, int, r, | |
| 2358 const struct kernel_rlimit*, l) | |
| 2359 LSS_INLINE _syscall0(pid_t, setsid) | |
| 2360 LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, | 1823 LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, |
| 2361 const stack_t*, o) | 1824 const stack_t*, o) |
| 2362 LSS_INLINE _syscall2(int, stat, const char*, f, | 1825 LSS_INLINE _syscall2(int, stat, const char*, f, |
| 2363 struct kernel_stat*, b) | 1826 struct kernel_stat*, b) |
| 2364 LSS_INLINE _syscall2(int, statfs, const char*, f, | |
| 2365 struct kernel_statfs*, b) | |
| 2366 LSS_INLINE _syscall3(ssize_t, write, int, f, | 1827 LSS_INLINE _syscall3(ssize_t, write, int, f, |
| 2367 const void *, b, size_t, c) | 1828 const void *, b, size_t, c) |
| 2368 LSS_INLINE _syscall3(ssize_t, writev, int, f, | |
| 2369 const struct kernel_iovec*, v, size_t, c) | |
| 2370 #if defined(__NR_getcpu) | 1829 #if defined(__NR_getcpu) |
| 2371 LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, | 1830 LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, |
| 2372 unsigned *, node, void *, unused); | 1831 unsigned *, node, void *, unused); |
| 2373 #endif | 1832 #endif |
| 2374 #if defined(__x86_64__) || \ | 1833 #if defined(__x86_64__) || \ |
| 2375 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) | 1834 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) |
| 2376 LSS_INLINE _syscall3(int, recvmsg, int, s, | |
| 2377 struct kernel_msghdr*, m, int, f) | |
| 2378 LSS_INLINE _syscall3(int, sendmsg, int, s, | |
| 2379 const struct kernel_msghdr*, m, int, f) | |
| 2380 LSS_INLINE _syscall6(int, sendto, int, s, | |
| 2381 const void*, m, size_t, l, | |
| 2382 int, f, | |
| 2383 const struct kernel_sockaddr*, a, int, t) | |
| 2384 LSS_INLINE _syscall2(int, shutdown, int, s, | |
| 2385 int, h) | |
| 2386 LSS_INLINE _syscall3(int, socket, int, d, | 1835 LSS_INLINE _syscall3(int, socket, int, d, |
| 2387 int, t, int, p) | 1836 int, t, int, p) |
| 2388 LSS_INLINE _syscall4(int, socketpair, int, d, | |
| 2389 int, t, int, p, int*, s) | |
| 2390 #endif | 1837 #endif |
| 2391 #if defined(__x86_64__) | 1838 #if defined(__x86_64__) |
| 2392 LSS_INLINE _syscall4(int, fallocate, int, fd, int, mode, | |
| 2393 loff_t, offset, loff_t, len) | |
| 2394 LSS_INLINE _syscall6(void*, mmap, void*, s, | 1839 LSS_INLINE _syscall6(void*, mmap, void*, s, |
| 2395 size_t, l, int, p, | 1840 size_t, l, int, p, |
| 2396 int, f, int, d, | 1841 int, f, int, d, |
| 2397 __off64_t, o) | 1842 __off64_t, o) |
| 2398 LSS_INLINE _syscall4(int, newfstatat, int, d, | |
| 2399 const char *, p, | |
| 2400 struct kernel_stat*, b, int, f) | |
| 2401 | |
| 2402 LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { | |
| 2403 return LSS_NAME(setfsgid)(gid); | |
| 2404 } | |
| 2405 | |
| 2406 LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { | |
| 2407 return LSS_NAME(setfsuid)(uid); | |
| 2408 } | |
| 2409 | |
| 2410 LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { | |
| 2411 return LSS_NAME(setresgid)(rgid, egid, sgid); | |
| 2412 } | |
| 2413 | |
| 2414 LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { | |
| 2415 return LSS_NAME(setresuid)(ruid, euid, suid); | |
| 2416 } | |
| 2417 | 1843 |
| 2418 LSS_INLINE int LSS_NAME(sigaction)(int signum, | 1844 LSS_INLINE int LSS_NAME(sigaction)(int signum, |
| 2419 const struct kernel_sigaction *act, | 1845 const struct kernel_sigaction *act, |
| 2420 struct kernel_sigaction *oldact) { | 1846 struct kernel_sigaction *oldact) { |
| 2421 /* On x86_64, the kernel requires us to always set our own | 1847 /* On x86_64, the kernel requires us to always set our own |
| 2422 * SA_RESTORER in order to be able to return from a signal handler. | 1848 * SA_RESTORER in order to be able to return from a signal handler. |
| 2423 * This function must have a "magic" signature that the "gdb" | 1849 * This function must have a "magic" signature that the "gdb" |
| 2424 * (and maybe the kernel?) can recognize. | 1850 * (and maybe the kernel?) can recognize. |
| 2425 */ | 1851 */ |
| 2426 if (act != NULL && !(act->sa_flags & SA_RESTORER)) { | 1852 if (act != NULL && !(act->sa_flags & SA_RESTORER)) { |
| 2427 struct kernel_sigaction a = *act; | 1853 struct kernel_sigaction a = *act; |
| 2428 a.sa_flags |= SA_RESTORER; | 1854 a.sa_flags |= SA_RESTORER; |
| 2429 a.sa_restorer = LSS_NAME(restore_rt)(); | 1855 a.sa_restorer = LSS_NAME(restore_rt)(); |
| 2430 return LSS_NAME(rt_sigaction)(signum, &a, oldact, | 1856 return LSS_NAME(rt_sigaction)(signum, &a, oldact, |
| 2431 (KERNEL_NSIG+7)/8); | 1857 (KERNEL_NSIG+7)/8); |
| 2432 } else { | 1858 } else { |
| 2433 return LSS_NAME(rt_sigaction)(signum, act, oldact, | 1859 return LSS_NAME(rt_sigaction)(signum, act, oldact, |
| 2434 (KERNEL_NSIG+7)/8); | 1860 (KERNEL_NSIG+7)/8); |
| 2435 } | 1861 } |
| 2436 } | 1862 } |
| 2437 | 1863 |
| 2438 LSS_INLINE int LSS_NAME(sigpending)(struct kernel_sigset_t *set) { | |
| 2439 return LSS_NAME(rt_sigpending)(set, (KERNEL_NSIG+7)/8); | |
| 2440 } | |
| 2441 | |
| 2442 LSS_INLINE int LSS_NAME(sigprocmask)(int how, | 1864 LSS_INLINE int LSS_NAME(sigprocmask)(int how, |
| 2443 const struct kernel_sigset_t *set, | 1865 const struct kernel_sigset_t *set, |
| 2444 struct kernel_sigset_t *oldset) { | 1866 struct kernel_sigset_t *oldset) { |
| 2445 return LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); | 1867 return LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); |
| 2446 } | 1868 } |
| 2447 | |
| 2448 LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { | |
| 2449 return LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8); | |
| 2450 } | |
| 2451 #endif | 1869 #endif |
| 2452 #if defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ | 1870 #if defined(__x86_64__) || \ |
| 1871 defined(__arm__) || \ |
| 2453 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) | 1872 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) |
| 2454 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, | 1873 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, |
| 2455 int*, s, int, o, | 1874 int*, s, int, o, |
| 2456 struct kernel_rusage*, r) | 1875 struct kernel_rusage*, r) |
| 2457 | |
| 2458 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){ | 1876 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){ |
| 2459 return LSS_NAME(wait4)(pid, status, options, 0); | 1877 return LSS_NAME(wait4)(pid, status, options, 0); |
| 2460 } | 1878 } |
| 2461 #endif | 1879 #endif |
| 2462 #if defined(__i386__) || defined(__x86_64__) | 1880 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) |
| 2463 LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m) | 1881 LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m) |
| 2464 LSS_INLINE _syscall3(int, unlinkat, int, d, const char *, p, int, f) | |
| 2465 #endif | |
| 2466 #if defined(__i386__) || defined(__ARM_ARCH_3__) | |
| 2467 #define __NR__setfsgid32 __NR_setfsgid32 | |
| 2468 #define __NR__setfsuid32 __NR_setfsuid32 | |
| 2469 #define __NR__setresgid32 __NR_setresgid32 | |
| 2470 #define __NR__setresuid32 __NR_setresuid32 | |
| 2471 LSS_INLINE _syscall2(int, ugetrlimit, int, r, | |
| 2472 struct kernel_rlimit*, l) | |
| 2473 LSS_INLINE _syscall1(int, _setfsgid32, gid_t, f) | |
| 2474 LSS_INLINE _syscall1(int, _setfsuid32, uid_t, f) | |
| 2475 LSS_INLINE _syscall3(int, _setresgid32, gid_t, r, | |
| 2476 gid_t, e, gid_t, s) | |
| 2477 LSS_INLINE _syscall3(int, _setresuid32, uid_t, r, | |
| 2478 uid_t, e, uid_t, s) | |
| 2479 | |
| 2480 LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { | |
| 2481 int rc; | |
| 2482 if ((rc = LSS_NAME(_setfsgid32)(gid)) < 0 && | |
| 2483 LSS_ERRNO == ENOSYS) { | |
| 2484 if ((unsigned int)gid & ~0xFFFFu) { | |
| 2485 rc = EINVAL; | |
| 2486 } else { | |
| 2487 rc = LSS_NAME(setfsgid)(gid); | |
| 2488 } | |
| 2489 } | |
| 2490 return rc; | |
| 2491 } | |
| 2492 | |
| 2493 LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { | |
| 2494 int rc; | |
| 2495 if ((rc = LSS_NAME(_setfsuid32)(uid)) < 0 && | |
| 2496 LSS_ERRNO == ENOSYS) { | |
| 2497 if ((unsigned int)uid & ~0xFFFFu) { | |
| 2498 rc = EINVAL; | |
| 2499 } else { | |
| 2500 rc = LSS_NAME(setfsuid)(uid); | |
| 2501 } | |
| 2502 } | |
| 2503 return rc; | |
| 2504 } | |
| 2505 | |
| 2506 LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { | |
| 2507 int rc; | |
| 2508 if ((rc = LSS_NAME(_setresgid32)(rgid, egid, sgid)) < 0 && | |
| 2509 LSS_ERRNO == ENOSYS) { | |
| 2510 if ((unsigned int)rgid & ~0xFFFFu || | |
| 2511 (unsigned int)egid & ~0xFFFFu || | |
| 2512 (unsigned int)sgid & ~0xFFFFu) { | |
| 2513 rc = EINVAL; | |
| 2514 } else { | |
| 2515 rc = LSS_NAME(setresgid)(rgid, egid, sgid); | |
| 2516 } | |
| 2517 } | |
| 2518 return rc; | |
| 2519 } | |
| 2520 | |
| 2521 LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { | |
| 2522 int rc; | |
| 2523 if ((rc = LSS_NAME(_setresuid32)(ruid, euid, suid)) < 0 && | |
| 2524 LSS_ERRNO == ENOSYS) { | |
| 2525 if ((unsigned int)ruid & ~0xFFFFu || | |
| 2526 (unsigned int)euid & ~0xFFFFu || | |
| 2527 (unsigned int)suid & ~0xFFFFu) { | |
| 2528 rc = EINVAL; | |
| 2529 } else { | |
| 2530 rc = LSS_NAME(setresuid)(ruid, euid, suid); | |
| 2531 } | |
| 2532 } | |
| 2533 return rc; | |
| 2534 } | |
| 2535 #endif | 1882 #endif |
| 2536 LSS_INLINE int LSS_NAME(sigemptyset)(struct kernel_sigset_t *set) { | 1883 LSS_INLINE int LSS_NAME(sigemptyset)(struct kernel_sigset_t *set) { |
| 2537 memset(&set->sig, 0, sizeof(set->sig)); | 1884 memset(&set->sig, 0, sizeof(set->sig)); |
| 2538 return 0; | 1885 return 0; |
| 2539 } | 1886 } |
| 2540 | 1887 |
| 2541 LSS_INLINE int LSS_NAME(sigfillset)(struct kernel_sigset_t *set) { | 1888 LSS_INLINE int LSS_NAME(sigfillset)(struct kernel_sigset_t *set) { |
| 2542 memset(&set->sig, -1, sizeof(set->sig)); | 1889 memset(&set->sig, -1, sizeof(set->sig)); |
| 2543 return 0; | 1890 return 0; |
| 2544 } | 1891 } |
| 2545 | 1892 |
| 2546 LSS_INLINE int LSS_NAME(sigaddset)(struct kernel_sigset_t *set, | 1893 LSS_INLINE int LSS_NAME(sigaddset)(struct kernel_sigset_t *set, |
| 2547 int signum) { | 1894 int signum) { |
| 2548 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { | 1895 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { |
| 2549 LSS_ERRNO = EINVAL; | 1896 LSS_ERRNO = EINVAL; |
| 2550 return -1; | 1897 return -1; |
| 2551 } else { | 1898 } else { |
| 2552 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] | 1899 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] |
| 2553 |= 1UL << ((signum - 1) % (8*sizeof(set->sig[0]))); | 1900 |= 1UL << ((signum - 1) % (8*sizeof(set->sig[0]))); |
| 2554 return 0; | 1901 return 0; |
| 2555 } | 1902 } |
| 2556 } | 1903 } |
| 2557 | 1904 |
| 2558 LSS_INLINE int LSS_NAME(sigdelset)(struct kernel_sigset_t *set, | 1905 LSS_INLINE int LSS_NAME(sigdelset)(struct kernel_sigset_t *set, |
| 2559 int signum) { | 1906 int signum) { |
| 2560 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { | 1907 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { |
| 2561 LSS_ERRNO = EINVAL; | 1908 LSS_ERRNO = EINVAL; |
| 2562 return -1; | 1909 return -1; |
| 2563 } else { | 1910 } else { |
| 2564 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] | 1911 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] |
| 2565 &= ~(1UL << ((signum - 1) % (8*sizeof(set->sig[0])))); | 1912 &= ~(1UL << ((signum - 1) % (8*sizeof(set->sig[0])))); |
| 2566 return 0; | 1913 return 0; |
| 2567 } | 1914 } |
| 2568 } | 1915 } |
| 2569 | 1916 |
| 2570 LSS_INLINE int LSS_NAME(sigismember)(struct kernel_sigset_t *set, | 1917 #if defined(__i386__) || \ |
| 2571 int signum) { | 1918 defined(__arm__) || \ |
| 2572 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { | |
| 2573 LSS_ERRNO = EINVAL; | |
| 2574 return -1; | |
| 2575 } else { | |
| 2576 return !!(set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] & | |
| 2577 (1UL << ((signum - 1) % (8*sizeof(set->sig[0]))))); | |
| 2578 } | |
| 2579 } | |
| 2580 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | |
| 2581 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) | 1919 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) |
| 2582 #define __NR__sigaction __NR_sigaction | 1920 #define __NR__sigaction __NR_sigaction |
| 2583 #define __NR__sigpending __NR_sigpending | |
| 2584 #define __NR__sigprocmask __NR_sigprocmask | 1921 #define __NR__sigprocmask __NR_sigprocmask |
| 2585 #define __NR__sigsuspend __NR_sigsuspend | |
| 2586 #define __NR__socketcall __NR_socketcall | |
| 2587 LSS_INLINE _syscall2(int, fstat64, int, f, | 1922 LSS_INLINE _syscall2(int, fstat64, int, f, |
| 2588 struct kernel_stat64 *, b) | 1923 struct kernel_stat64 *, b) |
| 2589 LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, | 1924 LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, |
| 2590 loff_t *, res, uint, wh) | 1925 loff_t *, res, uint, wh) |
| 1926 #ifdef __PPC64__ |
| 1927 LSS_INLINE _syscall6(void*, mmap, void*, s, |
| 1928 size_t, l, int, p, |
| 1929 int, f, int, d, |
| 1930 off_t, o) |
| 1931 #else |
| 1932 #ifndef __ARM_EABI__ |
| 1933 /* Not available on ARM EABI Linux. */ |
| 2591 LSS_INLINE _syscall1(void*, mmap, void*, a) | 1934 LSS_INLINE _syscall1(void*, mmap, void*, a) |
| 2592 #ifndef __PPC64__ | 1935 #endif |
| 2593 LSS_INLINE _syscall6(void*, mmap2, void*, s, | 1936 LSS_INLINE _syscall6(void*, mmap2, void*, s, |
| 2594 size_t, l, int, p, | 1937 size_t, l, int, p, |
| 2595 int, f, int, d, | 1938 int, f, int, d, |
| 2596 off_t, o) | 1939 off_t, o) |
| 2597 #endif | 1940 #endif |
| 2598 LSS_INLINE _syscall3(int, _sigaction, int, s, | 1941 LSS_INLINE _syscall3(int, _sigaction, int, s, |
| 2599 const struct kernel_old_sigaction*, a, | 1942 const struct kernel_old_sigaction*, a, |
| 2600 struct kernel_old_sigaction*, o) | 1943 struct kernel_old_sigaction*, o) |
| 2601 LSS_INLINE _syscall1(int, _sigpending, unsigned long*, s) | |
| 2602 LSS_INLINE _syscall3(int, _sigprocmask, int, h, | 1944 LSS_INLINE _syscall3(int, _sigprocmask, int, h, |
| 2603 const unsigned long*, s, | 1945 const unsigned long*, s, |
| 2604 unsigned long*, o) | 1946 unsigned long*, o) |
| 2605 #ifdef __PPC__ | |
| 2606 LSS_INLINE _syscall1(int, _sigsuspend, unsigned long, s) | |
| 2607 #else | |
| 2608 LSS_INLINE _syscall3(int, _sigsuspend, const void*, a, | |
| 2609 int, b, | |
| 2610 unsigned long, s) | |
| 2611 #endif | |
| 2612 LSS_INLINE _syscall2(int, stat64, const char *, p, | 1947 LSS_INLINE _syscall2(int, stat64, const char *, p, |
| 2613 struct kernel_stat64 *, b) | 1948 struct kernel_stat64 *, b) |
| 2614 | 1949 |
| 2615 LSS_INLINE int LSS_NAME(sigaction)(int signum, | 1950 LSS_INLINE int LSS_NAME(sigaction)(int signum, |
| 2616 const struct kernel_sigaction *act, | 1951 const struct kernel_sigaction *act, |
| 2617 struct kernel_sigaction *oldact) { | 1952 struct kernel_sigaction *oldact) { |
| 2618 int old_errno = LSS_ERRNO; | 1953 int old_errno = LSS_ERRNO; |
| 2619 int rc; | 1954 int rc; |
| 2620 struct kernel_sigaction a; | 1955 struct kernel_sigaction a; |
| 2621 if (act != NULL) { | 1956 if (act != NULL) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2667 oldact->sa_flags = ptr_oa->sa_flags; | 2002 oldact->sa_flags = ptr_oa->sa_flags; |
| 2668 memcpy(&oldact->sa_mask, &ptr_oa->sa_mask, sizeof(ptr_oa->sa_mask)); | 2003 memcpy(&oldact->sa_mask, &ptr_oa->sa_mask, sizeof(ptr_oa->sa_mask)); |
| 2669 #ifndef __mips__ | 2004 #ifndef __mips__ |
| 2670 oldact->sa_restorer = ptr_oa->sa_restorer; | 2005 oldact->sa_restorer = ptr_oa->sa_restorer; |
| 2671 #endif | 2006 #endif |
| 2672 } | 2007 } |
| 2673 } | 2008 } |
| 2674 return rc; | 2009 return rc; |
| 2675 } | 2010 } |
| 2676 | 2011 |
| 2677 LSS_INLINE int LSS_NAME(sigpending)(struct kernel_sigset_t *set) { | |
| 2678 int old_errno = LSS_ERRNO; | |
| 2679 int rc = LSS_NAME(rt_sigpending)(set, (KERNEL_NSIG+7)/8); | |
| 2680 if (rc < 0 && LSS_ERRNO == ENOSYS) { | |
| 2681 LSS_ERRNO = old_errno; | |
| 2682 LSS_NAME(sigemptyset)(set); | |
| 2683 rc = LSS_NAME(_sigpending)(&set->sig[0]); | |
| 2684 } | |
| 2685 return rc; | |
| 2686 } | |
| 2687 | |
| 2688 LSS_INLINE int LSS_NAME(sigprocmask)(int how, | 2012 LSS_INLINE int LSS_NAME(sigprocmask)(int how, |
| 2689 const struct kernel_sigset_t *set, | 2013 const struct kernel_sigset_t *set, |
| 2690 struct kernel_sigset_t *oldset) { | 2014 struct kernel_sigset_t *oldset) { |
| 2691 int olderrno = LSS_ERRNO; | 2015 int olderrno = LSS_ERRNO; |
| 2692 int rc = LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); | 2016 int rc = LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); |
| 2693 if (rc < 0 && LSS_ERRNO == ENOSYS) { | 2017 if (rc < 0 && LSS_ERRNO == ENOSYS) { |
| 2694 LSS_ERRNO = olderrno; | 2018 LSS_ERRNO = olderrno; |
| 2695 if (oldset) { | 2019 if (oldset) { |
| 2696 LSS_NAME(sigemptyset)(oldset); | 2020 LSS_NAME(sigemptyset)(oldset); |
| 2697 } | 2021 } |
| 2698 rc = LSS_NAME(_sigprocmask)(how, | 2022 rc = LSS_NAME(_sigprocmask)(how, |
| 2699 set ? &set->sig[0] : NULL, | 2023 set ? &set->sig[0] : NULL, |
| 2700 oldset ? &oldset->sig[0] : NULL); | 2024 oldset ? &oldset->sig[0] : NULL); |
| 2701 } | 2025 } |
| 2702 return rc; | 2026 return rc; |
| 2703 } | 2027 } |
| 2704 | |
| 2705 LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { | |
| 2706 int olderrno = LSS_ERRNO; | |
| 2707 int rc = LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8); | |
| 2708 if (rc < 0 && LSS_ERRNO == ENOSYS) { | |
| 2709 LSS_ERRNO = olderrno; | |
| 2710 rc = LSS_NAME(_sigsuspend)( | |
| 2711 #ifndef __PPC__ | |
| 2712 set, 0, | |
| 2713 #endif | |
| 2714 set->sig[0]); | |
| 2715 } | |
| 2716 return rc; | |
| 2717 } | |
| 2718 #endif | 2028 #endif |
| 2719 #if defined(__PPC__) | 2029 #if defined(__PPC__) |
| 2720 #undef LSS_SC_LOADARGS_0 | 2030 #undef LSS_SC_LOADARGS_0 |
| 2721 #define LSS_SC_LOADARGS_0(dummy...) | 2031 #define LSS_SC_LOADARGS_0(dummy...) |
| 2722 #undef LSS_SC_LOADARGS_1 | 2032 #undef LSS_SC_LOADARGS_1 |
| 2723 #define LSS_SC_LOADARGS_1(arg1) \ | 2033 #define LSS_SC_LOADARGS_1(arg1) \ |
| 2724 __sc_4 = (unsigned long) (arg1) | 2034 __sc_4 = (unsigned long) (arg1) |
| 2725 #undef LSS_SC_LOADARGS_2 | 2035 #undef LSS_SC_LOADARGS_2 |
| 2726 #define LSS_SC_LOADARGS_2(arg1, arg2) \ | 2036 #define LSS_SC_LOADARGS_2(arg1, arg2) \ |
| 2727 LSS_SC_LOADARGS_1(arg1); \ | 2037 LSS_SC_LOADARGS_1(arg1); \ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2764 "=&r" (__sc_3), "=&r" (__sc_4), \ | 2074 "=&r" (__sc_3), "=&r" (__sc_4), \ |
| 2765 "=&r" (__sc_5), "=&r" (__sc_6), \ | 2075 "=&r" (__sc_5), "=&r" (__sc_6), \ |
| 2766 "=&r" (__sc_7), "=&r" (__sc_8) \ | 2076 "=&r" (__sc_7), "=&r" (__sc_8) \ |
| 2767 : LSS_ASMINPUT_##nr \ | 2077 : LSS_ASMINPUT_##nr \ |
| 2768 : "cr0", "ctr", "memory"); \ | 2078 : "cr0", "ctr", "memory"); \ |
| 2769 __sc_ret = __sc_3; \ | 2079 __sc_ret = __sc_3; \ |
| 2770 __sc_err = __sc_0; \ | 2080 __sc_err = __sc_0; \ |
| 2771 } \ | 2081 } \ |
| 2772 LSS_RETURN(type, __sc_ret, __sc_err) | 2082 LSS_RETURN(type, __sc_ret, __sc_err) |
| 2773 | 2083 |
| 2774 LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg, | |
| 2775 int flags){ | |
| 2776 LSS_SC_BODY(3, ssize_t, 17, s, msg, flags); | |
| 2777 } | |
| 2778 | |
| 2779 LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s, | |
| 2780 const struct kernel_msghdr *msg, | |
| 2781 int flags) { | |
| 2782 LSS_SC_BODY(3, ssize_t, 16, s, msg, flags); | |
| 2783 } | |
| 2784 | |
| 2785 // TODO(csilvers): why is this ifdef'ed out? | |
| 2786 #if 0 | |
| 2787 LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len, | |
| 2788 int flags, | |
| 2789 const struct kernel_sockaddr *to, | |
| 2790 unsigned int tolen) { | |
| 2791 LSS_BODY(6, ssize_t, 11, s, buf, len, flags, to, tolen); | |
| 2792 } | |
| 2793 #endif | |
| 2794 | |
| 2795 LSS_INLINE int LSS_NAME(shutdown)(int s, int how) { | |
| 2796 LSS_SC_BODY(2, int, 13, s, how); | |
| 2797 } | |
| 2798 | |
| 2799 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { | 2084 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { |
| 2800 LSS_SC_BODY(3, int, 1, domain, type, protocol); | 2085 LSS_SC_BODY(3, int, 1, domain, type, protocol); |
| 2801 } | 2086 } |
| 2087 #endif |
| 2088 #if defined(__i386__) || \ |
| 2089 (defined(__arm__) && !defined(__ARM_EABI__)) || \ |
| 2090 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) |
| 2802 | 2091 |
| 2803 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, | 2092 /* See sys_socketcall in net/socket.c in kernel source. |
| 2804 int sv[2]) { | 2093 * It de-multiplexes on its first arg and unpacks the arglist |
| 2805 LSS_SC_BODY(4, int, 8, d, type, protocol, sv); | 2094 * array in its second arg. |
| 2806 } | 2095 */ |
| 2807 #endif | 2096 LSS_INLINE _syscall2(long, socketcall, int, c, unsigned long*, a) |
| 2808 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | |
| 2809 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) | |
| 2810 #define __NR__socketcall __NR_socketcall | |
| 2811 LSS_INLINE _syscall2(int, _socketcall, int, c, | |
| 2812 va_list, a) | |
| 2813 | |
| 2814 LSS_INLINE int LSS_NAME(socketcall)(int op, ...) { | |
| 2815 int rc; | |
| 2816 va_list ap; | |
| 2817 va_start(ap, op); | |
| 2818 rc = LSS_NAME(_socketcall)(op, ap); | |
| 2819 va_end(ap); | |
| 2820 return rc; | |
| 2821 } | |
| 2822 | |
| 2823 LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg, | |
| 2824 int flags){ | |
| 2825 return (ssize_t)LSS_NAME(socketcall)(17, s, msg, flags); | |
| 2826 } | |
| 2827 | |
| 2828 LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s, | |
| 2829 const struct kernel_msghdr *msg, | |
| 2830 int flags) { | |
| 2831 return (ssize_t)LSS_NAME(socketcall)(16, s, msg, flags); | |
| 2832 } | |
| 2833 | |
| 2834 LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len, | |
| 2835 int flags, | |
| 2836 const struct kernel_sockaddr *to, | |
| 2837 unsigned int tolen) { | |
| 2838 return (ssize_t)LSS_NAME(socketcall)(11, s, buf, len, flags, to, tolen); | |
| 2839 } | |
| 2840 | |
| 2841 LSS_INLINE int LSS_NAME(shutdown)(int s, int how) { | |
| 2842 return LSS_NAME(socketcall)(13, s, how); | |
| 2843 } | |
| 2844 | 2097 |
| 2845 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { | 2098 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { |
| 2846 return LSS_NAME(socketcall)(1, domain, type, protocol); | 2099 unsigned long args[3] = { |
| 2100 (unsigned long) domain, |
| 2101 (unsigned long) type, |
| 2102 (unsigned long) protocol |
| 2103 }; |
| 2104 return LSS_NAME(socketcall)(1, args); |
| 2847 } | 2105 } |
| 2848 | 2106 #elif defined(__ARM_EABI__) |
| 2849 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, | 2107 LSS_INLINE _syscall3(int, socket, int, d, |
| 2850 int sv[2]) { | 2108 int, t, int, p) |
| 2851 return LSS_NAME(socketcall)(8, d, type, protocol, sv); | |
| 2852 } | |
| 2853 #endif | |
| 2854 #if defined(__i386__) || defined(__PPC__) | |
| 2855 LSS_INLINE _syscall4(int, fstatat64, int, d, | |
| 2856 const char *, p, | |
| 2857 struct kernel_stat64 *, b, int, f) | |
| 2858 #endif | 2109 #endif |
| 2859 #if defined(__i386__) || defined(__PPC__) || \ | 2110 #if defined(__i386__) || defined(__PPC__) || \ |
| 2860 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) | 2111 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) |
| 2861 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p, | 2112 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p, |
| 2862 int*, s, int, o) | 2113 int*, s, int, o) |
| 2863 #endif | 2114 #endif |
| 2864 #if defined(__mips__) | 2115 #if defined(__mips__) |
| 2865 /* sys_pipe() on MIPS has non-standard calling conventions, as it returns | 2116 /* sys_pipe() on MIPS has non-standard calling conventions, as it returns |
| 2866 * both file handles through CPU registers. | 2117 * both file handles through CPU registers. |
| 2867 */ | 2118 */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2879 return -1; | 2130 return -1; |
| 2880 } else { | 2131 } else { |
| 2881 p[0] = __v0; | 2132 p[0] = __v0; |
| 2882 p[1] = __v1; | 2133 p[1] = __v1; |
| 2883 return 0; | 2134 return 0; |
| 2884 } | 2135 } |
| 2885 } | 2136 } |
| 2886 #else | 2137 #else |
| 2887 LSS_INLINE _syscall1(int, pipe, int *, p) | 2138 LSS_INLINE _syscall1(int, pipe, int *, p) |
| 2888 #endif | 2139 #endif |
| 2889 /* TODO(csilvers): see if ppc can/should support this as well */ | |
| 2890 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | |
| 2891 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) | |
| 2892 #define __NR__statfs64 __NR_statfs64 | |
| 2893 #define __NR__fstatfs64 __NR_fstatfs64 | |
| 2894 LSS_INLINE _syscall3(int, _statfs64, const char*, p, | |
| 2895 size_t, s,struct kernel_statfs64*, b) | |
| 2896 LSS_INLINE _syscall3(int, _fstatfs64, int, f, | |
| 2897 size_t, s,struct kernel_statfs64*, b) | |
| 2898 LSS_INLINE int LSS_NAME(statfs64)(const char *p, | |
| 2899 struct kernel_statfs64 *b) { | |
| 2900 return LSS_NAME(_statfs64)(p, sizeof(*b), b); | |
| 2901 } | |
| 2902 LSS_INLINE int LSS_NAME(fstatfs64)(int f,struct kernel_statfs64 *b) { | |
| 2903 return LSS_NAME(_fstatfs64)(f, sizeof(*b), b); | |
| 2904 } | |
| 2905 #endif | |
| 2906 | |
| 2907 LSS_INLINE int LSS_NAME(execv)(const char *path, const char *const argv[]) { | |
| 2908 extern char **environ; | |
| 2909 return LSS_NAME(execve)(path, argv, (const char *const *)environ); | |
| 2910 } | |
| 2911 | 2140 |
| 2912 LSS_INLINE pid_t LSS_NAME(gettid)() { | 2141 LSS_INLINE pid_t LSS_NAME(gettid)() { |
| 2913 pid_t tid = LSS_NAME(_gettid)(); | 2142 pid_t tid = LSS_NAME(_gettid)(); |
| 2914 if (tid != -1) { | 2143 if (tid != -1) { |
| 2915 return tid; | 2144 return tid; |
| 2916 } | 2145 } |
| 2917 return LSS_NAME(getpid)(); | 2146 return LSS_NAME(getpid)(); |
| 2918 } | 2147 } |
| 2919 | 2148 |
| 2920 LSS_INLINE void *LSS_NAME(mremap)(void *old_address, size_t old_size, | 2149 LSS_INLINE void *LSS_NAME(mremap)(void *old_address, size_t old_size, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2937 * right after detaching from the tracee. | 2166 * right after detaching from the tracee. |
| 2938 */ | 2167 */ |
| 2939 int rc, err; | 2168 int rc, err; |
| 2940 LSS_NAME(sched_yield)(); | 2169 LSS_NAME(sched_yield)(); |
| 2941 rc = LSS_NAME(ptrace)(PTRACE_DETACH, pid, (void *)0, (void *)0); | 2170 rc = LSS_NAME(ptrace)(PTRACE_DETACH, pid, (void *)0, (void *)0); |
| 2942 err = LSS_ERRNO; | 2171 err = LSS_ERRNO; |
| 2943 LSS_NAME(kill)(pid, SIGCONT); | 2172 LSS_NAME(kill)(pid, SIGCONT); |
| 2944 LSS_ERRNO = err; | 2173 LSS_ERRNO = err; |
| 2945 return rc; | 2174 return rc; |
| 2946 } | 2175 } |
| 2947 | |
| 2948 LSS_INLINE int LSS_NAME(raise)(int sig) { | |
| 2949 return LSS_NAME(kill)(LSS_NAME(getpid)(), sig); | |
| 2950 } | |
| 2951 | |
| 2952 LSS_INLINE int LSS_NAME(setpgrp)() { | |
| 2953 return LSS_NAME(setpgid)(0, 0); | |
| 2954 } | |
| 2955 | |
| 2956 LSS_INLINE int LSS_NAME(sysconf)(int name) { | |
| 2957 extern int __getpagesize(void); | |
| 2958 switch (name) { | |
| 2959 case _SC_OPEN_MAX: { | |
| 2960 struct kernel_rlimit limit; | |
| 2961 return LSS_NAME(getrlimit)(RLIMIT_NOFILE, &limit) < 0 | |
| 2962 ? 8192 : limit.rlim_cur; | |
| 2963 } | |
| 2964 case _SC_PAGESIZE: | |
| 2965 return __getpagesize(); | |
| 2966 default: | |
| 2967 errno = ENOSYS; | |
| 2968 return -1; | |
| 2969 } | |
| 2970 } | |
| 2971 #if defined(__x86_64__) || \ | |
| 2972 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64) | |
| 2973 LSS_INLINE _syscall4(ssize_t, pread64, int, f, | |
| 2974 void *, b, size_t, c, | |
| 2975 loff_t, o) | |
| 2976 LSS_INLINE _syscall4(ssize_t, pwrite64, int, f, | |
| 2977 const void *, b, size_t, c, | |
| 2978 loff_t, o) | |
| 2979 LSS_INLINE _syscall3(int, readahead, int, f, | |
| 2980 loff_t, o, unsigned, c) | |
| 2981 #else | |
| 2982 #define __NR__pread64 __NR_pread64 | |
| 2983 #define __NR__pwrite64 __NR_pwrite64 | |
| 2984 #define __NR__readahead __NR_readahead | |
| 2985 LSS_INLINE _syscall5(ssize_t, _pread64, int, f, | |
| 2986 void *, b, size_t, c, unsigned, o1, | |
| 2987 unsigned, o2) | |
| 2988 LSS_INLINE _syscall5(ssize_t, _pwrite64, int, f, | |
| 2989 const void *, b, size_t, c, unsigned, o1, | |
| 2990 long, o2) | |
| 2991 LSS_INLINE _syscall4(int, _readahead, int, f, | |
| 2992 unsigned, o1, unsigned, o2, size_t, c); | |
| 2993 /* We force 64bit-wide parameters onto the stack, then access each | |
| 2994 * 32-bit component individually. This guarantees that we build the | |
| 2995 * correct parameters independent of the native byte-order of the | |
| 2996 * underlying architecture. | |
| 2997 */ | |
| 2998 LSS_INLINE ssize_t LSS_NAME(pread64)(int fd, void *buf, size_t count, | |
| 2999 loff_t off) { | |
| 3000 union { loff_t off; unsigned arg[2]; } o = { off }; | |
| 3001 return LSS_NAME(_pread64)(fd, buf, count, o.arg[0], o.arg[1]); | |
| 3002 } | |
| 3003 LSS_INLINE ssize_t LSS_NAME(pwrite64)(int fd, const void *buf, | |
| 3004 size_t count, loff_t off) { | |
| 3005 union { loff_t off; unsigned arg[2]; } o = { off }; | |
| 3006 return LSS_NAME(_pwrite64)(fd, buf, count, o.arg[0], o.arg[1]); | |
| 3007 } | |
| 3008 LSS_INLINE int LSS_NAME(readahead)(int fd, loff_t off, int len) { | |
| 3009 union { loff_t off; unsigned arg[2]; } o = { off }; | |
| 3010 return LSS_NAME(_readahead)(fd, o.arg[0], o.arg[1], len); | |
| 3011 } | |
| 3012 #endif | |
| 3013 #endif | 2176 #endif |
| 3014 | 2177 |
| 3015 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) | 2178 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) |
| 3016 } | 2179 } |
| 3017 #endif | 2180 #endif |
| 3018 | 2181 |
| 3019 #endif | 2182 #endif |
| 3020 #endif | 2183 #endif |
| OLD | NEW |