OLD | NEW |
1 /* Copyright (c) 2005-2011, Google Inc. | 1 /* Copyright (c) 2005-2011, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 * Do not access these symbols from outside this file. They are not part | 79 * Do not access these symbols from outside this file. They are not part |
80 * of the supported API. | 80 * of the supported API. |
81 */ | 81 */ |
82 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H | 82 #ifndef SYS_LINUX_SYSCALL_SUPPORT_H |
83 #define SYS_LINUX_SYSCALL_SUPPORT_H | 83 #define SYS_LINUX_SYSCALL_SUPPORT_H |
84 | 84 |
85 /* We currently only support x86-32, x86-64, ARM, MIPS, and PPC on Linux. | 85 /* We currently only support x86-32, x86-64, ARM, MIPS, and PPC on Linux. |
86 * Porting to other related platforms should not be difficult. | 86 * Porting to other related platforms should not be difficult. |
87 */ | 87 */ |
88 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ | 88 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ |
89 defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__)) \ | 89 defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ |
| 90 defined(__aarch64__)) \ |
90 && (defined(__linux) || defined(__ANDROID__)) | 91 && (defined(__linux) || defined(__ANDROID__)) |
91 | 92 |
92 #ifndef SYS_CPLUSPLUS | 93 #ifndef SYS_CPLUSPLUS |
93 #ifdef __cplusplus | 94 #ifdef __cplusplus |
94 /* Some system header files in older versions of gcc neglect to properly | 95 /* Some system header files in older versions of gcc neglect to properly |
95 * handle being included from C++. As it appears to be harmless to have | 96 * handle being included from C++. As it appears to be harmless to have |
96 * multiple nested 'extern "C"' blocks, just add another one here. | 97 * multiple nested 'extern "C"' blocks, just add another one here. |
97 */ | 98 */ |
98 extern "C" { | 99 extern "C" { |
99 #endif | 100 #endif |
100 | 101 |
101 #include <errno.h> | 102 #include <errno.h> |
102 #include <fcntl.h> | 103 #include <fcntl.h> |
| 104 #include <sched.h> |
103 #include <signal.h> | 105 #include <signal.h> |
104 #include <stdarg.h> | 106 #include <stdarg.h> |
105 #include <stddef.h> | 107 #include <stddef.h> |
106 #include <stdint.h> | 108 #include <stdint.h> |
107 #include <string.h> | 109 #include <string.h> |
108 #include <sys/ptrace.h> | 110 #include <sys/ptrace.h> |
109 #include <sys/resource.h> | 111 #include <sys/resource.h> |
110 #include <sys/time.h> | 112 #include <sys/time.h> |
111 #include <sys/types.h> | 113 #include <sys/types.h> |
112 #include <sys/syscall.h> | 114 #include <sys/syscall.h> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 /* include/linux/dirent.h */ | 167 /* include/linux/dirent.h */ |
166 struct kernel_dirent64 { | 168 struct kernel_dirent64 { |
167 unsigned long long d_ino; | 169 unsigned long long d_ino; |
168 long long d_off; | 170 long long d_off; |
169 unsigned short d_reclen; | 171 unsigned short d_reclen; |
170 unsigned char d_type; | 172 unsigned char d_type; |
171 char d_name[256]; | 173 char d_name[256]; |
172 }; | 174 }; |
173 | 175 |
174 /* include/linux/dirent.h */ | 176 /* include/linux/dirent.h */ |
| 177 #if defined(__aarch64__) |
| 178 // aarch64 only defines dirent64, just uses that for dirent too. |
| 179 #define kernel_dirent kernel_dirent64 |
| 180 #else |
175 struct kernel_dirent { | 181 struct kernel_dirent { |
176 long d_ino; | 182 long d_ino; |
177 long d_off; | 183 long d_off; |
178 unsigned short d_reclen; | 184 unsigned short d_reclen; |
179 char d_name[256]; | 185 char d_name[256]; |
180 }; | 186 }; |
| 187 #endif |
181 | 188 |
182 /* include/linux/uio.h */ | 189 /* include/linux/uio.h */ |
183 struct kernel_iovec { | 190 struct kernel_iovec { |
184 void *iov_base; | 191 void *iov_base; |
185 unsigned long iov_len; | 192 unsigned long iov_len; |
186 }; | 193 }; |
187 | 194 |
188 /* include/linux/socket.h */ | 195 /* include/linux/socket.h */ |
189 struct kernel_msghdr { | 196 struct kernel_msghdr { |
190 void *msg_name; | 197 void *msg_name; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 union { | 256 union { |
250 void (*sa_handler_)(int); | 257 void (*sa_handler_)(int); |
251 void (*sa_sigaction_)(int, siginfo_t *, void *); | 258 void (*sa_sigaction_)(int, siginfo_t *, void *); |
252 }; | 259 }; |
253 unsigned long sa_mask; | 260 unsigned long sa_mask; |
254 unsigned long sa_flags; | 261 unsigned long sa_flags; |
255 void (*sa_restorer)(void); | 262 void (*sa_restorer)(void); |
256 } __attribute__((packed,aligned(4))); | 263 } __attribute__((packed,aligned(4))); |
257 #elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) | 264 #elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) |
258 #define kernel_old_sigaction kernel_sigaction | 265 #define kernel_old_sigaction kernel_sigaction |
| 266 #elif defined(__aarch64__) |
| 267 // No kernel_old_sigaction defined for arm64. |
259 #endif | 268 #endif |
260 | 269 |
261 /* Some kernel functions (e.g. sigaction() in 2.6.23) require that the | 270 /* Some kernel functions (e.g. sigaction() in 2.6.23) require that the |
262 * exactly match the size of the signal set, even though the API was | 271 * exactly match the size of the signal set, even though the API was |
263 * intended to be extensible. We define our own KERNEL_NSIG to deal with | 272 * intended to be extensible. We define our own KERNEL_NSIG to deal with |
264 * this. | 273 * this. |
265 * Please note that glibc provides signals [1.._NSIG-1], whereas the | 274 * Please note that glibc provides signals [1.._NSIG-1], whereas the |
266 * kernel (and this header) provides the range [1..KERNEL_NSIG]. The | 275 * kernel (and this header) provides the range [1..KERNEL_NSIG]. The |
267 * actual number of signals is obviously the same, but the constants | 276 * actual number of signals is obviously the same, but the constants |
268 * differ by one. | 277 * differ by one. |
269 */ | 278 */ |
270 #ifdef __mips__ | 279 #ifdef __mips__ |
271 #define KERNEL_NSIG 128 | 280 #define KERNEL_NSIG 128 |
272 #else | 281 #else |
273 #define KERNEL_NSIG 64 | 282 #define KERNEL_NSIG 64 |
274 #endif | 283 #endif |
275 | 284 |
276 /* include/asm-{arm,i386,mips,x86_64}/signal.h */ | 285 /* include/asm-{arm,aarch64,i386,mips,x86_64}/signal.h */ |
277 struct kernel_sigset_t { | 286 struct kernel_sigset_t { |
278 unsigned long sig[(KERNEL_NSIG + 8*sizeof(unsigned long) - 1)/ | 287 unsigned long sig[(KERNEL_NSIG + 8*sizeof(unsigned long) - 1)/ |
279 (8*sizeof(unsigned long))]; | 288 (8*sizeof(unsigned long))]; |
280 }; | 289 }; |
281 | 290 |
282 /* include/asm-{arm,i386,mips,x86_64,ppc}/signal.h */ | 291 /* include/asm-{arm,i386,mips,x86_64,ppc}/signal.h */ |
283 struct kernel_sigaction { | 292 struct kernel_sigaction { |
284 #ifdef __mips__ | 293 #ifdef __mips__ |
285 unsigned long sa_flags; | 294 unsigned long sa_flags; |
286 union { | 295 union { |
(...skipping 11 matching lines...) Expand all Loading... |
298 struct kernel_sigset_t sa_mask; | 307 struct kernel_sigset_t sa_mask; |
299 #endif | 308 #endif |
300 }; | 309 }; |
301 | 310 |
302 /* include/linux/socket.h */ | 311 /* include/linux/socket.h */ |
303 struct kernel_sockaddr { | 312 struct kernel_sockaddr { |
304 unsigned short sa_family; | 313 unsigned short sa_family; |
305 char sa_data[14]; | 314 char sa_data[14]; |
306 }; | 315 }; |
307 | 316 |
308 /* include/asm-{arm,i386,mips,ppc}/stat.h */ | 317 /* include/asm-{arm,aarch64,i386,mips,ppc}/stat.h */ |
309 #ifdef __mips__ | 318 #ifdef __mips__ |
310 #if _MIPS_SIM == _MIPS_SIM_ABI64 | 319 #if _MIPS_SIM == _MIPS_SIM_ABI64 |
311 struct kernel_stat { | 320 struct kernel_stat { |
312 #else | 321 #else |
313 struct kernel_stat64 { | 322 struct kernel_stat64 { |
314 #endif | 323 #endif |
315 unsigned st_dev; | 324 unsigned st_dev; |
316 unsigned __pad0[3]; | 325 unsigned __pad0[3]; |
317 unsigned long long st_ino; | 326 unsigned long long st_ino; |
318 unsigned st_mode; | 327 unsigned st_mode; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 unsigned st_atime_; | 380 unsigned st_atime_; |
372 unsigned st_atime_nsec_; | 381 unsigned st_atime_nsec_; |
373 unsigned st_mtime_; | 382 unsigned st_mtime_; |
374 unsigned st_mtime_nsec_; | 383 unsigned st_mtime_nsec_; |
375 unsigned st_ctime_; | 384 unsigned st_ctime_; |
376 unsigned st_ctime_nsec_; | 385 unsigned st_ctime_nsec_; |
377 unsigned long long st_ino; | 386 unsigned long long st_ino; |
378 }; | 387 }; |
379 #endif | 388 #endif |
380 | 389 |
381 /* include/asm-{arm,i386,mips,x86_64,ppc}/stat.h */ | 390 /* include/asm-{arm,aarch64,i386,mips,x86_64,ppc}/stat.h */ |
382 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) | 391 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) |
383 struct kernel_stat { | 392 struct kernel_stat { |
384 /* The kernel headers suggest that st_dev and st_rdev should be 32bit | 393 /* The kernel headers suggest that st_dev and st_rdev should be 32bit |
385 * quantities encoding 12bit major and 20bit minor numbers in an interleaved | 394 * quantities encoding 12bit major and 20bit minor numbers in an interleaved |
386 * format. In reality, we do not see useful data in the top bits. So, | 395 * format. In reality, we do not see useful data in the top bits. So, |
387 * we'll leave the padding in here, until we find a better solution. | 396 * we'll leave the padding in here, until we find a better solution. |
388 */ | 397 */ |
389 unsigned short st_dev; | 398 unsigned short st_dev; |
390 short pad1; | 399 short pad1; |
391 unsigned st_ino; | 400 unsigned st_ino; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 long st_atime_; | 474 long st_atime_; |
466 long st_atime_nsec_; | 475 long st_atime_nsec_; |
467 long st_mtime_; | 476 long st_mtime_; |
468 long st_mtime_nsec_; | 477 long st_mtime_nsec_; |
469 long st_ctime_; | 478 long st_ctime_; |
470 long st_ctime_nsec_; | 479 long st_ctime_nsec_; |
471 int st_blksize; | 480 int st_blksize; |
472 int st_blocks; | 481 int st_blocks; |
473 int st_pad4[14]; | 482 int st_pad4[14]; |
474 }; | 483 }; |
| 484 #elif defined(__aarch64__) |
| 485 struct kernel_stat { |
| 486 unsigned long st_dev; |
| 487 unsigned long st_ino; |
| 488 unsigned int st_mode; |
| 489 unsigned int st_nlink; |
| 490 unsigned int st_uid; |
| 491 unsigned int st_gid; |
| 492 unsigned long st_rdev; |
| 493 unsigned long __pad1; |
| 494 long st_size; |
| 495 int st_blksize; |
| 496 int __pad2; |
| 497 long st_blocks; |
| 498 long st_atime_; |
| 499 unsigned long st_atime_nsec_; |
| 500 long st_mtime_; |
| 501 unsigned long st_mtime_nsec_; |
| 502 long st_ctime_; |
| 503 unsigned long st_ctime_nsec_; |
| 504 unsigned int __unused4; |
| 505 unsigned int __unused5; |
| 506 }; |
475 #endif | 507 #endif |
476 | 508 |
477 /* include/asm-{arm,i386,mips,x86_64,ppc}/statfs.h */ | 509 /* include/asm-{arm,aarch64,i386,mips,x86_64,ppc}/statfs.h */ |
478 #ifdef __mips__ | 510 #ifdef __mips__ |
479 #if _MIPS_SIM != _MIPS_SIM_ABI64 | 511 #if _MIPS_SIM != _MIPS_SIM_ABI64 |
480 struct kernel_statfs64 { | 512 struct kernel_statfs64 { |
481 unsigned long f_type; | 513 unsigned long f_type; |
482 unsigned long f_bsize; | 514 unsigned long f_bsize; |
483 unsigned long f_frsize; | 515 unsigned long f_frsize; |
484 unsigned long __pad; | 516 unsigned long __pad; |
485 unsigned long long f_blocks; | 517 unsigned long long f_blocks; |
486 unsigned long long f_bfree; | 518 unsigned long long f_bfree; |
487 unsigned long long f_files; | 519 unsigned long long f_files; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 struct { int val[2]; } f_fsid; | 584 struct { int val[2]; } f_fsid; |
553 unsigned long f_namelen; | 585 unsigned long f_namelen; |
554 unsigned long f_frsize; | 586 unsigned long f_frsize; |
555 unsigned long f_spare[5]; | 587 unsigned long f_spare[5]; |
556 }; | 588 }; |
557 #endif | 589 #endif |
558 | 590 |
559 | 591 |
560 /* Definitions missing from the standard header files */ | 592 /* Definitions missing from the standard header files */ |
561 #ifndef O_DIRECTORY | 593 #ifndef O_DIRECTORY |
562 #if defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) | 594 #if defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || defined(__aarch64__) |
563 #define O_DIRECTORY 0040000 | 595 #define O_DIRECTORY 0040000 |
564 #else | 596 #else |
565 #define O_DIRECTORY 0200000 | 597 #define O_DIRECTORY 0200000 |
566 #endif | 598 #endif |
567 #endif | 599 #endif |
568 #ifndef NT_PRXFPREG | 600 #ifndef NT_PRXFPREG |
569 #define NT_PRXFPREG 0x46e62b7f | 601 #define NT_PRXFPREG 0x46e62b7f |
570 #endif | 602 #endif |
571 #ifndef PTRACE_GETFPXREGS | 603 #ifndef PTRACE_GETFPXREGS |
572 #define PTRACE_GETFPXREGS ((enum __ptrace_request)18) | 604 #define PTRACE_GETFPXREGS ((enum __ptrace_request)18) |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 #ifndef __NR_ioprio_get | 938 #ifndef __NR_ioprio_get |
907 #define __NR_ioprio_get (__NR_SYSCALL_BASE + 315) | 939 #define __NR_ioprio_get (__NR_SYSCALL_BASE + 315) |
908 #endif | 940 #endif |
909 #ifndef __NR_move_pages | 941 #ifndef __NR_move_pages |
910 #define __NR_move_pages (__NR_SYSCALL_BASE + 344) | 942 #define __NR_move_pages (__NR_SYSCALL_BASE + 344) |
911 #endif | 943 #endif |
912 #ifndef __NR_getcpu | 944 #ifndef __NR_getcpu |
913 #define __NR_getcpu (__NR_SYSCALL_BASE + 345) | 945 #define __NR_getcpu (__NR_SYSCALL_BASE + 345) |
914 #endif | 946 #endif |
915 /* End of ARM 3/EABI definitions
*/ | 947 /* End of ARM 3/EABI definitions
*/ |
| 948 #elif defined(__aarch64__) |
| 949 #ifndef __NR_setxattr |
| 950 #define __NR_setxattr 5 |
| 951 #endif |
| 952 #ifndef __NR_lsetxattr |
| 953 #define __NR_lsetxattr 6 |
| 954 #endif |
| 955 #ifndef __NR_getxattr |
| 956 #define __NR_getxattr 8 |
| 957 #endif |
| 958 #ifndef __NR_lgetxattr |
| 959 #define __NR_lgetxattr 9 |
| 960 #endif |
| 961 #ifndef __NR_listxattr |
| 962 #define __NR_listxattr 11 |
| 963 #endif |
| 964 #ifndef __NR_llistxattr |
| 965 #define __NR_llistxattr 12 |
| 966 #endif |
| 967 #ifndef __NR_ioprio_set |
| 968 #define __NR_ioprio_set 30 |
| 969 #endif |
| 970 #ifndef __NR_ioprio_get |
| 971 #define __NR_ioprio_get 31 |
| 972 #endif |
| 973 #ifndef __NR_unlinkat |
| 974 #define __NR_unlinkat 35 |
| 975 #endif |
| 976 #ifndef __NR_fallocate |
| 977 #define __NR_fallocate 47 |
| 978 #endif |
| 979 #ifndef __NR_openat |
| 980 #define __NR_openat 56 |
| 981 #endif |
| 982 #ifndef __NR_quotactl |
| 983 #define __NR_quotactl 60 |
| 984 #endif |
| 985 #ifndef __NR_getdents64 |
| 986 #define __NR_getdents64 61 |
| 987 #endif |
| 988 #ifndef __NR_getdents |
| 989 #define __NR_getdents __NR_getdents64 |
| 990 #endif |
| 991 #ifndef __NR_pread64 |
| 992 #define __NR_pread64 67 |
| 993 #endif |
| 994 #ifndef __NR_pwrite64 |
| 995 #define __NR_pwrite64 68 |
| 996 #endif |
| 997 #ifndef __NR_ppoll |
| 998 #define __NR_ppoll 73 |
| 999 #endif |
| 1000 #ifndef __NR_readlinkat |
| 1001 #define __NR_readlinkat 78 |
| 1002 #endif |
| 1003 #ifndef __NR_newfstatat |
| 1004 #define __NR_newfstatat 79 |
| 1005 #endif |
| 1006 #ifndef __NR_set_tid_address |
| 1007 #define __NR_set_tid_address 96 |
| 1008 #endif |
| 1009 #ifndef __NR_futex |
| 1010 #define __NR_futex 98 |
| 1011 #endif |
| 1012 #ifndef __NR_clock_gettime |
| 1013 #define __NR_clock_gettime 113 |
| 1014 #endif |
| 1015 #ifndef __NR_clock_getres |
| 1016 #define __NR_clock_getres 114 |
| 1017 #endif |
| 1018 #ifndef __NR_sched_setaffinity |
| 1019 #define __NR_sched_setaffinity 122 |
| 1020 #define __NR_sched_getaffinity 123 |
| 1021 #endif |
| 1022 #ifndef __NR_tkill |
| 1023 #define __NR_tkill 130 |
| 1024 #endif |
| 1025 #ifndef __NR_setresuid |
| 1026 #define __NR_setresuid 147 |
| 1027 #define __NR_getresuid 148 |
| 1028 #define __NR_setresgid 149 |
| 1029 #define __NR_getresgid 150 |
| 1030 #endif |
| 1031 #ifndef __NR_gettid |
| 1032 #define __NR_gettid 178 |
| 1033 #endif |
| 1034 #ifndef __NR_readahead |
| 1035 #define __NR_readahead 213 |
| 1036 #endif |
| 1037 #ifndef __NR_fadvise64 |
| 1038 #define __NR_fadvise64 223 |
| 1039 #endif |
| 1040 #ifndef __NR_move_pages |
| 1041 #define __NR_move_pages 239 |
| 1042 #endif |
| 1043 /* End of aarch64 definitions */ |
916 #elif defined(__x86_64__) | 1044 #elif defined(__x86_64__) |
917 #ifndef __NR_pread64 | 1045 #ifndef __NR_pread64 |
918 #define __NR_pread64 17 | 1046 #define __NR_pread64 17 |
919 #endif | 1047 #endif |
920 #ifndef __NR_pwrite64 | 1048 #ifndef __NR_pwrite64 |
921 #define __NR_pwrite64 18 | 1049 #define __NR_pwrite64 18 |
922 #endif | 1050 #endif |
923 #ifndef __NR_setresuid | 1051 #ifndef __NR_setresuid |
924 #define __NR_setresuid 117 | 1052 #define __NR_setresuid 117 |
925 #define __NR_getresuid 118 | 1053 #define __NR_getresuid 118 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 #elif defined(SYS_PREFIX) && SYS_PREFIX == 7 | 1553 #elif defined(SYS_PREFIX) && SYS_PREFIX == 7 |
1426 #define LSS_NAME(name) sys7_##name | 1554 #define LSS_NAME(name) sys7_##name |
1427 #elif defined(SYS_PREFIX) && SYS_PREFIX == 8 | 1555 #elif defined(SYS_PREFIX) && SYS_PREFIX == 8 |
1428 #define LSS_NAME(name) sys8_##name | 1556 #define LSS_NAME(name) sys8_##name |
1429 #elif defined(SYS_PREFIX) && SYS_PREFIX == 9 | 1557 #elif defined(SYS_PREFIX) && SYS_PREFIX == 9 |
1430 #define LSS_NAME(name) sys9_##name | 1558 #define LSS_NAME(name) sys9_##name |
1431 #endif | 1559 #endif |
1432 | 1560 |
1433 #undef LSS_RETURN | 1561 #undef LSS_RETURN |
1434 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ | 1562 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ |
1435 || defined(__ARM_EABI__)) | 1563 || defined(__ARM_EABI__) || defined(__aarch64__)) |
1436 /* Failing system calls return a negative result in the range of | 1564 /* Failing system calls return a negative result in the range of |
1437 * -1..-4095. These are "errno" values with the sign inverted. | 1565 * -1..-4095. These are "errno" values with the sign inverted. |
1438 */ | 1566 */ |
1439 #define LSS_RETURN(type, res) \ | 1567 #define LSS_RETURN(type, res) \ |
1440 do { \ | 1568 do { \ |
1441 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ | 1569 if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ |
1442 LSS_ERRNO = -(res); \ | 1570 LSS_ERRNO = -(res); \ |
1443 res = -1; \ | 1571 res = -1; \ |
1444 } \ | 1572 } \ |
1445 return (type) (res); \ | 1573 return (type) (res); \ |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2308 "r"(__ptid), "r"(__tls), "r"(__ctid), | 2436 "r"(__ptid), "r"(__tls), "r"(__ctid), |
2309 "i"(__NR_clone), "i"(__NR_exit) | 2437 "i"(__NR_clone), "i"(__NR_exit) |
2310 #ifdef __thumb2__ | 2438 #ifdef __thumb2__ |
2311 : "cc", "lr", "memory"); | 2439 : "cc", "lr", "memory"); |
2312 #else | 2440 #else |
2313 : "cc", "r7", "lr", "memory"); | 2441 : "cc", "r7", "lr", "memory"); |
2314 #endif | 2442 #endif |
2315 } | 2443 } |
2316 LSS_RETURN(int, __res); | 2444 LSS_RETURN(int, __res); |
2317 } | 2445 } |
| 2446 #elif defined(__aarch64__) |
| 2447 /* Most definitions of _syscallX() neglect to mark "memory" as being |
| 2448 * clobbered. This causes problems with compilers, that do a better job |
| 2449 * at optimizing across __asm__ calls. |
| 2450 * So, we just have to redefine all of the _syscallX() macros. |
| 2451 */ |
| 2452 #undef LSS_REG |
| 2453 #define LSS_REG(r,a) register int64_t __r##r __asm__("x"#r) = (int64_t)a |
| 2454 #undef LSS_BODY |
| 2455 #define LSS_BODY(type,name,args...) \ |
| 2456 register int64_t __res_x0 __asm__("x0"); \ |
| 2457 int64_t __res; \ |
| 2458 __asm__ __volatile__ ("mov x8, %1\n" \ |
| 2459 "svc 0x0\n" \ |
| 2460 : "=r"(__res_x0) \ |
| 2461 : "i"(__NR_##name) , ## args \ |
| 2462 : "x8", "memory"); \ |
| 2463 __res = __res_x0; \ |
| 2464 LSS_RETURN(type, __res) |
| 2465 #undef _syscall0 |
| 2466 #define _syscall0(type, name) \ |
| 2467 type LSS_NAME(name)(void) { \ |
| 2468 LSS_BODY(type, name); \ |
| 2469 } |
| 2470 #undef _syscall1 |
| 2471 #define _syscall1(type, name, type1, arg1) \ |
| 2472 type LSS_NAME(name)(type1 arg1) { \ |
| 2473 LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ |
| 2474 } |
| 2475 #undef _syscall2 |
| 2476 #define _syscall2(type, name, type1, arg1, type2, arg2) \ |
| 2477 type LSS_NAME(name)(type1 arg1, type2 arg2) { \ |
| 2478 LSS_REG(0, arg1); LSS_REG(1, arg2); \ |
| 2479 LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ |
| 2480 } |
| 2481 #undef _syscall3 |
| 2482 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ |
| 2483 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ |
| 2484 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ |
| 2485 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ |
| 2486 } |
| 2487 #undef _syscall4 |
| 2488 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ |
| 2489 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ |
| 2490 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ |
| 2491 LSS_REG(3, arg4); \ |
| 2492 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ |
| 2493 } |
| 2494 #undef _syscall5 |
| 2495 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 2496 type5,arg5) \ |
| 2497 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 2498 type5 arg5) { \ |
| 2499 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ |
| 2500 LSS_REG(3, arg4); LSS_REG(4, arg5); \ |
| 2501 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ |
| 2502 "r"(__r4)); \ |
| 2503 } |
| 2504 #undef _syscall6 |
| 2505 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 2506 type5,arg5,type6,arg6) \ |
| 2507 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 2508 type5 arg5, type6 arg6) { \ |
| 2509 LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ |
| 2510 LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ |
| 2511 LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ |
| 2512 "r"(__r4), "r"(__r5)); \ |
| 2513 } |
| 2514 |
| 2515 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, |
| 2516 int flags, void *arg, int *parent_tidptr, |
| 2517 void *newtls, int *child_tidptr) { |
| 2518 int64_t __res; |
| 2519 { |
| 2520 register uint64_t __flags __asm__("x0") = flags; |
| 2521 register void *__stack __asm__("x1") = child_stack; |
| 2522 register void *__ptid __asm__("x2") = parent_tidptr; |
| 2523 register void *__tls __asm__("x3") = newtls; |
| 2524 register int *__ctid __asm__("x4") = child_tidptr; |
| 2525 __asm__ __volatile__(/* Push "arg" and "fn" onto the stack that will be |
| 2526 * used by the child. |
| 2527 */ |
| 2528 "stp %1, %4, [%2, #-16]!\n" |
| 2529 |
| 2530 /* %x0 = syscall(%x0 = flags, |
| 2531 * %x1 = child_stack, |
| 2532 * %x2 = parent_tidptr, |
| 2533 * %x3 = newtls, |
| 2534 * %x4 = child_tidptr) |
| 2535 */ |
| 2536 "mov x8, %8\n" |
| 2537 "svc 0x0\n" |
| 2538 |
| 2539 /* if (%r0 != 0) |
| 2540 * return %r0; |
| 2541 */ |
| 2542 "mov %0, x0\n" |
| 2543 "cbnz x0, 1f\n" |
| 2544 |
| 2545 /* In the child, now. Call "fn(arg)". |
| 2546 */ |
| 2547 "ldp x1, x0, [sp], #16\n" |
| 2548 "blr x1\n" |
| 2549 |
| 2550 /* Call _exit(%r0). |
| 2551 */ |
| 2552 "mov x8, %9\n" |
| 2553 "svc 0x0\n" |
| 2554 "1:\n" |
| 2555 : "=r" (__res) |
| 2556 : "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), |
| 2557 "r"(__ptid), "r"(__tls), "r"(__ctid), |
| 2558 "i"(__NR_clone), "i"(__NR_exit) |
| 2559 : "cc", "x8", "memory"); |
| 2560 } |
| 2561 LSS_RETURN(int, __res); |
| 2562 } |
2318 #elif defined(__mips__) | 2563 #elif defined(__mips__) |
2319 #undef LSS_REG | 2564 #undef LSS_REG |
2320 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \ | 2565 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \ |
2321 (unsigned long)(a) | 2566 (unsigned long)(a) |
2322 #undef LSS_BODY | 2567 #undef LSS_BODY |
2323 #define LSS_BODY(type,name,r7,...) \ | 2568 #define LSS_BODY(type,name,r7,...) \ |
2324 register unsigned long __v0 __asm__("$2") = __NR_##name; \ | 2569 register unsigned long __v0 __asm__("$2") = __NR_##name; \ |
2325 __asm__ __volatile__ ("syscall\n" \ | 2570 __asm__ __volatile__ ("syscall\n" \ |
2326 : "+r"(__v0), r7 (__r7) \ | 2571 : "+r"(__v0), r7 (__r7) \ |
2327 : "0"(__v0), ##__VA_ARGS__ \ | 2572 : "0"(__v0), ##__VA_ARGS__ \ |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2721 #define __NR__gettid __NR_gettid | 2966 #define __NR__gettid __NR_gettid |
2722 #define __NR__mremap __NR_mremap | 2967 #define __NR__mremap __NR_mremap |
2723 LSS_INLINE _syscall1(void *, brk, void *, e) | 2968 LSS_INLINE _syscall1(void *, brk, void *, e) |
2724 LSS_INLINE _syscall1(int, chdir, const char *,p) | 2969 LSS_INLINE _syscall1(int, chdir, const char *,p) |
2725 LSS_INLINE _syscall1(int, close, int, f) | 2970 LSS_INLINE _syscall1(int, close, int, f) |
2726 LSS_INLINE _syscall2(int, clock_getres, int, c, | 2971 LSS_INLINE _syscall2(int, clock_getres, int, c, |
2727 struct kernel_timespec*, t) | 2972 struct kernel_timespec*, t) |
2728 LSS_INLINE _syscall2(int, clock_gettime, int, c, | 2973 LSS_INLINE _syscall2(int, clock_gettime, int, c, |
2729 struct kernel_timespec*, t) | 2974 struct kernel_timespec*, t) |
2730 LSS_INLINE _syscall1(int, dup, int, f) | 2975 LSS_INLINE _syscall1(int, dup, int, f) |
2731 LSS_INLINE _syscall2(int, dup2, int, s, | 2976 #if !defined(__aarch64__) |
2732 int, d) | 2977 // The dup2 syscall has been deprecated on aarch64. We polyfill it below. |
| 2978 LSS_INLINE _syscall2(int, dup2, int, s, |
| 2979 int, d) |
| 2980 #endif |
2733 LSS_INLINE _syscall3(int, execve, const char*, f, | 2981 LSS_INLINE _syscall3(int, execve, const char*, f, |
2734 const char*const*,a,const char*const*, e) | 2982 const char*const*,a,const char*const*, e) |
2735 LSS_INLINE _syscall1(int, _exit, int, e) | 2983 LSS_INLINE _syscall1(int, _exit, int, e) |
2736 LSS_INLINE _syscall1(int, exit_group, int, e) | 2984 LSS_INLINE _syscall1(int, exit_group, int, e) |
2737 LSS_INLINE _syscall3(int, fcntl, int, f, | 2985 LSS_INLINE _syscall3(int, fcntl, int, f, |
2738 int, c, long, a) | 2986 int, c, long, a) |
2739 LSS_INLINE _syscall0(pid_t, fork) | 2987 #if !defined(__aarch64__) |
| 2988 // The fork syscall has been deprecated on aarch64. We polyfill it below. |
| 2989 LSS_INLINE _syscall0(pid_t, fork) |
| 2990 #endif |
2740 LSS_INLINE _syscall2(int, fstat, int, f, | 2991 LSS_INLINE _syscall2(int, fstat, int, f, |
2741 struct kernel_stat*, b) | 2992 struct kernel_stat*, b) |
2742 LSS_INLINE _syscall2(int, fstatfs, int, f, | 2993 LSS_INLINE _syscall2(int, fstatfs, int, f, |
2743 struct kernel_statfs*, b) | 2994 struct kernel_statfs*, b) |
2744 #if defined(__x86_64__) | 2995 #if defined(__x86_64__) |
2745 /* Need to make sure off_t isn't truncated to 32-bits under x32. */ | 2996 /* Need to make sure off_t isn't truncated to 32-bits under x32. */ |
2746 LSS_INLINE int LSS_NAME(ftruncate)(int f, off_t l) { | 2997 LSS_INLINE int LSS_NAME(ftruncate)(int f, off_t l) { |
2747 LSS_BODY(2, int, ftruncate, LSS_SYSCALL_ARG(f), (uint64_t)(l)); | 2998 LSS_BODY(2, int, ftruncate, LSS_SYSCALL_ARG(f), (uint64_t)(l)); |
2748 } | 2999 } |
2749 #else | 3000 #else |
2750 LSS_INLINE _syscall2(int, ftruncate, int, f, | 3001 LSS_INLINE _syscall2(int, ftruncate, int, f, |
2751 off_t, l) | 3002 off_t, l) |
2752 #endif | 3003 #endif |
2753 LSS_INLINE _syscall4(int, futex, int*, a, | 3004 LSS_INLINE _syscall4(int, futex, int*, a, |
2754 int, o, int, v, | 3005 int, o, int, v, |
2755 struct kernel_timespec*, t) | 3006 struct kernel_timespec*, t) |
2756 LSS_INLINE _syscall3(int, getdents, int, f, | 3007 LSS_INLINE _syscall3(int, getdents, int, f, |
2757 struct kernel_dirent*, d, int, c) | 3008 struct kernel_dirent*, d, int, c) |
2758 LSS_INLINE _syscall3(int, getdents64, int, f, | 3009 LSS_INLINE _syscall3(int, getdents64, int, f, |
2759 struct kernel_dirent64*, d, int, c) | 3010 struct kernel_dirent64*, d, int, c) |
2760 LSS_INLINE _syscall0(gid_t, getegid) | 3011 LSS_INLINE _syscall0(gid_t, getegid) |
2761 LSS_INLINE _syscall0(uid_t, geteuid) | 3012 LSS_INLINE _syscall0(uid_t, geteuid) |
2762 LSS_INLINE _syscall0(pid_t, getpgrp) | 3013 #if !defined(__aarch64__) |
| 3014 // The getgprp syscall has been deprecated on aarch64. |
| 3015 LSS_INLINE _syscall0(pid_t, getpgrp) |
| 3016 #endif |
2763 LSS_INLINE _syscall0(pid_t, getpid) | 3017 LSS_INLINE _syscall0(pid_t, getpid) |
2764 LSS_INLINE _syscall0(pid_t, getppid) | 3018 LSS_INLINE _syscall0(pid_t, getppid) |
2765 LSS_INLINE _syscall2(int, getpriority, int, a, | 3019 LSS_INLINE _syscall2(int, getpriority, int, a, |
2766 int, b) | 3020 int, b) |
2767 LSS_INLINE _syscall3(int, getresgid, gid_t *, r, | 3021 LSS_INLINE _syscall3(int, getresgid, gid_t *, r, |
2768 gid_t *, e, gid_t *, s) | 3022 gid_t *, e, gid_t *, s) |
2769 LSS_INLINE _syscall3(int, getresuid, uid_t *, r, | 3023 LSS_INLINE _syscall3(int, getresuid, uid_t *, r, |
2770 uid_t *, e, uid_t *, s) | 3024 uid_t *, e, uid_t *, s) |
2771 #if !defined(__ARM_EABI__) | 3025 #if !defined(__ARM_EABI__) |
2772 LSS_INLINE _syscall2(int, getrlimit, int, r, | 3026 LSS_INLINE _syscall2(int, getrlimit, int, r, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2811 LSS_INLINE _syscall2(int, munmap, void*, s, | 3065 LSS_INLINE _syscall2(int, munmap, void*, s, |
2812 size_t, l) | 3066 size_t, l) |
2813 LSS_INLINE _syscall6(long, move_pages, pid_t, p, | 3067 LSS_INLINE _syscall6(long, move_pages, pid_t, p, |
2814 unsigned long, n, void **,g, int *, d, | 3068 unsigned long, n, void **,g, int *, d, |
2815 int *, s, int, f) | 3069 int *, s, int, f) |
2816 LSS_INLINE _syscall3(int, mprotect, const void *,a, | 3070 LSS_INLINE _syscall3(int, mprotect, const void *,a, |
2817 size_t, l, int, p) | 3071 size_t, l, int, p) |
2818 LSS_INLINE _syscall5(void*, _mremap, void*, o, | 3072 LSS_INLINE _syscall5(void*, _mremap, void*, o, |
2819 size_t, os, size_t, ns, | 3073 size_t, os, size_t, ns, |
2820 unsigned long, f, void *, a) | 3074 unsigned long, f, void *, a) |
2821 LSS_INLINE _syscall3(int, open, const char*, p, | 3075 #if !defined(__aarch64__) |
2822 int, f, int, m) | 3076 // The open and poll syscalls have been deprecated on aarch64. We polyfill |
2823 LSS_INLINE _syscall3(int, poll, struct kernel_pollfd*, u, | 3077 // them below. |
2824 unsigned int, n, int, t) | 3078 LSS_INLINE _syscall3(int, open, const char*, p, |
| 3079 int, f, int, m) |
| 3080 LSS_INLINE _syscall3(int, poll, struct kernel_pollfd*, u, |
| 3081 unsigned int, n, int, t) |
| 3082 #endif |
2825 LSS_INLINE _syscall5(int, prctl, int, option, | 3083 LSS_INLINE _syscall5(int, prctl, int, option, |
2826 unsigned long, arg2, | 3084 unsigned long, arg2, |
2827 unsigned long, arg3, | 3085 unsigned long, arg3, |
2828 unsigned long, arg4, | 3086 unsigned long, arg4, |
2829 unsigned long, arg5) | 3087 unsigned long, arg5) |
2830 LSS_INLINE _syscall4(long, ptrace, int, r, | 3088 LSS_INLINE _syscall4(long, ptrace, int, r, |
2831 pid_t, p, void *, a, void *, d) | 3089 pid_t, p, void *, a, void *, d) |
2832 #if defined(__NR_quotactl) | 3090 #if defined(__NR_quotactl) |
2833 // Defined on x86_64 / i386 only | 3091 // Defined on x86_64 / i386 only |
2834 LSS_INLINE _syscall4(int, quotactl, int, cmd, const char *, special, | 3092 LSS_INLINE _syscall4(int, quotactl, int, cmd, const char *, special, |
2835 int, id, caddr_t, addr) | 3093 int, id, caddr_t, addr) |
2836 #endif | 3094 #endif |
2837 LSS_INLINE _syscall3(ssize_t, read, int, f, | 3095 LSS_INLINE _syscall3(ssize_t, read, int, f, |
2838 void *, b, size_t, c) | 3096 void *, b, size_t, c) |
2839 LSS_INLINE _syscall3(int, readlink, const char*, p, | 3097 #if !defined(__aarch64__) |
2840 char*, b, size_t, s) | 3098 // The readlink syscall has been deprecated on aarch64. We polyfill below. |
| 3099 LSS_INLINE _syscall3(int, readlink, const char*, p, |
| 3100 char*, b, size_t, s) |
| 3101 #endif |
2841 LSS_INLINE _syscall4(int, rt_sigaction, int, s, | 3102 LSS_INLINE _syscall4(int, rt_sigaction, int, s, |
2842 const struct kernel_sigaction*, a, | 3103 const struct kernel_sigaction*, a, |
2843 struct kernel_sigaction*, o, size_t, c) | 3104 struct kernel_sigaction*, o, size_t, c) |
2844 LSS_INLINE _syscall2(int, rt_sigpending, struct kernel_sigset_t *, s, | 3105 LSS_INLINE _syscall2(int, rt_sigpending, struct kernel_sigset_t *, s, |
2845 size_t, c) | 3106 size_t, c) |
2846 LSS_INLINE _syscall4(int, rt_sigprocmask, int, h, | 3107 LSS_INLINE _syscall4(int, rt_sigprocmask, int, h, |
2847 const struct kernel_sigset_t*, s, | 3108 const struct kernel_sigset_t*, s, |
2848 struct kernel_sigset_t*, o, size_t, c) | 3109 struct kernel_sigset_t*, o, size_t, c) |
2849 LSS_INLINE _syscall2(int, rt_sigsuspend, | 3110 LSS_INLINE _syscall2(int, rt_sigsuspend, |
2850 const struct kernel_sigset_t*, s, size_t, c) | 3111 const struct kernel_sigset_t*, s, size_t, c) |
(...skipping 14 matching lines...) Expand all Loading... |
2865 LSS_INLINE _syscall3(int, setresgid, gid_t, r, | 3126 LSS_INLINE _syscall3(int, setresgid, gid_t, r, |
2866 gid_t, e, gid_t, s) | 3127 gid_t, e, gid_t, s) |
2867 LSS_INLINE _syscall3(int, setresuid, uid_t, r, | 3128 LSS_INLINE _syscall3(int, setresuid, uid_t, r, |
2868 uid_t, e, uid_t, s) | 3129 uid_t, e, uid_t, s) |
2869 LSS_INLINE _syscall2(int, setrlimit, int, r, | 3130 LSS_INLINE _syscall2(int, setrlimit, int, r, |
2870 const struct kernel_rlimit*, l) | 3131 const struct kernel_rlimit*, l) |
2871 LSS_INLINE _syscall0(pid_t, setsid) | 3132 LSS_INLINE _syscall0(pid_t, setsid) |
2872 LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, | 3133 LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, |
2873 const stack_t*, o) | 3134 const stack_t*, o) |
2874 #if defined(__NR_sigreturn) | 3135 #if defined(__NR_sigreturn) |
2875 LSS_INLINE _syscall1(int, sigreturn, unsigned long, u) | 3136 LSS_INLINE _syscall1(int, sigreturn, unsigned long, u) |
2876 #endif | 3137 #endif |
2877 LSS_INLINE _syscall2(int, stat, const char*, f, | 3138 #if !defined(__aarch64__) |
2878 struct kernel_stat*, b) | 3139 // The stat syscall has been deprecated on aarch64. We polyfill it below. |
| 3140 LSS_INLINE _syscall2(int, stat, const char*, f, |
| 3141 struct kernel_stat*, b) |
| 3142 #endif |
2879 LSS_INLINE _syscall2(int, statfs, const char*, f, | 3143 LSS_INLINE _syscall2(int, statfs, const char*, f, |
2880 struct kernel_statfs*, b) | 3144 struct kernel_statfs*, b) |
2881 LSS_INLINE _syscall3(int, tgkill, pid_t, p, | 3145 LSS_INLINE _syscall3(int, tgkill, pid_t, p, |
2882 pid_t, t, int, s) | 3146 pid_t, t, int, s) |
2883 LSS_INLINE _syscall2(int, tkill, pid_t, p, | 3147 LSS_INLINE _syscall2(int, tkill, pid_t, p, |
2884 int, s) | 3148 int, s) |
2885 LSS_INLINE _syscall1(int, unlink, const char*, f) | 3149 #if !defined(__aarch64__) |
| 3150 // The unlink syscall has been deprecated on aarch64. We polyfill it below. |
| 3151 LSS_INLINE _syscall1(int, unlink, const char*, f) |
| 3152 #endif |
2886 LSS_INLINE _syscall3(ssize_t, write, int, f, | 3153 LSS_INLINE _syscall3(ssize_t, write, int, f, |
2887 const void *, b, size_t, c) | 3154 const void *, b, size_t, c) |
2888 LSS_INLINE _syscall3(ssize_t, writev, int, f, | 3155 LSS_INLINE _syscall3(ssize_t, writev, int, f, |
2889 const struct kernel_iovec*, v, size_t, c) | 3156 const struct kernel_iovec*, v, size_t, c) |
2890 #if defined(__NR_getcpu) | 3157 #if defined(__NR_getcpu) |
2891 LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, | 3158 LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, |
2892 unsigned *, node, void *, unused) | 3159 unsigned *, node, void *, unused) |
2893 #endif | 3160 #endif |
2894 #if defined(__x86_64__) || \ | 3161 #if defined(__x86_64__) || \ |
2895 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) | 3162 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2984 const struct kernel_sigset_t *set, | 3251 const struct kernel_sigset_t *set, |
2985 struct kernel_sigset_t *oldset) { | 3252 struct kernel_sigset_t *oldset) { |
2986 return LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); | 3253 return LSS_NAME(rt_sigprocmask)(how, set, oldset, (KERNEL_NSIG+7)/8); |
2987 } | 3254 } |
2988 | 3255 |
2989 LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { | 3256 LSS_INLINE int LSS_NAME(sigsuspend)(const struct kernel_sigset_t *set) { |
2990 return LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8); | 3257 return LSS_NAME(rt_sigsuspend)(set, (KERNEL_NSIG+7)/8); |
2991 } | 3258 } |
2992 #endif | 3259 #endif |
2993 #if defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ | 3260 #if defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ |
2994 defined(__ARM_EABI__) || \ | 3261 defined(__ARM_EABI__) || defined(__aarch64__) || \ |
2995 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) | 3262 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) |
2996 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, | 3263 LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, |
2997 int*, s, int, o, | 3264 int*, s, int, o, |
2998 struct kernel_rusage*, r) | 3265 struct kernel_rusage*, r) |
2999 | 3266 |
3000 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){ | 3267 LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){ |
3001 return LSS_NAME(wait4)(pid, status, options, 0); | 3268 return LSS_NAME(wait4)(pid, status, options, 0); |
3002 } | 3269 } |
3003 #endif | 3270 #endif |
3004 #if defined(__i386__) || defined(__x86_64__) | 3271 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) |
3005 LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m) | 3272 LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m) |
3006 LSS_INLINE _syscall3(int, unlinkat, int, d, const char *, p, int, f) | 3273 LSS_INLINE _syscall3(int, unlinkat, int, d, const char *, p, int, f) |
3007 #endif | 3274 #endif |
3008 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) | 3275 #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) |
3009 #define __NR__getresgid32 __NR_getresgid32 | 3276 #define __NR__getresgid32 __NR_getresgid32 |
3010 #define __NR__getresuid32 __NR_getresuid32 | 3277 #define __NR__getresuid32 __NR_getresuid32 |
3011 #define __NR__setfsgid32 __NR_setfsgid32 | 3278 #define __NR__setfsgid32 __NR_setfsgid32 |
3012 #define __NR__setfsuid32 __NR_setfsuid32 | 3279 #define __NR__setfsuid32 __NR_setfsuid32 |
3013 #define __NR__setresgid32 __NR_setresgid32 | 3280 #define __NR__setresgid32 __NR_setresgid32 |
3014 #define __NR__setresuid32 __NR_setresuid32 | 3281 #define __NR__setresuid32 __NR_setresuid32 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3382 | 3649 |
3383 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { | 3650 LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { |
3384 LSS_SC_BODY(3, int, 1, domain, type, protocol); | 3651 LSS_SC_BODY(3, int, 1, domain, type, protocol); |
3385 } | 3652 } |
3386 | 3653 |
3387 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, | 3654 LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, |
3388 int sv[2]) { | 3655 int sv[2]) { |
3389 LSS_SC_BODY(4, int, 8, d, type, protocol, sv); | 3656 LSS_SC_BODY(4, int, 8, d, type, protocol, sv); |
3390 } | 3657 } |
3391 #endif | 3658 #endif |
3392 #if defined(__ARM_EABI__) | 3659 #if defined(__ARM_EABI__) || defined (__aarch64__) |
3393 LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg, | 3660 LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg, |
3394 int, flags) | 3661 int, flags) |
3395 LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*, | 3662 LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*, |
3396 msg, int, flags) | 3663 msg, int, flags) |
3397 LSS_INLINE _syscall6(ssize_t, sendto, int, s, const void*, buf, size_t,len, | 3664 LSS_INLINE _syscall6(ssize_t, sendto, int, s, const void*, buf, size_t,len, |
3398 int, flags, const struct kernel_sockaddr*, to, | 3665 int, flags, const struct kernel_sockaddr*, to, |
3399 unsigned int, tolen) | 3666 unsigned int, tolen) |
3400 LSS_INLINE _syscall2(int, shutdown, int, s, int, how) | 3667 LSS_INLINE _syscall2(int, shutdown, int, s, int, how) |
3401 LSS_INLINE _syscall3(int, socket, int, domain, int, type, int, protocol) | 3668 LSS_INLINE _syscall3(int, socket, int, domain, int, type, int, protocol) |
3402 LSS_INLINE _syscall4(int, socketpair, int, d, int, type, int, protocol, | 3669 LSS_INLINE _syscall4(int, socketpair, int, d, int, type, int, protocol, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3473 if (__r7) { | 3740 if (__r7) { |
3474 unsigned long __errnovalue = __v0; | 3741 unsigned long __errnovalue = __v0; |
3475 LSS_ERRNO = __errnovalue; | 3742 LSS_ERRNO = __errnovalue; |
3476 return -1; | 3743 return -1; |
3477 } else { | 3744 } else { |
3478 p[0] = __v0; | 3745 p[0] = __v0; |
3479 p[1] = __v1; | 3746 p[1] = __v1; |
3480 return 0; | 3747 return 0; |
3481 } | 3748 } |
3482 } | 3749 } |
3483 #else | 3750 #elif !defined(__aarch64__) |
| 3751 // The unlink syscall has been deprecated on aarch64. We polyfill it below. |
3484 LSS_INLINE _syscall1(int, pipe, int *, p) | 3752 LSS_INLINE _syscall1(int, pipe, int *, p) |
3485 #endif | 3753 #endif |
3486 /* TODO(csilvers): see if ppc can/should support this as well */ | 3754 /* TODO(csilvers): see if ppc can/should support this as well */ |
3487 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | 3755 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ |
3488 defined(__ARM_EABI__) || \ | 3756 defined(__ARM_EABI__) || \ |
3489 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) | 3757 (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64) |
3490 #define __NR__statfs64 __NR_statfs64 | 3758 #define __NR__statfs64 __NR_statfs64 |
3491 #define __NR__fstatfs64 __NR_fstatfs64 | 3759 #define __NR__fstatfs64 __NR_fstatfs64 |
3492 LSS_INLINE _syscall3(int, _statfs64, const char*, p, | 3760 LSS_INLINE _syscall3(int, _statfs64, const char*, p, |
3493 size_t, s,struct kernel_statfs64*, b) | 3761 size_t, s,struct kernel_statfs64*, b) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3651 return LSS_NAME(_pwrite64)(fd, buf, count, | 3919 return LSS_NAME(_pwrite64)(fd, buf, count, |
3652 LSS_LLARG_PAD o.arg[0], o.arg[1]); | 3920 LSS_LLARG_PAD o.arg[0], o.arg[1]); |
3653 } | 3921 } |
3654 LSS_INLINE int LSS_NAME(readahead)(int fd, loff_t off, int len) { | 3922 LSS_INLINE int LSS_NAME(readahead)(int fd, loff_t off, int len) { |
3655 union { loff_t off; unsigned arg[2]; } o = { off }; | 3923 union { loff_t off; unsigned arg[2]; } o = { off }; |
3656 return LSS_NAME(_readahead)(fd, LSS_LLARG_PAD o.arg[0], o.arg[1], len); | 3924 return LSS_NAME(_readahead)(fd, LSS_LLARG_PAD o.arg[0], o.arg[1], len); |
3657 } | 3925 } |
3658 #endif | 3926 #endif |
3659 #endif | 3927 #endif |
3660 | 3928 |
| 3929 #if defined(__aarch64__) |
| 3930 LSS_INLINE _syscall3(int, dup3, int, s, int, d, int, f) |
| 3931 LSS_INLINE _syscall6(void *, mmap, void *, addr, size_t, length, int, prot, |
| 3932 int, flags, int, fd, int64_t, offset) |
| 3933 LSS_INLINE _syscall4(int, newfstatat, int, dirfd, const char *, pathname, |
| 3934 struct kernel_stat *, buf, int, flags) |
| 3935 LSS_INLINE _syscall2(int, pipe2, int *, pipefd, int, flags) |
| 3936 LSS_INLINE _syscall5(int, ppoll, struct kernel_pollfd *, u, |
| 3937 unsigned int, n, const struct kernel_timespec *, t, |
| 3938 const kernel_sigset_t *, sigmask, size_t, s) |
| 3939 LSS_INLINE _syscall4(int, readlinkat, int, d, const char *, p, char *, b, |
| 3940 size_t, s) |
| 3941 #endif |
| 3942 |
| 3943 /* |
| 3944 * Polyfills for deprecated syscalls. |
| 3945 */ |
| 3946 |
| 3947 #if defined(__aarch64__) |
| 3948 LSS_INLINE int LSS_NAME(dup2)(int s, int d) { |
| 3949 return LSS_NAME(dup3)(s, d, 0); |
| 3950 } |
| 3951 |
| 3952 LSS_INLINE int LSS_NAME(open)(const char *pathname, int flags, int mode) { |
| 3953 return LSS_NAME(openat)(AT_FDCWD, pathname, flags, mode); |
| 3954 } |
| 3955 |
| 3956 LSS_INLINE int LSS_NAME(unlink)(const char *pathname) { |
| 3957 return LSS_NAME(unlinkat)(AT_FDCWD, pathname, 0); |
| 3958 } |
| 3959 |
| 3960 LSS_INLINE int LSS_NAME(readlink)(const char *pathname, char *buffer, |
| 3961 size_t size) { |
| 3962 return LSS_NAME(readlinkat)(AT_FDCWD, pathname, buffer, size); |
| 3963 } |
| 3964 |
| 3965 LSS_INLINE pid_t LSS_NAME(pipe)(int *pipefd) { |
| 3966 return LSS_NAME(pipe2)(pipefd, 0); |
| 3967 } |
| 3968 |
| 3969 LSS_INLINE int LSS_NAME(poll)(struct kernel_pollfd *fds, unsigned int nfds, |
| 3970 int timeout) { |
| 3971 struct kernel_timespec timeout_ts; |
| 3972 struct kernel_timespec *timeout_ts_p = NULL; |
| 3973 |
| 3974 if (timeout >= 0) { |
| 3975 timeout_ts.tv_sec = timeout / 1000; |
| 3976 timeout_ts.tv_nsec = (timeout % 1000) * 1000000; |
| 3977 timeout_ts_p = &timeout_ts; |
| 3978 } |
| 3979 return LSS_NAME(ppoll)(fds, nfds, timeout_ts_p, NULL, 0); |
| 3980 } |
| 3981 |
| 3982 LSS_INLINE int LSS_NAME(stat)(const char *pathname, |
| 3983 struct kernel_stat *buf) { |
| 3984 return LSS_NAME(newfstatat)(AT_FDCWD, pathname, buf, 0); |
| 3985 } |
| 3986 |
| 3987 LSS_INLINE pid_t LSS_NAME(fork)(void) { |
| 3988 // No fork syscall on aarch64 - implement by means of the clone syscall. |
| 3989 // Note that this does not reset glibc's cached view of the PID/TID, so |
| 3990 // some glibc interfaces might go wrong in the forked subprocess. |
| 3991 int flags = SIGCHLD; |
| 3992 void *child_stack = NULL; |
| 3993 void *parent_tidptr = NULL; |
| 3994 void *newtls = NULL; |
| 3995 void *child_tidptr = NULL; |
| 3996 |
| 3997 LSS_REG(0, flags); |
| 3998 LSS_REG(1, child_stack); |
| 3999 LSS_REG(2, parent_tidptr); |
| 4000 LSS_REG(3, newtls); |
| 4001 LSS_REG(4, child_tidptr); |
| 4002 LSS_BODY(pid_t, clone, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), |
| 4003 "r"(__r4)); |
| 4004 } |
| 4005 #endif |
| 4006 |
3661 #ifdef __ANDROID__ | 4007 #ifdef __ANDROID__ |
3662 /* These restore the original values of these macros saved by the | 4008 /* These restore the original values of these macros saved by the |
3663 * corresponding #pragma push_macro near the top of this file. */ | 4009 * corresponding #pragma push_macro near the top of this file. */ |
3664 # pragma pop_macro("stat64") | 4010 # pragma pop_macro("stat64") |
3665 # pragma pop_macro("fstat64") | 4011 # pragma pop_macro("fstat64") |
3666 # pragma pop_macro("lstat64") | 4012 # pragma pop_macro("lstat64") |
3667 #endif | 4013 #endif |
3668 | 4014 |
3669 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) | 4015 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) |
3670 } | 4016 } |
3671 #endif | 4017 #endif |
3672 | 4018 |
3673 #endif | 4019 #endif |
3674 #endif | 4020 #endif |
OLD | NEW |