Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: third_party/tcmalloc/chromium/src/base/linux_syscall_support.h

Issue 9667026: Revert 126020 - Experiment for updating the tcmalloc chromium branch to r144 (gperftools 2.0). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
129 */ 72 */
130 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H 73 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H
131 #define SYS_LINUX_SYSCALL_SUPPORT_H 74 #define SYS_LINUX_SYSCALL_SUPPORT_H
132 75
133 /* We currently only support x86-32, x86-64, ARM, MIPS, and PPC on Linux. 76 /* We currently only support x86-32, x86-64, ARM, MIPS, and PPC on Linux.
134 * Porting to other related platforms should not be difficult. 77 * Porting to other related platforms should not be difficult.
135 */ 78 */
136 #if (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ 79 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \
137 defined(__mips__) || defined(__PPC__)) && defined(__linux) 80 defined(__mips__) || defined(__PPC__)) && defined(__linux)
138 81
139 #ifndef SYS_CPLUSPLUS 82 #ifndef SYS_CPLUSPLUS
140 #ifdef __cplusplus 83 #ifdef __cplusplus
141 /* Some system header files in older versions of gcc neglect to properly 84 /* Some system header files in older versions of gcc neglect to properly
142 * handle being included from C++. As it appears to be harmless to have 85 * handle being included from C++. As it appears to be harmless to have
143 * multiple nested 'extern "C"' blocks, just add another one here. 86 * multiple nested 'extern "C"' blocks, just add another one here.
144 */ 87 */
145 extern "C" { 88 extern "C" {
146 #endif 89 #endif
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 }; 147 };
205 148
206 /* include/linux/dirent.h */ 149 /* include/linux/dirent.h */
207 struct kernel_dirent { 150 struct kernel_dirent {
208 long d_ino; 151 long d_ino;
209 long d_off; 152 long d_off;
210 unsigned short d_reclen; 153 unsigned short d_reclen;
211 char d_name[256]; 154 char d_name[256];
212 }; 155 };
213 156
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
214 /* include/linux/time.h */ 187 /* include/linux/time.h */
215 struct kernel_timespec { 188 struct kernel_timespec {
216 long tv_sec; 189 long tv_sec;
217 long tv_nsec; 190 long tv_nsec;
218 }; 191 };
219 192
220 /* include/linux/time.h */ 193 /* include/linux/time.h */
221 struct kernel_timeval { 194 struct kernel_timeval {
222 long tv_sec; 195 long tv_sec;
223 long tv_usec; 196 long tv_usec;
(...skipping 13 matching lines...) Expand all
237 long ru_inblock; 210 long ru_inblock;
238 long ru_oublock; 211 long ru_oublock;
239 long ru_msgsnd; 212 long ru_msgsnd;
240 long ru_msgrcv; 213 long ru_msgrcv;
241 long ru_nsignals; 214 long ru_nsignals;
242 long ru_nvcsw; 215 long ru_nvcsw;
243 long ru_nivcsw; 216 long ru_nivcsw;
244 }; 217 };
245 218
246 struct siginfo; 219 struct siginfo;
247 #if defined(__i386__) || defined(__arm__) || defined(__PPC__) 220 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__PPC__)
248 221
249 /* include/asm-{arm,i386,mips,ppc}/signal.h */ 222 /* include/asm-{arm,i386,mips,ppc}/signal.h */
250 struct kernel_old_sigaction { 223 struct kernel_old_sigaction {
251 union { 224 union {
252 void (*sa_handler_)(int); 225 void (*sa_handler_)(int);
253 void (*sa_sigaction_)(int, struct siginfo *, void *); 226 void (*sa_sigaction_)(int, struct siginfo *, void *);
254 }; 227 };
255 unsigned long sa_mask; 228 unsigned long sa_mask;
256 unsigned long sa_flags; 229 unsigned long sa_flags;
257 void (*sa_restorer)(void); 230 void (*sa_restorer)(void);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 union { 267 union {
295 void (*sa_handler_)(int); 268 void (*sa_handler_)(int);
296 void (*sa_sigaction_)(int, struct siginfo *, void *); 269 void (*sa_sigaction_)(int, struct siginfo *, void *);
297 }; 270 };
298 unsigned long sa_flags; 271 unsigned long sa_flags;
299 void (*sa_restorer)(void); 272 void (*sa_restorer)(void);
300 struct kernel_sigset_t sa_mask; 273 struct kernel_sigset_t sa_mask;
301 #endif 274 #endif
302 }; 275 };
303 276
277 /* include/linux/socket.h */
278 struct kernel_sockaddr {
279 unsigned short sa_family;
280 char sa_data[14];
281 };
282
304 /* include/asm-{arm,i386,mips,ppc}/stat.h */ 283 /* include/asm-{arm,i386,mips,ppc}/stat.h */
305 #ifdef __mips__ 284 #ifdef __mips__
306 #if _MIPS_SIM == _MIPS_SIM_ABI64 285 #if _MIPS_SIM == _MIPS_SIM_ABI64
307 struct kernel_stat { 286 struct kernel_stat {
308 #else 287 #else
309 struct kernel_stat64 { 288 struct kernel_stat64 {
310 #endif 289 #endif
311 unsigned st_dev; 290 unsigned st_dev;
312 unsigned __pad0[3]; 291 unsigned __pad0[3];
313 unsigned long long st_ino; 292 unsigned long long st_ino;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 unsigned st_atime_nsec_; 347 unsigned st_atime_nsec_;
369 unsigned st_mtime_; 348 unsigned st_mtime_;
370 unsigned st_mtime_nsec_; 349 unsigned st_mtime_nsec_;
371 unsigned st_ctime_; 350 unsigned st_ctime_;
372 unsigned st_ctime_nsec_; 351 unsigned st_ctime_nsec_;
373 unsigned long long st_ino; 352 unsigned long long st_ino;
374 }; 353 };
375 #endif 354 #endif
376 355
377 /* include/asm-{arm,i386,mips,x86_64,ppc}/stat.h */ 356 /* include/asm-{arm,i386,mips,x86_64,ppc}/stat.h */
378 #if defined(__i386__) || defined(__arm__) 357 #if defined(__i386__) || defined(__ARM_ARCH_3__)
379 struct kernel_stat { 358 struct kernel_stat {
380 /* The kernel headers suggest that st_dev and st_rdev should be 32bit 359 /* The kernel headers suggest that st_dev and st_rdev should be 32bit
381 * quantities encoding 12bit major and 20bit minor numbers in an interleaved 360 * quantities encoding 12bit major and 20bit minor numbers in an interleaved
382 * format. In reality, we do not see useful data in the top bits. So, 361 * format. In reality, we do not see useful data in the top bits. So,
383 * we'll leave the padding in here, until we find a better solution. 362 * we'll leave the padding in here, until we find a better solution.
384 */ 363 */
385 unsigned short st_dev; 364 unsigned short st_dev;
386 short pad1; 365 short pad1;
387 unsigned st_ino; 366 unsigned st_ino;
388 unsigned short st_mode; 367 unsigned short st_mode;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 long st_mtime_; 442 long st_mtime_;
464 long st_mtime_nsec_; 443 long st_mtime_nsec_;
465 long st_ctime_; 444 long st_ctime_;
466 long st_ctime_nsec_; 445 long st_ctime_nsec_;
467 int st_blksize; 446 int st_blksize;
468 int st_blocks; 447 int st_blocks;
469 int st_pad4[14]; 448 int st_pad4[14];
470 }; 449 };
471 #endif 450 #endif
472 451
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
473 520
474 /* Definitions missing from the standard header files */ 521 /* Definitions missing from the standard header files */
475 #ifndef O_DIRECTORY 522 #ifndef O_DIRECTORY
476 #if defined(__arm__) 523 #if defined(__ARM_ARCH_3__)
477 #define O_DIRECTORY 0040000 524 #define O_DIRECTORY 0040000
478 #else 525 #else
479 #define O_DIRECTORY 0200000 526 #define O_DIRECTORY 0200000
480 #endif 527 #endif
481 #endif 528 #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
482 #ifndef PR_GET_DUMPABLE 535 #ifndef PR_GET_DUMPABLE
483 #define PR_GET_DUMPABLE 3 536 #define PR_GET_DUMPABLE 3
484 #endif 537 #endif
485 #ifndef PR_SET_DUMPABLE 538 #ifndef PR_SET_DUMPABLE
486 #define PR_SET_DUMPABLE 4 539 #define PR_SET_DUMPABLE 4
487 #endif 540 #endif
488 #ifndef AT_FDCWD 541 #ifndef AT_FDCWD
489 #define AT_FDCWD (-100) 542 #define AT_FDCWD (-100)
490 #endif 543 #endif
491 #ifndef AT_SYMLINK_NOFOLLOW 544 #ifndef AT_SYMLINK_NOFOLLOW
492 #define AT_SYMLINK_NOFOLLOW 0x100 545 #define AT_SYMLINK_NOFOLLOW 0x100
493 #endif 546 #endif
494 #ifndef AT_REMOVEDIR 547 #ifndef AT_REMOVEDIR
495 #define AT_REMOVEDIR 0x200 548 #define AT_REMOVEDIR 0x200
496 #endif 549 #endif
497 #ifndef MREMAP_FIXED 550 #ifndef MREMAP_FIXED
498 #define MREMAP_FIXED 2 551 #define MREMAP_FIXED 2
499 #endif 552 #endif
500 #ifndef SA_RESTORER 553 #ifndef SA_RESTORER
501 #define SA_RESTORER 0x04000000 554 #define SA_RESTORER 0x04000000
502 #endif 555 #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
503 576
504 #if defined(__i386__) 577 #if defined(__i386__)
578 #ifndef __NR_setresuid
579 #define __NR_setresuid 164
580 #define __NR_setresgid 170
581 #endif
505 #ifndef __NR_rt_sigaction 582 #ifndef __NR_rt_sigaction
506 #define __NR_rt_sigaction 174 583 #define __NR_rt_sigaction 174
507 #define __NR_rt_sigprocmask 175 584 #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
508 #endif 596 #endif
509 #ifndef __NR_stat64 597 #ifndef __NR_stat64
510 #define __NR_stat64 195 598 #define __NR_stat64 195
511 #endif 599 #endif
512 #ifndef __NR_fstat64 600 #ifndef __NR_fstat64
513 #define __NR_fstat64 197 601 #define __NR_fstat64 197
514 #endif 602 #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
515 #ifndef __NR_getdents64 611 #ifndef __NR_getdents64
516 #define __NR_getdents64 220 612 #define __NR_getdents64 220
517 #endif 613 #endif
518 #ifndef __NR_gettid 614 #ifndef __NR_gettid
519 #define __NR_gettid 224 615 #define __NR_gettid 224
520 #endif 616 #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
521 #ifndef __NR_futex 638 #ifndef __NR_futex
522 #define __NR_futex 240 639 #define __NR_futex 240
523 #endif 640 #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
524 #ifndef __NR_openat 669 #ifndef __NR_openat
525 #define __NR_openat 295 670 #define __NR_openat 295
526 #endif 671 #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
527 #ifndef __NR_getcpu 681 #ifndef __NR_getcpu
528 #define __NR_getcpu 318 682 #define __NR_getcpu 318
529 #endif 683 #endif
684 #ifndef __NR_fallocate
685 #define __NR_fallocate 324
686 #endif
530 /* End of i386 definitions */ 687 /* End of i386 definitions */
531 #elif defined(__arm__) 688 #elif defined(__ARM_ARCH_3__)
532 #ifndef __syscall 689 #ifndef __NR_setresuid
533 #if defined(__thumb__) || defined(__ARM_EABI__) 690 #define __NR_setresuid (__NR_SYSCALL_BASE + 164)
534 #define __SYS_REG(name) register long __sysreg __asm__("r6") = __NR_##name; 691 #define __NR_setresgid (__NR_SYSCALL_BASE + 170)
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)
547 #endif
548 #endif 692 #endif
549 #ifndef __NR_rt_sigaction 693 #ifndef __NR_rt_sigaction
550 #define __NR_rt_sigaction (__NR_SYSCALL_BASE + 174) 694 #define __NR_rt_sigaction (__NR_SYSCALL_BASE + 174)
551 #define __NR_rt_sigprocmask (__NR_SYSCALL_BASE + 175) 695 #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)
552 #endif 707 #endif
553 #ifndef __NR_stat64 708 #ifndef __NR_stat64
554 #define __NR_stat64 (__NR_SYSCALL_BASE + 195) 709 #define __NR_stat64 (__NR_SYSCALL_BASE + 195)
555 #endif 710 #endif
556 #ifndef __NR_fstat64 711 #ifndef __NR_fstat64
557 #define __NR_fstat64 (__NR_SYSCALL_BASE + 197) 712 #define __NR_fstat64 (__NR_SYSCALL_BASE + 197)
558 #endif 713 #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
559 #ifndef __NR_getdents64 722 #ifndef __NR_getdents64
560 #define __NR_getdents64 (__NR_SYSCALL_BASE + 217) 723 #define __NR_getdents64 (__NR_SYSCALL_BASE + 217)
561 #endif 724 #endif
562 #ifndef __NR_gettid 725 #ifndef __NR_gettid
563 #define __NR_gettid (__NR_SYSCALL_BASE + 224) 726 #define __NR_gettid (__NR_SYSCALL_BASE + 224)
564 #endif 727 #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
565 #ifndef __NR_futex 749 #ifndef __NR_futex
566 #define __NR_futex (__NR_SYSCALL_BASE + 240) 750 #define __NR_futex (__NR_SYSCALL_BASE + 240)
567 #endif 751 #endif
568 /* End of ARM definitions */ 752 #ifndef __NR_sched_setaffinity
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 */
569 #elif defined(__x86_64__) 784 #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
570 #ifndef __NR_gettid 795 #ifndef __NR_gettid
571 #define __NR_gettid 186 796 #define __NR_gettid 186
572 #endif 797 #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
573 #ifndef __NR_futex 819 #ifndef __NR_futex
574 #define __NR_futex 202 820 #define __NR_futex 202
575 #endif 821 #endif
822 #ifndef __NR_sched_setaffinity
823 #define __NR_sched_setaffinity 203
824 #define __NR_sched_getaffinity 204
825 #endif
576 #ifndef __NR_getdents64 826 #ifndef __NR_getdents64
577 #define __NR_getdents64 217 827 #define __NR_getdents64 217
578 #endif 828 #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
579 #ifndef __NR_openat 847 #ifndef __NR_openat
580 #define __NR_openat 257 848 #define __NR_openat 257
581 #endif 849 #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
582 /* End of x86-64 definitions */ 862 /* End of x86-64 definitions */
583 #elif defined(__mips__) 863 #elif defined(__mips__)
584 #if _MIPS_SIM == _MIPS_SIM_ABI32 864 #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
585 #ifndef __NR_rt_sigaction 869 #ifndef __NR_rt_sigaction
586 #define __NR_rt_sigaction (__NR_Linux + 194) 870 #define __NR_rt_sigaction (__NR_Linux + 194)
587 #define __NR_rt_sigprocmask (__NR_Linux + 195) 871 #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)
588 #endif 880 #endif
589 #ifndef __NR_stat64 881 #ifndef __NR_stat64
590 #define __NR_stat64 (__NR_Linux + 213) 882 #define __NR_stat64 (__NR_Linux + 213)
591 #endif 883 #endif
592 #ifndef __NR_fstat64 884 #ifndef __NR_fstat64
593 #define __NR_fstat64 (__NR_Linux + 215) 885 #define __NR_fstat64 (__NR_Linux + 215)
594 #endif 886 #endif
595 #ifndef __NR_getdents64 887 #ifndef __NR_getdents64
596 #define __NR_getdents64 (__NR_Linux + 219) 888 #define __NR_getdents64 (__NR_Linux + 219)
597 #endif 889 #endif
598 #ifndef __NR_gettid 890 #ifndef __NR_gettid
599 #define __NR_gettid (__NR_Linux + 222) 891 #define __NR_gettid (__NR_Linux + 222)
600 #endif 892 #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
601 #ifndef __NR_futex 914 #ifndef __NR_futex
602 #define __NR_futex (__NR_Linux + 238) 915 #define __NR_futex (__NR_Linux + 238)
603 #endif 916 #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
604 #ifndef __NR_openat 936 #ifndef __NR_openat
605 #define __NR_openat (__NR_Linux + 288) 937 #define __NR_openat (__NR_Linux + 288)
606 #endif 938 #endif
607 #ifndef __NR_fstatat 939 #ifndef __NR_fstatat
608 #define __NR_fstatat (__NR_Linux + 293) 940 #define __NR_fstatat (__NR_Linux + 293)
609 #endif 941 #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
610 #ifndef __NR_getcpu 948 #ifndef __NR_getcpu
611 #define __NR_getcpu (__NR_Linux + 312) 949 #define __NR_getcpu (__NR_Linux + 312)
612 #endif 950 #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
613 /* End of MIPS (old 32bit API) definitions */ 957 /* End of MIPS (old 32bit API) definitions */
614 #elif _MIPS_SIM == _MIPS_SIM_ABI64 958 #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
615 #ifndef __NR_gettid 969 #ifndef __NR_gettid
616 #define __NR_gettid (__NR_Linux + 178) 970 #define __NR_gettid (__NR_Linux + 178)
617 #endif 971 #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
618 #ifndef __NR_futex 993 #ifndef __NR_futex
619 #define __NR_futex (__NR_Linux + 194) 994 #define __NR_futex (__NR_Linux + 194)
620 #endif 995 #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
621 #ifndef __NR_openat 1009 #ifndef __NR_openat
622 #define __NR_openat (__NR_Linux + 247) 1010 #define __NR_openat (__NR_Linux + 247)
623 #endif 1011 #endif
624 #ifndef __NR_fstatat 1012 #ifndef __NR_fstatat
625 #define __NR_fstatat (__NR_Linux + 252) 1013 #define __NR_fstatat (__NR_Linux + 252)
626 #endif 1014 #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
627 #ifndef __NR_getcpu 1021 #ifndef __NR_getcpu
628 #define __NR_getcpu (__NR_Linux + 271) 1022 #define __NR_getcpu (__NR_Linux + 271)
629 #endif 1023 #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
630 /* End of MIPS (64bit API) definitions */ 1030 /* End of MIPS (64bit API) definitions */
631 #else 1031 #else
1032 #ifndef __NR_setresuid
1033 #define __NR_setresuid (__NR_Linux + 115)
1034 #define __NR_setresgid (__NR_Linux + 117)
1035 #endif
632 #ifndef __NR_gettid 1036 #ifndef __NR_gettid
633 #define __NR_gettid (__NR_Linux + 178) 1037 #define __NR_gettid (__NR_Linux + 178)
634 #endif 1038 #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
635 #ifndef __NR_futex 1060 #ifndef __NR_futex
636 #define __NR_futex (__NR_Linux + 194) 1061 #define __NR_futex (__NR_Linux + 194)
637 #endif 1062 #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
638 #ifndef __NR_openat 1082 #ifndef __NR_openat
639 #define __NR_openat (__NR_Linux + 251) 1083 #define __NR_openat (__NR_Linux + 251)
640 #endif 1084 #endif
641 #ifndef __NR_fstatat 1085 #ifndef __NR_fstatat
642 #define __NR_fstatat (__NR_Linux + 256) 1086 #define __NR_fstatat (__NR_Linux + 256)
643 #endif 1087 #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
644 #ifndef __NR_getcpu 1094 #ifndef __NR_getcpu
645 #define __NR_getcpu (__NR_Linux + 275) 1095 #define __NR_getcpu (__NR_Linux + 275)
646 #endif 1096 #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
647 /* End of MIPS (new 32bit API) definitions */ 1103 /* End of MIPS (new 32bit API) definitions */
648 #endif 1104 #endif
649 /* End of MIPS definitions */ 1105 /* End of MIPS definitions */
650 #elif defined(__PPC__) 1106 #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
651 #ifndef __NR_rt_sigaction 1115 #ifndef __NR_rt_sigaction
652 #define __NR_rt_sigaction 173 1116 #define __NR_rt_sigaction 173
653 #define __NR_rt_sigprocmask 174 1117 #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
654 #endif 1132 #endif
655 #ifndef __NR_stat64 1133 #ifndef __NR_stat64
656 #define __NR_stat64 195 1134 #define __NR_stat64 195
657 #endif 1135 #endif
658 #ifndef __NR_fstat64 1136 #ifndef __NR_fstat64
659 #define __NR_fstat64 197 1137 #define __NR_fstat64 197
660 #endif 1138 #endif
661 #ifndef __NR_getdents64 1139 #ifndef __NR_getdents64
662 #define __NR_getdents64 202 1140 #define __NR_getdents64 202
663 #endif 1141 #endif
664 #ifndef __NR_gettid 1142 #ifndef __NR_gettid
665 #define __NR_gettid 207 1143 #define __NR_gettid 207
666 #endif 1144 #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
667 #ifndef __NR_futex 1163 #ifndef __NR_futex
668 #define __NR_futex 221 1164 #define __NR_futex 221
669 #endif 1165 #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
670 #ifndef __NR_openat 1194 #ifndef __NR_openat
671 #define __NR_openat 286 1195 #define __NR_openat 286
672 #endif 1196 #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
673 #ifndef __NR_getcpu 1206 #ifndef __NR_getcpu
674 #define __NR_getcpu 302 1207 #define __NR_getcpu 302
675 #endif 1208 #endif
676 /* End of powerpc defininitions */ 1209 /* End of powerpc defininitions */
677 #endif 1210 #endif
678 1211
679 1212
680 /* After forking, we must make sure to only call system calls. */ 1213 /* After forking, we must make sure to only call system calls. */
681 #if __BOUNDED_POINTERS__ 1214 #if __BOUNDED_POINTERS__
682 #error "Need to port invocations of syscalls for bounded ptrs" 1215 #error "Need to port invocations of syscalls for bounded ptrs"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 #define LSS_NAME(name) sys6_##name 1262 #define LSS_NAME(name) sys6_##name
730 #elif SYS_PREFIX == 7 1263 #elif SYS_PREFIX == 7
731 #define LSS_NAME(name) sys7_##name 1264 #define LSS_NAME(name) sys7_##name
732 #elif SYS_PREFIX == 8 1265 #elif SYS_PREFIX == 8
733 #define LSS_NAME(name) sys8_##name 1266 #define LSS_NAME(name) sys8_##name
734 #elif SYS_PREFIX == 9 1267 #elif SYS_PREFIX == 9
735 #define LSS_NAME(name) sys9_##name 1268 #define LSS_NAME(name) sys9_##name
736 #endif 1269 #endif
737 1270
738 #undef LSS_RETURN 1271 #undef LSS_RETURN
739 #if (defined(__i386__) || defined(__x86_64__) || defined(__arm__)) 1272 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__))
740 /* Failing system calls return a negative result in the range of 1273 /* Failing system calls return a negative result in the range of
741 * -1..-4095. These are "errno" values with the sign inverted. 1274 * -1..-4095. These are "errno" values with the sign inverted.
742 */ 1275 */
743 #define LSS_RETURN(type, res) \ 1276 #define LSS_RETURN(type, res) \
744 do { \ 1277 do { \
745 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ 1278 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \
746 LSS_ERRNO = -(res); \ 1279 LSS_ERRNO = -(res); \
747 res = -1; \ 1280 res = -1; \
748 } \ 1281 } \
749 return (type) (res); \ 1282 return (type) (res); \
(...skipping 17 matching lines...) Expand all
767 #define LSS_RETURN(type, res, err) \ 1300 #define LSS_RETURN(type, res, err) \
768 do { \ 1301 do { \
769 if (err & 0x10000000 ) { \ 1302 if (err & 0x10000000 ) { \
770 LSS_ERRNO = (res); \ 1303 LSS_ERRNO = (res); \
771 res = -1; \ 1304 res = -1; \
772 } \ 1305 } \
773 return (type) (res); \ 1306 return (type) (res); \
774 } while (0) 1307 } while (0)
775 #endif 1308 #endif
776 #if defined(__i386__) 1309 #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
786 /* In PIC mode (e.g. when building shared libraries), gcc for i386 1310 /* In PIC mode (e.g. when building shared libraries), gcc for i386
787 * reserves ebx. Unfortunately, most distribution ship with implementations 1311 * reserves ebx. Unfortunately, most distribution ship with implementations
788 * of _syscallX() which clobber ebx. 1312 * of _syscallX() which clobber ebx.
789 * Also, most definitions of _syscallX() neglect to mark "memory" as being 1313 * Also, most definitions of _syscallX() neglect to mark "memory" as being
790 * clobbered. This causes problems with compilers, that do a better job 1314 * clobbered. This causes problems with compilers, that do a better job
791 * at optimizing across __asm__ calls. 1315 * at optimizing across __asm__ calls.
792 * So, we just have to redefine all of the _syscallX() macros. 1316 * So, we just have to redefine all of the _syscallX() macros.
793 */ 1317 */
794 #undef LSS_BODY 1318 #undef LSS_BODY
795 #define LSS_BODY(type,args...) \ 1319 #define LSS_BODY(type,args...) \
796 long __res; \ 1320 long __res; \
797 __asm__ __volatile__("push %%ebx\n" \ 1321 __asm__ __volatile__("push %%ebx\n" \
798 CFI_ADJUST_CFA_OFFSET(4) \
799 "movl %2,%%ebx\n" \ 1322 "movl %2,%%ebx\n" \
800 "int $0x80\n" \ 1323 "int $0x80\n" \
801 "pop %%ebx\n" \ 1324 "pop %%ebx" \
802 CFI_ADJUST_CFA_OFFSET(-4) \
803 args \ 1325 args \
804 : "esp", "memory"); \ 1326 : "memory"); \
805 LSS_RETURN(type,__res) 1327 LSS_RETURN(type,__res)
806 #undef _syscall0 1328 #undef _syscall0
807 #define _syscall0(type,name) \ 1329 #define _syscall0(type,name) \
808 type LSS_NAME(name)(void) { \ 1330 type LSS_NAME(name)(void) { \
809 long __res; \ 1331 long __res; \
810 __asm__ volatile("int $0x80" \ 1332 __asm__ volatile("int $0x80" \
811 : "=a" (__res) \ 1333 : "=a" (__res) \
812 : "0" (__NR_##name) \ 1334 : "0" (__NR_##name) \
813 : "memory"); \ 1335 : "memory"); \
814 LSS_RETURN(type,__res); \ 1336 LSS_RETURN(type,__res); \
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 long __res; \ 1373 long __res; \
852 __asm__ __volatile__("push %%ebx\n" \ 1374 __asm__ __volatile__("push %%ebx\n" \
853 "movl %2,%%ebx\n" \ 1375 "movl %2,%%ebx\n" \
854 "movl %1,%%eax\n" \ 1376 "movl %1,%%eax\n" \
855 "int $0x80\n" \ 1377 "int $0x80\n" \
856 "pop %%ebx" \ 1378 "pop %%ebx" \
857 : "=a" (__res) \ 1379 : "=a" (__res) \
858 : "i" (__NR_##name), "ri" ((long)(arg1)), \ 1380 : "i" (__NR_##name), "ri" ((long)(arg1)), \
859 "c" ((long)(arg2)), "d" ((long)(arg3)), \ 1381 "c" ((long)(arg2)), "d" ((long)(arg3)), \
860 "S" ((long)(arg4)), "D" ((long)(arg5)) \ 1382 "S" ((long)(arg4)), "D" ((long)(arg5)) \
861 : "esp", "memory"); \ 1383 : "memory"); \
862 LSS_RETURN(type,__res); \ 1384 LSS_RETURN(type,__res); \
863 } 1385 }
864 #undef _syscall6 1386 #undef _syscall6
865 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1387 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
866 type5,arg5,type6,arg6) \ 1388 type5,arg5,type6,arg6) \
867 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1389 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
868 type5 arg5, type6 arg6) { \ 1390 type5 arg5, type6 arg6) { \
869 long __res; \ 1391 long __res; \
870 struct { long __a1; long __a6; } __s = { (long)arg1, (long) arg6 }; \ 1392 struct { long __a1; long __a6; } __s = { (long)arg1, (long) arg6 }; \
871 __asm__ __volatile__("push %%ebp\n" \ 1393 __asm__ __volatile__("push %%ebp\n" \
872 "push %%ebx\n" \ 1394 "push %%ebx\n" \
873 "movl 4(%2),%%ebp\n" \ 1395 "movl 4(%2),%%ebp\n" \
874 "movl 0(%2), %%ebx\n" \ 1396 "movl 0(%2), %%ebx\n" \
875 "movl %1,%%eax\n" \ 1397 "movl %1,%%eax\n" \
876 "int $0x80\n" \ 1398 "int $0x80\n" \
877 "pop %%ebx\n" \ 1399 "pop %%ebx\n" \
878 "pop %%ebp" \ 1400 "pop %%ebp" \
879 : "=a" (__res) \ 1401 : "=a" (__res) \
880 : "i" (__NR_##name), "0" ((long)(&__s)), \ 1402 : "i" (__NR_##name), "0" ((long)(&__s)), \
881 "c" ((long)(arg2)), "d" ((long)(arg3)), \ 1403 "c" ((long)(arg2)), "d" ((long)(arg3)), \
882 "S" ((long)(arg4)), "D" ((long)(arg5)) \ 1404 "S" ((long)(arg4)), "D" ((long)(arg5)) \
883 : "esp", "memory"); \ 1405 : "memory"); \
884 LSS_RETURN(type,__res); \ 1406 LSS_RETURN(type,__res); \
885 } 1407 }
886 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, 1408 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
887 int flags, void *arg, int *parent_tidptr, 1409 int flags, void *arg, int *parent_tidptr,
888 void *newtls, int *child_tidptr) { 1410 void *newtls, int *child_tidptr) {
889 long __res; 1411 long __res;
890 __asm__ __volatile__(/* if (fn == NULL) 1412 __asm__ __volatile__(/* if (fn == NULL)
891 * return -EINVAL; 1413 * return -EINVAL;
892 */ 1414 */
893 "movl %3,%%ecx\n" 1415 "movl %3,%%ecx\n"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 "movl $1,%%eax\n" 1481 "movl $1,%%eax\n"
960 "int $0x80\n" 1482 "int $0x80\n"
961 1483
962 /* Return to parent. 1484 /* Return to parent.
963 */ 1485 */
964 "1:\n" 1486 "1:\n"
965 : "=a" (__res) 1487 : "=a" (__res)
966 : "0"(-EINVAL), "i"(__NR_clone), 1488 : "0"(-EINVAL), "i"(__NR_clone),
967 "m"(fn), "m"(child_stack), "m"(flags), "m"(arg), 1489 "m"(fn), "m"(child_stack), "m"(flags), "m"(arg),
968 "m"(parent_tidptr), "m"(newtls), "m"(child_tidptr) 1490 "m"(parent_tidptr), "m"(newtls), "m"(child_tidptr)
969 : "esp", "memory", "ecx", "edx", "esi", "edi"); 1491 : "memory", "ecx", "edx", "esi", "edi");
970 LSS_RETURN(int, __res); 1492 LSS_RETURN(int, __res);
971 } 1493 }
972 1494
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
973 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { 1521 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) {
974 /* On i386, the kernel does not know how to return from a signal 1522 /* On i386, the kernel does not know how to return from a signal
975 * handler. Instead, it relies on user space to provide a 1523 * handler. Instead, it relies on user space to provide a
976 * restorer function that calls the {rt_,}sigreturn() system call. 1524 * restorer function that calls the {rt_,}sigreturn() system call.
977 * Unfortunately, we cannot just reference the glibc version of this 1525 * Unfortunately, we cannot just reference the glibc version of this
978 * function, as glibc goes out of its way to make it inaccessible. 1526 * function, as glibc goes out of its way to make it inaccessible.
979 */ 1527 */
980 void (*res)(void); 1528 void (*res)(void);
981 __asm__ __volatile__("call 2f\n" 1529 __asm__ __volatile__("call 2f\n"
982 "0:.align 16\n" 1530 "0:.align 16\n"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 LSS_BODY(type, name, "D" ((long)(arg1)), "S" ((long)(arg2)), \ 1589 LSS_BODY(type, name, "D" ((long)(arg1)), "S" ((long)(arg2)), \
1042 "d" ((long)(arg3))); \ 1590 "d" ((long)(arg3))); \
1043 } 1591 }
1044 #undef _syscall4 1592 #undef _syscall4
1045 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ 1593 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
1046 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ 1594 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
1047 long __res; \ 1595 long __res; \
1048 __asm__ __volatile__("movq %5,%%r10; syscall" : \ 1596 __asm__ __volatile__("movq %5,%%r10; syscall" : \
1049 "=a" (__res) : "0" (__NR_##name), \ 1597 "=a" (__res) : "0" (__NR_##name), \
1050 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ 1598 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \
1051 "r" ((long)(arg4)) : "r10", "r11", "rcx", "memory"); \ 1599 "g" ((long)(arg4)) : "r10", "r11", "rcx", "memory"); \
1052 LSS_RETURN(type, __res); \ 1600 LSS_RETURN(type, __res); \
1053 } 1601 }
1054 #undef _syscall5 1602 #undef _syscall5
1055 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1603 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
1056 type5,arg5) \ 1604 type5,arg5) \
1057 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1605 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
1058 type5 arg5) { \ 1606 type5 arg5) { \
1059 long __res; \ 1607 long __res; \
1060 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; syscall" : \ 1608 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; syscall" : \
1061 "=a" (__res) : "0" (__NR_##name), \ 1609 "=a" (__res) : "0" (__NR_##name), \
1062 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ 1610 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \
1063 "r" ((long)(arg4)), "r" ((long)(arg5)) : \ 1611 "g" ((long)(arg4)), "g" ((long)(arg5)) : \
1064 "r8", "r10", "r11", "rcx", "memory"); \ 1612 "r8", "r10", "r11", "rcx", "memory"); \
1065 LSS_RETURN(type, __res); \ 1613 LSS_RETURN(type, __res); \
1066 } 1614 }
1067 #undef _syscall6 1615 #undef _syscall6
1068 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1616 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
1069 type5,arg5,type6,arg6) \ 1617 type5,arg5,type6,arg6) \
1070 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1618 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
1071 type5 arg5, type6 arg6) { \ 1619 type5 arg5, type6 arg6) { \
1072 long __res; \ 1620 long __res; \
1073 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; movq %7,%%r9;" \ 1621 __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; movq %7,%%r9;" \
1074 "syscall" : \ 1622 "syscall" : \
1075 "=a" (__res) : "0" (__NR_##name), \ 1623 "=a" (__res) : "0" (__NR_##name), \
1076 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ 1624 "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \
1077 "r" ((long)(arg4)), "r" ((long)(arg5)), "r" ((long)(arg6)) : \ 1625 "g" ((long)(arg4)), "g" ((long)(arg5)), "g" ((long)(arg6)) : \
1078 "r8", "r9", "r10", "r11", "rcx", "memory"); \ 1626 "r8", "r9", "r10", "r11", "rcx", "memory"); \
1079 LSS_RETURN(type, __res); \ 1627 LSS_RETURN(type, __res); \
1080 } 1628 }
1081 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, 1629 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
1082 int flags, void *arg, int *parent_tidptr, 1630 int flags, void *arg, int *parent_tidptr,
1083 void *newtls, int *child_tidptr) { 1631 void *newtls, int *child_tidptr) {
1084 long __res; 1632 long __res;
1085 { 1633 {
1634 register void *__tls __asm__("r8") = newtls;
1635 register int *__ctid __asm__("r10") = child_tidptr;
1086 __asm__ __volatile__(/* if (fn == NULL) 1636 __asm__ __volatile__(/* if (fn == NULL)
1087 * return -EINVAL; 1637 * return -EINVAL;
1088 */ 1638 */
1089 "testq %4,%4\n" 1639 "testq %4,%4\n"
1090 "jz 1f\n" 1640 "jz 1f\n"
1091 1641
1092 /* if (child_stack == NULL) 1642 /* if (child_stack == NULL)
1093 * return -EINVAL; 1643 * return -EINVAL;
1094 */ 1644 */
1095 "testq %5,%5\n" 1645 "testq %5,%5\n"
(...skipping 12 matching lines...) Expand all
1108 "movq %4,0(%5)\n" 1658 "movq %4,0(%5)\n"
1109 1659
1110 /* %rax = syscall(%rax = __NR_clone, 1660 /* %rax = syscall(%rax = __NR_clone,
1111 * %rdi = flags, 1661 * %rdi = flags,
1112 * %rsi = child_stack, 1662 * %rsi = child_stack,
1113 * %rdx = parent_tidptr, 1663 * %rdx = parent_tidptr,
1114 * %r8 = new_tls, 1664 * %r8 = new_tls,
1115 * %r10 = child_tidptr) 1665 * %r10 = child_tidptr)
1116 */ 1666 */
1117 "movq %2,%%rax\n" 1667 "movq %2,%%rax\n"
1118 "movq %9,%%r8\n"
1119 "movq %10,%%r10\n"
1120 "syscall\n" 1668 "syscall\n"
1121 1669
1122 /* if (%rax != 0) 1670 /* if (%rax != 0)
1123 * return; 1671 * return;
1124 */ 1672 */
1125 "testq %%rax,%%rax\n" 1673 "testq %%rax,%%rax\n"
1126 "jnz 1f\n" 1674 "jnz 1f\n"
1127 1675
1128 /* In the child. Terminate frame pointer chain. 1676 /* In the child. Terminate frame pointer chain.
1129 */ 1677 */
(...skipping 10 matching lines...) Expand all
1140 "movq %%rax,%%rdi\n" 1688 "movq %%rax,%%rdi\n"
1141 "movq %3,%%rax\n" 1689 "movq %3,%%rax\n"
1142 "syscall\n" 1690 "syscall\n"
1143 1691
1144 /* Return to parent. 1692 /* Return to parent.
1145 */ 1693 */
1146 "1:\n" 1694 "1:\n"
1147 : "=a" (__res) 1695 : "=a" (__res)
1148 : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), 1696 : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit),
1149 "r"(fn), "S"(child_stack), "D"(flags), "r"(arg), 1697 "r"(fn), "S"(child_stack), "D"(flags), "r"(arg),
1150 "d"(parent_tidptr), "g"(newtls), "g"(child_tidptr ) 1698 "d"(parent_tidptr), "r"(__tls), "r"(__ctid)
1151 : "rsp", "memory", "r8", "r10", "r11", "rcx"); 1699 : "memory", "r11", "rcx");
1152 } 1700 }
1153 LSS_RETURN(int, __res); 1701 LSS_RETURN(int, __res);
1154 } 1702 }
1703 LSS_INLINE _syscall4(int, fadvise64, int, fd, loff_t, offset, loff_t, len,
1704 int, advice)
1155 1705
1156 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { 1706 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) {
1157 /* On x86-64, the kernel does not know how to return from 1707 /* On x86-64, the kernel does not know how to return from
1158 * a signal handler. Instead, it relies on user space to provide a 1708 * a signal handler. Instead, it relies on user space to provide a
1159 * restorer function that calls the rt_sigreturn() system call. 1709 * restorer function that calls the rt_sigreturn() system call.
1160 * Unfortunately, we cannot just reference the glibc version of this 1710 * Unfortunately, we cannot just reference the glibc version of this
1161 * function, as glibc goes out of its way to make it inaccessible. 1711 * function, as glibc goes out of its way to make it inaccessible.
1162 */ 1712 */
1163 void (*res)(void); 1713 void (*res)(void);
1164 __asm__ __volatile__("call 2f\n" 1714 __asm__ __volatile__("call 2f\n"
1165 "0:.align 16\n" 1715 "0:.align 16\n"
1166 "1:movq %1,%%rax\n" 1716 "1:movq %1,%%rax\n"
1167 "syscall\n" 1717 "syscall\n"
1168 "2:popq %0\n" 1718 "2:popq %0\n"
1169 "addq $(1b-0b),%0\n" 1719 "addq $(1b-0b),%0\n"
1170 : "=a" (res) 1720 : "=a" (res)
1171 : "i" (__NR_rt_sigreturn)); 1721 : "i" (__NR_rt_sigreturn));
1172 return res; 1722 return res;
1173 } 1723 }
1174 #elif defined(__arm__) 1724 #elif defined(__ARM_ARCH_3__)
1175 /* Most definitions of _syscallX() neglect to mark "memory" as being 1725 /* Most definitions of _syscallX() neglect to mark "memory" as being
1176 * clobbered. This causes problems with compilers, that do a better job 1726 * clobbered. This causes problems with compilers, that do a better job
1177 * at optimizing across __asm__ calls. 1727 * at optimizing across __asm__ calls.
1178 * So, we just have to redefine all fo the _syscallX() macros. 1728 * So, we just have to redefine all fo the _syscallX() macros.
1179 */ 1729 */
1180 #undef LSS_REG 1730 #undef LSS_REG
1181 #define LSS_REG(r,a) register long __r##r __asm__("r"#r) = (long)a 1731 #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
1193 #undef LSS_BODY 1732 #undef LSS_BODY
1194 #define LSS_BODY(type, name, args...) \ 1733 #define LSS_BODY(type,name,args...) \
1195 register long __res_r0 __asm__("r0"); \ 1734 register long __res_r0 __asm__("r0"); \
1196 long __res; \ 1735 long __res; \
1197 __SYS_REG(name) \ 1736 __asm__ __volatile__ (__syscall(name) \
1198 __asm__ __volatile__ (__syscall_safe(name) \ 1737 : "=r"(__res_r0) : args : "lr", "memory"); \
1199 : "=r"(__res_r0) \
1200 : __SYS_REG_LIST(args) \
1201 : "lr", "memory"); \
1202 __res = __res_r0; \ 1738 __res = __res_r0; \
1203 LSS_RETURN(type, __res) 1739 LSS_RETURN(type, __res)
1204 #undef _syscall0 1740 #undef _syscall0
1205 #define _syscall0(type, name) \ 1741 #define _syscall0(type, name) \
1206 type LSS_NAME(name)() { \ 1742 type LSS_NAME(name)() { \
1207 LSS_BODY(type, name); \ 1743 LSS_BODY(type, name); \
1208 } 1744 }
1209 #undef _syscall1 1745 #undef _syscall1
1210 #define _syscall1(type, name, type1, arg1) \ 1746 #define _syscall1(type, name, type1, arg1) \
1211 type LSS_NAME(name)(type1 arg1) { \ 1747 type LSS_NAME(name)(type1 arg1) { \
1212 /* There is no need for using a volatile temp. */ \ 1748 LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \
1213 LSS_REG(0, arg1); \
1214 LSS_BODY(type, name, "r"(__r0)); \
1215 } 1749 }
1216 #undef _syscall2 1750 #undef _syscall2
1217 #define _syscall2(type, name, type1, arg1, type2, arg2) \ 1751 #define _syscall2(type, name, type1, arg1, type2, arg2) \
1218 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ 1752 type LSS_NAME(name)(type1 arg1, type2 arg2) { \
1219 LSS_SAVE_ARG(0, arg1); \ 1753 LSS_REG(0, arg1); LSS_REG(1, arg2); \
1220 LSS_SAVE_ARG(1, arg2); \
1221 LSS_LOAD_ARG(0); \
1222 LSS_LOAD_ARG(1); \
1223 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ 1754 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \
1224 } 1755 }
1225 #undef _syscall3 1756 #undef _syscall3
1226 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 1757 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
1227 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ 1758 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \
1228 LSS_SAVE_ARG(0, arg1); \ 1759 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \
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); \
1234 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ 1760 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \
1235 } 1761 }
1236 #undef _syscall4 1762 #undef _syscall4
1237 #define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ 1763 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
1238 type4, arg4) \
1239 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ 1764 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
1240 LSS_SAVE_ARG(0, arg1); \ 1765 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \
1241 LSS_SAVE_ARG(1, arg2); \ 1766 LSS_REG(3, arg4); \
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); \
1248 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ 1767 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \
1249 } 1768 }
1250 #undef _syscall5 1769 #undef _syscall5
1251 #define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ 1770 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
1252 type4, arg4, type5, arg5) \ 1771 type5,arg5) \
1253 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1772 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
1254 type5 arg5) { \ 1773 type5 arg5) { \
1255 LSS_SAVE_ARG(0, arg1); \ 1774 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \
1256 LSS_SAVE_ARG(1, arg2); \ 1775 LSS_REG(3, arg4); LSS_REG(4, arg5); \
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); \
1264 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ 1776 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \
1265 "r"(__r4)); \ 1777 "r"(__r4)); \
1266 } 1778 }
1267 #undef _syscall6 1779 #undef _syscall6
1268 #define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ 1780 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
1269 type4, arg4, type5, arg5, type6, arg6) \ 1781 type5,arg5,type6,arg6) \
1270 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1782 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
1271 type5 arg5, type6 arg6) { \ 1783 type5 arg5, type6 arg6) { \
1272 LSS_SAVE_ARG(0, arg1); \ 1784 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \
1273 LSS_SAVE_ARG(1, arg2); \ 1785 LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \
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); \
1282 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ 1786 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \
1283 "r"(__r4), "r"(__r5)); \ 1787 "r"(__r4), "r"(__r5)); \
1284 } 1788 }
1285 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, 1789 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
1286 int flags, void *arg, int *parent_tidptr, 1790 int flags, void *arg, int *parent_tidptr,
1287 void *newtls, int *child_tidptr) { 1791 void *newtls, int *child_tidptr) {
1288 register long __res __asm__("r5"); 1792 long __res;
1289 { 1793 {
1290 if (fn == NULL || child_stack == NULL) { 1794 register int __flags __asm__("r0") = flags;
1291 __res = -EINVAL; 1795 register void *__stack __asm__("r1") = child_stack;
1292 goto clone_exit; 1796 register void *__ptid __asm__("r2") = parent_tidptr;
1293 } 1797 register void *__tls __asm__("r3") = newtls;
1798 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"
1294 1806
1295 /* stash first 4 arguments on stack first because we can only load 1807 /* Push "arg" and "fn" onto the stack that will be
1296 * them after all function calls. 1808 * used by the child.
1297 */ 1809 */
1298 int tmp_flags = flags; 1810 "str %5,[%3,#-4]!\n"
1299 int * tmp_stack = (int*) child_stack; 1811 "str %2,[%3,#-4]!\n"
1300 void * tmp_ptid = parent_tidptr;
1301 void * tmp_tls = newtls;
1302 1812
1303 register int *__ctid __asm__("r4") = child_tidptr; 1813 /* %r0 = syscall(%r0 = flags,
1304
1305 /* Push "arg" and "fn" onto the stack that will be
1306 * used by the child.
1307 */
1308 *(--tmp_stack) = (int) arg;
1309 *(--tmp_stack) = (int) fn;
1310
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,
1325 * %r1 = child_stack, 1814 * %r1 = child_stack,
1326 * %r2 = parent_tidptr, 1815 * %r2 = parent_tidptr,
1327 * %r3 = newtls, 1816 * %r3 = newtls,
1328 * %r4 = child_tidptr) 1817 * %r4 = child_tidptr)
1329 */ 1818 */
1330 "push {r7}\n"
1331 "mov r7,%1\n"
1332 __syscall(clone)"\n" 1819 __syscall(clone)"\n"
1333 1820
1334 /* if (%r0 != 0) 1821 /* if (%r0 != 0)
1335 * return %r0; 1822 * return %r0;
1336 */ 1823 */
1337 "movs %0,r0\n" 1824 "movs %0,r0\n"
1338 "bne 1f\n" 1825 "bne 1f\n"
1339 1826
1340 /* In the child, now. Call "fn(arg)". 1827 /* In the child, now. Call "fn(arg)".
1341 */ 1828 */
1342 "ldr r0,[sp, #4]\n" 1829 "ldr r0,[sp, #4]\n"
1343 "mov lr,pc\n" 1830 "mov lr,pc\n"
1344 "ldr pc,[sp]\n" 1831 "ldr pc,[sp]\n"
1345 1832
1346 /* Call _exit(%r0), which never returns. We only 1833 /* Call _exit(%r0).
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.
1350 */ 1834 */
1351 "mov r7,%2\n"
1352 __syscall(exit)"\n" 1835 __syscall(exit)"\n"
1353 1836 "1:\n"
1354 /* Pop r7 from the stack only in the parent.
1355 */
1356 "1: pop {r7}\n"
1357 : "=r" (__res) 1837 : "=r" (__res)
1358 : "r"(__sysreg), 1838 : "i"(-EINVAL),
1359 "i"(__NR_exit), "r"(__stack), "r"(__flags), 1839 "r"(fn), "r"(__stack), "r"(__flags), "r"(arg),
1360 "r"(__ptid), "r"(__tls), "r"(__ctid) 1840 "r"(__ptid), "r"(__tls), "r"(__ctid)
1361 : "cc", "lr", "memory"); 1841 : "lr", "memory");
1362 } 1842 }
1363 clone_exit:
1364 LSS_RETURN(int, __res); 1843 LSS_RETURN(int, __res);
1365 } 1844 }
1366 #elif defined(__mips__) 1845 #elif defined(__mips__)
1367 #undef LSS_REG 1846 #undef LSS_REG
1368 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \ 1847 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \
1369 (unsigned long)(a) 1848 (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
1381 #undef LSS_BODY 1849 #undef LSS_BODY
1382 #define LSS_BODY(type,name,r7,...) \ 1850 #define LSS_BODY(type,name,r7,...) \
1383 register unsigned long __v0 __asm__("$2") = __NR_##name; \ 1851 register unsigned long __v0 __asm__("$2") = __NR_##name; \
1384 __asm__ __volatile__ ("syscall\n" \ 1852 __asm__ __volatile__ ("syscall\n" \
1385 : "=&r"(__v0), r7 (__r7) \ 1853 : "=&r"(__v0), r7 (__r7) \
1386 : "0"(__v0), ##__VA_ARGS__ \ 1854 : "0"(__v0), ##__VA_ARGS__ \
1387 : MIPS_SYSCALL_CLOBBERS); \ 1855 : "$8", "$9", "$10", "$11", "$12", \
1856 "$13", "$14", "$15", "$24", "memory"); \
1388 LSS_RETURN(type, __v0, __r7) 1857 LSS_RETURN(type, __v0, __r7)
1389 #undef _syscall0 1858 #undef _syscall0
1390 #define _syscall0(type, name) \ 1859 #define _syscall0(type, name) \
1391 type LSS_NAME(name)() { \ 1860 type LSS_NAME(name)() { \
1392 register unsigned long __r7 __asm__("$7"); \ 1861 register unsigned long __r7 __asm__("$7"); \
1393 LSS_BODY(type, name, "=r"); \ 1862 LSS_BODY(type, name, "=r"); \
1394 } 1863 }
1395 #undef _syscall1 1864 #undef _syscall1
1396 #define _syscall1(type, name, type1, arg1) \ 1865 #define _syscall1(type, name, type1, arg1) \
1397 type LSS_NAME(name)(type1 arg1) { \ 1866 type LSS_NAME(name)(type1 arg1) { \
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 "lw $2, %6\n" \ 1904 "lw $2, %6\n" \
1436 "subu $29, 32\n" \ 1905 "subu $29, 32\n" \
1437 "sw $2, 16($29)\n" \ 1906 "sw $2, 16($29)\n" \
1438 "li $2, %2\n" \ 1907 "li $2, %2\n" \
1439 "syscall\n" \ 1908 "syscall\n" \
1440 "addiu $29, 32\n" \ 1909 "addiu $29, 32\n" \
1441 ".set reorder\n" \ 1910 ".set reorder\n" \
1442 : "=&r"(__v0), "+r" (__r7) \ 1911 : "=&r"(__v0), "+r" (__r7) \
1443 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ 1912 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \
1444 "r"(__r6), "m" ((unsigned long)arg5) \ 1913 "r"(__r6), "m" ((unsigned long)arg5) \
1445 : MIPS_SYSCALL_CLOBBERS); \ 1914 : "$8", "$9", "$10", "$11", "$12", \
1915 "$13", "$14", "$15", "$24", "memory"); \
1446 LSS_RETURN(type, __v0, __r7); \ 1916 LSS_RETURN(type, __v0, __r7); \
1447 } 1917 }
1448 #else 1918 #else
1449 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1919 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
1450 type5,arg5) \ 1920 type5,arg5) \
1451 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1921 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
1452 type5 arg5) { \ 1922 type5 arg5) { \
1453 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ 1923 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \
1454 LSS_REG(7, arg4); LSS_REG(8, arg5); \ 1924 LSS_REG(7, arg4); LSS_REG(8, arg5); \
1455 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ 1925 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \
(...skipping 19 matching lines...) Expand all
1475 "sw $2, 16($29)\n" \ 1945 "sw $2, 16($29)\n" \
1476 "sw $8, 20($29)\n" \ 1946 "sw $8, 20($29)\n" \
1477 "li $2, %2\n" \ 1947 "li $2, %2\n" \
1478 "syscall\n" \ 1948 "syscall\n" \
1479 "addiu $29, 32\n" \ 1949 "addiu $29, 32\n" \
1480 ".set reorder\n" \ 1950 ".set reorder\n" \
1481 : "=&r"(__v0), "+r" (__r7) \ 1951 : "=&r"(__v0), "+r" (__r7) \
1482 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ 1952 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \
1483 "r"(__r6), "r" ((unsigned long)arg5), \ 1953 "r"(__r6), "r" ((unsigned long)arg5), \
1484 "r" ((unsigned long)arg6) \ 1954 "r" ((unsigned long)arg6) \
1485 : MIPS_SYSCALL_CLOBBERS); \ 1955 : "$8", "$9", "$10", "$11", "$12", \
1956 "$13", "$14", "$15", "$24", "memory"); \
1486 LSS_RETURN(type, __v0, __r7); \ 1957 LSS_RETURN(type, __v0, __r7); \
1487 } 1958 }
1488 #else 1959 #else
1489 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1960 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
1490 type5,arg5,type6,arg6) \ 1961 type5,arg5,type6,arg6) \
1491 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1962 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
1492 type5 arg5,type6 arg6) { \ 1963 type5 arg5,type6 arg6) { \
1493 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ 1964 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \
1494 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \ 1965 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \
1495 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ 1966 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 "r" (__ctidptr) 2242 "r" (__ctidptr)
1772 : "cr0", "cr1", "memory", "ctr", 2243 : "cr0", "cr1", "memory", "ctr",
1773 "r0", "r29", "r27", "r28"); 2244 "r0", "r29", "r27", "r28");
1774 } 2245 }
1775 LSS_RETURN(int, __ret, __err); 2246 LSS_RETURN(int, __ret, __err);
1776 } 2247 }
1777 #endif 2248 #endif
1778 #define __NR__exit __NR_exit 2249 #define __NR__exit __NR_exit
1779 #define __NR__gettid __NR_gettid 2250 #define __NR__gettid __NR_gettid
1780 #define __NR__mremap __NR_mremap 2251 #define __NR__mremap __NR_mremap
2252 LSS_INLINE _syscall1(int, chdir, const char *,p)
1781 LSS_INLINE _syscall1(int, close, int, f) 2253 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)
1782 LSS_INLINE _syscall1(int, _exit, int, e) 2263 LSS_INLINE _syscall1(int, _exit, int, e)
1783 LSS_INLINE _syscall3(int, fcntl, int, f, 2264 LSS_INLINE _syscall3(int, fcntl, int, f,
1784 int, c, long, a) 2265 int, c, long, a)
2266 LSS_INLINE _syscall0(pid_t, fork)
1785 LSS_INLINE _syscall2(int, fstat, int, f, 2267 LSS_INLINE _syscall2(int, fstat, int, f,
1786 struct kernel_stat*, b) 2268 struct kernel_stat*, b)
2269 LSS_INLINE _syscall2(int, fstatfs, int, f,
2270 struct kernel_statfs*, b)
1787 LSS_INLINE _syscall4(int, futex, int*, a, 2271 LSS_INLINE _syscall4(int, futex, int*, a,
1788 int, o, int, v, 2272 int, o, int, v,
1789 struct kernel_timespec*, t) 2273 struct kernel_timespec*, t)
1790 LSS_INLINE _syscall3(int, getdents, int, f, 2274 LSS_INLINE _syscall3(int, getdents, int, f,
1791 struct kernel_dirent*, d, int, c) 2275 struct kernel_dirent*, d, int, c)
1792 #ifdef __NR_getdents64
1793 LSS_INLINE _syscall3(int, getdents64, int, f, 2276 LSS_INLINE _syscall3(int, getdents64, int, f,
1794 struct kernel_dirent64*, d, int, c) 2277 struct kernel_dirent64*, d, int, c)
1795 #endif 2278 LSS_INLINE _syscall0(gid_t, getegid)
2279 LSS_INLINE _syscall0(uid_t, geteuid)
2280 LSS_INLINE _syscall0(pid_t, getpgrp)
1796 LSS_INLINE _syscall0(pid_t, getpid) 2281 LSS_INLINE _syscall0(pid_t, getpid)
1797 LSS_INLINE _syscall0(pid_t, getppid) 2282 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)
1798 LSS_INLINE _syscall0(pid_t, _gettid) 2288 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)
1799 LSS_INLINE _syscall2(int, kill, pid_t, p, 2307 LSS_INLINE _syscall2(int, kill, pid_t, p,
1800 int, s) 2308 int, s)
1801 LSS_INLINE _syscall3(off_t, lseek, int, f, 2309 LSS_INLINE _syscall3(off_t, lseek, int, f,
1802 off_t, o, int, w) 2310 off_t, o, int, w)
1803 LSS_INLINE _syscall2(int, munmap, void*, s, 2311 LSS_INLINE _syscall2(int, munmap, void*, s,
1804 size_t, l) 2312 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)
1805 LSS_INLINE _syscall5(void*, _mremap, void*, o, 2316 LSS_INLINE _syscall5(void*, _mremap, void*, o,
1806 size_t, os, size_t, ns, 2317 size_t, os, size_t, ns,
1807 unsigned long, f, void *, a) 2318 unsigned long, f, void *, a)
1808 LSS_INLINE _syscall3(int, open, const char*, p, 2319 LSS_INLINE _syscall3(int, open, const char*, p,
1809 int, f, int, m) 2320 int, f, int, m)
2321 LSS_INLINE _syscall3(int, poll, struct kernel_pollfd*, u,
2322 unsigned int, n, int, t)
1810 LSS_INLINE _syscall2(int, prctl, int, o, 2323 LSS_INLINE _syscall2(int, prctl, int, o,
1811 long, a) 2324 long, a)
1812 LSS_INLINE _syscall4(long, ptrace, int, r, 2325 LSS_INLINE _syscall4(long, ptrace, int, r,
1813 pid_t, p, void *, a, void *, d) 2326 pid_t, p, void *, a, void *, d)
1814 LSS_INLINE _syscall3(ssize_t, read, int, f, 2327 LSS_INLINE _syscall3(ssize_t, read, int, f,
1815 void *, b, size_t, c) 2328 void *, b, size_t, c)
2329 LSS_INLINE _syscall3(int, readlink, const char*, p,
2330 char*, b, size_t, s)
1816 LSS_INLINE _syscall4(int, rt_sigaction, int, s, 2331 LSS_INLINE _syscall4(int, rt_sigaction, int, s,
1817 const struct kernel_sigaction*, a, 2332 const struct kernel_sigaction*, a,
1818 struct kernel_sigaction*, o, size_t, c) 2333 struct kernel_sigaction*, o, size_t, c)
2334 LSS_INLINE _syscall2(int, rt_sigpending, struct kernel_sigset_t *, s,
2335 size_t, c)
1819 LSS_INLINE _syscall4(int, rt_sigprocmask, int, h, 2336 LSS_INLINE _syscall4(int, rt_sigprocmask, int, h,
1820 const struct kernel_sigset_t*, s, 2337 const struct kernel_sigset_t*, s,
1821 struct kernel_sigset_t*, o, size_t, c); 2338 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)
1822 LSS_INLINE _syscall0(int, sched_yield) 2345 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)
1823 LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, 2362 LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s,
1824 const stack_t*, o) 2363 const stack_t*, o)
1825 LSS_INLINE _syscall2(int, stat, const char*, f, 2364 LSS_INLINE _syscall2(int, stat, const char*, f,
1826 struct kernel_stat*, b) 2365 struct kernel_stat*, b)
2366 LSS_INLINE _syscall2(int, statfs, const char*, f,
2367 struct kernel_statfs*, b)
1827 LSS_INLINE _syscall3(ssize_t, write, int, f, 2368 LSS_INLINE _syscall3(ssize_t, write, int, f,
1828 const void *, b, size_t, c) 2369 const void *, b, size_t, c)
2370 LSS_INLINE _syscall3(ssize_t, writev, int, f,
2371 const struct kernel_iovec*, v, size_t, c)
1829 #if defined(__NR_getcpu) 2372 #if defined(__NR_getcpu)
1830 LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, 2373 LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu,
1831 unsigned *, node, void *, unused); 2374 unsigned *, node, void *, unused);
1832 #endif 2375 #endif
1833 #if defined(__x86_64__) || \ 2376 #if defined(__x86_64__) || \
1834 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) 2377 (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)
1835 LSS_INLINE _syscall3(int, socket, int, d, 2388 LSS_INLINE _syscall3(int, socket, int, d,
1836 int, t, int, p) 2389 int, t, int, p)
2390 LSS_INLINE _syscall4(int, socketpair, int, d,
2391 int, t, int, p, int*, s)
1837 #endif 2392 #endif
1838 #if defined(__x86_64__) 2393 #if defined(__x86_64__)
2394 LSS_INLINE _syscall4(int, fallocate, int, fd, int, mode,
2395 loff_t, offset, loff_t, len)
1839 LSS_INLINE _syscall6(void*, mmap, void*, s, 2396 LSS_INLINE _syscall6(void*, mmap, void*, s,
1840 size_t, l, int, p, 2397 size_t, l, int, p,
1841 int, f, int, d, 2398 int, f, int, d,
1842 __off64_t, o) 2399 __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 }
1843 2419
1844 LSS_INLINE int LSS_NAME(sigaction)(int signum, 2420 LSS_INLINE int LSS_NAME(sigaction)(int signum,
1845 const struct kernel_sigaction *act, 2421 const struct kernel_sigaction *act,
1846 struct kernel_sigaction *oldact) { 2422 struct kernel_sigaction *oldact) {
1847 /* On x86_64, the kernel requires us to always set our own 2423 /* On x86_64, the kernel requires us to always set our own
1848 * SA_RESTORER in order to be able to return from a signal handler. 2424 * SA_RESTORER in order to be able to return from a signal handler.
1849 * This function must have a "magic" signature that the "gdb" 2425 * This function must have a "magic" signature that the "gdb"
1850 * (and maybe the kernel?) can recognize. 2426 * (and maybe the kernel?) can recognize.
1851 */ 2427 */
1852 if (act != NULL && !(act->sa_flags & SA_RESTORER)) { 2428 if (act != NULL && !(act->sa_flags & SA_RESTORER)) {
1853 struct kernel_sigaction a = *act; 2429 struct kernel_sigaction a = *act;
1854 a.sa_flags |= SA_RESTORER; 2430 a.sa_flags |= SA_RESTORER;
1855 a.sa_restorer = LSS_NAME(restore_rt)(); 2431 a.sa_restorer = LSS_NAME(restore_rt)();
1856 return LSS_NAME(rt_sigaction)(signum, &a, oldact, 2432 return LSS_NAME(rt_sigaction)(signum, &a, oldact,
1857 (KERNEL_NSIG+7)/8); 2433 (KERNEL_NSIG+7)/8);
1858 } else { 2434 } else {
1859 return LSS_NAME(rt_sigaction)(signum, act, oldact, 2435 return LSS_NAME(rt_sigaction)(signum, act, oldact,
1860 (KERNEL_NSIG+7)/8); 2436 (KERNEL_NSIG+7)/8);
1861 } 2437 }
1862 } 2438 }
1863 2439
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
1864 LSS_INLINE int LSS_NAME(sigprocmask)(int how, 2444 LSS_INLINE int LSS_NAME(sigprocmask)(int how,
1865 const struct kernel_sigset_t *set, 2445 const struct kernel_sigset_t *set,
1866 struct kernel_sigset_t *oldset) { 2446 struct kernel_sigset_t *oldset) {
1867 return LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); 2447 return LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8);
1868 } 2448 }
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 }
1869 #endif 2453 #endif
1870 #if defined(__x86_64__) || \ 2454 #if defined(__x86_64__) || defined(__ARM_ARCH_3__) || \
1871 defined(__arm__) || \
1872 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) 2455 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32)
1873 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, 2456 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p,
1874 int*, s, int, o, 2457 int*, s, int, o,
1875 struct kernel_rusage*, r) 2458 struct kernel_rusage*, r)
2459
1876 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){ 2460 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){
1877 return LSS_NAME(wait4)(pid, status, options, 0); 2461 return LSS_NAME(wait4)(pid, status, options, 0);
1878 } 2462 }
1879 #endif 2463 #endif
1880 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) 2464 #if defined(__i386__) || defined(__x86_64__)
1881 LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m) 2465 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 }
1882 #endif 2537 #endif
1883 LSS_INLINE int LSS_NAME(sigemptyset)(struct kernel_sigset_t *set) { 2538 LSS_INLINE int LSS_NAME(sigemptyset)(struct kernel_sigset_t *set) {
1884 memset(&set->sig, 0, sizeof(set->sig)); 2539 memset(&set->sig, 0, sizeof(set->sig));
1885 return 0; 2540 return 0;
1886 } 2541 }
1887 2542
1888 LSS_INLINE int LSS_NAME(sigfillset)(struct kernel_sigset_t *set) { 2543 LSS_INLINE int LSS_NAME(sigfillset)(struct kernel_sigset_t *set) {
1889 memset(&set->sig, -1, sizeof(set->sig)); 2544 memset(&set->sig, -1, sizeof(set->sig));
1890 return 0; 2545 return 0;
1891 } 2546 }
1892 2547
1893 LSS_INLINE int LSS_NAME(sigaddset)(struct kernel_sigset_t *set, 2548 LSS_INLINE int LSS_NAME(sigaddset)(struct kernel_sigset_t *set,
1894 int signum) { 2549 int signum) {
1895 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { 2550 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) {
1896 LSS_ERRNO = EINVAL; 2551 LSS_ERRNO = EINVAL;
1897 return -1; 2552 return -1;
1898 } else { 2553 } else {
1899 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] 2554 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))]
1900 |= 1UL << ((signum - 1) % (8*sizeof(set->sig[0]))); 2555 |= 1UL << ((signum - 1) % (8*sizeof(set->sig[0])));
1901 return 0; 2556 return 0;
1902 } 2557 }
1903 } 2558 }
1904 2559
1905 LSS_INLINE int LSS_NAME(sigdelset)(struct kernel_sigset_t *set, 2560 LSS_INLINE int LSS_NAME(sigdelset)(struct kernel_sigset_t *set,
1906 int signum) { 2561 int signum) {
1907 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) { 2562 if (signum < 1 || signum > (int)(8*sizeof(set->sig))) {
1908 LSS_ERRNO = EINVAL; 2563 LSS_ERRNO = EINVAL;
1909 return -1; 2564 return -1;
1910 } else { 2565 } else {
1911 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))] 2566 set->sig[(signum - 1)/(8*sizeof(set->sig[0]))]
1912 &= ~(1UL << ((signum - 1) % (8*sizeof(set->sig[0])))); 2567 &= ~(1UL << ((signum - 1) % (8*sizeof(set->sig[0]))));
1913 return 0; 2568 return 0;
1914 } 2569 }
1915 } 2570 }
1916 2571
1917 #if defined(__i386__) || \ 2572 LSS_INLINE int LSS_NAME(sigismember)(struct kernel_sigset_t *set,
1918 defined(__arm__) || \ 2573 int signum) {
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__) || \
1919 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) 2583 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__)
1920 #define __NR__sigaction __NR_sigaction 2584 #define __NR__sigaction __NR_sigaction
2585 #define __NR__sigpending __NR_sigpending
1921 #define __NR__sigprocmask __NR_sigprocmask 2586 #define __NR__sigprocmask __NR_sigprocmask
2587 #define __NR__sigsuspend __NR_sigsuspend
2588 #define __NR__socketcall __NR_socketcall
1922 LSS_INLINE _syscall2(int, fstat64, int, f, 2589 LSS_INLINE _syscall2(int, fstat64, int, f,
1923 struct kernel_stat64 *, b) 2590 struct kernel_stat64 *, b)
1924 LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, 2591 LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo,
1925 loff_t *, res, uint, wh) 2592 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. */
1934 LSS_INLINE _syscall1(void*, mmap, void*, a) 2593 LSS_INLINE _syscall1(void*, mmap, void*, a)
1935 #endif 2594 #ifndef __PPC64__
1936 LSS_INLINE _syscall6(void*, mmap2, void*, s, 2595 LSS_INLINE _syscall6(void*, mmap2, void*, s,
1937 size_t, l, int, p, 2596 size_t, l, int, p,
1938 int, f, int, d, 2597 int, f, int, d,
1939 off_t, o) 2598 off_t, o)
1940 #endif 2599 #endif
1941 LSS_INLINE _syscall3(int, _sigaction, int, s, 2600 LSS_INLINE _syscall3(int, _sigaction, int, s,
1942 const struct kernel_old_sigaction*, a, 2601 const struct kernel_old_sigaction*, a,
1943 struct kernel_old_sigaction*, o) 2602 struct kernel_old_sigaction*, o)
2603 LSS_INLINE _syscall1(int, _sigpending, unsigned long*, s)
1944 LSS_INLINE _syscall3(int, _sigprocmask, int, h, 2604 LSS_INLINE _syscall3(int, _sigprocmask, int, h,
1945 const unsigned long*, s, 2605 const unsigned long*, s,
1946 unsigned long*, o) 2606 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
1947 LSS_INLINE _syscall2(int, stat64, const char *, p, 2614 LSS_INLINE _syscall2(int, stat64, const char *, p,
1948 struct kernel_stat64 *, b) 2615 struct kernel_stat64 *, b)
1949 2616
1950 LSS_INLINE int LSS_NAME(sigaction)(int signum, 2617 LSS_INLINE int LSS_NAME(sigaction)(int signum,
1951 const struct kernel_sigaction *act, 2618 const struct kernel_sigaction *act,
1952 struct kernel_sigaction *oldact) { 2619 struct kernel_sigaction *oldact) {
1953 int old_errno = LSS_ERRNO; 2620 int old_errno = LSS_ERRNO;
1954 int rc; 2621 int rc;
1955 struct kernel_sigaction a; 2622 struct kernel_sigaction a;
1956 if (act != NULL) { 2623 if (act != NULL) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 oldact->sa_flags = ptr_oa->sa_flags; 2669 oldact->sa_flags = ptr_oa->sa_flags;
2003 memcpy(&oldact->sa_mask, &ptr_oa->sa_mask, sizeof(ptr_oa->sa_mask)); 2670 memcpy(&oldact->sa_mask, &ptr_oa->sa_mask, sizeof(ptr_oa->sa_mask));
2004 #ifndef __mips__ 2671 #ifndef __mips__
2005 oldact->sa_restorer = ptr_oa->sa_restorer; 2672 oldact->sa_restorer = ptr_oa->sa_restorer;
2006 #endif 2673 #endif
2007 } 2674 }
2008 } 2675 }
2009 return rc; 2676 return rc;
2010 } 2677 }
2011 2678
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
2012 LSS_INLINE int LSS_NAME(sigprocmask)(int how, 2690 LSS_INLINE int LSS_NAME(sigprocmask)(int how,
2013 const struct kernel_sigset_t *set, 2691 const struct kernel_sigset_t *set,
2014 struct kernel_sigset_t *oldset) { 2692 struct kernel_sigset_t *oldset) {
2015 int olderrno = LSS_ERRNO; 2693 int olderrno = LSS_ERRNO;
2016 int rc = LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); 2694 int rc = LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8);
2017 if (rc < 0 && LSS_ERRNO == ENOSYS) { 2695 if (rc < 0 && LSS_ERRNO == ENOSYS) {
2018 LSS_ERRNO = olderrno; 2696 LSS_ERRNO = olderrno;
2019 if (oldset) { 2697 if (oldset) {
2020 LSS_NAME(sigemptyset)(oldset); 2698 LSS_NAME(sigemptyset)(oldset);
2021 } 2699 }
2022 rc = LSS_NAME(_sigprocmask)(how, 2700 rc = LSS_NAME(_sigprocmask)(how,
2023 set ? &set->sig[0] : NULL, 2701 set ? &set->sig[0] : NULL,
2024 oldset ? &oldset->sig[0] : NULL); 2702 oldset ? &oldset->sig[0] : NULL);
2025 } 2703 }
2026 return rc; 2704 return rc;
2027 } 2705 }
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 }
2028 #endif 2720 #endif
2029 #if defined(__PPC__) 2721 #if defined(__PPC__)
2030 #undef LSS_SC_LOADARGS_0 2722 #undef LSS_SC_LOADARGS_0
2031 #define LSS_SC_LOADARGS_0(dummy...) 2723 #define LSS_SC_LOADARGS_0(dummy...)
2032 #undef LSS_SC_LOADARGS_1 2724 #undef LSS_SC_LOADARGS_1
2033 #define LSS_SC_LOADARGS_1(arg1) \ 2725 #define LSS_SC_LOADARGS_1(arg1) \
2034 __sc_4 = (unsigned long) (arg1) 2726 __sc_4 = (unsigned long) (arg1)
2035 #undef LSS_SC_LOADARGS_2 2727 #undef LSS_SC_LOADARGS_2
2036 #define LSS_SC_LOADARGS_2(arg1, arg2) \ 2728 #define LSS_SC_LOADARGS_2(arg1, arg2) \
2037 LSS_SC_LOADARGS_1(arg1); \ 2729 LSS_SC_LOADARGS_1(arg1); \
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 "=&r" (__sc_3), "=&r" (__sc_4), \ 2766 "=&r" (__sc_3), "=&r" (__sc_4), \
2075 "=&r" (__sc_5), "=&r" (__sc_6), \ 2767 "=&r" (__sc_5), "=&r" (__sc_6), \
2076 "=&r" (__sc_7), "=&r" (__sc_8) \ 2768 "=&r" (__sc_7), "=&r" (__sc_8) \
2077 : LSS_ASMINPUT_##nr \ 2769 : LSS_ASMINPUT_##nr \
2078 : "cr0", "ctr", "memory"); \ 2770 : "cr0", "ctr", "memory"); \
2079 __sc_ret = __sc_3; \ 2771 __sc_ret = __sc_3; \
2080 __sc_err = __sc_0; \ 2772 __sc_err = __sc_0; \
2081 } \ 2773 } \
2082 LSS_RETURN(type, __sc_ret, __sc_err) 2774 LSS_RETURN(type, __sc_ret, __sc_err)
2083 2775
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
2084 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { 2801 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) {
2085 LSS_SC_BODY(3, int, 1, domain, type, protocol); 2802 LSS_SC_BODY(3, int, 1, domain, type, protocol);
2086 } 2803 }
2804
2805 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol,
2806 int sv[2]) {
2807 LSS_SC_BODY(4, int, 8, d, type, protocol, sv);
2808 }
2087 #endif 2809 #endif
2088 #if defined(__i386__) || \ 2810 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \
2089 (defined(__arm__) && !defined(__ARM_EABI__)) || \
2090 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) 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)
2091 2815
2092 /* See sys_socketcall in net/socket.c in kernel source. 2816 LSS_INLINE int LSS_NAME(socketcall)(int op, ...) {
2093 * It de-multiplexes on its first arg and unpacks the arglist 2817 int rc;
2094 * array in its second arg. 2818 va_list ap;
2095 */ 2819 va_start(ap, op);
2096 LSS_INLINE _syscall2(long, socketcall, int, c, unsigned long*, a) 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 }
2097 2846
2098 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { 2847 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) {
2099 unsigned long args[3] = { 2848 return LSS_NAME(socketcall)(1, domain, type, protocol);
2100 (unsigned long) domain,
2101 (unsigned long) type,
2102 (unsigned long) protocol
2103 };
2104 return LSS_NAME(socketcall)(1, args);
2105 } 2849 }
2106 #elif defined(__ARM_EABI__) 2850
2107 LSS_INLINE _syscall3(int, socket, int, d, 2851 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol,
2108 int, t, int, p) 2852 int sv[2]) {
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)
2109 #endif 2860 #endif
2110 #if defined(__i386__) || defined(__PPC__) || \ 2861 #if defined(__i386__) || defined(__PPC__) || \
2111 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) 2862 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32)
2112 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p, 2863 LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p,
2113 int*, s, int, o) 2864 int*, s, int, o)
2114 #endif 2865 #endif
2115 #if defined(__mips__) 2866 #if defined(__mips__)
2116 /* sys_pipe() on MIPS has non-standard calling conventions, as it returns 2867 /* sys_pipe() on MIPS has non-standard calling conventions, as it returns
2117 * both file handles through CPU registers. 2868 * both file handles through CPU registers.
2118 */ 2869 */
(...skipping 11 matching lines...) Expand all
2130 return -1; 2881 return -1;
2131 } else { 2882 } else {
2132 p[0] = __v0; 2883 p[0] = __v0;
2133 p[1] = __v1; 2884 p[1] = __v1;
2134 return 0; 2885 return 0;
2135 } 2886 }
2136 } 2887 }
2137 #else 2888 #else
2138 LSS_INLINE _syscall1(int, pipe, int *, p) 2889 LSS_INLINE _syscall1(int, pipe, int *, p)
2139 #endif 2890 #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 }
2140 2913
2141 LSS_INLINE pid_t LSS_NAME(gettid)() { 2914 LSS_INLINE pid_t LSS_NAME(gettid)() {
2142 pid_t tid = LSS_NAME(_gettid)(); 2915 pid_t tid = LSS_NAME(_gettid)();
2143 if (tid != -1) { 2916 if (tid != -1) {
2144 return tid; 2917 return tid;
2145 } 2918 }
2146 return LSS_NAME(getpid)(); 2919 return LSS_NAME(getpid)();
2147 } 2920 }
2148 2921
2149 LSS_INLINE void *LSS_NAME(mremap)(void *old_address, size_t old_size, 2922 LSS_INLINE void *LSS_NAME(mremap)(void *old_address, size_t old_size,
(...skipping 16 matching lines...) Expand all
2166 * right after detaching from the tracee. 2939 * right after detaching from the tracee.
2167 */ 2940 */
2168 int rc, err; 2941 int rc, err;
2169 LSS_NAME(sched_yield)(); 2942 LSS_NAME(sched_yield)();
2170 rc = LSS_NAME(ptrace)(PTRACE_DETACH, pid, (void *)0, (void *)0); 2943 rc = LSS_NAME(ptrace)(PTRACE_DETACH, pid, (void *)0, (void *)0);
2171 err = LSS_ERRNO; 2944 err = LSS_ERRNO;
2172 LSS_NAME(kill)(pid, SIGCONT); 2945 LSS_NAME(kill)(pid, SIGCONT);
2173 LSS_ERRNO = err; 2946 LSS_ERRNO = err;
2174 return rc; 2947 return rc;
2175 } 2948 }
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
2176 #endif 3015 #endif
2177 3016
2178 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) 3017 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS)
2179 } 3018 }
2180 #endif 3019 #endif
2181 3020
2182 #endif 3021 #endif
2183 #endif 3022 #endif
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/base/googleinit.h ('k') | third_party/tcmalloc/chromium/src/base/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698