| OLD | NEW |
| 1 /* Copyright (c) 2005-2010, Google Inc. | 1 /* Copyright (c) 2005-2010, 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(__linux) | 90 && (defined(__linux) || defined(__ANDROID__)) |
| 91 | 91 |
| 92 #ifndef SYS_CPLUSPLUS | 92 #ifndef SYS_CPLUSPLUS |
| 93 #ifdef __cplusplus | 93 #ifdef __cplusplus |
| 94 /* Some system header files in older versions of gcc neglect to properly | 94 /* 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 | 95 * handle being included from C++. As it appears to be harmless to have |
| 96 * multiple nested 'extern "C"' blocks, just add another one here. | 96 * multiple nested 'extern "C"' blocks, just add another one here. |
| 97 */ | 97 */ |
| 98 extern "C" { | 98 extern "C" { |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 #include <errno.h> | 101 #include <errno.h> |
| 102 #include <fcntl.h> |
| 102 #include <signal.h> | 103 #include <signal.h> |
| 103 #include <stdarg.h> | 104 #include <stdarg.h> |
| 104 #include <stddef.h> | 105 #include <stddef.h> |
| 105 #include <string.h> | 106 #include <string.h> |
| 106 #include <sys/ptrace.h> | 107 #include <sys/ptrace.h> |
| 107 #include <sys/resource.h> | 108 #include <sys/resource.h> |
| 108 #include <sys/time.h> | 109 #include <sys/time.h> |
| 109 #include <sys/types.h> | 110 #include <sys/types.h> |
| 110 #include <syscall.h> | 111 #include <sys/syscall.h> |
| 111 #include <unistd.h> | 112 #include <unistd.h> |
| 112 #include <linux/unistd.h> | 113 #include <linux/unistd.h> |
| 113 #include <endian.h> | 114 #include <endian.h> |
| 114 | 115 |
| 115 #ifdef __mips__ | 116 #ifdef __mips__ |
| 116 /* Include definitions of the ABI currently in use. */ | 117 /* Include definitions of the ABI currently in use. */ |
| 117 #include <sgidefs.h> | 118 #include <sgidefs.h> |
| 118 #endif | 119 #endif |
| 119 #endif | 120 #endif |
| 120 | 121 |
| (...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2131 { | 2132 { |
| 2132 register int __flags __asm__("r0") = flags; | 2133 register int __flags __asm__("r0") = flags; |
| 2133 register void *__stack __asm__("r1") = child_stack; | 2134 register void *__stack __asm__("r1") = child_stack; |
| 2134 register void *__ptid __asm__("r2") = parent_tidptr; | 2135 register void *__ptid __asm__("r2") = parent_tidptr; |
| 2135 register void *__tls __asm__("r3") = newtls; | 2136 register void *__tls __asm__("r3") = newtls; |
| 2136 register int *__ctid __asm__("r4") = child_tidptr; | 2137 register int *__ctid __asm__("r4") = child_tidptr; |
| 2137 __asm__ __volatile__(/* if (fn == NULL || child_stack == NULL) | 2138 __asm__ __volatile__(/* if (fn == NULL || child_stack == NULL) |
| 2138 * return -EINVAL; | 2139 * return -EINVAL; |
| 2139 */ | 2140 */ |
| 2140 "cmp %2,#0\n" | 2141 "cmp %2,#0\n" |
| 2142 "it ne\n" |
| 2141 "cmpne %3,#0\n" | 2143 "cmpne %3,#0\n" |
| 2144 "it eq\n" |
| 2142 "moveq %0,%1\n" | 2145 "moveq %0,%1\n" |
| 2143 "beq 1f\n" | 2146 "beq 1f\n" |
| 2144 | 2147 |
| 2145 /* Push "arg" and "fn" onto the stack that will be | 2148 /* Push "arg" and "fn" onto the stack that will be |
| 2146 * used by the child. | 2149 * used by the child. |
| 2147 */ | 2150 */ |
| 2148 "str %5,[%3,#-4]!\n" | 2151 "str %5,[%3,#-4]!\n" |
| 2149 "str %2,[%3,#-4]!\n" | 2152 "str %2,[%3,#-4]!\n" |
| 2150 | 2153 |
| 2151 /* %r0 = syscall(%r0 = flags, | 2154 /* %r0 = syscall(%r0 = flags, |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3005 } | 3008 } |
| 3006 } | 3009 } |
| 3007 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ | 3010 #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ |
| 3008 defined(__ARM_EABI__) || \ | 3011 defined(__ARM_EABI__) || \ |
| 3009 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) | 3012 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) |
| 3010 #define __NR__sigaction __NR_sigaction | 3013 #define __NR__sigaction __NR_sigaction |
| 3011 #define __NR__sigpending __NR_sigpending | 3014 #define __NR__sigpending __NR_sigpending |
| 3012 #define __NR__sigprocmask __NR_sigprocmask | 3015 #define __NR__sigprocmask __NR_sigprocmask |
| 3013 #define __NR__sigsuspend __NR_sigsuspend | 3016 #define __NR__sigsuspend __NR_sigsuspend |
| 3014 #define __NR__socketcall __NR_socketcall | 3017 #define __NR__socketcall __NR_socketcall |
| 3018 #if ! defined(__ANDROID__) |
| 3019 /* The Android NDK #defines stat64 stat, so avoid multiple-definition */ |
| 3015 LSS_INLINE _syscall2(int, fstat64, int, f, | 3020 LSS_INLINE _syscall2(int, fstat64, int, f, |
| 3016 struct kernel_stat64 *, b) | 3021 struct kernel_stat64 *, b) |
| 3017 LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, | 3022 #endif |
| 3023 LSS_INLINE _syscall5(int, _llseek, uint, fd, |
| 3024 unsigned long, hi, unsigned long, lo, |
| 3018 loff_t *, res, uint, wh) | 3025 loff_t *, res, uint, wh) |
| 3019 #if !defined(__ARM_EABI__) | 3026 #if !defined(__ARM_EABI__) |
| 3020 LSS_INLINE _syscall1(void*, mmap, void*, a) | 3027 LSS_INLINE _syscall1(void*, mmap, void*, a) |
| 3021 #endif | 3028 #endif |
| 3022 LSS_INLINE _syscall6(void*, mmap2, void*, s, | 3029 LSS_INLINE _syscall6(void*, mmap2, void*, s, |
| 3023 size_t, l, int, p, | 3030 size_t, l, int, p, |
| 3024 int, f, int, d, | 3031 int, f, int, d, |
| 3025 __off64_t, o) | 3032 off_t, o) |
| 3026 LSS_INLINE _syscall3(int, _sigaction, int, s, | 3033 LSS_INLINE _syscall3(int, _sigaction, int, s, |
| 3027 const struct kernel_old_sigaction*, a, | 3034 const struct kernel_old_sigaction*, a, |
| 3028 struct kernel_old_sigaction*, o) | 3035 struct kernel_old_sigaction*, o) |
| 3029 LSS_INLINE _syscall1(int, _sigpending, unsigned long*, s) | 3036 LSS_INLINE _syscall1(int, _sigpending, unsigned long*, s) |
| 3030 LSS_INLINE _syscall3(int, _sigprocmask, int, h, | 3037 LSS_INLINE _syscall3(int, _sigprocmask, int, h, |
| 3031 const unsigned long*, s, | 3038 const unsigned long*, s, |
| 3032 unsigned long*, o) | 3039 unsigned long*, o) |
| 3033 #ifdef __PPC__ | 3040 #ifdef __PPC__ |
| 3034 LSS_INLINE _syscall1(int, _sigsuspend, unsigned long, s) | 3041 LSS_INLINE _syscall1(int, _sigsuspend, unsigned long, s) |
| 3035 #else | 3042 #else |
| 3036 LSS_INLINE _syscall3(int, _sigsuspend, const void*, a, | 3043 LSS_INLINE _syscall3(int, _sigsuspend, const void*, a, |
| 3037 int, b, | 3044 int, b, |
| 3038 unsigned long, s) | 3045 unsigned long, s) |
| 3039 #endif | 3046 #endif |
| 3047 #if ! defined(__ANDROID__) |
| 3048 /* The Android NDK #defines stat64 stat, so avoid multiple-definition */ |
| 3040 LSS_INLINE _syscall2(int, stat64, const char *, p, | 3049 LSS_INLINE _syscall2(int, stat64, const char *, p, |
| 3041 struct kernel_stat64 *, b) | 3050 struct kernel_stat64 *, b) |
| 3051 #endif |
| 3042 | 3052 |
| 3043 LSS_INLINE int LSS_NAME(sigaction)(int signum, | 3053 LSS_INLINE int LSS_NAME(sigaction)(int signum, |
| 3044 const struct kernel_sigaction *act, | 3054 const struct kernel_sigaction *act, |
| 3045 struct kernel_sigaction *oldact) { | 3055 struct kernel_sigaction *oldact) { |
| 3046 int old_errno = LSS_ERRNO; | 3056 int old_errno = LSS_ERRNO; |
| 3047 int rc; | 3057 int rc; |
| 3048 struct kernel_sigaction a; | 3058 struct kernel_sigaction a; |
| 3049 if (act != NULL) { | 3059 if (act != NULL) { |
| 3050 a = *act; | 3060 a = *act; |
| 3051 #ifdef __i386__ | 3061 #ifdef __i386__ |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3464 } | 3474 } |
| 3465 #endif | 3475 #endif |
| 3466 #endif | 3476 #endif |
| 3467 | 3477 |
| 3468 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) | 3478 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) |
| 3469 } | 3479 } |
| 3470 #endif | 3480 #endif |
| 3471 | 3481 |
| 3472 #endif | 3482 #endif |
| 3473 #endif | 3483 #endif |
| OLD | NEW |