Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2005-2011, Google Inc. | 1 /* Copyright (c) 2005-2011, 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 * A pointer to this symbol can be obtained by calling | 75 * A pointer to this symbol can be obtained by calling |
| 76 * get_syscall_entrypoint() | 76 * get_syscall_entrypoint() |
| 77 * | 77 * |
| 78 * This file defines a few internal symbols that all start with "LSS_". | 78 * This file defines a few internal symbols that all start with "LSS_". |
| 79 * Do not access these symbols from outside this file. They are not part | 79 * Do not access these symbols from outside this file. They are not part |
| 80 * of the supported API. | 80 * of the supported API. |
| 81 */ | 81 */ |
| 82 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H | 82 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H |
| 83 #define SYS_LINUX_SYSCALL_SUPPORT_H | 83 #define SYS_LINUX_SYSCALL_SUPPORT_H |
| 84 | 84 |
| 85 /* We currently only support x86-32, x86-64, ARM, MIPS, and PPC on Linux. | 85 /* We currently only support x86-32, x86-64, ARM, MIPS, PPC, s390 and s390x |
| 86 * on Linux. | |
| 86 * Porting to other related platforms should not be difficult. | 87 * Porting to other related platforms should not be difficult. |
| 87 */ | 88 */ |
| 88 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ | 89 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ |
| 89 defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ | 90 defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ |
| 90 defined(__aarch64__)) \ | 91 defined(__aarch64__) || defined(__s390__)) \ |
| 91 && (defined(__linux) || defined(__ANDROID__)) | 92 && (defined(__linux) || defined(__ANDROID__)) |
| 92 | 93 |
| 93 #ifndef SYS_CPLUSPLUS | 94 #ifndef SYS_CPLUSPLUS |
| 94 #ifdef __cplusplus | 95 #ifdef __cplusplus |
| 95 /* Some system header files in older versions of gcc neglect to properly | 96 /* Some system header files in older versions of gcc neglect to properly |
| 96 * handle being included from C++. As it appears to be harmless to have | 97 * handle being included from C++. As it appears to be harmless to have |
| 97 * multiple nested 'extern "C"' blocks, just add another one here. | 98 * multiple nested 'extern "C"' blocks, just add another one here. |
| 98 */ | 99 */ |
| 99 extern "C" { | 100 extern "C" { |
| 100 #endif | 101 #endif |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 long ru_inblock; | 250 long ru_inblock; |
| 250 long ru_oublock; | 251 long ru_oublock; |
| 251 long ru_msgsnd; | 252 long ru_msgsnd; |
| 252 long ru_msgrcv; | 253 long ru_msgrcv; |
| 253 long ru_nsignals; | 254 long ru_nsignals; |
| 254 long ru_nvcsw; | 255 long ru_nvcsw; |
| 255 long ru_nivcsw; | 256 long ru_nivcsw; |
| 256 }; | 257 }; |
| 257 | 258 |
| 258 #if defined(__i386__) || defined(__ARM_EABI__) || defined(__ARM_ARCH_3__) \ | 259 #if defined(__i386__) || defined(__ARM_EABI__) || defined(__ARM_ARCH_3__) \ |
| 259 || defined(__PPC__) | 260 || defined(__PPC__) || (defined(__s390__) && !defined(__s390x__)) |
| 260 | 261 |
| 261 /* include/asm-{arm,i386,mips,ppc}/signal.h */ | 262 /* include/asm-{arm,i386,mips,ppc}/signal.h */ |
| 262 struct kernel_old_sigaction { | 263 struct kernel_old_sigaction { |
| 263 union { | 264 union { |
| 264 void (*sa_handler_)(int); | 265 void (*sa_handler_)(int); |
| 265 void (*sa_sigaction_)(int, siginfo_t *, void *); | 266 void (*sa_sigaction_)(int, siginfo_t *, void *); |
| 266 }; | 267 }; |
| 267 unsigned long sa_mask; | 268 unsigned long sa_mask; |
| 268 unsigned long sa_flags; | 269 unsigned long sa_flags; |
| 269 void (*sa_restorer)(void); | 270 void (*sa_restorer)(void); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 struct kernel_sigset_t sa_mask; | 315 struct kernel_sigset_t sa_mask; |
| 315 #endif | 316 #endif |
| 316 }; | 317 }; |
| 317 | 318 |
| 318 /* include/linux/socket.h */ | 319 /* include/linux/socket.h */ |
| 319 struct kernel_sockaddr { | 320 struct kernel_sockaddr { |
| 320 unsigned short sa_family; | 321 unsigned short sa_family; |
| 321 char sa_data[14]; | 322 char sa_data[14]; |
| 322 }; | 323 }; |
| 323 | 324 |
| 324 /* include/asm-{arm,aarch64,i386,mips,ppc}/stat.h */ | 325 /* include/asm-{arm,aarch64,i386,mips,ppc,s390}/stat.h */ |
| 325 #ifdef __mips__ | 326 #ifdef __mips__ |
| 326 #if _MIPS_SIM == _MIPS_SIM_ABI64 | 327 #if _MIPS_SIM == _MIPS_SIM_ABI64 |
| 327 struct kernel_stat { | 328 struct kernel_stat { |
| 328 #else | 329 #else |
| 329 struct kernel_stat64 { | 330 struct kernel_stat64 { |
| 330 #endif | 331 #endif |
| 331 unsigned st_dev; | 332 unsigned st_dev; |
| 332 unsigned __pad0[3]; | 333 unsigned __pad0[3]; |
| 333 unsigned long long st_ino; | 334 unsigned long long st_ino; |
| 334 unsigned st_mode; | 335 unsigned st_mode; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 unsigned st_atime_; | 388 unsigned st_atime_; |
| 388 unsigned st_atime_nsec_; | 389 unsigned st_atime_nsec_; |
| 389 unsigned st_mtime_; | 390 unsigned st_mtime_; |
| 390 unsigned st_mtime_nsec_; | 391 unsigned st_mtime_nsec_; |
| 391 unsigned st_ctime_; | 392 unsigned st_ctime_; |
| 392 unsigned st_ctime_nsec_; | 393 unsigned st_ctime_nsec_; |
| 393 unsigned long long st_ino; | 394 unsigned long long st_ino; |
| 394 }; | 395 }; |
| 395 #endif | 396 #endif |
| 396 | 397 |
| 397 /* include/asm-{arm,aarch64,i386,mips,x86_64,ppc}/stat.h */ | 398 /* include/asm-{arm,aarch64,i386,mips,x86_64,ppc,s390}/stat.h */ |
| 398 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) | 399 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) |
| 399 struct kernel_stat { | 400 struct kernel_stat { |
| 400 /* The kernel headers suggest that st_dev and st_rdev should be 32bit | 401 /* The kernel headers suggest that st_dev and st_rdev should be 32bit |
| 401 * quantities encoding 12bit major and 20bit minor numbers in an interleaved | 402 * quantities encoding 12bit major and 20bit minor numbers in an interleaved |
| 402 * format. In reality, we do not see useful data in the top bits. So, | 403 * format. In reality, we do not see useful data in the top bits. So, |
| 403 * we'll leave the padding in here, until we find a better solution. | 404 * we'll leave the padding in here, until we find a better solution. |
| 404 */ | 405 */ |
| 405 unsigned short st_dev; | 406 unsigned short st_dev; |
| 406 short pad1; | 407 short pad1; |
| 407 unsigned st_ino; | 408 unsigned st_ino; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 long st_blocks; | 505 long st_blocks; |
| 505 long st_atime_; | 506 long st_atime_; |
| 506 unsigned long st_atime_nsec_; | 507 unsigned long st_atime_nsec_; |
| 507 long st_mtime_; | 508 long st_mtime_; |
| 508 unsigned long st_mtime_nsec_; | 509 unsigned long st_mtime_nsec_; |
| 509 long st_ctime_; | 510 long st_ctime_; |
| 510 unsigned long st_ctime_nsec_; | 511 unsigned long st_ctime_nsec_; |
| 511 unsigned int __unused4; | 512 unsigned int __unused4; |
| 512 unsigned int __unused5; | 513 unsigned int __unused5; |
| 513 }; | 514 }; |
| 515 #elif defined(__s390x__) | |
| 516 struct kernel_stat { | |
| 517 unsigned long st_dev; | |
| 518 unsigned long st_ino; | |
| 519 unsigned long st_nlink; | |
| 520 unsigned int st_mode; | |
| 521 unsigned int st_uid; | |
| 522 unsigned int st_gid; | |
| 523 unsigned int __pad1; | |
| 524 unsigned long st_rdev; | |
| 525 unsigned long st_size; | |
| 526 unsigned long st_atime_; | |
| 527 unsigned long st_atime_nsec_; | |
| 528 unsigned long st_mtime_; | |
| 529 unsigned long st_mtime_nsec_; | |
| 530 unsigned long st_ctime_; | |
| 531 unsigned long st_ctime_nsec_; | |
| 532 unsigned long st_blksize; | |
| 533 long st_blocks; | |
| 534 unsigned long __unused[3]; | |
| 535 }; | |
| 536 #elif defined(__s390__) | |
| 537 struct kernel_stat { | |
| 538 unsigned short st_dev; | |
| 539 unsigned short __pad1; | |
| 540 unsigned long st_ino; | |
| 541 unsigned short st_mode; | |
| 542 unsigned short st_nlink; | |
| 543 unsigned short st_uid; | |
| 544 unsigned short st_gid; | |
| 545 unsigned short st_rdev; | |
| 546 unsigned short __pad2; | |
| 547 unsigned long st_size; | |
| 548 unsigned long st_blksize; | |
| 549 unsigned long st_blocks; | |
| 550 unsigned long st_atime_; | |
| 551 unsigned long st_atime_nsec_; | |
| 552 unsigned long st_mtime_; | |
| 553 unsigned long st_mtime_nsec_; | |
| 554 unsigned long st_ctime_; | |
| 555 unsigned long st_ctime_nsec_; | |
| 556 unsigned long __unused4; | |
| 557 unsigned long __unused5; | |
| 558 }; | |
| 514 #endif | 559 #endif |
| 515 | 560 |
| 516 /* include/asm-{arm,aarch64,i386,mips,x86_64,ppc}/statfs.h */ | 561 /* include/asm-{arm,aarch64,i386,mips,x86_64,ppc,s390}/statfs.h */ |
| 517 #ifdef __mips__ | 562 #ifdef __mips__ |
| 518 #if _MIPS_SIM != _MIPS_SIM_ABI64 | 563 #if _MIPS_SIM != _MIPS_SIM_ABI64 |
| 519 struct kernel_statfs64 { | 564 struct kernel_statfs64 { |
| 520 unsigned long f_type; | 565 unsigned long f_type; |
| 521 unsigned long f_bsize; | 566 unsigned long f_bsize; |
| 522 unsigned long f_frsize; | 567 unsigned long f_frsize; |
| 523 unsigned long __pad; | 568 unsigned long __pad; |
| 524 unsigned long long f_blocks; | 569 unsigned long long f_blocks; |
| 525 unsigned long long f_bfree; | 570 unsigned long long f_bfree; |
| 526 unsigned long long f_files; | 571 unsigned long long f_files; |
| 527 unsigned long long f_ffree; | 572 unsigned long long f_ffree; |
| 528 unsigned long long f_bavail; | 573 unsigned long long f_bavail; |
| 529 struct { int val[2]; } f_fsid; | 574 struct { int val[2]; } f_fsid; |
| 530 unsigned long f_namelen; | 575 unsigned long f_namelen; |
| 531 unsigned long f_spare[6]; | 576 unsigned long f_spare[6]; |
| 532 }; | 577 }; |
| 533 #endif | 578 #endif |
| 579 #elif defined(__s390__) | |
| 580 /* See also arch/s390/include/asm/compat.h */ | |
| 581 struct kernel_statfs64 { | |
| 582 unsigned int f_type; | |
| 583 unsigned int f_bsize; | |
| 584 unsigned long long f_blocks; | |
| 585 unsigned long long f_bfree; | |
| 586 unsigned long long f_bavail; | |
| 587 unsigned long long f_files; | |
| 588 unsigned long long f_ffree; | |
| 589 struct { int val[2]; } f_fsid; | |
| 590 unsigned int f_namelen; | |
| 591 unsigned int f_frsize; | |
| 592 unsigned int f_flags; | |
| 593 unsigned int f_spare[4]; | |
| 594 }; | |
| 534 #elif !defined(__x86_64__) | 595 #elif !defined(__x86_64__) |
| 535 struct kernel_statfs64 { | 596 struct kernel_statfs64 { |
| 536 unsigned long f_type; | 597 unsigned long f_type; |
| 537 unsigned long f_bsize; | 598 unsigned long f_bsize; |
| 538 unsigned long long f_blocks; | 599 unsigned long long f_blocks; |
| 539 unsigned long long f_bfree; | 600 unsigned long long f_bfree; |
| 540 unsigned long long f_bavail; | 601 unsigned long long f_bavail; |
| 541 unsigned long long f_files; | 602 unsigned long long f_files; |
| 542 unsigned long long f_ffree; | 603 unsigned long long f_ffree; |
| 543 struct { int val[2]; } f_fsid; | 604 struct { int val[2]; } f_fsid; |
| 544 unsigned long f_namelen; | 605 unsigned long f_namelen; |
| 545 unsigned long f_frsize; | 606 unsigned long f_frsize; |
| 546 unsigned long f_spare[5]; | 607 unsigned long f_spare[5]; |
| 547 }; | 608 }; |
| 548 #endif | 609 #endif |
| 549 | 610 |
| 550 /* include/asm-{arm,i386,mips,x86_64,ppc,generic}/statfs.h */ | 611 /* include/asm-{arm,i386,mips,x86_64,ppc,generic,s390}/statfs.h */ |
| 551 #ifdef __mips__ | 612 #ifdef __mips__ |
| 552 struct kernel_statfs { | 613 struct kernel_statfs { |
| 553 long f_type; | 614 long f_type; |
| 554 long f_bsize; | 615 long f_bsize; |
| 555 long f_frsize; | 616 long f_frsize; |
| 556 long f_blocks; | 617 long f_blocks; |
| 557 long f_bfree; | 618 long f_bfree; |
| 558 long f_files; | 619 long f_files; |
| 559 long f_ffree; | 620 long f_ffree; |
| 560 long f_bavail; | 621 long f_bavail; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 572 uint64_t f_blocks; | 633 uint64_t f_blocks; |
| 573 uint64_t f_bfree; | 634 uint64_t f_bfree; |
| 574 uint64_t f_bavail; | 635 uint64_t f_bavail; |
| 575 uint64_t f_files; | 636 uint64_t f_files; |
| 576 uint64_t f_ffree; | 637 uint64_t f_ffree; |
| 577 struct { int val[2]; } f_fsid; | 638 struct { int val[2]; } f_fsid; |
| 578 uint64_t f_namelen; | 639 uint64_t f_namelen; |
| 579 uint64_t f_frsize; | 640 uint64_t f_frsize; |
| 580 uint64_t f_spare[5]; | 641 uint64_t f_spare[5]; |
| 581 }; | 642 }; |
| 643 #elif defined(__s390__) | |
| 644 struct kernel_statfs { | |
| 645 unsigned int f_type; | |
| 646 unsigned int f_bsize; | |
| 647 unsigned long f_blocks; | |
| 648 unsigned long f_bfree; | |
| 649 unsigned long f_bavail; | |
| 650 unsigned long f_files; | |
| 651 unsigned long f_ffree; | |
| 652 struct { int val[2]; } f_fsid; | |
| 653 unsigned int f_namelen; | |
| 654 unsigned int f_frsize; | |
| 655 unsigned int f_flags; | |
| 656 unsigned int f_spare[4]; | |
| 657 }; | |
| 582 #else | 658 #else |
| 583 struct kernel_statfs { | 659 struct kernel_statfs { |
| 584 unsigned long f_type; | 660 unsigned long f_type; |
| 585 unsigned long f_bsize; | 661 unsigned long f_bsize; |
| 586 unsigned long f_blocks; | 662 unsigned long f_blocks; |
| 587 unsigned long f_bfree; | 663 unsigned long f_bfree; |
| 588 unsigned long f_bavail; | 664 unsigned long f_bavail; |
| 589 unsigned long f_files; | 665 unsigned long f_files; |
| 590 unsigned long f_ffree; | 666 unsigned long f_ffree; |
| 591 struct { int val[2]; } f_fsid; | 667 struct { int val[2]; } f_fsid; |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 944 #endif | 1020 #endif |
| 945 #ifndef __NR_ioprio_get | 1021 #ifndef __NR_ioprio_get |
| 946 #define __NR_ioprio_get (__NR_SYSCALL_BASE + 315) | 1022 #define __NR_ioprio_get (__NR_SYSCALL_BASE + 315) |
| 947 #endif | 1023 #endif |
| 948 #ifndef __NR_move_pages | 1024 #ifndef __NR_move_pages |
| 949 #define __NR_move_pages (__NR_SYSCALL_BASE + 344) | 1025 #define __NR_move_pages (__NR_SYSCALL_BASE + 344) |
| 950 #endif | 1026 #endif |
| 951 #ifndef __NR_getcpu | 1027 #ifndef __NR_getcpu |
| 952 #define __NR_getcpu (__NR_SYSCALL_BASE + 345) | 1028 #define __NR_getcpu (__NR_SYSCALL_BASE + 345) |
| 953 #endif | 1029 #endif |
| 954 /* End of ARM 3/EABI definitions */ | 1030 /* End of ARM 3/EABI definitions */ |
| 955 #elif defined(__aarch64__) | 1031 #elif defined(__aarch64__) |
| 956 #ifndef __NR_setxattr | 1032 #ifndef __NR_setxattr |
| 957 #define __NR_setxattr 5 | 1033 #define __NR_setxattr 5 |
| 958 #endif | 1034 #endif |
| 959 #ifndef __NR_lsetxattr | 1035 #ifndef __NR_lsetxattr |
| 960 #define __NR_lsetxattr 6 | 1036 #define __NR_lsetxattr 6 |
| 961 #endif | 1037 #endif |
| 962 #ifndef __NR_getxattr | 1038 #ifndef __NR_getxattr |
| 963 #define __NR_getxattr 8 | 1039 #define __NR_getxattr 8 |
| 964 #endif | 1040 #endif |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1497 #ifndef __NR_unlinkat | 1573 #ifndef __NR_unlinkat |
| 1498 #define __NR_unlinkat 292 | 1574 #define __NR_unlinkat 292 |
| 1499 #endif | 1575 #endif |
| 1500 #ifndef __NR_move_pages | 1576 #ifndef __NR_move_pages |
| 1501 #define __NR_move_pages 301 | 1577 #define __NR_move_pages 301 |
| 1502 #endif | 1578 #endif |
| 1503 #ifndef __NR_getcpu | 1579 #ifndef __NR_getcpu |
| 1504 #define __NR_getcpu 302 | 1580 #define __NR_getcpu 302 |
| 1505 #endif | 1581 #endif |
| 1506 /* End of powerpc defininitions */ | 1582 /* End of powerpc defininitions */ |
| 1583 #elif defined(__s390__) | |
| 1584 #ifndef __s390x__ | |
|
vapier
2016/06/08 17:46:05
this nest is super hard to follow. rewrite it lik
bryanpkc-ibm
2016/06/08 20:38:05
Done.
| |
| 1585 #ifndef __NR_getrlimit | |
| 1586 #define __NR_getrlimit 76 | |
| 1587 #endif | |
| 1588 #endif /* !__s390x__ */ | |
| 1589 #ifndef __NR_quotactl | |
| 1590 #define __NR_quotactl 131 | |
| 1591 #endif | |
| 1592 #ifndef __s390x__ | |
| 1593 #ifndef __NR_setfsuid | |
| 1594 #define __NR_setfsuid 138 | |
| 1595 #define __NR_setfsgid 139 | |
| 1596 #endif | |
| 1597 #ifndef __NR_setresuid | |
| 1598 #define __NR_setresuid 164 | |
| 1599 #define __NR_getresuid 165 | |
| 1600 #define __NR_setresgid 170 | |
| 1601 #define __NR_getresgid 171 | |
| 1602 #endif | |
| 1603 #endif /* !__s390x__ */ | |
| 1604 #ifndef __NR_rt_sigreturn | |
| 1605 #define __NR_rt_sigreturn 173 | |
| 1606 #endif | |
| 1607 #ifndef __NR_rt_sigaction | |
| 1608 #define __NR_rt_sigaction 174 | |
| 1609 #endif | |
| 1610 #ifndef __NR_rt_sigprocmask | |
| 1611 #define __NR_rt_sigprocmask 175 | |
| 1612 #endif | |
| 1613 #ifndef __NR_rt_sigpending | |
| 1614 #define __NR_rt_sigpending 176 | |
| 1615 #endif | |
| 1616 #ifndef __NR_rt_sigsuspend | |
| 1617 #define __NR_rt_sigsuspend 179 | |
| 1618 #endif | |
| 1619 #ifndef __NR_pread64 | |
| 1620 #define __NR_pread64 180 | |
| 1621 #endif | |
| 1622 #ifndef __NR_pwrite64 | |
| 1623 #define __NR_pwrite64 181 | |
| 1624 #endif | |
| 1625 #ifndef __s390x__ | |
| 1626 #ifndef __NR_ugetrlimit | |
| 1627 #define __NR_ugetrlimit 191 | |
| 1628 #endif | |
| 1629 #else /* !__s390x__ */ | |
| 1630 #ifndef __NR_getrlimit | |
| 1631 #define __NR_getrlimit 191 | |
| 1632 #endif | |
| 1633 #endif /* __s390x__ */ | |
| 1634 #ifndef __s390x__ | |
| 1635 #ifndef __NR_mmap2 | |
| 1636 #define __NR_mmap2 192 | |
| 1637 #endif | |
| 1638 #endif /* !__s390x__ */ | |
| 1639 #ifndef __s390x__ | |
| 1640 #ifndef __NR_setresuid32 | |
| 1641 #define __NR_setresuid32 208 | |
| 1642 #define __NR_getresuid32 209 | |
| 1643 #define __NR_setresgid32 210 | |
| 1644 #define __NR_getresgid32 211 | |
| 1645 #endif | |
| 1646 #ifndef __NR_setfsuid32 | |
| 1647 #define __NR_setfsuid32 215 | |
| 1648 #define __NR_setfsgid32 216 | |
| 1649 #endif | |
| 1650 #else /* !__s390x__ */ | |
| 1651 #ifndef __NR_setresuid | |
| 1652 #define __NR_setresuid 208 | |
| 1653 #define __NR_getresuid 209 | |
| 1654 #define __NR_setresgid 210 | |
| 1655 #define __NR_getresgid 211 | |
| 1656 #endif | |
| 1657 #ifndef __NR_setfsuid | |
| 1658 #define __NR_setfsuid 215 | |
| 1659 #define __NR_setfsgid 216 | |
| 1660 #endif | |
| 1661 #endif /* __s390x__ */ | |
| 1662 #ifndef __NR_getdents64 | |
| 1663 #define __NR_getdents64 220 | |
| 1664 #endif | |
| 1665 #ifndef __NR_readahead | |
| 1666 #define __NR_readahead 222 | |
| 1667 #endif | |
| 1668 #ifndef __NR_setxattr | |
| 1669 #define __NR_setxattr 224 | |
| 1670 #endif | |
| 1671 #ifndef __NR_lsetxattr | |
| 1672 #define __NR_lsetxattr 225 | |
| 1673 #endif | |
| 1674 #ifndef __NR_getxattr | |
| 1675 #define __NR_getxattr 227 | |
| 1676 #endif | |
| 1677 #ifndef __NR_lgetxattr | |
| 1678 #define __NR_lgetxattr 228 | |
| 1679 #endif | |
| 1680 #ifndef __NR_listxattr | |
| 1681 #define __NR_listxattr 230 | |
| 1682 #endif | |
| 1683 #ifndef __NR_llistxattr | |
| 1684 #define __NR_llistxattr 231 | |
| 1685 #endif | |
| 1686 #ifndef __NR_gettid | |
| 1687 #define __NR_gettid 236 | |
| 1688 #endif | |
| 1689 #ifndef __NR_tkill | |
| 1690 #define __NR_tkill 237 | |
| 1691 #endif | |
| 1692 #ifndef __NR_futex | |
| 1693 #define __NR_futex 238 | |
| 1694 #endif | |
| 1695 #ifndef __NR_sched_setaffinity | |
| 1696 #define __NR_sched_setaffinity 239 | |
| 1697 #endif | |
| 1698 #ifndef __NR_sched_getaffinity | |
| 1699 #define __NR_sched_getaffinity 240 | |
| 1700 #endif | |
| 1701 #ifndef __NR_set_tid_address | |
| 1702 #define __NR_set_tid_address 252 | |
| 1703 #endif | |
| 1704 #ifndef __NR_fadvise64 | |
| 1705 #define __NR_fadvise64 253 | |
| 1706 #endif | |
| 1707 #ifndef __NR_clock_gettime | |
| 1708 #define __NR_clock_gettime 260 | |
| 1709 #endif | |
| 1710 #ifndef __NR_clock_getres | |
| 1711 #define __NR_clock_getres 261 | |
| 1712 #endif | |
| 1713 #ifndef __NR_statfs64 | |
| 1714 #define __NR_statfs64 265 | |
| 1715 #endif | |
| 1716 #ifndef __NR_fstatfs64 | |
| 1717 #define __NR_fstatfs64 266 | |
| 1718 #endif | |
| 1719 #ifndef __NR_ioprio_set | |
| 1720 #define __NR_ioprio_set 282 | |
| 1721 #endif | |
| 1722 #ifndef __NR_ioprio_get | |
| 1723 #define __NR_ioprio_get 283 | |
| 1724 #endif | |
| 1725 #ifndef __NR_openat | |
| 1726 #define __NR_openat 288 | |
| 1727 #endif | |
| 1728 #ifndef __s390x__ | |
| 1729 #ifndef __NR_fstatat64 | |
| 1730 #define __NR_fstatat64 293 | |
| 1731 #endif | |
| 1732 #else /* !__s390x__ */ | |
| 1733 #ifndef __NR_newfstatat | |
| 1734 #define __NR_newfstatat 293 | |
| 1735 #endif | |
| 1736 #endif /* __s390x__ */ | |
| 1737 #ifndef __NR_unlinkat | |
| 1738 #define __NR_unlinkat 294 | |
| 1739 #endif | |
| 1740 #ifndef __NR_move_pages | |
| 1741 #define __NR_move_pages 310 | |
| 1742 #endif | |
| 1743 #ifndef __NR_getcpu | |
| 1744 #define __NR_getcpu 311 | |
| 1745 #endif | |
| 1746 #ifndef __NR_fallocate | |
| 1747 #define __NR_fallocate 314 | |
| 1748 #endif | |
| 1749 /* End of s390/s390x definitions */ | |
| 1507 #endif | 1750 #endif |
| 1508 | 1751 |
| 1509 | 1752 |
| 1510 /* After forking, we must make sure to only call system calls. */ | 1753 /* After forking, we must make sure to only call system calls. */ |
| 1511 #if defined(__BOUNDED_POINTERS__) | 1754 #if defined(__BOUNDED_POINTERS__) |
| 1512 #error "Need to port invocations of syscalls for bounded ptrs" | 1755 #error "Need to port invocations of syscalls for bounded ptrs" |
| 1513 #else | 1756 #else |
| 1514 /* The core dumper and the thread lister get executed after threads | 1757 /* The core dumper and the thread lister get executed after threads |
| 1515 * have been suspended. As a consequence, we cannot call any functions | 1758 * have been suspended. As a consequence, we cannot call any functions |
| 1516 * that acquire locks. Unfortunately, libc wraps most system calls | 1759 * that acquire locks. Unfortunately, libc wraps most system calls |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1560 #elif defined(SYS_PREFIX) && SYS_PREFIX == 7 | 1803 #elif defined(SYS_PREFIX) && SYS_PREFIX == 7 |
| 1561 #define LSS_NAME(name) sys7_##name | 1804 #define LSS_NAME(name) sys7_##name |
| 1562 #elif defined(SYS_PREFIX) && SYS_PREFIX == 8 | 1805 #elif defined(SYS_PREFIX) && SYS_PREFIX == 8 |
| 1563 #define LSS_NAME(name) sys8_##name | 1806 #define LSS_NAME(name) sys8_##name |
| 1564 #elif defined(SYS_PREFIX) && SYS_PREFIX == 9 | 1807 #elif defined(SYS_PREFIX) && SYS_PREFIX == 9 |
| 1565 #define LSS_NAME(name) sys9_##name | 1808 #define LSS_NAME(name) sys9_##name |
| 1566 #endif | 1809 #endif |
| 1567 | 1810 |
| 1568 #undef LSS_RETURN | 1811 #undef LSS_RETURN |
| 1569 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ | 1812 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ |
| 1570 || defined(__ARM_EABI__) || defined(__aarch64__)) | 1813 || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__)) |
| 1571 /* Failing system calls return a negative result in the range of | 1814 /* Failing system calls return a negative result in the range of |
| 1572 * -1..-4095. These are "errno" values with the sign inverted. | 1815 * -1..-4095. These are "errno" values with the sign inverted. |
| 1573 */ | 1816 */ |
| 1574 #define LSS_RETURN(type, res) \ | 1817 #define LSS_RETURN(type, res) \ |
| 1575 do { \ | 1818 do { \ |
| 1576 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ | 1819 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ |
| 1577 LSS_ERRNO = -(res); \ | 1820 LSS_ERRNO = -(res); \ |
| 1578 res = -1; \ | 1821 res = -1; \ |
| 1579 } \ | 1822 } \ |
| 1580 return (type) (res); \ | 1823 return (type) (res); \ |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2969 : "0" (-1), "1" (EINVAL), | 3212 : "0" (-1), "1" (EINVAL), |
| 2970 "i" (__NR_clone), "i" (__NR_exit), | 3213 "i" (__NR_clone), "i" (__NR_exit), |
| 2971 "r" (__fn), "r" (__cstack), "r" (__flags), | 3214 "r" (__fn), "r" (__cstack), "r" (__flags), |
| 2972 "r" (__arg), "r" (__ptidptr), "r" (__newtls), | 3215 "r" (__arg), "r" (__ptidptr), "r" (__newtls), |
| 2973 "r" (__ctidptr) | 3216 "r" (__ctidptr) |
| 2974 : "cr0", "cr1", "memory", "ctr", | 3217 : "cr0", "cr1", "memory", "ctr", |
| 2975 "r0", "r29", "r27", "r28"); | 3218 "r0", "r29", "r27", "r28"); |
| 2976 } | 3219 } |
| 2977 LSS_RETURN(int, __ret, __err); | 3220 LSS_RETURN(int, __ret, __err); |
| 2978 } | 3221 } |
| 3222 #elif defined(__s390__) | |
| 3223 #undef LSS_REG | |
| 3224 #define LSS_REG(r, a) register unsigned long __r##r __asm__("r"#r) = (unsign ed long) a | |
| 3225 #undef LSS_BODY | |
| 3226 #define LSS_BODY(type, name, args...) \ | |
| 3227 register unsigned long __nr __asm__("r1") \ | |
| 3228 = (unsigned long)(__NR_##name); \ | |
| 3229 register long __res_r2 __asm__("r2"); \ | |
| 3230 long __res; \ | |
| 3231 __asm__ __volatile__ \ | |
| 3232 ("svc 0\n\t" \ | |
| 3233 : "=r"(__res_r2) \ | |
|
vapier
2016/06/08 17:46:05
i think you want to use a "d" constraint here (and
bryanpkc-ibm
2016/06/08 20:38:05
Done.
| |
| 3234 : "r"(__nr), ## args \ | |
| 3235 : "memory"); \ | |
| 3236 __res = __res_r2; \ | |
| 3237 LSS_RETURN(type, __res) | |
| 3238 #undef _syscall0 | |
| 3239 #define _syscall0(type, name) \ | |
| 3240 type LSS_NAME(name)(void) { \ | |
| 3241 LSS_BODY(type, name); \ | |
| 3242 } | |
| 3243 #undef _syscall1 | |
| 3244 #define _syscall1(type, name, type1, arg1) \ | |
| 3245 type LSS_NAME(name)(type1 arg1) { \ | |
| 3246 LSS_REG(2, arg1); \ | |
| 3247 LSS_BODY(type, name, "0"(__r2)); \ | |
| 3248 } | |
| 3249 #undef _syscall2 | |
| 3250 #define _syscall2(type, name, type1, arg1, type2, arg2) \ | |
| 3251 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ | |
| 3252 LSS_REG(2, arg1); LSS_REG(3, arg2); \ | |
| 3253 LSS_BODY(type, name, "0"(__r2), "r"(__r3)); \ | |
| 3254 } | |
| 3255 #undef _syscall3 | |
| 3256 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ | |
| 3257 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ | |
| 3258 LSS_REG(2, arg1); LSS_REG(3, arg2); LSS_REG(4, arg3); \ | |
| 3259 LSS_BODY(type, name, "0"(__r2), "r"(__r3), "r"(__r4)); \ | |
| 3260 } | |
| 3261 #undef _syscall4 | |
| 3262 #define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ | |
| 3263 type4, arg4) \ | |
| 3264 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, \ | |
| 3265 type4 arg4) { \ | |
| 3266 LSS_REG(2, arg1); LSS_REG(3, arg2); LSS_REG(4, arg3); \ | |
| 3267 LSS_REG(5, arg4); \ | |
| 3268 LSS_BODY(type, name, "0"(__r2), "r"(__r3), "r"(__r4), \ | |
| 3269 "r"(__r5)); \ | |
| 3270 } | |
| 3271 #undef _syscall5 | |
| 3272 #define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ | |
| 3273 type4, arg4, type5, arg5) \ | |
| 3274 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, \ | |
| 3275 type4 arg4, type5 arg5) { \ | |
| 3276 LSS_REG(2, arg1); LSS_REG(3, arg2); LSS_REG(4, arg3); \ | |
| 3277 LSS_REG(5, arg4); LSS_REG(6, arg5); \ | |
| 3278 LSS_BODY(type, name, "0"(__r2), "r"(__r3), "r"(__r4), \ | |
| 3279 "r"(__r5), "r"(__r6)); \ | |
| 3280 } | |
| 3281 #undef _syscall6 | |
| 3282 #define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ | |
| 3283 type4, arg4, type5, arg5, type6, arg6) \ | |
| 3284 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, \ | |
| 3285 type4 arg4, type5 arg5, type6 arg6) { \ | |
| 3286 LSS_REG(2, arg1); LSS_REG(3, arg2); LSS_REG(4, arg3); \ | |
| 3287 LSS_REG(5, arg4); LSS_REG(6, arg5); LSS_REG(7, arg6); \ | |
| 3288 LSS_BODY(type, name, "0"(__r2), "r"(__r3), "r"(__r4), \ | |
| 3289 "r"(__r5), "r"(__r6), "r"(__r7)); \ | |
| 3290 } | |
| 3291 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, | |
| 3292 int flags, void *arg, int *parent_tidptr, | |
| 3293 void *newtls, int *child_tidptr) { | |
| 3294 long __ret; | |
| 3295 { | |
| 3296 register int (*__fn)(void *) __asm__ ("r1") = fn; | |
| 3297 register void *__cstack __asm__ ("r2") = child_stack; | |
| 3298 register int __flags __asm__ ("r3") = flags; | |
| 3299 register void *__arg __asm__ ("r0") = arg; | |
| 3300 register int *__ptidptr __asm__ ("r4") = parent_tidptr; | |
| 3301 register void *__newtls __asm__ ("r6") = newtls; | |
| 3302 register int *__ctidptr __asm__ ("r5") = child_tidptr; | |
| 3303 __asm__ __volatile__ ( | |
| 3304 #ifndef __s390x__ | |
| 3305 /* arg already in r0 */ | |
| 3306 "ltr %4, %4\n\t" /* check fn, which is already in r1 */ | |
| 3307 "jz 1f\n\t" /* NULL function pointer, return -EINVAL */ | |
| 3308 "ltr %5, %5\n\t" /* check child_stack, which is already in r2 * / | |
| 3309 "jz 1f\n\t" /* NULL stack pointer, return -EINVAL */ | |
| 3310 /* flags already in r3 */ | |
| 3311 /* parent_tidptr already in r4 */ | |
| 3312 /* child_tidptr already in r5 */ | |
| 3313 /* newtls already in r6 */ | |
| 3314 "svc %2\n\t" /* invoke clone syscall */ | |
| 3315 "ltr %0,%%r2\n\t" /* load return code into __ret and test */ | |
| 3316 "jnz 1f\n\t" /* return to parent if non-zero */ | |
| 3317 /* start child thread */ | |
| 3318 "lr %%r2, %7\n\t" /* set first parameter to void *arg */ | |
| 3319 "ahi %%r15, -96\n\t" /* make room on the stack for the save area */ | |
| 3320 "xc 0(4,%%r15), 0(%%r15)\n\t" | |
| 3321 "basr %%r14, %4\n\t" /* jump to fn */ | |
| 3322 "svc %3\n" /* invoke exit syscall */ | |
| 3323 "1:\n" | |
| 3324 #else | |
| 3325 /* arg already in r0 */ | |
| 3326 "ltgr %4, %4\n\t" /* check fn, which is already in r1 */ | |
| 3327 "jz 1f\n\t" /* NULL function pointer, return -EINVAL */ | |
| 3328 "ltgr %5, %5\n\t" /* check child_stack, which is already in r2 * / | |
| 3329 "jz 1f\n\t" /* NULL stack pointer, return -EINVAL */ | |
| 3330 /* flags already in r3 */ | |
| 3331 /* parent_tidptr already in r4 */ | |
| 3332 /* child_tidptr already in r5 */ | |
| 3333 /* newtls already in r6 */ | |
| 3334 "svc %2\n\t" /* invoke clone syscall */ | |
| 3335 "ltgr %0, %%r2\n\t" /* load return code into __ret and test */ | |
| 3336 "jnz 1f\n\t" /* return to parent if non-zero */ | |
| 3337 /* start child thread */ | |
| 3338 "lgr %%r2, %7\n\t" /* set first parameter to void *arg */ | |
| 3339 "aghi %%r15, -160\n\t" /* make room on the stack for the save area */ | |
| 3340 "xc 0(8,%%r15), 0(%%r15)\n\t" | |
| 3341 "basr %%r14, %4\n\t" /* jump to fn */ | |
| 3342 "svc %3\n" /* invoke exit syscall */ | |
| 3343 "1:\n" | |
| 3344 #endif | |
| 3345 : "=r" (__ret) | |
| 3346 : "0" (-EINVAL), "i" (__NR_clone), "i" (__NR_exit), | |
| 3347 "r" (__fn), "r" (__cstack), "r" (__flags), "r" (__arg), | |
| 3348 "r" (__ptidptr), "r" (__newtls), "r" (__ctidptr) | |
| 3349 : "cc", "r14", "memory" | |
| 3350 ); | |
| 3351 } | |
| 3352 LSS_RETURN(int, __ret); | |
| 3353 } | |
| 2979 #endif | 3354 #endif |
| 2980 #define __NR__exit __NR_exit | 3355 #define __NR__exit __NR_exit |
| 2981 #define __NR__gettid __NR_gettid | 3356 #define __NR__gettid __NR_gettid |
| 2982 #define __NR__mremap __NR_mremap | 3357 #define __NR__mremap __NR_mremap |
| 2983 LSS_INLINE _syscall1(void *, brk, void *, e) | 3358 LSS_INLINE _syscall1(void *, brk, void *, e) |
| 2984 LSS_INLINE _syscall1(int, chdir, const char *,p) | 3359 LSS_INLINE _syscall1(int, chdir, const char *,p) |
| 2985 LSS_INLINE _syscall1(int, close, int, f) | 3360 LSS_INLINE _syscall1(int, close, int, f) |
| 2986 LSS_INLINE _syscall2(int, clock_getres, int, c, | 3361 LSS_INLINE _syscall2(int, clock_getres, int, c, |
| 2987 struct kernel_timespec*, t) | 3362 struct kernel_timespec*, t) |
| 2988 LSS_INLINE _syscall2(int, clock_gettime, int, c, | 3363 LSS_INLINE _syscall2(int, clock_gettime, int, c, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3190 LSS_INLINE _syscall4(int, socketpair, int, d, | 3565 LSS_INLINE _syscall4(int, socketpair, int, d, |
| 3191 int, t, int, p, int*, s) | 3566 int, t, int, p, int*, s) |
| 3192 #endif | 3567 #endif |
| 3193 #if defined(__x86_64__) | 3568 #if defined(__x86_64__) |
| 3194 /* Need to make sure loff_t isn't truncated to 32-bits under x32. */ | 3569 /* Need to make sure loff_t isn't truncated to 32-bits under x32. */ |
| 3195 LSS_INLINE int LSS_NAME(fallocate)(int f, int mode, loff_t offset, | 3570 LSS_INLINE int LSS_NAME(fallocate)(int f, int mode, loff_t offset, |
| 3196 loff_t len) { | 3571 loff_t len) { |
| 3197 LSS_BODY(4, int, fallocate, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(mode), | 3572 LSS_BODY(4, int, fallocate, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(mode), |
| 3198 (uint64_t)(offset), (uint64_t)(len)); | 3573 (uint64_t)(offset), (uint64_t)(len)); |
| 3199 } | 3574 } |
| 3200 | 3575 #endif |
| 3576 #if defined(__s390__) | |
| 3577 LSS_INLINE _syscall4(int, fadvise64, | |
| 3578 int, fd, loff_t, offset, loff_t, len, int, advice) | |
| 3579 LSS_INLINE _syscall4(int, fallocate, | |
| 3580 int, f, int, mode, loff_t, offset, loff_t, len) | |
| 3581 /* On s390, mmap() and mmap2() arguments are passed in memory. */ | |
| 3582 LSS_INLINE void* LSS_NAME(mmap)(void *s, size_t l, int p, int f, int d, | |
| 3583 off_t o) { | |
| 3584 unsigned long a[6] = { (unsigned long) s, (unsigned long) l, | |
| 3585 (unsigned long) p, (unsigned long) f, | |
| 3586 (unsigned long) d, (unsigned long) o }; | |
| 3587 register void *_a __asm__ ("r2") = a; | |
| 3588 LSS_BODY(void*, mmap, "0"(_a)); | |
| 3589 } | |
| 3590 #if !defined(__s390x__) | |
| 3591 LSS_INLINE void* LSS_NAME(mmap2)(void *s, size_t l, int p, int f, int d, | |
|
vapier
2016/06/08 17:46:05
do you need mmap2 at all ? the args are all trunc
bryanpkc-ibm
2016/06/08 20:38:05
I added support for mmap2 since it already existed
vapier
2016/06/08 21:03:29
i'm not sure why it'd be a problem ? mmap() requi
| |
| 3592 off_t o) { | |
| 3593 unsigned long a[6] = { (unsigned long) s, (unsigned long) l, | |
| 3594 (unsigned long) p, (unsigned long) f, | |
| 3595 (unsigned long) d, (unsigned long) o }; | |
| 3596 register void *_a __asm__ ("r2") = a; | |
| 3597 LSS_BODY(void*, mmap2, "0"(_a)); | |
| 3598 } | |
| 3599 #endif | |
| 3600 #endif | |
| 3601 #if defined(__x86_64__) || defined(__s390x__) | |
| 3201 LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid, | 3602 LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid, |
| 3202 gid_t *egid, | 3603 gid_t *egid, |
| 3203 gid_t *sgid) { | 3604 gid_t *sgid) { |
| 3204 return LSS_NAME(getresgid)(rgid, egid, sgid); | 3605 return LSS_NAME(getresgid)(rgid, egid, sgid); |
| 3205 } | 3606 } |
| 3206 | 3607 |
| 3207 LSS_INLINE int LSS_NAME(getresuid32)(uid_t *ruid, | 3608 LSS_INLINE int LSS_NAME(getresuid32)(uid_t *ruid, |
| 3208 uid_t *euid, | 3609 uid_t *euid, |
| 3209 uid_t *suid) { | 3610 uid_t *suid) { |
| 3210 return LSS_NAME(getresuid)(ruid, euid, suid); | 3611 return LSS_NAME(getresuid)(ruid, euid, suid); |
| 3211 } | 3612 } |
| 3212 | 3613 #if defined(__x86_64__) |
| 3213 /* Need to make sure __off64_t isn't truncated to 32-bits under x32. */ | 3614 /* Need to make sure __off64_t isn't truncated to 32-bits under x32. */ |
| 3214 LSS_INLINE void* LSS_NAME(mmap)(void *s, size_t l, int p, int f, int d, | 3615 LSS_INLINE void* LSS_NAME(mmap)(void *s, size_t l, int p, int f, int d, |
| 3215 int64_t o) { | 3616 int64_t o) { |
| 3216 LSS_BODY(6, void*, mmap, LSS_SYSCALL_ARG(s), LSS_SYSCALL_ARG(l), | 3617 LSS_BODY(6, void*, mmap, LSS_SYSCALL_ARG(s), LSS_SYSCALL_ARG(l), |
| 3217 LSS_SYSCALL_ARG(p), LSS_SYSCALL_ARG(f), | 3618 LSS_SYSCALL_ARG(p), LSS_SYSCALL_ARG(f), |
| 3218 LSS_SYSCALL_ARG(d), (uint64_t)(o)); | 3619 LSS_SYSCALL_ARG(d), (uint64_t)(o)); |
| 3219 } | 3620 } |
| 3220 | 3621 #endif |
| 3221 LSS_INLINE _syscall4(int, newfstatat, int, d, | 3622 LSS_INLINE _syscall4(int, newfstatat, int, d, |
| 3222 const char *, p, | 3623 const char *, p, |
| 3223 struct kernel_stat*, b, int, f) | 3624 struct kernel_stat*, b, int, f) |
| 3224 | 3625 |
| 3225 LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { | 3626 LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { |
| 3226 return LSS_NAME(setfsgid)(gid); | 3627 return LSS_NAME(setfsgid)(gid); |
| 3227 } | 3628 } |
| 3228 | 3629 |
| 3229 LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { | 3630 LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { |
| 3230 return LSS_NAME(setfsuid)(uid); | 3631 return LSS_NAME(setfsuid)(uid); |
| 3231 } | 3632 } |
| 3232 | 3633 |
| 3233 LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { | 3634 LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { |
| 3234 return LSS_NAME(setresgid)(rgid, egid, sgid); | 3635 return LSS_NAME(setresgid)(rgid, egid, sgid); |
| 3235 } | 3636 } |
| 3236 | 3637 |
| 3237 LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { | 3638 LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { |
| 3238 return LSS_NAME(setresuid)(ruid, euid, suid); | 3639 return LSS_NAME(setresuid)(ruid, euid, suid); |
| 3239 } | 3640 } |
| 3240 | 3641 |
| 3241 LSS_INLINE int LSS_NAME(sigaction)(int signum, | 3642 LSS_INLINE int LSS_NAME(sigaction)(int signum, |
| 3242 const struct kernel_sigaction *act, | 3643 const struct kernel_sigaction *act, |
| 3243 struct kernel_sigaction *oldact) { | 3644 struct kernel_sigaction *oldact) { |
| 3645 #if defined(__x86_64__) | |
| 3244 /* On x86_64, the kernel requires us to always set our own | 3646 /* On x86_64, the kernel requires us to always set our own |
| 3245 * SA_RESTORER in order to be able to return from a signal handler. | 3647 * SA_RESTORER in order to be able to return from a signal handler. |
| 3246 * This function must have a "magic" signature that the "gdb" | 3648 * This function must have a "magic" signature that the "gdb" |
| 3247 * (and maybe the kernel?) can recognize. | 3649 * (and maybe the kernel?) can recognize. |
| 3248 */ | 3650 */ |
| 3249 if (act != NULL && !(act->sa_flags & SA_RESTORER)) { | 3651 if (act != NULL && !(act->sa_flags & SA_RESTORER)) { |
| 3250 struct kernel_sigaction a = *act; | 3652 struct kernel_sigaction a = *act; |
| 3251 a.sa_flags |= SA_RESTORER; | 3653 a.sa_flags |= SA_RESTORER; |
| 3252 a.sa_restorer = LSS_NAME(restore_rt)(); | 3654 a.sa_restorer = LSS_NAME(restore_rt)(); |
| 3253 return LSS_NAME(rt_sigaction)(signum, &a, oldact, | 3655 return LSS_NAME(rt_sigaction)(signum, &a, oldact, |
| 3254 (KERNEL_NSIG+7)/8); | 3656 (KERNEL_NSIG+7)/8); |
| 3255 } else { | 3657 } else |
| 3658 #endif | |
| 3256 return LSS_NAME(rt_sigaction)(signum, act, oldact, | 3659 return LSS_NAME(rt_sigaction)(signum, act, oldact, |
| 3257 (KERNEL_NSIG+7)/8); | 3660 (KERNEL_NSIG+7)/8); |
| 3258 } | |
| 3259 } | 3661 } |
| 3260 | 3662 |
| 3261 LSS_INLINE int LSS_NAME(sigpending)(struct kernel_sigset_t *set) { | 3663 LSS_INLINE int LSS_NAME(sigpending)(struct kernel_sigset_t *set) { |
| 3262 return LSS_NAME(rt_sigpending)(set, (KERNEL_NSIG+7)/8); | 3664 return LSS_NAME(rt_sigpending)(set, (KERNEL_NSIG+7)/8); |
| 3263 } | 3665 } |
| 3264 | 3666 |
| 3265 LSS_INLINE int LSS_NAME(sigprocmask)(int how, | 3667 LSS_INLINE int LSS_NAME(sigprocmask)(int how, |
| 3266 const struct kernel_sigset_t *set, | 3668 const struct kernel_sigset_t *set, |
| 3267 struct kernel_sigset_t *oldset) { | 3669 struct kernel_sigset_t *oldset) { |
| 3268 return LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); | 3670 return LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); |
| 3269 } | 3671 } |
| 3270 | 3672 |
| 3271 LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { | 3673 LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { |
| 3272 return LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8); | 3674 return LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8); |
| 3273 } | 3675 } |
| 3274 #endif | 3676 #endif |
| 3275 #if defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ | 3677 #if defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ |
| 3276 defined(__ARM_EABI__) || defined(__aarch64__) || \ | 3678 defined(__ARM_EABI__) || defined(__aarch64__) || \ |
| 3277 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) | 3679 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) || \ |
| 3680 defined(__s390__) | |
| 3278 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, | 3681 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, |
| 3279 int*, s, int, o, | 3682 int*, s, int, o, |
| 3280 struct kernel_rusage*, r) | 3683 struct kernel_rusage*, r) |
| 3281 | 3684 |
| 3282 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){ | 3685 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){ |
| 3283 return LSS_NAME(wait4)(pid, status, options, 0); | 3686 return LSS_NAME(wait4)(pid, status, options, 0); |
| 3284 } | 3687 } |
| 3285 #endif | 3688 #endif |
| 3286 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) | 3689 #if defined(__NR_openat) |
| 3287 LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m) | 3690 LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m) |
| 3691 #endif | |
| 3692 #if defined(__NR_unlinkat) | |
| 3288 LSS_INLINE _syscall3(int, unlinkat, int, d, const char *, p, int, f) | 3693 LSS_INLINE _syscall3(int, unlinkat, int, d, const char *, p, int, f) |
| 3289 #endif | 3694 #endif |
| 3290 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) | 3695 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || \ |
| 3696 (defined(__s390__) && !defined(__s390x__)) | |
| 3291 #define __NR__getresgid32 __NR_getresgid32 | 3697 #define __NR__getresgid32 __NR_getresgid32 |
| 3292 #define __NR__getresuid32 __NR_getresuid32 | 3698 #define __NR__getresuid32 __NR_getresuid32 |
| 3293 #define __NR__setfsgid32 __NR_setfsgid32 | 3699 #define __NR__setfsgid32 __NR_setfsgid32 |
| 3294 #define __NR__setfsuid32 __NR_setfsuid32 | 3700 #define __NR__setfsuid32 __NR_setfsuid32 |
| 3295 #define __NR__setresgid32 __NR_setresgid32 | 3701 #define __NR__setresgid32 __NR_setresgid32 |
| 3296 #define __NR__setresuid32 __NR_setresuid32 | 3702 #define __NR__setresuid32 __NR_setresuid32 |
| 3297 #if defined(__ARM_EABI__) | 3703 #if defined(__ARM_EABI__) |
| 3298 LSS_INLINE _syscall2(int, ugetrlimit, int, r, | 3704 LSS_INLINE _syscall2(int, ugetrlimit, int, r, |
| 3299 struct kernel_rlimit*, l) | 3705 struct kernel_rlimit*, l) |
| 3300 #endif | 3706 #endif |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3434 LSS_INLINE int LSS_NAME(sigismember)(struct kernel_sigset_t *set, | 3840 LSS_INLINE int LSS_NAME(sigismember)(struct kernel_sigset_t *set, |
| 3435 int signum) { | 3841 int signum) { |
| 3436 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { | 3842 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { |
| 3437 LSS_ERRNO = EINVAL; | 3843 LSS_ERRNO = EINVAL; |
| 3438 return -1; | 3844 return -1; |
| 3439 } else { | 3845 } else { |
| 3440 return !!(set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] & | 3846 return !!(set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] & |
| 3441 (1UL << ((signum - 1) % (8*sizeof(set->sig[0]))))); | 3847 (1UL << ((signum - 1) % (8*sizeof(set->sig[0]))))); |
| 3442 } | 3848 } |
| 3443 } | 3849 } |
| 3444 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | 3850 #if defined(__i386__) || \ |
| 3445 defined(__ARM_EABI__) || \ | 3851 defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || \ |
| 3446 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) | 3852 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \ |
| 3853 defined(__PPC__) || \ | |
| 3854 (defined(__s390__) && !defined(__s390x__)) | |
| 3447 #define __NR__sigaction __NR_sigaction | 3855 #define __NR__sigaction __NR_sigaction |
| 3448 #define __NR__sigpending __NR_sigpending | 3856 #define __NR__sigpending __NR_sigpending |
| 3449 #define __NR__sigprocmask __NR_sigprocmask | 3857 #define __NR__sigprocmask __NR_sigprocmask |
| 3450 #define __NR__sigsuspend __NR_sigsuspend | 3858 #define __NR__sigsuspend __NR_sigsuspend |
| 3451 #define __NR__socketcall __NR_socketcall | 3859 #define __NR__socketcall __NR_socketcall |
| 3452 LSS_INLINE _syscall2(int, fstat64, int, f, | 3860 LSS_INLINE _syscall2(int, fstat64, int, f, |
| 3453 struct kernel_stat64 *, b) | 3861 struct kernel_stat64 *, b) |
| 3454 LSS_INLINE _syscall5(int, _llseek, uint, fd, | 3862 LSS_INLINE _syscall5(int, _llseek, uint, fd, |
| 3455 unsigned long, hi, unsigned long, lo, | 3863 unsigned long, hi, unsigned long, lo, |
| 3456 loff_t *, res, uint, wh) | 3864 loff_t *, res, uint, wh) |
| 3457 #if !defined(__ARM_EABI__) | 3865 #if !defined(__ARM_EABI__) && !defined(__s390__) |
| 3458 LSS_INLINE _syscall1(void*, mmap, void*, a) | 3866 LSS_INLINE _syscall1(void*, mmap, void*, a) |
|
vapier
2016/06/08 17:46:05
would be nice to move your new generic func above
bryanpkc-ibm
2016/06/08 20:38:05
OK, I wasn't sure if I should touch the ARM code,
vapier
2016/06/08 21:03:29
if it's the right thing to do, don't worry about t
| |
| 3459 #endif | 3867 #endif |
| 3868 #if !defined(__s390__) | |
| 3460 LSS_INLINE _syscall6(void*, mmap2, void*, s, | 3869 LSS_INLINE _syscall6(void*, mmap2, void*, s, |
| 3461 size_t, l, int, p, | 3870 size_t, l, int, p, |
| 3462 int, f, int, d, | 3871 int, f, int, d, |
| 3463 off_t, o) | 3872 off_t, o) |
| 3873 #endif | |
| 3464 LSS_INLINE _syscall3(int, _sigaction, int, s, | 3874 LSS_INLINE _syscall3(int, _sigaction, int, s, |
| 3465 const struct kernel_old_sigaction*, a, | 3875 const struct kernel_old_sigaction*, a, |
| 3466 struct kernel_old_sigaction*, o) | 3876 struct kernel_old_sigaction*, o) |
| 3467 LSS_INLINE _syscall1(int, _sigpending, unsigned long*, s) | 3877 LSS_INLINE _syscall1(int, _sigpending, unsigned long*, s) |
| 3468 LSS_INLINE _syscall3(int, _sigprocmask, int, h, | 3878 LSS_INLINE _syscall3(int, _sigprocmask, int, h, |
| 3469 const unsigned long*, s, | 3879 const unsigned long*, s, |
| 3470 unsigned long*, o) | 3880 unsigned long*, o) |
| 3471 #ifdef __PPC__ | 3881 #ifdef __PPC__ |
| 3472 LSS_INLINE _syscall1(int, _sigsuspend, unsigned long, s) | 3882 LSS_INLINE _syscall1(int, _sigsuspend, unsigned long, s) |
| 3473 #else | 3883 #else |
| 3474 LSS_INLINE _syscall3(int, _sigsuspend, const void*, a, | 3884 LSS_INLINE _syscall3(int, _sigsuspend, const void*, a, |
| 3475 int, b, | 3885 int, b, |
| 3476 unsigned long, s) | 3886 unsigned long, s) |
| 3477 #endif | 3887 #endif |
| 3478 LSS_INLINE _syscall2(int, stat64, const char *, p, | 3888 LSS_INLINE _syscall2(int, stat64, const char *, p, |
| 3479 struct kernel_stat64 *, b) | 3889 struct kernel_stat64 *, b) |
| 3480 | |
| 3481 LSS_INLINE int LSS_NAME(sigaction)(int signum, | 3890 LSS_INLINE int LSS_NAME(sigaction)(int signum, |
| 3482 const struct kernel_sigaction *act, | 3891 const struct kernel_sigaction *act, |
| 3483 struct kernel_sigaction *oldact) { | 3892 struct kernel_sigaction *oldact) { |
| 3484 int old_errno = LSS_ERRNO; | 3893 int old_errno = LSS_ERRNO; |
| 3485 int rc; | 3894 int rc; |
| 3486 struct kernel_sigaction a; | 3895 struct kernel_sigaction a; |
| 3487 if (act != NULL) { | 3896 if (act != NULL) { |
| 3488 a = *act; | 3897 a = *act; |
| 3489 #ifdef __i386__ | 3898 #ifdef __i386__ |
| 3490 /* On i386, the kernel requires us to always set our own | 3899 /* On i386, the kernel requires us to always set our own |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3678 msg, int, flags) | 4087 msg, int, flags) |
| 3679 LSS_INLINE _syscall6(ssize_t, sendto, int, s, const void*, buf, size_t,len, | 4088 LSS_INLINE _syscall6(ssize_t, sendto, int, s, const void*, buf, size_t,len, |
| 3680 int, flags, const struct kernel_sockaddr*, to, | 4089 int, flags, const struct kernel_sockaddr*, to, |
| 3681 unsigned int, tolen) | 4090 unsigned int, tolen) |
| 3682 LSS_INLINE _syscall2(int, shutdown, int, s, int, how) | 4091 LSS_INLINE _syscall2(int, shutdown, int, s, int, how) |
| 3683 LSS_INLINE _syscall3(int, socket, int, domain, int, type, int, protocol) | 4092 LSS_INLINE _syscall3(int, socket, int, domain, int, type, int, protocol) |
| 3684 LSS_INLINE _syscall4(int, socketpair, int, d, int, type, int, protocol, | 4093 LSS_INLINE _syscall4(int, socketpair, int, d, int, type, int, protocol, |
| 3685 int*, sv) | 4094 int*, sv) |
| 3686 #endif | 4095 #endif |
| 3687 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | 4096 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ |
| 3688 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) | 4097 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \ |
| 4098 defined(__s390__) | |
| 3689 #define __NR__socketcall __NR_socketcall | 4099 #define __NR__socketcall __NR_socketcall |
| 3690 LSS_INLINE _syscall2(int, _socketcall, int, c, | 4100 LSS_INLINE _syscall2(int, _socketcall, int, c, |
| 3691 va_list, a) | 4101 va_list, a) |
| 3692 LSS_INLINE int LSS_NAME(socketcall)(int op, ...) { | 4102 LSS_INLINE int LSS_NAME(socketcall)(int op, ...) { |
| 3693 int rc; | 4103 int rc; |
| 3694 va_list ap; | 4104 va_list ap; |
| 3695 va_start(ap, op); | 4105 va_start(ap, op); |
| 3696 rc = LSS_NAME(_socketcall)(op, ap); | 4106 rc = LSS_NAME(_socketcall)(op, ap); |
| 3697 va_end(ap); | 4107 va_end(ap); |
| 3698 return rc; | 4108 return rc; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 3722 | 4132 |
| 3723 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { | 4133 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { |
| 3724 return LSS_NAME(socketcall)(1, domain, type, protocol); | 4134 return LSS_NAME(socketcall)(1, domain, type, protocol); |
| 3725 } | 4135 } |
| 3726 | 4136 |
| 3727 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, | 4137 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, |
| 3728 int sv[2]) { | 4138 int sv[2]) { |
| 3729 return LSS_NAME(socketcall)(8, d, type, protocol, sv); | 4139 return LSS_NAME(socketcall)(8, d, type, protocol, sv); |
| 3730 } | 4140 } |
| 3731 #endif | 4141 #endif |
| 3732 #if defined(__i386__) || defined(__PPC__) | 4142 #if defined(__NR_fstatat64) |
| 3733 LSS_INLINE _syscall4(int, fstatat64, int, d, | 4143 LSS_INLINE _syscall4(int, fstatat64, int, d, |
| 3734 const char *, p, | 4144 const char *, p, |
| 3735 struct kernel_stat64 *, b, int, f) | 4145 struct kernel_stat64 *, b, int, f) |
| 3736 #endif | 4146 #endif |
| 3737 #if defined(__i386__) || defined(__PPC__) || \ | 4147 #if defined(__i386__) || defined(__PPC__) || \ |
| 3738 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) | 4148 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) |
| 3739 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p, | 4149 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p, |
| 3740 int*, s, int, o) | 4150 int*, s, int, o) |
| 3741 #endif | 4151 #endif |
| 3742 #if defined(__mips__) | 4152 #if defined(__mips__) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 3761 p[1] = __v1; | 4171 p[1] = __v1; |
| 3762 return 0; | 4172 return 0; |
| 3763 } | 4173 } |
| 3764 } | 4174 } |
| 3765 #elif !defined(__aarch64__) | 4175 #elif !defined(__aarch64__) |
| 3766 // The unlink syscall has been deprecated on aarch64. We polyfill it below. | 4176 // The unlink syscall has been deprecated on aarch64. We polyfill it below. |
| 3767 LSS_INLINE _syscall1(int, pipe, int *, p) | 4177 LSS_INLINE _syscall1(int, pipe, int *, p) |
| 3768 #endif | 4178 #endif |
| 3769 /* TODO(csilvers): see if ppc can/should support this as well */ | 4179 /* TODO(csilvers): see if ppc can/should support this as well */ |
| 3770 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | 4180 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ |
| 3771 defined(__ARM_EABI__) || \ | 4181 defined(__ARM_EABI__) || \ |
| 3772 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) | 4182 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) || \ |
| 4183 (defined(__s390__) && !defined(__s390x__)) | |
| 3773 #define __NR__statfs64 __NR_statfs64 | 4184 #define __NR__statfs64 __NR_statfs64 |
| 3774 #define __NR__fstatfs64 __NR_fstatfs64 | 4185 #define __NR__fstatfs64 __NR_fstatfs64 |
| 3775 LSS_INLINE _syscall3(int, _statfs64, const char*, p, | 4186 LSS_INLINE _syscall3(int, _statfs64, const char*, p, |
| 3776 size_t, s,struct kernel_statfs64*, b) | 4187 size_t, s,struct kernel_statfs64*, b) |
| 3777 LSS_INLINE _syscall3(int, _fstatfs64, int, f, | 4188 LSS_INLINE _syscall3(int, _fstatfs64, int, f, |
| 3778 size_t, s,struct kernel_statfs64*, b) | 4189 size_t, s,struct kernel_statfs64*, b) |
| 3779 LSS_INLINE int LSS_NAME(statfs64)(const char *p, | 4190 LSS_INLINE int LSS_NAME(statfs64)(const char *p, |
| 3780 struct kernel_statfs64 *b) { | 4191 struct kernel_statfs64 *b) { |
| 3781 return LSS_NAME(_statfs64)(p, sizeof(*b), b); | 4192 return LSS_NAME(_statfs64)(p, sizeof(*b), b); |
| 3782 } | 4193 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4028 # pragma pop_macro("fstat64") | 4439 # pragma pop_macro("fstat64") |
| 4029 # pragma pop_macro("lstat64") | 4440 # pragma pop_macro("lstat64") |
| 4030 #endif | 4441 #endif |
| 4031 | 4442 |
| 4032 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) | 4443 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) |
| 4033 } | 4444 } |
| 4034 #endif | 4445 #endif |
| 4035 | 4446 |
| 4036 #endif | 4447 #endif |
| 4037 #endif | 4448 #endif |
| OLD | NEW |