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" |
(...skipping 12 matching lines...) Expand all Loading... |
1658 "movq %4,0(%5)\n" | 1108 "movq %4,0(%5)\n" |
1659 | 1109 |
1660 /* %rax = syscall(%rax = __NR_clone, | 1110 /* %rax = syscall(%rax = __NR_clone, |
1661 * %rdi = flags, | 1111 * %rdi = flags, |
1662 * %rsi = child_stack, | 1112 * %rsi = child_stack, |
1663 * %rdx = parent_tidptr, | 1113 * %rdx = parent_tidptr, |
1664 * %r8 = new_tls, | 1114 * %r8 = new_tls, |
1665 * %r10 = child_tidptr) | 1115 * %r10 = child_tidptr) |
1666 */ | 1116 */ |
1667 "movq %2,%%rax\n" | 1117 "movq %2,%%rax\n" |
| 1118 "movq %9,%%r8\n" |
| 1119 "movq %10,%%r10\n" |
1668 "syscall\n" | 1120 "syscall\n" |
1669 | 1121 |
1670 /* if (%rax != 0) | 1122 /* if (%rax != 0) |
1671 * return; | 1123 * return; |
1672 */ | 1124 */ |
1673 "testq %%rax,%%rax\n" | 1125 "testq %%rax,%%rax\n" |
1674 "jnz 1f\n" | 1126 "jnz 1f\n" |
1675 | 1127 |
1676 /* In the child. Terminate frame pointer chain. | 1128 /* In the child. Terminate frame pointer chain. |
1677 */ | 1129 */ |
(...skipping 10 matching lines...) Expand all Loading... |
1688 "movq %%rax,%%rdi\n" | 1140 "movq %%rax,%%rdi\n" |
1689 "movq %3,%%rax\n" | 1141 "movq %3,%%rax\n" |
1690 "syscall\n" | 1142 "syscall\n" |
1691 | 1143 |
1692 /* Return to parent. | 1144 /* Return to parent. |
1693 */ | 1145 */ |
1694 "1:\n" | 1146 "1:\n" |
1695 : "=a" (__res) | 1147 : "=a" (__res) |
1696 : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), | 1148 : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), |
1697 "r"(fn), "S"(child_stack), "D"(flags), "r"(arg), | 1149 "r"(fn), "S"(child_stack), "D"(flags), "r"(arg), |
1698 "d"(parent_tidptr), "r"(__tls), "r"(__ctid) | 1150 "d"(parent_tidptr), "g"(newtls), "g"(child_tidptr
) |
1699 : "memory", "r11", "rcx"); | 1151 : "rsp", "memory", "r8", "r10", "r11", "rcx"); |
1700 } | 1152 } |
1701 LSS_RETURN(int, __res); | 1153 LSS_RETURN(int, __res); |
1702 } | 1154 } |
1703 LSS_INLINE _syscall4(int, fadvise64, int, fd, loff_t, offset, loff_t, len, | |
1704 int, advice) | |
1705 | 1155 |
1706 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { | 1156 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { |
1707 /* 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 |
1708 * 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 |
1709 * restorer function that calls the rt_sigreturn() system call. | 1159 * restorer function that calls the rt_sigreturn() system call. |
1710 * Unfortunately, we cannot just reference the glibc version of this | 1160 * Unfortunately, we cannot just reference the glibc version of this |
1711 * 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. |
1712 */ | 1162 */ |
1713 void (*res)(void); | 1163 void (*res)(void); |
1714 __asm__ __volatile__("call 2f\n" | 1164 __asm__ __volatile__("call 2f\n" |
1715 "0:.align 16\n" | 1165 "0:.align 16\n" |
1716 "1:movq %1,%%rax\n" | 1166 "1:movq %1,%%rax\n" |
1717 "syscall\n" | 1167 "syscall\n" |
1718 "2:popq %0\n" | 1168 "2:popq %0\n" |
1719 "addq $(1b-0b),%0\n" | 1169 "addq $(1b-0b),%0\n" |
1720 : "=a" (res) | 1170 : "=a" (res) |
1721 : "i" (__NR_rt_sigreturn)); | 1171 : "i" (__NR_rt_sigreturn)); |
1722 return res; | 1172 return res; |
1723 } | 1173 } |
1724 #elif defined(__ARM_ARCH_3__) | 1174 #elif defined(__arm__) |
1725 /* Most definitions of _syscallX() neglect to mark "memory" as being | 1175 /* Most definitions of _syscallX() neglect to mark "memory" as being |
1726 * clobbered. This causes problems with compilers, that do a better job | 1176 * clobbered. This causes problems with compilers, that do a better job |
1727 * at optimizing across __asm__ calls. | 1177 * at optimizing across __asm__ calls. |
1728 * So, we just have to redefine all fo the _syscallX() macros. | 1178 * So, we just have to redefine all fo the _syscallX() macros. |
1729 */ | 1179 */ |
1730 #undef LSS_REG | 1180 #undef LSS_REG |
1731 #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 |
1732 #undef LSS_BODY | 1193 #undef LSS_BODY |
1733 #define LSS_BODY(type,name,args...) \ | 1194 #define LSS_BODY(type, name, args...) \ |
1734 register long __res_r0 __asm__("r0"); \ | 1195 register long __res_r0 __asm__("r0"); \ |
1735 long __res; \ | 1196 long __res; \ |
1736 __asm__ __volatile__ (__syscall(name) \ | 1197 __SYS_REG(name) \ |
1737 : "=r"(__res_r0) : args : "lr", "memory"); \ | 1198 __asm__ __volatile__ (__syscall_safe(name) \ |
| 1199 : "=r"(__res_r0) \ |
| 1200 : __SYS_REG_LIST(args) \ |
| 1201 : "lr", "memory"); \ |
1738 __res = __res_r0; \ | 1202 __res = __res_r0; \ |
1739 LSS_RETURN(type, __res) | 1203 LSS_RETURN(type, __res) |
1740 #undef _syscall0 | 1204 #undef _syscall0 |
1741 #define _syscall0(type, name) \ | 1205 #define _syscall0(type, name) \ |
1742 type LSS_NAME(name)() { \ | 1206 type LSS_NAME(name)() { \ |
1743 LSS_BODY(type, name); \ | 1207 LSS_BODY(type, name); \ |
1744 } | 1208 } |
1745 #undef _syscall1 | 1209 #undef _syscall1 |
1746 #define _syscall1(type, name, type1, arg1) \ | 1210 #define _syscall1(type, name, type1, arg1) \ |
1747 type LSS_NAME(name)(type1 arg1) { \ | 1211 type LSS_NAME(name)(type1 arg1) { \ |
1748 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)); \ |
1749 } | 1215 } |
1750 #undef _syscall2 | 1216 #undef _syscall2 |
1751 #define _syscall2(type, name, type1, arg1, type2, arg2) \ | 1217 #define _syscall2(type, name, type1, arg1, type2, arg2) \ |
1752 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ | 1218 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ |
1753 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); \ |
1754 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ | 1223 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ |
1755 } | 1224 } |
1756 #undef _syscall3 | 1225 #undef _syscall3 |
1757 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ | 1226 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ |
1758 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ | 1227 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ |
1759 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); \ |
1760 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ | 1234 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ |
1761 } | 1235 } |
1762 #undef _syscall4 | 1236 #undef _syscall4 |
1763 #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) \ |
1764 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) { \ |
1765 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ | 1240 LSS_SAVE_ARG(0, arg1); \ |
1766 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); \ |
1767 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)); \ |
1768 } | 1249 } |
1769 #undef _syscall5 | 1250 #undef _syscall5 |
1770 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 1251 #define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ |
1771 type5,arg5) \ | 1252 type4, arg4, type5, arg5) \ |
1772 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, \ |
1773 type5 arg5) { \ | 1254 type5 arg5) { \ |
1774 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ | 1255 LSS_SAVE_ARG(0, arg1); \ |
1775 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); \ |
1776 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), \ |
1777 "r"(__r4)); \ | 1265 "r"(__r4)); \ |
1778 } | 1266 } |
1779 #undef _syscall6 | 1267 #undef _syscall6 |
1780 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 1268 #define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ |
1781 type5,arg5,type6,arg6) \ | 1269 type4, arg4, type5, arg5, type6, arg6) \ |
1782 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, \ |
1783 type5 arg5, type6 arg6) { \ | 1271 type5 arg5, type6 arg6) { \ |
1784 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ | 1272 LSS_SAVE_ARG(0, arg1); \ |
1785 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); \ |
1786 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), \ |
1787 "r"(__r4), "r"(__r5)); \ | 1283 "r"(__r4), "r"(__r5)); \ |
1788 } | 1284 } |
1789 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, |
1790 int flags, void *arg, int *parent_tidptr, | 1286 int flags, void *arg, int *parent_tidptr, |
1791 void *newtls, int *child_tidptr) { | 1287 void *newtls, int *child_tidptr) { |
1792 long __res; | 1288 register long __res __asm__("r5"); |
1793 { | 1289 { |
1794 register int __flags __asm__("r0") = flags; | 1290 if (fn == NULL || child_stack == NULL) { |
1795 register void *__stack __asm__("r1") = child_stack; | 1291 __res = -EINVAL; |
1796 register void *__ptid __asm__("r2") = parent_tidptr; | 1292 goto clone_exit; |
1797 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 |
1798 register int *__ctid __asm__("r4") = child_tidptr; | 1303 register int *__ctid __asm__("r4") = child_tidptr; |
1799 __asm__ __volatile__(/* if (fn == NULL || child_stack == NULL) | |
1800 * return -EINVAL; | |
1801 */ | |
1802 "cmp %2,#0\n" | |
1803 "cmpne %3,#0\n" | |
1804 "moveq %0,%1\n" | |
1805 "beq 1f\n" | |
1806 | 1304 |
1807 /* Push "arg" and "fn" onto the stack that will be | 1305 /* Push "arg" and "fn" onto the stack that will be |
1808 * used by the child. | 1306 * used by the child. |
1809 */ | 1307 */ |
1810 "str %5,[%3,#-4]!\n" | 1308 *(--tmp_stack) = (int) arg; |
1811 "str %2,[%3,#-4]!\n" | 1309 *(--tmp_stack) = (int) fn; |
1812 | 1310 |
1813 /* %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, |
1814 * %r1 = child_stack, | 1325 * %r1 = child_stack, |
1815 * %r2 = parent_tidptr, | 1326 * %r2 = parent_tidptr, |
1816 * %r3 = newtls, | 1327 * %r3 = newtls, |
1817 * %r4 = child_tidptr) | 1328 * %r4 = child_tidptr) |
1818 */ | 1329 */ |
| 1330 "push {r7}\n" |
| 1331 "mov r7,%1\n" |
1819 __syscall(clone)"\n" | 1332 __syscall(clone)"\n" |
1820 | 1333 |
1821 /* if (%r0 != 0) | 1334 /* if (%r0 != 0) |
1822 * return %r0; | 1335 * return %r0; |
1823 */ | 1336 */ |
1824 "movs %0,r0\n" | 1337 "movs %0,r0\n" |
1825 "bne 1f\n" | 1338 "bne 1f\n" |
1826 | 1339 |
1827 /* In the child, now. Call "fn(arg)". | 1340 /* In the child, now. Call "fn(arg)". |
1828 */ | 1341 */ |
1829 "ldr r0,[sp, #4]\n" | 1342 "ldr r0,[sp, #4]\n" |
1830 "mov lr,pc\n" | 1343 "mov lr,pc\n" |
1831 "ldr pc,[sp]\n" | 1344 "ldr pc,[sp]\n" |
1832 | 1345 |
1833 /* 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. |
1834 */ | 1350 */ |
| 1351 "mov r7,%2\n" |
1835 __syscall(exit)"\n" | 1352 __syscall(exit)"\n" |
1836 "1:\n" | 1353 |
| 1354 /* Pop r7 from the stack only in the parent. |
| 1355 */ |
| 1356 "1: pop {r7}\n" |
1837 : "=r" (__res) | 1357 : "=r" (__res) |
1838 : "i"(-EINVAL), | 1358 : "r"(__sysreg), |
1839 "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), | 1359 "i"(__NR_exit), "r"(__stack), "r"(__flags), |
1840 "r"(__ptid), "r"(__tls), "r"(__ctid) | 1360 "r"(__ptid), "r"(__tls), "r"(__ctid) |
1841 : "lr", "memory"); | 1361 : "cc", "lr", "memory"); |
1842 } | 1362 } |
| 1363 clone_exit: |
1843 LSS_RETURN(int, __res); | 1364 LSS_RETURN(int, __res); |
1844 } | 1365 } |
1845 #elif defined(__mips__) | 1366 #elif defined(__mips__) |
1846 #undef LSS_REG | 1367 #undef LSS_REG |
1847 #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) = \ |
1848 (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 |
1849 #undef LSS_BODY | 1381 #undef LSS_BODY |
1850 #define LSS_BODY(type,name,r7,...) \ | 1382 #define LSS_BODY(type,name,r7,...) \ |
1851 register unsigned long __v0 __asm__("$2") = __NR_##name; \ | 1383 register unsigned long __v0 __asm__("$2") = __NR_##name; \ |
1852 __asm__ __volatile__ ("syscall\n" \ | 1384 __asm__ __volatile__ ("syscall\n" \ |
1853 : "=&r"(__v0), r7 (__r7) \ | 1385 : "=&r"(__v0), r7 (__r7) \ |
1854 : "0"(__v0), ##__VA_ARGS__ \ | 1386 : "0"(__v0), ##__VA_ARGS__ \ |
1855 : "$8", "$9", "$10", "$11", "$12", \ | 1387 : MIPS_SYSCALL_CLOBBERS); \ |
1856 "$13", "$14", "$15", "$24", "memory"); \ | |
1857 LSS_RETURN(type, __v0, __r7) | 1388 LSS_RETURN(type, __v0, __r7) |
1858 #undef _syscall0 | 1389 #undef _syscall0 |
1859 #define _syscall0(type, name) \ | 1390 #define _syscall0(type, name) \ |
1860 type LSS_NAME(name)() { \ | 1391 type LSS_NAME(name)() { \ |
1861 register unsigned long __r7 __asm__("$7"); \ | 1392 register unsigned long __r7 __asm__("$7"); \ |
1862 LSS_BODY(type, name, "=r"); \ | 1393 LSS_BODY(type, name, "=r"); \ |
1863 } | 1394 } |
1864 #undef _syscall1 | 1395 #undef _syscall1 |
1865 #define _syscall1(type, name, type1, arg1) \ | 1396 #define _syscall1(type, name, type1, arg1) \ |
1866 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... |
1904 "lw $2, %6\n" \ | 1435 "lw $2, %6\n" \ |
1905 "subu $29, 32\n" \ | 1436 "subu $29, 32\n" \ |
1906 "sw $2, 16($29)\n" \ | 1437 "sw $2, 16($29)\n" \ |
1907 "li $2, %2\n" \ | 1438 "li $2, %2\n" \ |
1908 "syscall\n" \ | 1439 "syscall\n" \ |
1909 "addiu $29, 32\n" \ | 1440 "addiu $29, 32\n" \ |
1910 ".set reorder\n" \ | 1441 ".set reorder\n" \ |
1911 : "=&r"(__v0), "+r" (__r7) \ | 1442 : "=&r"(__v0), "+r" (__r7) \ |
1912 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ | 1443 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ |
1913 "r"(__r6), "m" ((unsigned long)arg5) \ | 1444 "r"(__r6), "m" ((unsigned long)arg5) \ |
1914 : "$8", "$9", "$10", "$11", "$12", \ | 1445 : MIPS_SYSCALL_CLOBBERS); \ |
1915 "$13", "$14", "$15", "$24", "memory"); \ | |
1916 LSS_RETURN(type, __v0, __r7); \ | 1446 LSS_RETURN(type, __v0, __r7); \ |
1917 } | 1447 } |
1918 #else | 1448 #else |
1919 #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, \ |
1920 type5,arg5) \ | 1450 type5,arg5) \ |
1921 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, \ |
1922 type5 arg5) { \ | 1452 type5 arg5) { \ |
1923 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); \ |
1924 LSS_REG(7, arg4); LSS_REG(8, arg5); \ | 1454 LSS_REG(7, arg4); LSS_REG(8, arg5); \ |
1925 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... |
1945 "sw $2, 16($29)\n" \ | 1475 "sw $2, 16($29)\n" \ |
1946 "sw $8, 20($29)\n" \ | 1476 "sw $8, 20($29)\n" \ |
1947 "li $2, %2\n" \ | 1477 "li $2, %2\n" \ |
1948 "syscall\n" \ | 1478 "syscall\n" \ |
1949 "addiu $29, 32\n" \ | 1479 "addiu $29, 32\n" \ |
1950 ".set reorder\n" \ | 1480 ".set reorder\n" \ |
1951 : "=&r"(__v0), "+r" (__r7) \ | 1481 : "=&r"(__v0), "+r" (__r7) \ |
1952 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ | 1482 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ |
1953 "r"(__r6), "r" ((unsigned long)arg5), \ | 1483 "r"(__r6), "r" ((unsigned long)arg5), \ |
1954 "r" ((unsigned long)arg6) \ | 1484 "r" ((unsigned long)arg6) \ |
1955 : "$8", "$9", "$10", "$11", "$12", \ | 1485 : MIPS_SYSCALL_CLOBBERS); \ |
1956 "$13", "$14", "$15", "$24", "memory"); \ | |
1957 LSS_RETURN(type, __v0, __r7); \ | 1486 LSS_RETURN(type, __v0, __r7); \ |
1958 } | 1487 } |
1959 #else | 1488 #else |
1960 #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, \ |
1961 type5,arg5,type6,arg6) \ | 1490 type5,arg5,type6,arg6) \ |
1962 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, \ |
1963 type5 arg5,type6 arg6) { \ | 1492 type5 arg5,type6 arg6) { \ |
1964 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); \ |
1965 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); \ |
1966 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... |
2242 "r" (__ctidptr) | 1771 "r" (__ctidptr) |
2243 : "cr0", "cr1", "memory", "ctr", | 1772 : "cr0", "cr1", "memory", "ctr", |
2244 "r0", "r29", "r27", "r28"); | 1773 "r0", "r29", "r27", "r28"); |
2245 } | 1774 } |
2246 LSS_RETURN(int, __ret, __err); | 1775 LSS_RETURN(int, __ret, __err); |
2247 } | 1776 } |
2248 #endif | 1777 #endif |
2249 #define __NR__exit __NR_exit | 1778 #define __NR__exit __NR_exit |
2250 #define __NR__gettid __NR_gettid | 1779 #define __NR__gettid __NR_gettid |
2251 #define __NR__mremap __NR_mremap | 1780 #define __NR__mremap __NR_mremap |
2252 LSS_INLINE _syscall1(int, chdir, const char *,p) | |
2253 LSS_INLINE _syscall1(int, close, int, f) | 1781 LSS_INLINE _syscall1(int, close, int, f) |
2254 LSS_INLINE _syscall2(int, clock_getres, int, c, | |
2255 struct kernel_timespec*, t) | |
2256 LSS_INLINE _syscall2(int, clock_gettime, int, c, | |
2257 struct kernel_timespec*, t) | |
2258 LSS_INLINE _syscall1(int, dup, int, f) | |
2259 LSS_INLINE _syscall2(int, dup2, int, s, | |
2260 int, d) | |
2261 LSS_INLINE _syscall3(int, execve, const char*, f, | |
2262 const char*const*,a,const char*const*, e) | |
2263 LSS_INLINE _syscall1(int, _exit, int, e) | 1782 LSS_INLINE _syscall1(int, _exit, int, e) |
2264 LSS_INLINE _syscall3(int, fcntl, int, f, | 1783 LSS_INLINE _syscall3(int, fcntl, int, f, |
2265 int, c, long, a) | 1784 int, c, long, a) |
2266 LSS_INLINE _syscall0(pid_t, fork) | |
2267 LSS_INLINE _syscall2(int, fstat, int, f, | 1785 LSS_INLINE _syscall2(int, fstat, int, f, |
2268 struct kernel_stat*, b) | 1786 struct kernel_stat*, b) |
2269 LSS_INLINE _syscall2(int, fstatfs, int, f, | |
2270 struct kernel_statfs*, b) | |
2271 LSS_INLINE _syscall4(int, futex, int*, a, | 1787 LSS_INLINE _syscall4(int, futex, int*, a, |
2272 int, o, int, v, | 1788 int, o, int, v, |
2273 struct kernel_timespec*, t) | 1789 struct kernel_timespec*, t) |
2274 LSS_INLINE _syscall3(int, getdents, int, f, | 1790 LSS_INLINE _syscall3(int, getdents, int, f, |
2275 struct kernel_dirent*, d, int, c) | 1791 struct kernel_dirent*, d, int, c) |
| 1792 #ifdef __NR_getdents64 |
2276 LSS_INLINE _syscall3(int, getdents64, int, f, | 1793 LSS_INLINE _syscall3(int, getdents64, int, f, |
2277 struct kernel_dirent64*, d, int, c) | 1794 struct kernel_dirent64*, d, int, c) |
2278 LSS_INLINE _syscall0(gid_t, getegid) | 1795 #endif |
2279 LSS_INLINE _syscall0(uid_t, geteuid) | |
2280 LSS_INLINE _syscall0(pid_t, getpgrp) | |
2281 LSS_INLINE _syscall0(pid_t, getpid) | 1796 LSS_INLINE _syscall0(pid_t, getpid) |
2282 LSS_INLINE _syscall0(pid_t, getppid) | 1797 LSS_INLINE _syscall0(pid_t, getppid) |
2283 LSS_INLINE _syscall2(int, getpriority, int, a, | |
2284 int, b) | |
2285 LSS_INLINE _syscall2(int, getrlimit, int, r, | |
2286 struct kernel_rlimit*, l) | |
2287 LSS_INLINE _syscall1(pid_t, getsid, pid_t, p) | |
2288 LSS_INLINE _syscall0(pid_t, _gettid) | 1798 LSS_INLINE _syscall0(pid_t, _gettid) |
2289 LSS_INLINE _syscall5(int, setxattr, const char *,p, | |
2290 const char *, n, const void *,v, | |
2291 size_t, s, int, f) | |
2292 LSS_INLINE _syscall5(int, lsetxattr, const char *,p, | |
2293 const char *, n, const void *,v, | |
2294 size_t, s, int, f) | |
2295 LSS_INLINE _syscall4(ssize_t, getxattr, const char *,p, | |
2296 const char *, n, void *, v, size_t, s) | |
2297 LSS_INLINE _syscall4(ssize_t, lgetxattr, const char *,p, | |
2298 const char *, n, void *, v, size_t, s) | |
2299 LSS_INLINE _syscall3(ssize_t, listxattr, const char *,p, | |
2300 char *, l, size_t, s) | |
2301 LSS_INLINE _syscall3(ssize_t, llistxattr, const char *,p, | |
2302 char *, l, size_t, s) | |
2303 LSS_INLINE _syscall2(int, ioprio_get, int, which, | |
2304 int, who) | |
2305 LSS_INLINE _syscall3(int, ioprio_set, int, which, | |
2306 int, who, int, ioprio) | |
2307 LSS_INLINE _syscall2(int, kill, pid_t, p, | 1799 LSS_INLINE _syscall2(int, kill, pid_t, p, |
2308 int, s) | 1800 int, s) |
2309 LSS_INLINE _syscall3(off_t, lseek, int, f, | 1801 LSS_INLINE _syscall3(off_t, lseek, int, f, |
2310 off_t, o, int, w) | 1802 off_t, o, int, w) |
2311 LSS_INLINE _syscall2(int, munmap, void*, s, | 1803 LSS_INLINE _syscall2(int, munmap, void*, s, |
2312 size_t, l) | 1804 size_t, l) |
2313 LSS_INLINE _syscall6(long, move_pages, pid_t, p, | |
2314 unsigned long, n, void **,g, int *, d, | |
2315 int *, s, int, f) | |
2316 LSS_INLINE _syscall5(void*, _mremap, void*, o, | 1805 LSS_INLINE _syscall5(void*, _mremap, void*, o, |
2317 size_t, os, size_t, ns, | 1806 size_t, os, size_t, ns, |
2318 unsigned long, f, void *, a) | 1807 unsigned long, f, void *, a) |
2319 LSS_INLINE _syscall3(int, open, const char*, p, | 1808 LSS_INLINE _syscall3(int, open, const char*, p, |
2320 int, f, int, m) | 1809 int, f, int, m) |
2321 LSS_INLINE _syscall3(int, poll, struct kernel_pollfd*, u, | |
2322 unsigned int, n, int, t) | |
2323 LSS_INLINE _syscall2(int, prctl, int, o, | 1810 LSS_INLINE _syscall2(int, prctl, int, o, |
2324 long, a) | 1811 long, a) |
2325 LSS_INLINE _syscall4(long, ptrace, int, r, | 1812 LSS_INLINE _syscall4(long, ptrace, int, r, |
2326 pid_t, p, void *, a, void *, d) | 1813 pid_t, p, void *, a, void *, d) |
2327 LSS_INLINE _syscall3(ssize_t, read, int, f, | 1814 LSS_INLINE _syscall3(ssize_t, read, int, f, |
2328 void *, b, size_t, c) | 1815 void *, b, size_t, c) |
2329 LSS_INLINE _syscall3(int, readlink, const char*, p, | |
2330 char*, b, size_t, s) | |
2331 LSS_INLINE _syscall4(int, rt_sigaction, int, s, | 1816 LSS_INLINE _syscall4(int, rt_sigaction, int, s, |
2332 const struct kernel_sigaction*, a, | 1817 const struct kernel_sigaction*, a, |
2333 struct kernel_sigaction*, o, size_t, c) | 1818 struct kernel_sigaction*, o, size_t, c) |
2334 LSS_INLINE _syscall2(int, rt_sigpending, struct kernel_sigset_t *, s, | |
2335 size_t, c) | |
2336 LSS_INLINE _syscall4(int, rt_sigprocmask, int, h, | 1819 LSS_INLINE _syscall4(int, rt_sigprocmask, int, h, |
2337 const struct kernel_sigset_t*, s, | 1820 const struct kernel_sigset_t*, s, |
2338 struct kernel_sigset_t*, o, size_t, c); | 1821 struct kernel_sigset_t*, o, size_t, c); |
2339 LSS_INLINE _syscall2(int, rt_sigsuspend, | |
2340 const struct kernel_sigset_t*, s, size_t, c); | |
2341 LSS_INLINE _syscall3(int, sched_getaffinity,pid_t, p, | |
2342 unsigned int, l, unsigned long *, m) | |
2343 LSS_INLINE _syscall3(int, sched_setaffinity,pid_t, p, | |
2344 unsigned int, l, unsigned long *, m) | |
2345 LSS_INLINE _syscall0(int, sched_yield) | 1822 LSS_INLINE _syscall0(int, sched_yield) |
2346 LSS_INLINE _syscall1(long, set_tid_address, int *, t) | |
2347 LSS_INLINE _syscall1(int, setfsgid, gid_t, g) | |
2348 LSS_INLINE _syscall1(int, setfsuid, uid_t, u) | |
2349 LSS_INLINE _syscall1(int, setuid, uid_t, u) | |
2350 LSS_INLINE _syscall1(int, setgid, gid_t, g) | |
2351 LSS_INLINE _syscall2(int, setpgid, pid_t, p, | |
2352 pid_t, g) | |
2353 LSS_INLINE _syscall3(int, setpriority, int, a, | |
2354 int, b, int, p) | |
2355 LSS_INLINE _syscall3(int, setresgid, gid_t, r, | |
2356 gid_t, e, gid_t, s) | |
2357 LSS_INLINE _syscall3(int, setresuid, uid_t, r, | |
2358 uid_t, e, uid_t, s) | |
2359 LSS_INLINE _syscall2(int, setrlimit, int, r, | |
2360 const struct kernel_rlimit*, l) | |
2361 LSS_INLINE _syscall0(pid_t, setsid) | |
2362 LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, | 1823 LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, |
2363 const stack_t*, o) | 1824 const stack_t*, o) |
2364 LSS_INLINE _syscall2(int, stat, const char*, f, | 1825 LSS_INLINE _syscall2(int, stat, const char*, f, |
2365 struct kernel_stat*, b) | 1826 struct kernel_stat*, b) |
2366 LSS_INLINE _syscall2(int, statfs, const char*, f, | |
2367 struct kernel_statfs*, b) | |
2368 LSS_INLINE _syscall3(ssize_t, write, int, f, | 1827 LSS_INLINE _syscall3(ssize_t, write, int, f, |
2369 const void *, b, size_t, c) | 1828 const void *, b, size_t, c) |
2370 LSS_INLINE _syscall3(ssize_t, writev, int, f, | |
2371 const struct kernel_iovec*, v, size_t, c) | |
2372 #if defined(__NR_getcpu) | 1829 #if defined(__NR_getcpu) |
2373 LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, | 1830 LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, |
2374 unsigned *, node, void *, unused); | 1831 unsigned *, node, void *, unused); |
2375 #endif | 1832 #endif |
2376 #if defined(__x86_64__) || \ | 1833 #if defined(__x86_64__) || \ |
2377 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) | 1834 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) |
2378 LSS_INLINE _syscall3(int, recvmsg, int, s, | |
2379 struct kernel_msghdr*, m, int, f) | |
2380 LSS_INLINE _syscall3(int, sendmsg, int, s, | |
2381 const struct kernel_msghdr*, m, int, f) | |
2382 LSS_INLINE _syscall6(int, sendto, int, s, | |
2383 const void*, m, size_t, l, | |
2384 int, f, | |
2385 const struct kernel_sockaddr*, a, int, t) | |
2386 LSS_INLINE _syscall2(int, shutdown, int, s, | |
2387 int, h) | |
2388 LSS_INLINE _syscall3(int, socket, int, d, | 1835 LSS_INLINE _syscall3(int, socket, int, d, |
2389 int, t, int, p) | 1836 int, t, int, p) |
2390 LSS_INLINE _syscall4(int, socketpair, int, d, | |
2391 int, t, int, p, int*, s) | |
2392 #endif | 1837 #endif |
2393 #if defined(__x86_64__) | 1838 #if defined(__x86_64__) |
2394 LSS_INLINE _syscall4(int, fallocate, int, fd, int, mode, | |
2395 loff_t, offset, loff_t, len) | |
2396 LSS_INLINE _syscall6(void*, mmap, void*, s, | 1839 LSS_INLINE _syscall6(void*, mmap, void*, s, |
2397 size_t, l, int, p, | 1840 size_t, l, int, p, |
2398 int, f, int, d, | 1841 int, f, int, d, |
2399 __off64_t, o) | 1842 __off64_t, o) |
2400 LSS_INLINE _syscall4(int, newfstatat, int, d, | |
2401 const char *, p, | |
2402 struct kernel_stat*, b, int, f) | |
2403 | |
2404 LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { | |
2405 return LSS_NAME(setfsgid)(gid); | |
2406 } | |
2407 | |
2408 LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { | |
2409 return LSS_NAME(setfsuid)(uid); | |
2410 } | |
2411 | |
2412 LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { | |
2413 return LSS_NAME(setresgid)(rgid, egid, sgid); | |
2414 } | |
2415 | |
2416 LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { | |
2417 return LSS_NAME(setresuid)(ruid, euid, suid); | |
2418 } | |
2419 | 1843 |
2420 LSS_INLINE int LSS_NAME(sigaction)(int signum, | 1844 LSS_INLINE int LSS_NAME(sigaction)(int signum, |
2421 const struct kernel_sigaction *act, | 1845 const struct kernel_sigaction *act, |
2422 struct kernel_sigaction *oldact) { | 1846 struct kernel_sigaction *oldact) { |
2423 /* 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 |
2424 * 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. |
2425 * This function must have a "magic" signature that the "gdb" | 1849 * This function must have a "magic" signature that the "gdb" |
2426 * (and maybe the kernel?) can recognize. | 1850 * (and maybe the kernel?) can recognize. |
2427 */ | 1851 */ |
2428 if (act != NULL && !(act->sa_flags & SA_RESTORER)) { | 1852 if (act != NULL && !(act->sa_flags & SA_RESTORER)) { |
2429 struct kernel_sigaction a = *act; | 1853 struct kernel_sigaction a = *act; |
2430 a.sa_flags |= SA_RESTORER; | 1854 a.sa_flags |= SA_RESTORER; |
2431 a.sa_restorer = LSS_NAME(restore_rt)(); | 1855 a.sa_restorer = LSS_NAME(restore_rt)(); |
2432 return LSS_NAME(rt_sigaction)(signum, &a, oldact, | 1856 return LSS_NAME(rt_sigaction)(signum, &a, oldact, |
2433 (KERNEL_NSIG+7)/8); | 1857 (KERNEL_NSIG+7)/8); |
2434 } else { | 1858 } else { |
2435 return LSS_NAME(rt_sigaction)(signum, act, oldact, | 1859 return LSS_NAME(rt_sigaction)(signum, act, oldact, |
2436 (KERNEL_NSIG+7)/8); | 1860 (KERNEL_NSIG+7)/8); |
2437 } | 1861 } |
2438 } | 1862 } |
2439 | 1863 |
2440 LSS_INLINE int LSS_NAME(sigpending)(struct kernel_sigset_t *set) { | |
2441 return LSS_NAME(rt_sigpending)(set, (KERNEL_NSIG+7)/8); | |
2442 } | |
2443 | |
2444 LSS_INLINE int LSS_NAME(sigprocmask)(int how, | 1864 LSS_INLINE int LSS_NAME(sigprocmask)(int how, |
2445 const struct kernel_sigset_t *set, | 1865 const struct kernel_sigset_t *set, |
2446 struct kernel_sigset_t *oldset) { | 1866 struct kernel_sigset_t *oldset) { |
2447 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); |
2448 } | 1868 } |
2449 | |
2450 LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { | |
2451 return LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8); | |
2452 } | |
2453 #endif | 1869 #endif |
2454 #if defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ | 1870 #if defined(__x86_64__) || \ |
| 1871 defined(__arm__) || \ |
2455 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) | 1872 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) |
2456 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, | 1873 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, |
2457 int*, s, int, o, | 1874 int*, s, int, o, |
2458 struct kernel_rusage*, r) | 1875 struct kernel_rusage*, r) |
2459 | |
2460 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){ |
2461 return LSS_NAME(wait4)(pid, status, options, 0); | 1877 return LSS_NAME(wait4)(pid, status, options, 0); |
2462 } | 1878 } |
2463 #endif | 1879 #endif |
2464 #if defined(__i386__) || defined(__x86_64__) | 1880 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) |
2465 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) |
2466 LSS_INLINE _syscall3(int, unlinkat, int, d, const char *, p, int, f) | |
2467 #endif | |
2468 #if defined(__i386__) || defined(__ARM_ARCH_3__) | |
2469 #define __NR__setfsgid32 __NR_setfsgid32 | |
2470 #define __NR__setfsuid32 __NR_setfsuid32 | |
2471 #define __NR__setresgid32 __NR_setresgid32 | |
2472 #define __NR__setresuid32 __NR_setresuid32 | |
2473 LSS_INLINE _syscall2(int, ugetrlimit, int, r, | |
2474 struct kernel_rlimit*, l) | |
2475 LSS_INLINE _syscall1(int, _setfsgid32, gid_t, f) | |
2476 LSS_INLINE _syscall1(int, _setfsuid32, uid_t, f) | |
2477 LSS_INLINE _syscall3(int, _setresgid32, gid_t, r, | |
2478 gid_t, e, gid_t, s) | |
2479 LSS_INLINE _syscall3(int, _setresuid32, uid_t, r, | |
2480 uid_t, e, uid_t, s) | |
2481 | |
2482 LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { | |
2483 int rc; | |
2484 if ((rc = LSS_NAME(_setfsgid32)(gid)) < 0 && | |
2485 LSS_ERRNO == ENOSYS) { | |
2486 if ((unsigned int)gid & ~0xFFFFu) { | |
2487 rc = EINVAL; | |
2488 } else { | |
2489 rc = LSS_NAME(setfsgid)(gid); | |
2490 } | |
2491 } | |
2492 return rc; | |
2493 } | |
2494 | |
2495 LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { | |
2496 int rc; | |
2497 if ((rc = LSS_NAME(_setfsuid32)(uid)) < 0 && | |
2498 LSS_ERRNO == ENOSYS) { | |
2499 if ((unsigned int)uid & ~0xFFFFu) { | |
2500 rc = EINVAL; | |
2501 } else { | |
2502 rc = LSS_NAME(setfsuid)(uid); | |
2503 } | |
2504 } | |
2505 return rc; | |
2506 } | |
2507 | |
2508 LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { | |
2509 int rc; | |
2510 if ((rc = LSS_NAME(_setresgid32)(rgid, egid, sgid)) < 0 && | |
2511 LSS_ERRNO == ENOSYS) { | |
2512 if ((unsigned int)rgid & ~0xFFFFu || | |
2513 (unsigned int)egid & ~0xFFFFu || | |
2514 (unsigned int)sgid & ~0xFFFFu) { | |
2515 rc = EINVAL; | |
2516 } else { | |
2517 rc = LSS_NAME(setresgid)(rgid, egid, sgid); | |
2518 } | |
2519 } | |
2520 return rc; | |
2521 } | |
2522 | |
2523 LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { | |
2524 int rc; | |
2525 if ((rc = LSS_NAME(_setresuid32)(ruid, euid, suid)) < 0 && | |
2526 LSS_ERRNO == ENOSYS) { | |
2527 if ((unsigned int)ruid & ~0xFFFFu || | |
2528 (unsigned int)euid & ~0xFFFFu || | |
2529 (unsigned int)suid & ~0xFFFFu) { | |
2530 rc = EINVAL; | |
2531 } else { | |
2532 rc = LSS_NAME(setresuid)(ruid, euid, suid); | |
2533 } | |
2534 } | |
2535 return rc; | |
2536 } | |
2537 #endif | 1882 #endif |
2538 LSS_INLINE int LSS_NAME(sigemptyset)(struct kernel_sigset_t *set) { | 1883 LSS_INLINE int LSS_NAME(sigemptyset)(struct kernel_sigset_t *set) { |
2539 memset(&set->sig, 0, sizeof(set->sig)); | 1884 memset(&set->sig, 0, sizeof(set->sig)); |
2540 return 0; | 1885 return 0; |
2541 } | 1886 } |
2542 | 1887 |
2543 LSS_INLINE int LSS_NAME(sigfillset)(struct kernel_sigset_t *set) { | 1888 LSS_INLINE int LSS_NAME(sigfillset)(struct kernel_sigset_t *set) { |
2544 memset(&set->sig, -1, sizeof(set->sig)); | 1889 memset(&set->sig, -1, sizeof(set->sig)); |
2545 return 0; | 1890 return 0; |
2546 } | 1891 } |
2547 | 1892 |
2548 LSS_INLINE int LSS_NAME(sigaddset)(struct kernel_sigset_t *set, | 1893 LSS_INLINE int LSS_NAME(sigaddset)(struct kernel_sigset_t *set, |
2549 int signum) { | 1894 int signum) { |
2550 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { | 1895 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { |
2551 LSS_ERRNO = EINVAL; | 1896 LSS_ERRNO = EINVAL; |
2552 return -1; | 1897 return -1; |
2553 } else { | 1898 } else { |
2554 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] | 1899 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] |
2555 |= 1UL << ((signum - 1) % (8*sizeof(set->sig[0]))); | 1900 |= 1UL << ((signum - 1) % (8*sizeof(set->sig[0]))); |
2556 return 0; | 1901 return 0; |
2557 } | 1902 } |
2558 } | 1903 } |
2559 | 1904 |
2560 LSS_INLINE int LSS_NAME(sigdelset)(struct kernel_sigset_t *set, | 1905 LSS_INLINE int LSS_NAME(sigdelset)(struct kernel_sigset_t *set, |
2561 int signum) { | 1906 int signum) { |
2562 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { | 1907 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { |
2563 LSS_ERRNO = EINVAL; | 1908 LSS_ERRNO = EINVAL; |
2564 return -1; | 1909 return -1; |
2565 } else { | 1910 } else { |
2566 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] | 1911 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] |
2567 &= ~(1UL << ((signum - 1) % (8*sizeof(set->sig[0])))); | 1912 &= ~(1UL << ((signum - 1) % (8*sizeof(set->sig[0])))); |
2568 return 0; | 1913 return 0; |
2569 } | 1914 } |
2570 } | 1915 } |
2571 | 1916 |
2572 LSS_INLINE int LSS_NAME(sigismember)(struct kernel_sigset_t *set, | 1917 #if defined(__i386__) || \ |
2573 int signum) { | 1918 defined(__arm__) || \ |
2574 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { | |
2575 LSS_ERRNO = EINVAL; | |
2576 return -1; | |
2577 } else { | |
2578 return !!(set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] & | |
2579 (1UL << ((signum - 1) % (8*sizeof(set->sig[0]))))); | |
2580 } | |
2581 } | |
2582 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | |
2583 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) | 1919 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) |
2584 #define __NR__sigaction __NR_sigaction | 1920 #define __NR__sigaction __NR_sigaction |
2585 #define __NR__sigpending __NR_sigpending | |
2586 #define __NR__sigprocmask __NR_sigprocmask | 1921 #define __NR__sigprocmask __NR_sigprocmask |
2587 #define __NR__sigsuspend __NR_sigsuspend | |
2588 #define __NR__socketcall __NR_socketcall | |
2589 LSS_INLINE _syscall2(int, fstat64, int, f, | 1922 LSS_INLINE _syscall2(int, fstat64, int, f, |
2590 struct kernel_stat64 *, b) | 1923 struct kernel_stat64 *, b) |
2591 LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, | 1924 LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, |
2592 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. */ |
2593 LSS_INLINE _syscall1(void*, mmap, void*, a) | 1934 LSS_INLINE _syscall1(void*, mmap, void*, a) |
2594 #ifndef __PPC64__ | 1935 #endif |
2595 LSS_INLINE _syscall6(void*, mmap2, void*, s, | 1936 LSS_INLINE _syscall6(void*, mmap2, void*, s, |
2596 size_t, l, int, p, | 1937 size_t, l, int, p, |
2597 int, f, int, d, | 1938 int, f, int, d, |
2598 off_t, o) | 1939 off_t, o) |
2599 #endif | 1940 #endif |
2600 LSS_INLINE _syscall3(int, _sigaction, int, s, | 1941 LSS_INLINE _syscall3(int, _sigaction, int, s, |
2601 const struct kernel_old_sigaction*, a, | 1942 const struct kernel_old_sigaction*, a, |
2602 struct kernel_old_sigaction*, o) | 1943 struct kernel_old_sigaction*, o) |
2603 LSS_INLINE _syscall1(int, _sigpending, unsigned long*, s) | |
2604 LSS_INLINE _syscall3(int, _sigprocmask, int, h, | 1944 LSS_INLINE _syscall3(int, _sigprocmask, int, h, |
2605 const unsigned long*, s, | 1945 const unsigned long*, s, |
2606 unsigned long*, o) | 1946 unsigned long*, o) |
2607 #ifdef __PPC__ | |
2608 LSS_INLINE _syscall1(int, _sigsuspend, unsigned long, s) | |
2609 #else | |
2610 LSS_INLINE _syscall3(int, _sigsuspend, const void*, a, | |
2611 int, b, | |
2612 unsigned long, s) | |
2613 #endif | |
2614 LSS_INLINE _syscall2(int, stat64, const char *, p, | 1947 LSS_INLINE _syscall2(int, stat64, const char *, p, |
2615 struct kernel_stat64 *, b) | 1948 struct kernel_stat64 *, b) |
2616 | 1949 |
2617 LSS_INLINE int LSS_NAME(sigaction)(int signum, | 1950 LSS_INLINE int LSS_NAME(sigaction)(int signum, |
2618 const struct kernel_sigaction *act, | 1951 const struct kernel_sigaction *act, |
2619 struct kernel_sigaction *oldact) { | 1952 struct kernel_sigaction *oldact) { |
2620 int old_errno = LSS_ERRNO; | 1953 int old_errno = LSS_ERRNO; |
2621 int rc; | 1954 int rc; |
2622 struct kernel_sigaction a; | 1955 struct kernel_sigaction a; |
2623 if (act != NULL) { | 1956 if (act != NULL) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2669 oldact->sa_flags = ptr_oa->sa_flags; | 2002 oldact->sa_flags = ptr_oa->sa_flags; |
2670 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)); |
2671 #ifndef __mips__ | 2004 #ifndef __mips__ |
2672 oldact->sa_restorer = ptr_oa->sa_restorer; | 2005 oldact->sa_restorer = ptr_oa->sa_restorer; |
2673 #endif | 2006 #endif |
2674 } | 2007 } |
2675 } | 2008 } |
2676 return rc; | 2009 return rc; |
2677 } | 2010 } |
2678 | 2011 |
2679 LSS_INLINE int LSS_NAME(sigpending)(struct kernel_sigset_t *set) { | |
2680 int old_errno = LSS_ERRNO; | |
2681 int rc = LSS_NAME(rt_sigpending)(set, (KERNEL_NSIG+7)/8); | |
2682 if (rc < 0 && LSS_ERRNO == ENOSYS) { | |
2683 LSS_ERRNO = old_errno; | |
2684 LSS_NAME(sigemptyset)(set); | |
2685 rc = LSS_NAME(_sigpending)(&set->sig[0]); | |
2686 } | |
2687 return rc; | |
2688 } | |
2689 | |
2690 LSS_INLINE int LSS_NAME(sigprocmask)(int how, | 2012 LSS_INLINE int LSS_NAME(sigprocmask)(int how, |
2691 const struct kernel_sigset_t *set, | 2013 const struct kernel_sigset_t *set, |
2692 struct kernel_sigset_t *oldset) { | 2014 struct kernel_sigset_t *oldset) { |
2693 int olderrno = LSS_ERRNO; | 2015 int olderrno = LSS_ERRNO; |
2694 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); |
2695 if (rc < 0 && LSS_ERRNO == ENOSYS) { | 2017 if (rc < 0 && LSS_ERRNO == ENOSYS) { |
2696 LSS_ERRNO = olderrno; | 2018 LSS_ERRNO = olderrno; |
2697 if (oldset) { | 2019 if (oldset) { |
2698 LSS_NAME(sigemptyset)(oldset); | 2020 LSS_NAME(sigemptyset)(oldset); |
2699 } | 2021 } |
2700 rc = LSS_NAME(_sigprocmask)(how, | 2022 rc = LSS_NAME(_sigprocmask)(how, |
2701 set ? &set->sig[0] : NULL, | 2023 set ? &set->sig[0] : NULL, |
2702 oldset ? &oldset->sig[0] : NULL); | 2024 oldset ? &oldset->sig[0] : NULL); |
2703 } | 2025 } |
2704 return rc; | 2026 return rc; |
2705 } | 2027 } |
2706 | |
2707 LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { | |
2708 int olderrno = LSS_ERRNO; | |
2709 int rc = LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8); | |
2710 if (rc < 0 && LSS_ERRNO == ENOSYS) { | |
2711 LSS_ERRNO = olderrno; | |
2712 rc = LSS_NAME(_sigsuspend)( | |
2713 #ifndef __PPC__ | |
2714 set, 0, | |
2715 #endif | |
2716 set->sig[0]); | |
2717 } | |
2718 return rc; | |
2719 } | |
2720 #endif | 2028 #endif |
2721 #if defined(__PPC__) | 2029 #if defined(__PPC__) |
2722 #undef LSS_SC_LOADARGS_0 | 2030 #undef LSS_SC_LOADARGS_0 |
2723 #define LSS_SC_LOADARGS_0(dummy...) | 2031 #define LSS_SC_LOADARGS_0(dummy...) |
2724 #undef LSS_SC_LOADARGS_1 | 2032 #undef LSS_SC_LOADARGS_1 |
2725 #define LSS_SC_LOADARGS_1(arg1) \ | 2033 #define LSS_SC_LOADARGS_1(arg1) \ |
2726 __sc_4 = (unsigned long) (arg1) | 2034 __sc_4 = (unsigned long) (arg1) |
2727 #undef LSS_SC_LOADARGS_2 | 2035 #undef LSS_SC_LOADARGS_2 |
2728 #define LSS_SC_LOADARGS_2(arg1, arg2) \ | 2036 #define LSS_SC_LOADARGS_2(arg1, arg2) \ |
2729 LSS_SC_LOADARGS_1(arg1); \ | 2037 LSS_SC_LOADARGS_1(arg1); \ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2766 "=&r" (__sc_3), "=&r" (__sc_4), \ | 2074 "=&r" (__sc_3), "=&r" (__sc_4), \ |
2767 "=&r" (__sc_5), "=&r" (__sc_6), \ | 2075 "=&r" (__sc_5), "=&r" (__sc_6), \ |
2768 "=&r" (__sc_7), "=&r" (__sc_8) \ | 2076 "=&r" (__sc_7), "=&r" (__sc_8) \ |
2769 : LSS_ASMINPUT_##nr \ | 2077 : LSS_ASMINPUT_##nr \ |
2770 : "cr0", "ctr", "memory"); \ | 2078 : "cr0", "ctr", "memory"); \ |
2771 __sc_ret = __sc_3; \ | 2079 __sc_ret = __sc_3; \ |
2772 __sc_err = __sc_0; \ | 2080 __sc_err = __sc_0; \ |
2773 } \ | 2081 } \ |
2774 LSS_RETURN(type, __sc_ret, __sc_err) | 2082 LSS_RETURN(type, __sc_ret, __sc_err) |
2775 | 2083 |
2776 LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg, | |
2777 int flags){ | |
2778 LSS_SC_BODY(3, ssize_t, 17, s, msg, flags); | |
2779 } | |
2780 | |
2781 LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s, | |
2782 const struct kernel_msghdr *msg, | |
2783 int flags) { | |
2784 LSS_SC_BODY(3, ssize_t, 16, s, msg, flags); | |
2785 } | |
2786 | |
2787 // TODO(csilvers): why is this ifdef'ed out? | |
2788 #if 0 | |
2789 LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len, | |
2790 int flags, | |
2791 const struct kernel_sockaddr *to, | |
2792 unsigned int tolen) { | |
2793 LSS_BODY(6, ssize_t, 11, s, buf, len, flags, to, tolen); | |
2794 } | |
2795 #endif | |
2796 | |
2797 LSS_INLINE int LSS_NAME(shutdown)(int s, int how) { | |
2798 LSS_SC_BODY(2, int, 13, s, how); | |
2799 } | |
2800 | |
2801 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) { |
2802 LSS_SC_BODY(3, int, 1, domain, type, protocol); | 2085 LSS_SC_BODY(3, int, 1, domain, type, protocol); |
2803 } | 2086 } |
| 2087 #endif |
| 2088 #if defined(__i386__) || \ |
| 2089 (defined(__arm__) && !defined(__ARM_EABI__)) || \ |
| 2090 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) |
2804 | 2091 |
2805 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, | 2092 /* See sys_socketcall in net/socket.c in kernel source. |
2806 int sv[2]) { | 2093 * It de-multiplexes on its first arg and unpacks the arglist |
2807 LSS_SC_BODY(4, int, 8, d, type, protocol, sv); | 2094 * array in its second arg. |
2808 } | 2095 */ |
2809 #endif | 2096 LSS_INLINE _syscall2(long, socketcall, int, c, unsigned long*, a) |
2810 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | |
2811 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) | |
2812 #define __NR__socketcall __NR_socketcall | |
2813 LSS_INLINE _syscall2(int, _socketcall, int, c, | |
2814 va_list, a) | |
2815 | |
2816 LSS_INLINE int LSS_NAME(socketcall)(int op, ...) { | |
2817 int rc; | |
2818 va_list ap; | |
2819 va_start(ap, op); | |
2820 rc = LSS_NAME(_socketcall)(op, ap); | |
2821 va_end(ap); | |
2822 return rc; | |
2823 } | |
2824 | |
2825 LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg, | |
2826 int flags){ | |
2827 return (ssize_t)LSS_NAME(socketcall)(17, s, msg, flags); | |
2828 } | |
2829 | |
2830 LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s, | |
2831 const struct kernel_msghdr *msg, | |
2832 int flags) { | |
2833 return (ssize_t)LSS_NAME(socketcall)(16, s, msg, flags); | |
2834 } | |
2835 | |
2836 LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len, | |
2837 int flags, | |
2838 const struct kernel_sockaddr *to, | |
2839 unsigned int tolen) { | |
2840 return (ssize_t)LSS_NAME(socketcall)(11, s, buf, len, flags, to, tolen); | |
2841 } | |
2842 | |
2843 LSS_INLINE int LSS_NAME(shutdown)(int s, int how) { | |
2844 return LSS_NAME(socketcall)(13, s, how); | |
2845 } | |
2846 | 2097 |
2847 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) { |
2848 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); |
2849 } | 2105 } |
2850 | 2106 #elif defined(__ARM_EABI__) |
2851 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, | 2107 LSS_INLINE _syscall3(int, socket, int, d, |
2852 int sv[2]) { | 2108 int, t, int, p) |
2853 return LSS_NAME(socketcall)(8, d, type, protocol, sv); | |
2854 } | |
2855 #endif | |
2856 #if defined(__i386__) || defined(__PPC__) | |
2857 LSS_INLINE _syscall4(int, fstatat64, int, d, | |
2858 const char *, p, | |
2859 struct kernel_stat64 *, b, int, f) | |
2860 #endif | 2109 #endif |
2861 #if defined(__i386__) || defined(__PPC__) || \ | 2110 #if defined(__i386__) || defined(__PPC__) || \ |
2862 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) | 2111 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) |
2863 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p, | 2112 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p, |
2864 int*, s, int, o) | 2113 int*, s, int, o) |
2865 #endif | 2114 #endif |
2866 #if defined(__mips__) | 2115 #if defined(__mips__) |
2867 /* 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 |
2868 * both file handles through CPU registers. | 2117 * both file handles through CPU registers. |
2869 */ | 2118 */ |
(...skipping 11 matching lines...) Expand all Loading... |
2881 return -1; | 2130 return -1; |
2882 } else { | 2131 } else { |
2883 p[0] = __v0; | 2132 p[0] = __v0; |
2884 p[1] = __v1; | 2133 p[1] = __v1; |
2885 return 0; | 2134 return 0; |
2886 } | 2135 } |
2887 } | 2136 } |
2888 #else | 2137 #else |
2889 LSS_INLINE _syscall1(int, pipe, int *, p) | 2138 LSS_INLINE _syscall1(int, pipe, int *, p) |
2890 #endif | 2139 #endif |
2891 /* TODO(csilvers): see if ppc can/should support this as well */ | |
2892 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | |
2893 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) | |
2894 #define __NR__statfs64 __NR_statfs64 | |
2895 #define __NR__fstatfs64 __NR_fstatfs64 | |
2896 LSS_INLINE _syscall3(int, _statfs64, const char*, p, | |
2897 size_t, s,struct kernel_statfs64*, b) | |
2898 LSS_INLINE _syscall3(int, _fstatfs64, int, f, | |
2899 size_t, s,struct kernel_statfs64*, b) | |
2900 LSS_INLINE int LSS_NAME(statfs64)(const char *p, | |
2901 struct kernel_statfs64 *b) { | |
2902 return LSS_NAME(_statfs64)(p, sizeof(*b), b); | |
2903 } | |
2904 LSS_INLINE int LSS_NAME(fstatfs64)(int f,struct kernel_statfs64 *b) { | |
2905 return LSS_NAME(_fstatfs64)(f, sizeof(*b), b); | |
2906 } | |
2907 #endif | |
2908 | |
2909 LSS_INLINE int LSS_NAME(execv)(const char *path, const char *const argv[]) { | |
2910 extern char **environ; | |
2911 return LSS_NAME(execve)(path, argv, (const char *const *)environ); | |
2912 } | |
2913 | 2140 |
2914 LSS_INLINE pid_t LSS_NAME(gettid)() { | 2141 LSS_INLINE pid_t LSS_NAME(gettid)() { |
2915 pid_t tid = LSS_NAME(_gettid)(); | 2142 pid_t tid = LSS_NAME(_gettid)(); |
2916 if (tid != -1) { | 2143 if (tid != -1) { |
2917 return tid; | 2144 return tid; |
2918 } | 2145 } |
2919 return LSS_NAME(getpid)(); | 2146 return LSS_NAME(getpid)(); |
2920 } | 2147 } |
2921 | 2148 |
2922 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... |
2939 * right after detaching from the tracee. | 2166 * right after detaching from the tracee. |
2940 */ | 2167 */ |
2941 int rc, err; | 2168 int rc, err; |
2942 LSS_NAME(sched_yield)(); | 2169 LSS_NAME(sched_yield)(); |
2943 rc = LSS_NAME(ptrace)(PTRACE_DETACH, pid, (void *)0, (void *)0); | 2170 rc = LSS_NAME(ptrace)(PTRACE_DETACH, pid, (void *)0, (void *)0); |
2944 err = LSS_ERRNO; | 2171 err = LSS_ERRNO; |
2945 LSS_NAME(kill)(pid, SIGCONT); | 2172 LSS_NAME(kill)(pid, SIGCONT); |
2946 LSS_ERRNO = err; | 2173 LSS_ERRNO = err; |
2947 return rc; | 2174 return rc; |
2948 } | 2175 } |
2949 | |
2950 LSS_INLINE int LSS_NAME(raise)(int sig) { | |
2951 return LSS_NAME(kill)(LSS_NAME(getpid)(), sig); | |
2952 } | |
2953 | |
2954 LSS_INLINE int LSS_NAME(setpgrp)() { | |
2955 return LSS_NAME(setpgid)(0, 0); | |
2956 } | |
2957 | |
2958 LSS_INLINE int LSS_NAME(sysconf)(int name) { | |
2959 extern int __getpagesize(void); | |
2960 switch (name) { | |
2961 case _SC_OPEN_MAX: { | |
2962 struct kernel_rlimit limit; | |
2963 return LSS_NAME(getrlimit)(RLIMIT_NOFILE, &limit) < 0 | |
2964 ? 8192 : limit.rlim_cur; | |
2965 } | |
2966 case _SC_PAGESIZE: | |
2967 return __getpagesize(); | |
2968 default: | |
2969 errno = ENOSYS; | |
2970 return -1; | |
2971 } | |
2972 } | |
2973 #if defined(__x86_64__) || \ | |
2974 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64) | |
2975 LSS_INLINE _syscall4(ssize_t, pread64, int, f, | |
2976 void *, b, size_t, c, | |
2977 loff_t, o) | |
2978 LSS_INLINE _syscall4(ssize_t, pwrite64, int, f, | |
2979 const void *, b, size_t, c, | |
2980 loff_t, o) | |
2981 LSS_INLINE _syscall3(int, readahead, int, f, | |
2982 loff_t, o, unsigned, c) | |
2983 #else | |
2984 #define __NR__pread64 __NR_pread64 | |
2985 #define __NR__pwrite64 __NR_pwrite64 | |
2986 #define __NR__readahead __NR_readahead | |
2987 LSS_INLINE _syscall5(ssize_t, _pread64, int, f, | |
2988 void *, b, size_t, c, unsigned, o1, | |
2989 unsigned, o2) | |
2990 LSS_INLINE _syscall5(ssize_t, _pwrite64, int, f, | |
2991 const void *, b, size_t, c, unsigned, o1, | |
2992 long, o2) | |
2993 LSS_INLINE _syscall4(int, _readahead, int, f, | |
2994 unsigned, o1, unsigned, o2, size_t, c); | |
2995 /* We force 64bit-wide parameters onto the stack, then access each | |
2996 * 32-bit component individually. This guarantees that we build the | |
2997 * correct parameters independent of the native byte-order of the | |
2998 * underlying architecture. | |
2999 */ | |
3000 LSS_INLINE ssize_t LSS_NAME(pread64)(int fd, void *buf, size_t count, | |
3001 loff_t off) { | |
3002 union { loff_t off; unsigned arg[2]; } o = { off }; | |
3003 return LSS_NAME(_pread64)(fd, buf, count, o.arg[0], o.arg[1]); | |
3004 } | |
3005 LSS_INLINE ssize_t LSS_NAME(pwrite64)(int fd, const void *buf, | |
3006 size_t count, loff_t off) { | |
3007 union { loff_t off; unsigned arg[2]; } o = { off }; | |
3008 return LSS_NAME(_pwrite64)(fd, buf, count, o.arg[0], o.arg[1]); | |
3009 } | |
3010 LSS_INLINE int LSS_NAME(readahead)(int fd, loff_t off, int len) { | |
3011 union { loff_t off; unsigned arg[2]; } o = { off }; | |
3012 return LSS_NAME(_readahead)(fd, o.arg[0], o.arg[1], len); | |
3013 } | |
3014 #endif | |
3015 #endif | 2176 #endif |
3016 | 2177 |
3017 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) | 2178 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) |
3018 } | 2179 } |
3019 #endif | 2180 #endif |
3020 | 2181 |
3021 #endif | 2182 #endif |
3022 #endif | 2183 #endif |
OLD | NEW |