diff --git a/ndk/sources/android/libportable/arch-arm/fenv.c b/ndk/sources/android/libportable/arch-arm/fenv.c index 71f370d9f..d3c18af07 100644 --- a/ndk/sources/android/libportable/arch-arm/fenv.c +++ b/ndk/sources/android/libportable/arch-arm/fenv.c @@ -1,5 +1,5 @@ /* - * Copyright 2013, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,91 +14,4 @@ * limitations under the License. */ -#ifdef __ARM_ARCH_7A__ - -#include -#include #include - -int WRAP(fegetenv)(fenv_t* __envp) { - fenv_t _fpscr; - __asm__ __volatile__("vmrs %0,fpscr" : "=r" (_fpscr)); - *__envp = _fpscr; - return 0; -} - -int WRAP(fesetenv)(const fenv_t* __envp) { - fenv_t _fpscr = *__envp; - __asm__ __volatile__("vmsr fpscr,%0" : :"ri" (_fpscr)); - return 0; -} - -int WRAP(feclearexcept)(int __excepts) { - fexcept_t __fpscr; - WRAP(fegetenv)(&__fpscr); - __fpscr &= ~__excepts; - WRAP(fesetenv)(&__fpscr); - return 0; -} - -int WRAP(fegetexceptflag)(fexcept_t* __flagp, int __excepts) { - fexcept_t __fpscr; - WRAP(fegetenv)(&__fpscr); - *__flagp = __fpscr & __excepts; - return 0; -} - -int WRAP(fesetexceptflag)(const fexcept_t* __flagp, int __excepts) { - fexcept_t __fpscr; - WRAP(fegetenv)(&__fpscr); - __fpscr &= ~__excepts; - __fpscr |= *__flagp & __excepts; - WRAP(fesetenv)(&__fpscr); - return 0; -} - -int WRAP(feraiseexcept)(int __excepts) { - fexcept_t __ex = __excepts; - WRAP(fesetexceptflag)(&__ex, __excepts); - return 0; -} - -int WRAP(fetestexcept)(int __excepts) { - fexcept_t __fpscr; - WRAP(fegetenv)(&__fpscr); - return (__fpscr & __excepts); -} - -int WRAP(fegetround)(void) { - fenv_t _fpscr; - WRAP(fegetenv)(&_fpscr); - return ((_fpscr >> _FPSCR_RMODE_SHIFT) & 0x3); -} - -int WRAP(fesetround)(int __round) { - fenv_t _fpscr; - WRAP(fegetenv)(&_fpscr); - _fpscr &= ~(0x3 << _FPSCR_RMODE_SHIFT); - _fpscr |= (__round << _FPSCR_RMODE_SHIFT); - WRAP(fesetenv)(&_fpscr); - return 0; -} - -int WRAP(feholdexcept)(fenv_t* __envp) { - fenv_t __env; - WRAP(fegetenv)(&__env); - *__envp = __env; - __env &= ~(FE_ALL_EXCEPT | _FPSCR_ENABLE_MASK); - WRAP(fesetenv)(&__env); - return 0; -} - -int WRAP(feupdateenv)(const fenv_t* __envp) { - fexcept_t __fpscr; - WRAP(fegetenv)(&__fpscr); - WRAP(fesetenv)(__envp); - WRAP(feraiseexcept)(__fpscr & FE_ALL_EXCEPT); - return 0; -} - -#endif /* __ARM_ARCH_7A__ */ diff --git a/ndk/sources/android/libportable/common/include/stdarg_portable.h b/ndk/sources/android/libportable/arch-arm/stat.c similarity index 66% rename from ndk/sources/android/libportable/common/include/stdarg_portable.h rename to ndk/sources/android/libportable/arch-arm/stat.c index 726ed1150..8a2a477bc 100644 --- a/ndk/sources/android/libportable/common/include/stdarg_portable.h +++ b/ndk/sources/android/libportable/arch-arm/stat.c @@ -14,17 +14,4 @@ * limitations under the License. */ -#ifndef _STDARG_PORTABLE_H_ -#define _STDARG_PORTABLE_H_ - -// The elements are not important. This struct should be interpreted -// differently by all targets. -typedef struct va_list_portable { - void *ptr1; - void *ptr2; - void *ptr3; - int offset1; - int offset2; -} va_list_portable; - -#endif /* _STDARG_PORTABLE_H_ */ +#include diff --git a/ndk/sources/android/libportable/arch-arm/unwind.c b/ndk/sources/android/libportable/arch-arm/unwind.c index 99f2dacc4..f7e63264f 100644 --- a/ndk/sources/android/libportable/arch-arm/unwind.c +++ b/ndk/sources/android/libportable/arch-arm/unwind.c @@ -1,5 +1,5 @@ /* - * Copyright 2013, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ndk/sources/android/libportable/arch-mips/md_swap.c b/ndk/sources/android/libportable/arch-arm/vfs.c similarity index 50% rename from ndk/sources/android/libportable/arch-mips/md_swap.c rename to ndk/sources/android/libportable/arch-arm/vfs.c index 59e422470..fe8becd43 100644 --- a/ndk/sources/android/libportable/arch-mips/md_swap.c +++ b/ndk/sources/android/libportable/arch-arm/vfs.c @@ -1,5 +1,5 @@ /* - * Copyright 2013, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,25 +14,4 @@ * limitations under the License. */ -#include -#include -#include - -#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2) - -uint16_t WRAP(__swap16md)(uint16_t x) { - register uint16_t _x = x; - register uint16_t _r; - __asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x)); - return _r; -} - -uint32_t WRAP(__swap32md)(uint32_t x) { - register uint32_t _x = x; - register uint32_t _r; - __asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); - return _r; -} - -#endif - +#include diff --git a/ndk/sources/android/libportable/arch-arm64/fenv.c b/ndk/sources/android/libportable/arch-arm64/fenv.c new file mode 100644 index 000000000..d3c18af07 --- /dev/null +++ b/ndk/sources/android/libportable/arch-arm64/fenv.c @@ -0,0 +1,17 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include diff --git a/ndk/sources/android/libportable/arch-arm64/stat.c b/ndk/sources/android/libportable/arch-arm64/stat.c new file mode 100644 index 000000000..8a2a477bc --- /dev/null +++ b/ndk/sources/android/libportable/arch-arm64/stat.c @@ -0,0 +1,17 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include diff --git a/ndk/sources/android/libportable/arch-arm64/vfs.c b/ndk/sources/android/libportable/arch-arm64/vfs.c index 94d6793b3..fe8becd43 100644 --- a/ndk/sources/android/libportable/arch-arm64/vfs.c +++ b/ndk/sources/android/libportable/arch-arm64/vfs.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,5 +14,4 @@ * limitations under the License. */ -#include #include diff --git a/ndk/sources/android/libportable/arch-mips/_setjmp.S b/ndk/sources/android/libportable/arch-mips/_setjmp.S deleted file mode 100644 index b05127614..000000000 --- a/ndk/sources/android/libportable/arch-mips/_setjmp.S +++ /dev/null @@ -1,192 +0,0 @@ -/* Derived from: $OpenBSD: _setjmp.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */ - -/* - * Copyright (c) 2002 Opsycon AB (www.opsycon.se / www.opsycon.com) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Opsycon AB nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#include -#include -#include - -#include "jboffsets.h" - -/* - * _setjmp, _longjmp (not restoring signal state) - * - * XXX FPSET should probably be taken from SR setting. hmmm... - * GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp! - * - */ - -FRAMESZ= MKFSIZ(0,4) -GPOFF= FRAMESZ-2*REGSZ - -#define FPREG64_S(FPR, OFF, BASE) \ - swc1 FPR, OFF(BASE) ; \ - mfhc1 t0, FPR ; \ - sw t0, OFF+4(BASE) ; - -#define FPREG64_L(FPR, OFF, BASE) \ - lw t0, OFF+4(BASE) ; \ - lw t1, OFF(BASE) ; \ - mtc1 t1, FPR ; \ - mthc1 t0, FPR ; \ - -LEAF(_setjmp_portable, FRAMESZ) - PTR_SUBU sp, FRAMESZ - SETUP_GP64(GPOFF, _setjmp) - SAVE_GP(GPOFF) - .set noreorder -#if defined(__mips64) - dli v0, MAGIC__SETJMP -#else - li v0, MAGIC__SETJMP -#endif - REG_S v0, JB_MAGIC(a0) - REG_S s0, JB_S0(a0) - REG_S s1, JB_S1(a0) - REG_S s2, JB_S2(a0) - REG_S s3, JB_S3(a0) - REG_S s4, JB_S4(a0) - REG_S s5, JB_S5(a0) - REG_S s6, JB_S6(a0) - REG_S s7, JB_S7(a0) - REG_S s8, JB_S8(a0) - REG_L v0, GPOFF(sp) - REG_S v0, JB_GP(a0) - PTR_ADDU v0, sp, FRAMESZ - REG_S v0, JB_SP(a0) - REG_S ra, JB_PC(a0) - -#if !defined(SOFTFLOAT) - /* - * Would be nice if we could tell if the FP registers are currently being used; - * Assume they are, and use pointer to jmp_buf in a0 to save FP registers and the - * jmp_buf.fpused flag. - */ - li v0, 1 # v0 = 1 - REG_S v0, JB_FPUSED(a0) # a0->jb_fpused = v0:1 - cfc1 v0, $31 -#if _MIPS_FPSET == 32 - FPREG64_S($f20, JB_F20, a0) - FPREG64_S($f21, JB_F21, a0) - FPREG64_S($f22, JB_F22, a0) - FPREG64_S($f23, JB_F23, a0) - FPREG64_S($f24, JB_F24, a0) - FPREG64_S($f25, JB_F25, a0) - FPREG64_S($f26, JB_F26, a0) - FPREG64_S($f27, JB_F27, a0) - FPREG64_S($f28, JB_F28, a0) - FPREG64_S($f29, JB_F29, a0) - FPREG64_S($f30, JB_F30, a0) - FPREG64_S($f31, JB_F31, a0) -#else - swc1 $f20, JB_F20(a0) - swc1 $f21, JB_F21(a0) - swc1 $f22, JB_F22(a0) - swc1 $f23, JB_F23(a0) - swc1 $f24, JB_F24(a0) - swc1 $f25, JB_F25(a0) - swc1 $f26, JB_F26(a0) - swc1 $f27, JB_F27(a0) - swc1 $f28, JB_F28(a0) - swc1 $f29, JB_F29(a0) - swc1 $f30, JB_F30(a0) - swc1 $f31, JB_F31(a0) -#endif - REG_S v0, JB_FSR(a0) -#endif /* !SOFTFLOAT */ - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ - j ra - move v0, zero -END(_setjmp_portable) - -LEAF(_longjmp_portable, FRAMESZ) - PTR_SUBU sp, FRAMESZ - SETUP_GP64(GPOFF, _longjmp) - SAVE_GP(GPOFF) - .set noreorder - REG_L v0, JB_MAGIC(a0) - bne v0, MAGIC__SETJMP, botch # jump if error - REG_L ra, JB_PC(a0) - REG_L v0, JB_FSR(a0) - REG_L s0, JB_S0(a0) - REG_L s1, JB_S1(a0) - REG_L s2, JB_S2(a0) - REG_L s3, JB_S3(a0) - REG_L s4, JB_S4(a0) - REG_L s5, JB_S5(a0) - REG_L s6, JB_S6(a0) - REG_L s7, JB_S7(a0) - REG_L s8, JB_S8(a0) - REG_L gp, JB_GP(a0) - REG_L sp, JB_SP(a0) -#if !defined(SOFTFLOAT) - ctc1 v0, $31 -#if _MIPS_FPSET == 32 - FPREG64_L($f20, JB_F20, a0) - FPREG64_L($f21, JB_F21, a0) - FPREG64_L($f22, JB_F22, a0) - FPREG64_L($f23, JB_F23, a0) - FPREG64_L($f24, JB_F24, a0) - FPREG64_L($f25, JB_F25, a0) - FPREG64_L($f26, JB_F26, a0) - FPREG64_L($f27, JB_F27, a0) - FPREG64_L($f28, JB_F28, a0) - FPREG64_L($f29, JB_F29, a0) - FPREG64_L($f30, JB_F30, a0) - FPREG64_L($f31, JB_F31, a0) -#else - lwc1 $f20, JB_F20(a0) - lwc1 $f21, JB_F21(a0) - lwc1 $f22, JB_F22(a0) - lwc1 $f23, JB_F23(a0) - lwc1 $f24, JB_F24(a0) - lwc1 $f25, JB_F25(a0) - lwc1 $f26, JB_F26(a0) - lwc1 $f27, JB_F27(a0) - lwc1 $f28, JB_F28(a0) - lwc1 $f29, JB_F29(a0) - lwc1 $f30, JB_F30(a0) - lwc1 $f31, JB_F31(a0) -#endif -#endif /* !SOFTFLOAT */ - bne a1, zero, 1f - nop - li a1, 1 # never return 0! -1: - j ra - move v0, a1 - -botch: - jal abort - nop - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ -END(_longjmp_portable) diff --git a/ndk/sources/android/libportable/arch-mips/clone.c b/ndk/sources/android/libportable/arch-mips/clone.c deleted file mode 100644 index 7498ef635..000000000 --- a/ndk/sources/android/libportable/arch-mips/clone.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PORTABLE_TAG "clone_portable" -#include - - -/* - * This function maps the clone function call defined in: - * $TOP/bionic/libc/bionic/bionic_clone.c - * - * which calls the __bionic_clone() system call which is defined in: - * $TOP/bionic/libc/unistd/arch-mips/bionic/clone.S - * - * We have to map the low byte of the 'flags' parameter which - * contains the number of the termination signal sent to the - * parent when the child dies. - * - * Note that if this signal is specified as anything other than - * SIGCHLD, then the parent process must specify the __WALL or - * __WCLONE options when waiting for the child with wait(2). - * - * If no signal is specified, then the parent process is not - * signaled when the child terminates. - */ -int WRAP(clone)(int (*fn)(void *), void *child_stack, int port_flags, void *arg, ...) -{ - va_list args; - int ret; - int mips_flags; - void *new_tls = NULL; - int *child_tidptr = NULL; - int *parent_tidptr = NULL; - int mips_term_signum; - char *mips_term_signame; - int portable_term_signum; - char *portable_term_signame; - int cloning_vm = ((port_flags & CLONE_VM) == CLONE_VM); - int cloning_files = ((port_flags & CLONE_FILES) == CLONE_FILES); - int cloning_sighand = ((port_flags & CLONE_SIGHAND) == CLONE_SIGHAND); - - ALOGV(" "); - ALOGV("%s(fn:%p, child_stack:%p, port_flags:0x%x, arg:%p, ...) {", __func__, - fn, child_stack, port_flags, arg); - - /* Shared file descriptor table requires shared memory. */ - if (cloning_files != cloning_vm) { - ALOGE("%s: cloning_files:%d != cloning_vm:%d) ...", __func__, - cloning_files, cloning_vm); - - ALOGE("%s: ... port_flags:0x%x Not Supported by Lib-Portable!", __func__, - port_flags); - } - - /* Shared signal handler table requires shared memory. */ - if (cloning_sighand != cloning_vm) { - ALOGE("%s: cloning_sighand:%d != cloning_vm:%d) ...", __func__, - cloning_sighand, cloning_vm); - - ALOGE("%s: ... port_flags:0x%x Not Supported by Lib-Portable!", __func__, - port_flags); - } - - /* Extract optional parameters - they are cumulative. */ - va_start(args, arg); - if (port_flags & (CLONE_PARENT_SETTID|CLONE_SETTLS|CLONE_CHILD_SETTID)) { - parent_tidptr = va_arg(args, int*); - } - if (port_flags & (CLONE_SETTLS|CLONE_CHILD_SETTID)) { - new_tls = va_arg(args, void*); - } - if (port_flags & CLONE_CHILD_SETTID) { - child_tidptr = va_arg(args, int*); - } - va_end(args); - - /* - * Map the LSB of the flags as explained above. - */ - portable_term_signum = port_flags & 0xFF; - if (portable_term_signum == 0) { - mips_flags = port_flags; - } else { - portable_term_signame = map_portable_signum_to_name(portable_term_signum); - ALOGV("%s: portable_term_signum:0x%x:'%s'", __func__, - portable_term_signum, portable_term_signame); - mips_term_signum = signum_pton(portable_term_signum); - mips_term_signame = map_mips_signum_to_name(mips_term_signum); - ALOGV("%s: mips_term_signum:0x%x:'%s'", __func__, - mips_term_signum, mips_term_signame); - mips_flags = (port_flags & ~0xFF) | (mips_term_signum & 0xFF); - } - ALOGV("%s: clone(%p, %p, 0x%x, %p, %p, %p, %p);", __func__, - fn, child_stack, mips_flags, arg, parent_tidptr, new_tls, child_tidptr); - - ret = REAL(clone)(fn, child_stack, mips_flags, arg, parent_tidptr, - new_tls, child_tidptr); - - if (ret > 0) { - /* - * Disable mapping in the parent if the child could interfere - * and make things even worse than skipping the signal and - * file read mapping. - */ - if (cloning_files != cloning_vm) { - filefd_disable_mapping(); - } - if (cloning_sighand != cloning_vm) { - signal_disable_mapping(); - } - } - - ALOGV("%s: return(ret:%d); }", __func__, ret); - return ret; -} diff --git a/ndk/sources/android/libportable/arch-mips/errno.c b/ndk/sources/android/libportable/arch-mips/errno.c index 14e292528..b9ed45657 100644 --- a/ndk/sources/android/libportable/arch-mips/errno.c +++ b/ndk/sources/android/libportable/arch-mips/errno.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,357 +14,4 @@ * limitations under the License. */ -#include -#include -#include -#include #include - -#define PORTABLE_TAG "errno_portable" -#include - -#if ENAMETOOLONG==ENAMETOOLONG_PORTABLE -#error Bad build environment -#endif - -__hidden int errno_ntop(int native_errno) -{ - switch (native_errno) { - case ENAMETOOLONG: return ENAMETOOLONG_PORTABLE; - case ENOLCK: return ENOLCK_PORTABLE; - case ENOSYS: return ENOSYS_PORTABLE; - case ENOTEMPTY: return ENOTEMPTY_PORTABLE; - case ELOOP: return ELOOP_PORTABLE; - case EWOULDBLOCK: return EWOULDBLOCK_PORTABLE; - case ENOMSG: return ENOMSG_PORTABLE; - case EIDRM: return EIDRM_PORTABLE; - case ECHRNG: return ECHRNG_PORTABLE; - case EL2NSYNC: return EL2NSYNC_PORTABLE; - case EL3HLT: return EL3HLT_PORTABLE; - case EL3RST: return EL3RST_PORTABLE; - case ELNRNG: return ELNRNG_PORTABLE; - case EUNATCH: return EUNATCH_PORTABLE; - case ENOCSI: return ENOCSI_PORTABLE; - case EL2HLT: return EL2HLT_PORTABLE; - case EBADE: return EBADE_PORTABLE; - case EBADR: return EBADR_PORTABLE; - case EXFULL: return EXFULL_PORTABLE; - case ENOANO: return ENOANO_PORTABLE; - case EBADRQC: return EBADRQC_PORTABLE; - case EBADSLT: return EBADSLT_PORTABLE; - case EDEADLOCK: return EDEADLOCK_PORTABLE; - case EBFONT: return EBFONT_PORTABLE; - case ENOSTR: return ENOSTR_PORTABLE; - case ENODATA: return ENODATA_PORTABLE; - case ETIME: return ETIME_PORTABLE; - case ENOSR: return ENOSR_PORTABLE; - case ENONET: return ENONET_PORTABLE; - case ENOPKG: return ENOPKG_PORTABLE; - case EREMOTE: return EREMOTE_PORTABLE; - case ENOLINK: return ENOLINK_PORTABLE; - case EADV: return EADV_PORTABLE; - case ESRMNT: return ESRMNT_PORTABLE; - case ECOMM: return ECOMM_PORTABLE; - case EPROTO: return EPROTO_PORTABLE; - case EMULTIHOP: return EMULTIHOP_PORTABLE; - case EDOTDOT: return EDOTDOT_PORTABLE; - case EBADMSG: return EBADMSG_PORTABLE; - case EOVERFLOW: return EOVERFLOW_PORTABLE; - case ENOTUNIQ: return ENOTUNIQ_PORTABLE; - case EBADFD: return EBADFD_PORTABLE; - case EREMCHG: return EREMCHG_PORTABLE; - case ELIBACC: return ELIBACC_PORTABLE; - case ELIBBAD: return ELIBBAD_PORTABLE; - case ELIBSCN: return ELIBSCN_PORTABLE; - case ELIBMAX: return ELIBMAX_PORTABLE; - case ELIBEXEC: return ELIBEXEC_PORTABLE; - case EILSEQ: return EILSEQ_PORTABLE; - case ERESTART: return ERESTART_PORTABLE; - case ESTRPIPE: return ESTRPIPE_PORTABLE; - case EUSERS: return EUSERS_PORTABLE; - case ENOTSOCK: return ENOTSOCK_PORTABLE; - case EDESTADDRREQ: return EDESTADDRREQ_PORTABLE; - case EMSGSIZE: return EMSGSIZE_PORTABLE; - case EPROTOTYPE: return EPROTOTYPE_PORTABLE; - case ENOPROTOOPT: return ENOPROTOOPT_PORTABLE; - case EPROTONOSUPPORT: return EPROTONOSUPPORT_PORTABLE; - case ESOCKTNOSUPPORT: return ESOCKTNOSUPPORT_PORTABLE; - case EOPNOTSUPP: return EOPNOTSUPP_PORTABLE; - case EPFNOSUPPORT: return EPFNOSUPPORT_PORTABLE; - case EAFNOSUPPORT: return EAFNOSUPPORT_PORTABLE; - case EADDRINUSE: return EADDRINUSE_PORTABLE; - case EADDRNOTAVAIL: return EADDRNOTAVAIL_PORTABLE; - case ENETDOWN: return ENETDOWN_PORTABLE; - case ENETUNREACH: return ENETUNREACH_PORTABLE; - case ENETRESET: return ENETRESET_PORTABLE; - case ECONNABORTED: return ECONNABORTED_PORTABLE; - case ECONNRESET: return ECONNRESET_PORTABLE; - case ENOBUFS: return ENOBUFS_PORTABLE; - case EISCONN: return EISCONN_PORTABLE; - case ENOTCONN: return ENOTCONN_PORTABLE; - case ESHUTDOWN: return ESHUTDOWN_PORTABLE; - case ETOOMANYREFS: return ETOOMANYREFS_PORTABLE; - case ETIMEDOUT: return ETIMEDOUT_PORTABLE; - case ECONNREFUSED: return ECONNREFUSED_PORTABLE; - case EHOSTDOWN: return EHOSTDOWN_PORTABLE; - case EHOSTUNREACH: return EHOSTUNREACH_PORTABLE; - case EALREADY: return EALREADY_PORTABLE; - case EINPROGRESS: return EINPROGRESS_PORTABLE; - case ESTALE: return ESTALE_PORTABLE; - case EUCLEAN: return EUCLEAN_PORTABLE; - case ENOTNAM: return ENOTNAM_PORTABLE; - case ENAVAIL: return ENAVAIL_PORTABLE; - case EISNAM: return EISNAM_PORTABLE; - case EREMOTEIO: return EREMOTEIO_PORTABLE; - case EDQUOT: return EDQUOT_PORTABLE; - case ENOMEDIUM: return ENOMEDIUM_PORTABLE; - case EMEDIUMTYPE: return EMEDIUMTYPE_PORTABLE; - case ECANCELED: return ECANCELED_PORTABLE; - case ENOKEY: return ENOKEY_PORTABLE; - case EKEYEXPIRED: return EKEYEXPIRED_PORTABLE; - case EKEYREVOKED: return EKEYREVOKED_PORTABLE; - case EKEYREJECTED: return EKEYREJECTED_PORTABLE; - case EOWNERDEAD: return EOWNERDEAD_PORTABLE; - case ENOTRECOVERABLE: return ENOTRECOVERABLE_PORTABLE; - } - return native_errno; -} - -__hidden int errno_pton(int portable_errno) -{ - switch (portable_errno) { - case ENAMETOOLONG_PORTABLE: return ENAMETOOLONG; - case ENOLCK_PORTABLE: return ENOLCK; - case ENOSYS_PORTABLE: return ENOSYS; - case ENOTEMPTY_PORTABLE: return ENOTEMPTY; - case ELOOP_PORTABLE: return ELOOP; - case EWOULDBLOCK_PORTABLE: return EWOULDBLOCK; - case ENOMSG_PORTABLE: return ENOMSG; - case EIDRM_PORTABLE: return EIDRM; - case ECHRNG_PORTABLE: return ECHRNG; - case EL2NSYNC_PORTABLE: return EL2NSYNC; - case EL3HLT_PORTABLE: return EL3HLT; - case EL3RST_PORTABLE: return EL3RST; - case ELNRNG_PORTABLE: return ELNRNG; - case EUNATCH_PORTABLE: return EUNATCH; - case ENOCSI_PORTABLE: return ENOCSI; - case EL2HLT_PORTABLE: return EL2HLT; - case EBADE_PORTABLE: return EBADE; - case EBADR_PORTABLE: return EBADR; - case EXFULL_PORTABLE: return EXFULL; - case ENOANO_PORTABLE: return ENOANO; - case EBADRQC_PORTABLE: return EBADRQC; - case EBADSLT_PORTABLE: return EBADSLT; - case EDEADLOCK_PORTABLE: return EDEADLOCK; - case EBFONT_PORTABLE: return EBFONT; - case ENOSTR_PORTABLE: return ENOSTR; - case ENODATA_PORTABLE: return ENODATA; - case ETIME_PORTABLE: return ETIME; - case ENOSR_PORTABLE: return ENOSR; - case ENONET_PORTABLE: return ENONET; - case ENOPKG_PORTABLE: return ENOPKG; - case EREMOTE_PORTABLE: return EREMOTE; - case ENOLINK_PORTABLE: return ENOLINK; - case EADV_PORTABLE: return EADV; - case ESRMNT_PORTABLE: return ESRMNT; - case ECOMM_PORTABLE: return ECOMM; - case EPROTO_PORTABLE: return EPROTO; - case EMULTIHOP_PORTABLE: return EMULTIHOP; - case EDOTDOT_PORTABLE: return EDOTDOT; - case EBADMSG_PORTABLE: return EBADMSG; - case EOVERFLOW_PORTABLE: return EOVERFLOW; - case ENOTUNIQ_PORTABLE: return ENOTUNIQ; - case EBADFD_PORTABLE: return EBADFD; - case EREMCHG_PORTABLE: return EREMCHG; - case ELIBACC_PORTABLE: return ELIBACC; - case ELIBBAD_PORTABLE: return ELIBBAD; - case ELIBSCN_PORTABLE: return ELIBSCN; - case ELIBMAX_PORTABLE: return ELIBMAX; - case ELIBEXEC_PORTABLE: return ELIBEXEC; - case EILSEQ_PORTABLE: return EILSEQ; - case ERESTART_PORTABLE: return ERESTART; - case ESTRPIPE_PORTABLE: return ESTRPIPE; - case EUSERS_PORTABLE: return EUSERS; - case ENOTSOCK_PORTABLE: return ENOTSOCK; - case EDESTADDRREQ_PORTABLE: return EDESTADDRREQ; - case EMSGSIZE_PORTABLE: return EMSGSIZE; - case EPROTOTYPE_PORTABLE: return EPROTOTYPE; - case ENOPROTOOPT_PORTABLE: return ENOPROTOOPT; - case EPROTONOSUPPORT_PORTABLE: return EPROTONOSUPPORT; - case ESOCKTNOSUPPORT_PORTABLE: return ESOCKTNOSUPPORT; - case EOPNOTSUPP_PORTABLE: return EOPNOTSUPP; - case EPFNOSUPPORT_PORTABLE: return EPFNOSUPPORT; - case EAFNOSUPPORT_PORTABLE: return EAFNOSUPPORT; - case EADDRINUSE_PORTABLE: return EADDRINUSE; - case EADDRNOTAVAIL_PORTABLE: return EADDRNOTAVAIL; - case ENETDOWN_PORTABLE: return ENETDOWN; - case ENETUNREACH_PORTABLE: return ENETUNREACH; - case ENETRESET_PORTABLE: return ENETRESET; - case ECONNABORTED_PORTABLE: return ECONNABORTED; - case ECONNRESET_PORTABLE: return ECONNRESET; - case ENOBUFS_PORTABLE: return ENOBUFS; - case EISCONN_PORTABLE: return EISCONN; - case ENOTCONN_PORTABLE: return ENOTCONN; - case ESHUTDOWN_PORTABLE: return ESHUTDOWN; - case ETOOMANYREFS_PORTABLE: return ETOOMANYREFS; - case ETIMEDOUT_PORTABLE: return ETIMEDOUT; - case ECONNREFUSED_PORTABLE: return ECONNREFUSED; - case EHOSTDOWN_PORTABLE: return EHOSTDOWN; - case EHOSTUNREACH_PORTABLE: return EHOSTUNREACH; - case EALREADY_PORTABLE: return EALREADY; - case EINPROGRESS_PORTABLE: return EINPROGRESS; - case ESTALE_PORTABLE: return ESTALE; - case EUCLEAN_PORTABLE: return EUCLEAN; - case ENOTNAM_PORTABLE: return ENOTNAM; - case ENAVAIL_PORTABLE: return ENAVAIL; - case EISNAM_PORTABLE: return EISNAM; - case EREMOTEIO_PORTABLE: return EREMOTEIO; - case EDQUOT_PORTABLE: return EDQUOT; - case ENOMEDIUM_PORTABLE: return ENOMEDIUM; - case EMEDIUMTYPE_PORTABLE: return EMEDIUMTYPE; - case ECANCELED_PORTABLE: return ECANCELED; - case ENOKEY_PORTABLE: return ENOKEY; - case EKEYEXPIRED_PORTABLE: return EKEYEXPIRED; - case EKEYREVOKED_PORTABLE: return EKEYREVOKED; - case EKEYREJECTED_PORTABLE: return EKEYREJECTED; - case EOWNERDEAD_PORTABLE: return EOWNERDEAD; - case ENOTRECOVERABLE_PORTABLE: return ENOTRECOVERABLE; - } - return portable_errno; -} - -/* Key for the thread-specific portable errno */ -static pthread_key_t errno_key; - -/* Once-only initialisation of the key */ -static pthread_once_t errno_key_once = PTHREAD_ONCE_INIT; - -/* Free the thread-specific portable errno */ -static void errno_key_destroy(void *buf) -{ - if (buf) - free(buf); -} - -/* Allocate the key */ -static void errno_key_create(void) -{ - pthread_key_create(&errno_key, errno_key_destroy); -} - -struct errno_state { - int pshadow; /* copy of last portable errno */ - int perrno; /* portable errno that may be modified by app */ -}; - -/* Return the thread-specific portable errno */ -static struct errno_state *errno_key_data(void) -{ - struct errno_state *data; - static struct errno_state errno_state; - - pthread_once(&errno_key_once, errno_key_create); - data = (struct errno_state *)pthread_getspecific(errno_key); - if (data == NULL) { - data = malloc(sizeof(struct errno_state)); - pthread_setspecific(errno_key, data); - } - if (data == NULL) - data = &errno_state; - return data; -} - -/* - * Attempt to return a thread specific location containnig the portable errno. - * This can be assigned to without affecting the native errno. If the key - * allocation fails fall back to using the native errno location. - */ -volatile int* WRAP(__errno)() -{ - struct errno_state *p; - int save_errno; - - /* pthread_* calls may modify errno so use a copy */ - save_errno = *REAL(__errno)(); - - p = errno_key_data(); - - ALOGV(" "); - ALOGV("%s(): { save_errno = errno:%d, (p:%p)->{pshadow:%d, perrno:%d}", __func__, - save_errno, p, p->pshadow, p->perrno); - - if (save_errno == 0 && p->pshadow != p->perrno) { - /* - * portable errno has changed but native hasn't - * - copy portable error back to native - */ - p->pshadow = p->perrno; - save_errno = errno_pton(p->perrno); - } - else if (save_errno != 0 && p->pshadow == p->perrno) { - /* - * Native errno has changed but portable hasn't - * - copy native error to portable. - */ - p->pshadow = p->perrno = errno_ntop(save_errno); - save_errno = 0; - } - else if (save_errno != 0 && p->pshadow != p->perrno) { - /* - * Both native and portable errno values have changed - * so give priority to native errno - * - copy native error to portable - */ - p->pshadow = p->perrno = errno_ntop(save_errno); - save_errno = 0; - } - - ALOGV("%s: new save_errno:%d p:%p->{pshadow:%d, perrno:%d}", __func__, - save_errno, p, p->pshadow, p->perrno); - - *REAL(__errno)() = save_errno; - - ALOGV("%s: return (&p->perrno):%p; }", __func__, &p->perrno); - - /* return pointer to the modifiable portable errno value */ - return &p->perrno; -} - - -/* set portable errno */ -void WRAP(__set_errno)(int portable_errno) -{ - struct errno_state *p; - int save_errno; - - /* pthread_* calls may modify errno so use a copy */ - save_errno = *REAL(__errno)(); - - p = errno_key_data(); - - ALOGV("%s(): { save_errno = errno:%d, p:%p->{pshadow:%d, perrno:%d}", __func__, - save_errno, p, p->pshadow, p->perrno); - - p->pshadow = p->perrno = portable_errno; - - save_errno = errno_pton(portable_errno); - - ALOGV("%s: new save_errno:%d, p:%p->{pshadow:%d, perrno:%d}", __func__, - save_errno, p, p->pshadow, p->perrno); - - *REAL(__errno)() = save_errno; - - ALOGV("%s: return; }", __func__); -} - -extern char* REAL(strerror)(int); -char *WRAP(strerror)(int errnum) -{ - return REAL(strerror)(errno_pton(errnum)); -} - -/* BSD style strerror_r */ -int WRAP(strerror_r)(int errnum, char *buf, size_t buflen) -{ - return REAL(strerror_r)(errno_pton(errnum), buf, buflen); -} diff --git a/ndk/sources/android/libportable/arch-mips/eventfd.c b/ndk/sources/android/libportable/arch-mips/eventfd.c deleted file mode 100644 index 35285d96f..000000000 --- a/ndk/sources/android/libportable/arch-mips/eventfd.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#define PORTABLE_TAG "eventfd_portable" -#include - - -/* NOTE: LTP defaults to using O_NONBLOCK even if EFD_NONBLOCK is defined */ - - -/* - * Portable to Native event flags mapper. - */ -static inline int efd_flags_pton(int portable_flags) -{ - int native_flags = 0; - - ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags); - - if (portable_flags & EFD_NONBLOCK_PORTABLE) { - native_flags |= EFD_NONBLOCK; - portable_flags &= ~EFD_NONBLOCK_PORTABLE; - } - - if (portable_flags & EFD_CLOEXEC_PORTABLE) { - native_flags |= EFD_CLOEXEC; - portable_flags &= EFD_CLOEXEC_PORTABLE; - } - - if (portable_flags & EFD_SEMAPHORE_PORTABLE) { - native_flags |= EFD_SEMAPHORE; - portable_flags &= EFD_SEMAPHORE_PORTABLE; - } - - if (portable_flags != 0) { - ALOGW("%s: portable_flags:0x%x != 0; Unsupported Flags being used!", - __func__, portable_flags); - } - ALOGV("%s: return(native_flags:%d); }", __func__, native_flags); - return native_flags; -} - - -/* - * In the original eventfd() the portable_flags were unused up to - * linux 2.6.26 and had to be zero. Android simply uses the - * new eventfd2 system call number, so it likely best to just use - * the Android eventfd() for both eventfd and eventfd2 system calls. - */ -int WRAP(eventfd)(unsigned int initval, int portable_flags) { - int rv; - int native_flags; - - ALOGV(" "); - ALOGV("%s(initval:%u, portable_flags:%d) {", __func__, - initval, portable_flags); - - native_flags = efd_flags_pton(portable_flags); - - rv = REAL(eventfd)(initval, native_flags); - if (rv >= 0) { - if (native_flags & EFD_CLOEXEC) { - filefd_CLOEXEC_enabled(rv); - } - filefd_opened(rv, EVENT_FD_TYPE); - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - diff --git a/ndk/sources/android/libportable/arch-mips/fcntl.c b/ndk/sources/android/libportable/arch-mips/fcntl.c index 174b02719..de620c550 100644 --- a/ndk/sources/android/libportable/arch-mips/fcntl.c +++ b/ndk/sources/android/libportable/arch-mips/fcntl.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,426 +14,4 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include - -#include - -#if F_GETLK_PORTABLE==F_GETLK -#error Bad build environment -#endif - -#define PORTABLE_TAG "fcntl_portable" -#include - -static char *map_portable_cmd_to_name(int cmd) -{ - char *name; - - switch(cmd) { - case F_DUPFD_PORTABLE: name = "F_DUPFD_PORTABLE"; break; /* 0 */ - case F_GETFD_PORTABLE: name = "F_GETFD_PORTABLE"; break; /* 1 */ - case F_SETFD_PORTABLE: name = "F_SETFD_PORTABLE"; break; /* 2 */ - case F_GETFL_PORTABLE: name = "F_GETFL_PORTABLE"; break; /* 3 */ - case F_SETFL_PORTABLE: name = "F_SETFL_PORTABLE"; break; /* 4 */ - case F_GETLK_PORTABLE: name = "F_GETLK_PORTABLE"; break; /* 5 */ - case F_SETLK_PORTABLE: name = "F_SETLK_PORTABLE"; break; /* 6 */ - case F_SETLKW_PORTABLE: name = "F_SETLKW_PORTABLE"; break; /* 7 */ - case F_SETOWN_PORTABLE: name = "F_SETOWN_PORTABLE"; break; /* 8 */ - case F_GETOWN_PORTABLE: name = "F_GETOWN_PORTABLE"; break; /* 9 */ - case F_SETSIG_PORTABLE: name = "F_SETSIG_PORTABLE"; break; /* 10 */ - case F_GETSIG_PORTABLE: name = "F_GETSIG_PORTABLE"; break; /* 11 */ - case F_GETLK64_PORTABLE: name = "F_GETLK64_PORTABLE"; break; /* 12 */ - case F_SETLK64_PORTABLE: name = "F_SETLK64_PORTABLE"; break; /* 13 */ - case F_SETLKW64_PORTABLE: name = "F_SETLKW64_PORTABLE"; break; /* 14 */ - case F_SETLEASE_PORTABLE: name = "F_SETLEASE_PORTABLE"; break; /* 1024 */ - case F_GETLEASE_PORTABLE: name = "F_GETLEASE_PORTABLE"; break; /* 1025 */ - case F_NOTIFY_PORTABLE: name = "F_NOTIFY_PORTABLE"; break; /* 1026 */ - case F_CANCELLK_PORTABLE: name = "F_CANCELLK_PORTABLE"; break; /* 1029 */ - case F_DUPFD_CLOEXEC_PORTABLE: name = "F_DUPFD_CLOEXEC_PORTABLE"; break; /* 1030 */ - default: name = ""; break; - } - return name; -} - - -/* - * Maps a fcntl portable cmd to a native command. - */ -static int fcntl_cmd_pton(int portable_cmd) -{ - int native_cmd; - char *error_msg = NULL; - - switch(portable_cmd) { - case F_DUPFD_PORTABLE: /* 0 --> 0 */ - native_cmd = F_DUPFD; - break; - - case F_GETFD_PORTABLE: /* 1 --> 1 */ - native_cmd = F_GETFD; - break; - - case F_SETFD_PORTABLE: /* 2 --> 2 */ - native_cmd = F_SETFD; - break; - - case F_GETFL_PORTABLE: /* 3 --> 3 */ - native_cmd = F_GETFL; - break; - - case F_SETFL_PORTABLE: /* 4 --> 4 */ - native_cmd = F_SETFL; - break; - - case F_GETLK_PORTABLE: /* 5 --> 14 */ - native_cmd = F_GETLK; - break; - - case F_SETLK_PORTABLE: /* 6 --> 6 */ - native_cmd = F_SETLK; - break; - - case F_SETLKW_PORTABLE: /* 7 --> 7 */ - native_cmd = F_SETLKW; - break; - - case F_SETOWN_PORTABLE: /* 8 --> 24 */ - native_cmd = F_SETOWN; - break; - - case F_GETOWN_PORTABLE: /* 9 --> 23 */ - native_cmd = F_GETOWN; - break; - - case F_SETSIG_PORTABLE: /* 10 --> 10 */ - native_cmd = F_SETSIG; - break; - - case F_GETSIG_PORTABLE: /* 11 --> 11 */ - native_cmd = F_GETSIG; - break; - - case F_GETLK64_PORTABLE: /* 12 --> 33 */ - native_cmd = F_GETLK64; - break; - - case F_SETLK64_PORTABLE: /* 13 --> 34 */ - native_cmd = F_SETLK64; - break; - - case F_SETLKW64_PORTABLE: /* 14 --> 35 */ - native_cmd = F_SETLKW64; - break; - - case F_SETLEASE_PORTABLE: /* 1024 --> 1024 */ - native_cmd = F_SETLEASE; - break; - - case F_GETLEASE_PORTABLE: /* 1025 --> 1025 */ - native_cmd = F_GETLEASE; - break; - - case F_NOTIFY_PORTABLE: /* 1026 --> 1026 */ - native_cmd = F_NOTIFY; - break; - - case F_CANCELLK_PORTABLE: /* 1029 --> void */ - error_msg = "Case F_CANCELLK_PORTABLE: Not supported by MIPS. "; - native_cmd = portable_cmd; - break; - - case F_DUPFD_CLOEXEC_PORTABLE: /* 1030 --> VOID; Not currently used by Bionic */ - error_msg = "Case F_DUPFD_CLOEXEC_PORTABLE: Not supported by MIPS. "; - native_cmd = portable_cmd; - break; - - default: - error_msg = "Case Default: Command Not Supported. "; - native_cmd = portable_cmd; - break; - } - -done: - if (error_msg != NULL) { - ALOGE("%s(portable_cmd:%d:0x%x): %sreturn(native_cmd:%d:0x%x);", __func__, - portable_cmd, portable_cmd, error_msg, native_cmd, native_cmd); - } else { - ALOGV("%s(portable_cmd:%d:0x%x): return(native_cmd:%d:0x%x);", __func__, - portable_cmd, portable_cmd, native_cmd, native_cmd); - } - return native_cmd; -} - - -static int fcntl_flags_pton(int flags) -{ - int mipsflags = flags & O_ACCMODE_PORTABLE; - - if (flags & O_CREAT_PORTABLE) - mipsflags |= O_CREAT; - if (flags & O_EXCL_PORTABLE) - mipsflags |= O_EXCL; - if (flags & O_NOCTTY_PORTABLE) - mipsflags |= O_NOCTTY; - if (flags & O_TRUNC_PORTABLE) - mipsflags |= O_TRUNC; - if (flags & O_APPEND_PORTABLE) - mipsflags |= O_APPEND; - if (flags & O_NONBLOCK_PORTABLE) - mipsflags |= O_NONBLOCK; - if (flags & O_SYNC_PORTABLE) - mipsflags |= O_SYNC; - if (flags & FASYNC_PORTABLE) - mipsflags |= FASYNC; - if (flags & O_DIRECT_PORTABLE) - mipsflags |= O_DIRECT; - if (flags & O_LARGEFILE_PORTABLE) - mipsflags |= O_LARGEFILE; - if (flags & O_DIRECTORY_PORTABLE) - mipsflags |= O_DIRECTORY; - if (flags & O_NOFOLLOW_PORTABLE) - mipsflags |= O_NOFOLLOW; - if (flags & O_NOATIME_PORTABLE) - mipsflags |= O_NOATIME; - if (flags & O_NDELAY_PORTABLE) - mipsflags |= O_NDELAY; - - ALOGV("%s(flags:0x%x): return(mipsflags:0x%x);", __func__, - flags, mipsflags); - - return mipsflags; -} - -static int fcntl_flags_ntop(int flags) -{ - int portableflags = flags & O_ACCMODE_PORTABLE; - - if (flags & O_CREAT) - portableflags |= O_CREAT_PORTABLE; - if (flags & O_EXCL) - portableflags |= O_EXCL_PORTABLE; - if (flags & O_NOCTTY) - portableflags |= O_NOCTTY_PORTABLE; - if (flags & O_TRUNC) - portableflags |= O_TRUNC_PORTABLE; - if (flags & O_APPEND) - portableflags |= O_APPEND_PORTABLE; - if (flags & O_NONBLOCK) - portableflags |= O_NONBLOCK_PORTABLE; - if (flags & O_SYNC) - portableflags |= O_SYNC_PORTABLE; - if (flags & FASYNC) - portableflags |= FASYNC_PORTABLE; - if (flags & O_DIRECT) - portableflags |= O_DIRECT_PORTABLE; - if (flags & O_LARGEFILE) - portableflags |= O_LARGEFILE_PORTABLE; - if (flags & O_DIRECTORY) - portableflags |= O_DIRECTORY_PORTABLE; - if (flags & O_NOFOLLOW) - portableflags |= O_NOFOLLOW_PORTABLE; - if (flags & O_NOATIME) - portableflags |= O_NOATIME_PORTABLE; - if (flags & O_NDELAY) - portableflags |= O_NDELAY_PORTABLE; - - ALOGV("%s(flags:0x%x): return(portableflags:0x%x);", __func__, - flags, portableflags); - - return portableflags; -} - -extern int __fcntl64(int, int, void *); - -/* - * For 32 bit flocks we are converting a portable/ARM struct flock to a MIPS struct flock: - * - * MIPS: ARM: - * struct flock { struct flock_portable { - * short l_type; short l_type; - * - * short l_whence; short l_whence; - * off_t l_start; loff_t l_start; - * off_t l_len; loff_t l_len; - * long l_sysid; - * - * __kernel_pid_t l_pid; pid_t l_pid; - * long pad[4]; - * }; } - * - * which have identically sized structure members: - * - * For a 64 bit flocks we only have to deal with - * a four byte padding in the ARM/Portable structure: - * - * MIPS: ARM: - * struct flock64 { struct flock64_portable { - * short l_type; short l_type; - * short l_whence; short l_whence; - * unsigned char __padding[4]; <---- NOTE - * loff_t l_start; loff_t l_start; - * loff_t l_len; loff_t l_len; - * pid_t l_pid; pid_t l_pid; - * } } - */ -int WRAP(fcntl)(int fd, int portable_cmd, ...) -{ - int flags; - va_list ap; - void *arg; - int mips_cmd; - int result = 0; - struct flock flock; /* Native MIPS structure */ - struct flock64 flock64; /* Native MIPS structure */ - char *portable_cmd_name = map_portable_cmd_to_name(portable_cmd); - struct flock_portable *flock_portable = NULL; - struct flock64_portable *flock64_portable = NULL; - - ALOGV(" "); - ALOGV("%s(fd:%d, portable_cmd:%d:'%s', ...) {", __func__, - fd, portable_cmd, - portable_cmd_name); - - - va_start(ap, portable_cmd); - arg = va_arg(ap, void *); - va_end(ap); - - mips_cmd = fcntl_cmd_pton(portable_cmd); - switch(mips_cmd) { - case F_GETLK: - case F_SETLK: - case F_SETLKW: - flock_portable = (struct flock_portable *) arg; - - if (invalid_pointer(flock_portable)) { - ALOGE("%s: flock_portable:%p == {NULL||-1}", __func__, flock_portable); - *REAL(__errno)() = EFAULT; - result = -1; - goto done; - } - - /* - * Lock type and Whence are the same for all ARCHs - * (F_RDLCK:0, F_WRLCK:1, F_UNLCK:2) - * (SEEK_SET:0, SEEK_CUR:1, SEEK_END:2) - */ - flock.l_type = flock_portable->l_type; - flock.l_whence = flock_portable->l_whence; - flock.l_start = (off_t) flock_portable->l_start; - flock.l_len = (off_t) flock_portable->l_len; - flock.l_sysid = 0L; - flock.l_pid = flock_portable->l_pid; /* Perhaps 0 would be better */ - - result = __fcntl64(fd, mips_cmd, (void *) &flock); - - flock_portable->l_type = flock.l_type; - flock_portable->l_whence = flock.l_whence; - flock_portable->l_start = flock.l_start; - flock_portable->l_len = flock.l_len; - flock_portable->l_pid = flock.l_pid; - break; - - case F_GETLK64: - case F_SETLK64: - case F_SETLKW64: - flock64_portable = (struct flock64_portable *) arg; - - if (invalid_pointer(flock_portable)) { - ALOGE("%s: flock_portable:%p == {NULL||-1}", __func__, flock_portable); - *REAL(__errno)() = EFAULT; - result = -1; - goto done; - } - - /* - * Lock type and Whence are the same for all ARCHs - * (F_RDLCK:0, F_WRLCK:1, F_UNLCK:2) - * (SEEK_SET:0, SEEK_CUR:1, SEEK_END:2) - */ - flock64.l_type = flock64_portable->l_type; - flock64.l_whence = flock64_portable->l_whence; - flock64.l_start = (off_t) flock64_portable->l_start; - flock64.l_len = (off_t) flock64_portable->l_len; - flock64.l_pid = flock64_portable->l_pid; /* Perhaps 0 would be better */ - - result = __fcntl64(fd, mips_cmd, (void *) &flock); - - flock64_portable->l_type = flock64.l_type; - flock64_portable->l_whence = flock64.l_whence; - flock64_portable->l_start = flock64.l_start; - flock64_portable->l_len = flock64.l_len; - flock64_portable->l_pid = flock64.l_pid; - break; - - case F_SETFL: - flags = fcntl_flags_pton((int)arg); - result = __fcntl64(fd, mips_cmd, (void *)flags); - break; - - case F_GETFL: - result = __fcntl64(fd, mips_cmd, arg); - if (result != -1) - result = fcntl_flags_ntop(result); - break; - - case F_DUPFD: - case F_GETFD: - case F_SETFD: - case F_SETOWN: - case F_GETOWN: - case F_SETSIG: - case F_GETSIG: - case F_SETLEASE: - case F_GETLEASE: - case F_NOTIFY: - ALOGV("%s: Calling __fcntl64(fd:%d, mips_cmd:0x%x, arg:%p);", __func__, - fd, mips_cmd, arg); - - result = __fcntl64(fd, mips_cmd, arg); - - if (result < 0) { - ALOGV("%s: result = %d = __fcntl64(fd:%d, mips_cmd:0x%x, arg:%p);", __func__, - result, fd, mips_cmd, arg); - } else { - if (mips_cmd == F_SETFD) { - /* - * File descriptor flag bits got set or cleared. - */ - flags = (int)arg; - if (flags & FD_CLOEXEC) { - filefd_CLOEXEC_enabled(fd); - } else { - filefd_CLOEXEC_disabled(fd); - } - } - } - break; - - default: - /* - * This is likely a rare situation, abort() would hang fcntl13 LTP test. - */ - ALOGE("%s: mips_cmd:%d doesn't appear to be supported;", __func__, - mips_cmd); - - ALOGV("%s: Assume it doesn't need to be mapped!", __func__); - - result = __fcntl64(fd, mips_cmd, arg); - } - -done: - ALOGV("%s: return(result:%d); }", __func__, result); - return result; -} - diff --git a/ndk/sources/android/libportable/arch-mips/fenv.c b/ndk/sources/android/libportable/arch-mips/fenv.c index d7b600f9a..d3c18af07 100644 --- a/ndk/sources/android/libportable/arch-mips/fenv.c +++ b/ndk/sources/android/libportable/arch-mips/fenv.c @@ -1,5 +1,5 @@ /* - * Copyright 2013, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,195 +14,4 @@ * limitations under the License. */ -#include -#include -#include #include - -static inline int mips_change_except(int flags) -{ - int mipsflags = 0; - int exception = flags & FE_ALL_EXCEPT_PORTABLE; - - // exception flags - if (exception & FE_INVALID_PORTABLE) - mipsflags |= FE_INVALID; - if (exception & FE_DIVBYZERO_PORTABLE) - mipsflags |= FE_DIVBYZERO; - if (exception & FE_OVERFLOW_PORTABLE) - mipsflags |= FE_OVERFLOW; - if (exception & FE_UNDERFLOW_PORTABLE) - mipsflags |= FE_UNDERFLOW; - if (exception & FE_INEXACT_PORTABLE) - mipsflags |= FE_INEXACT; - - return mipsflags; -} - -static inline int mips_change_rounding(int flags) -{ - int mipsflags = 0; - int rounding = flags & 0x03; - - // rounding flags - switch(rounding) - { - case FE_TONEAREST_PORTABLE: - mipsflags = FE_TONEAREST; - break; - case FE_DOWNWARD_PORTABLE: - mipsflags = FE_DOWNWARD; - break; - case FE_UPWARD_PORTABLE: - mipsflags = FE_UPWARD; - break; - case FE_TOWARDZERO_PORTABLE: - mipsflags = FE_TOWARDZERO; - break; - } - return mipsflags; -} - -static inline int mips_get_except(int mipsflags) -{ - int flags = 0; - int exception = mipsflags & FE_ALL_EXCEPT; - - // exception flags - if (exception & FE_INVALID) - flags |= FE_INVALID_PORTABLE; - if (exception & FE_DIVBYZERO) - flags |= FE_DIVBYZERO_PORTABLE; - if (exception & FE_OVERFLOW) - flags |= FE_OVERFLOW_PORTABLE; - if (exception & FE_UNDERFLOW) - flags |= FE_UNDERFLOW_PORTABLE; - if (exception & FE_INEXACT) - flags |= FE_INEXACT_PORTABLE; - return flags; -} - -static inline int mips_get_rounding(int mipsflags) -{ - int flags = 0; - int rounding = mipsflags & _FCSR_RMASK; - - // rounding flags - switch(rounding) - { - case FE_TONEAREST: - flags = FE_TONEAREST_PORTABLE; - break; - case FE_DOWNWARD: - flags = FE_DOWNWARD_PORTABLE; - break; - case FE_UPWARD: - flags = FE_UPWARD_PORTABLE; - break; - case FE_TOWARDZERO: - flags = FE_TOWARDZERO_PORTABLE; - break; - } - return flags; -} - -int WRAP(fegetenv)(fenv_t* __envp) { - fenv_t _fcsr = 0; -#ifdef __mips_hard_float - __asm__ __volatile__("cfc1 %0,$31" : "=r" (_fcsr)); -#endif - *__envp = _fcsr; - return 0; -} - -int WRAP(fesetenv)(const fenv_t* __envp) { - fenv_t _fcsr = *__envp; -#ifdef __mips_hard_float - __asm__ __volatile__("ctc1 %0,$31" : : "r" (_fcsr)); -#endif - return 0; -} - -int WRAP(feclearexcept)(int __excepts) { - __excepts = mips_change_except(__excepts); - fexcept_t __fcsr; - WRAP(fegetenv)(&__fcsr); - __excepts &= FE_ALL_EXCEPT; - __fcsr &= ~(__excepts | (__excepts << _FCSR_CAUSE_SHIFT)); - WRAP(fesetenv)(&__fcsr); - return 0; -} - -int WRAP(fegetexceptflag)(fexcept_t* __flagp, int __excepts) { - __excepts = mips_change_except(__excepts); - fexcept_t __fcsr; - WRAP(fegetenv)(&__fcsr); - *__flagp = mips_get_except(__fcsr & __excepts & FE_ALL_EXCEPT); - return 0; -} - -int WRAP(fesetexceptflag)(const fexcept_t* __flagp, int __excepts) { - int __flagp_ = mips_change_except(*__flagp); - __excepts = mips_change_except(__excepts); - fexcept_t __fcsr; - WRAP(fegetenv)(&__fcsr); - /* Ensure that flags are all legal */ - __excepts &= FE_ALL_EXCEPT; - __fcsr &= ~__excepts; - __fcsr |= __flagp_ & __excepts; - WRAP(fesetenv)(&__fcsr); - return 0; -} - -int WRAP(feraiseexcept)(int __excepts) { - __excepts = mips_change_except(__excepts); - fexcept_t __fcsr; - WRAP(fegetenv)(&__fcsr); - /* Ensure that flags are all legal */ - __excepts &= FE_ALL_EXCEPT; - /* Cause bit needs to be set as well for generating the exception*/ - __fcsr |= __excepts | (__excepts << _FCSR_CAUSE_SHIFT); - WRAP(fesetenv)(&__fcsr); - return 0; -} - -int WRAP(fetestexcept)(int __excepts) { - __excepts = mips_change_except(__excepts); - fexcept_t __FCSR; - WRAP(fegetenv)(&__FCSR); - return mips_get_except(__FCSR & __excepts & FE_ALL_EXCEPT); -} - -int WRAP(fegetround)(void) { - fenv_t _fcsr; - WRAP(fegetenv)(&_fcsr); - return mips_get_rounding(_fcsr & _FCSR_RMASK); -} - -int WRAP(fesetround)(int __round) { - __round = mips_change_rounding(__round); - fenv_t _fcsr; - WRAP(fegetenv)(&_fcsr); - _fcsr &= ~_FCSR_RMASK; - _fcsr |= (__round & _FCSR_RMASK ); - WRAP(fesetenv)(&_fcsr); - return 0; -} - -int WRAP(feholdexcept)(fenv_t* __envp) { - fenv_t __env; - WRAP(fegetenv)(&__env); - *__envp = __env; - __env &= ~(FE_ALL_EXCEPT | _FCSR_ENABLE_MASK); - WRAP(fesetenv)(&__env); - return 0; -} - -int WRAP(feupdateenv)(const fenv_t* __envp) { - fexcept_t __fcsr; - WRAP(fegetenv)(&__fcsr); - WRAP(fesetenv)(__envp); - WRAP(feraiseexcept)(__fcsr & FE_ALL_EXCEPT); - return 0; -} - diff --git a/ndk/sources/android/libportable/arch-mips/filefd.c b/ndk/sources/android/libportable/arch-mips/filefd.c deleted file mode 100644 index 788edf18b..000000000 --- a/ndk/sources/android/libportable/arch-mips/filefd.c +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PORTABLE_TAG "filefd_portable" -#include - -/* - * Maintaining a list of special file descriptors in lib-portable: - * --------------------------------------------------------------- - * - * These are file descriptors which were opened with system calls - * which make it possible to read kernel data structures via the - * read system call. See man pages for: - * signalfd(2) - * eventfd(2) - * timerfd_create(2) - * - * The files conditioned with signalfd(2) need to have their reads - * intercepted to correct signal numbers. This is done using this table - * of mapped files. - * - * The signalfd(2) semantics are maintained across execve(2) by exporting - * and importing environment variables for file descriptors that are not - * marked as close-on-execute. For example testing import code with: - * Eg: - * export ANDROID_PORTABLE_MAPPED_FILE_DESCRIPTORS=10,17 - * export ANDROID_PORTABLE_MAPPED_FILE_TYPES=2,1 - * - * Where - * filefd_mapped_file[10] = SIGNAL_FD_TYPE:2 - * filefd_FD_CLOEXEC_file[10] = 0; - * and - * filefd_mapped_file[17] = EVENT_FD_TYPE:1 - * filefd_FD_CLOEXEC_file[17] = 0; - * - * A table of CLOEXEC_files is maintained via call-backs - * in open_portable() and fcntl_portable() which indicates - * the files with close-on-execute semantics. - * - * The signalfd(2) fork(2) and thread semantics are not - * affected by the mapping of signalfd() file descriptor reads. - * - * This algorithm requires that threads have the same sharing - * attributes for file descriptors and memory and will be disabled - * by a call from clone() if the environment is unsuitable for it's use. - */ - -static char *fd_env_name = "ANDROID_PORTABLE_MAPPED_FILE_DESCRIPTORS"; -static char *type_env_name = "ANDROID_PORTABLE_MAPPED_FILE_TYPES"; -static enum filefd_type filefd_mapped_file[__FD_SETSIZE]; -static int filefd_FD_CLOEXEC_file[__FD_SETSIZE]; - -static volatile int filefd_mapped_files = 0; -static volatile int filefd_enabled = 1; - -/* - * Assuming sizeof(int)==4, and __FD_SETSIZE < 10000 each token will - * occupy a maximum of 5 characters (4 digits + delimiter:','). The tokens - * are the numbers above, a file descriptor (0..9999), and the filefd_type's - * which are a single digit. - * - * The arrays used to manipulate the environment variables are allocated using - * malloc to avoid overrunning the stack. - */ -#if __FD_SETSIZE >= 10000 -#error MAX_ENV_SIZE must be increased -#endif - -#define MAX_ENV_SIZE (__FD_SETSIZE * 5) - -static int export_fd_env() -{ - const int max_env_size = MAX_ENV_SIZE; - int type_env_bytes_remaining = max_env_size; - char *type_env_allocated = NULL, *type_env; - int fd_env_bytes_remaining = max_env_size; - char *fd_env_allocated = NULL, *fd_env; - int exported_file_descriptors = 0; - enum filefd_type fd_type; - int overwrite = 1; - int fd_count = 0; - int saved_errno; - int fd_cloexec; - int len; - int rv1; - int rv2; - int rv; - int fd; - - ALOGV("%s:() {", __func__); - - saved_errno = *REAL(__errno)(); - - type_env_allocated = malloc(max_env_size); - fd_env_allocated = malloc(max_env_size); - if (type_env_allocated == NULL || fd_env_allocated == NULL) { - ALOGE("%s: type_env_allocated:%p, fd_env_allocated:%p; FIXME!", __func__, - type_env_allocated, fd_env_allocated); - - rv = -1; - goto done; - } else { - ALOGV("%s: type_env_allocated:%p, fd_env_allocated:%p;", __func__, - type_env_allocated, fd_env_allocated); - } - - type_env = type_env_allocated; - fd_env = fd_env_allocated; - - for (fd = 0; fd < __FD_SETSIZE; fd++) { - fd_type = filefd_mapped_file[fd]; - if (fd_type != UNUSED_FD_TYPE) { - ++fd_count; - ALOGV("%s: fd_type = %d = filefd_mapped_file[fd:%d]; ++fdcount:%d;", __func__, - fd_type, fd, fd_count); - - fd_cloexec = filefd_FD_CLOEXEC_file[fd]; - ALOGV("%s: fd_cloexec = %d = filefd_FD_CLOEXEC_file[fd:%d];", __func__, - fd_cloexec, fd); - - if (fd_cloexec == 0) { - rv = snprintf(fd_env, fd_env_bytes_remaining, "%d,", fd); - ASSERT(rv > 0); - fd_env += rv; - fd_env_bytes_remaining -= rv; - rv = snprintf(type_env, type_env_bytes_remaining, "%d,", filefd_mapped_file[fd]); - ASSERT(rv > 0); - type_env += rv; - type_env_bytes_remaining -= rv; - exported_file_descriptors++; - } - - /* - * There is a chance of inconsistent results here if - * another thread is updating the array while it was - * being copied, but this code is only run during exec - * so the state of the file descriptors that the child - * sees will be inconsistent anyway. - */ - if (fd_count == filefd_mapped_files) - break; - } - } - if (fd_count != filefd_mapped_files) { - ALOGE("%s: fd_count:%d != filefd_mapped_files:%d; [Likely Race; add futex?]", __func__, - fd_count, filefd_mapped_files); - - } - if (exported_file_descriptors == 0) { - rv1 = unsetenv(fd_env_name); - rv2 = unsetenv(type_env_name); - if (rv1 != 0 || rv2 != 0) { - ALOGV("%s: Note: unsetenv() failed!", __func__); - } - rv = 0; - } else { - if (fd_env > fd_env_allocated) { - fd_env--; /* backup fd_env to last ',' */ - } - *fd_env = '\0'; - - if (type_env > type_env_allocated) { - type_env--; /* backup type_env to last ',' */ - } - *type_env = '\0'; - - rv = setenv(fd_env_name, fd_env_allocated, overwrite); - if (rv != 0) { - ALOGE("%s: rv:%d = setenv(fd_env_name:'%s', fd_env_allocated:'%s' ...);", __func__, - rv, fd_env_name, fd_env_allocated); - } else { - ALOGV("%s: rv:%d = setenv(fd_env_name:'%s', fd_env_allocated:'%s' ...);", __func__, - rv, fd_env_name, fd_env_allocated); - } - if (rv != 0) goto done; - - rv = setenv(type_env_name, type_env_allocated, overwrite); - - if (rv != 0) { - ALOGE("%s: rv:%d = setenv(type_env_name:'%s', type_env_allocated:'%s' ...);", - __func__, rv, type_env_name, type_env_allocated); - } else { - ALOGV("%s: rv:%d = setenv(type_env_name:'%s', type_env_allocated:'%s' ...);", - __func__, rv, type_env_name, type_env_allocated); - } - } - -done: - if (type_env_allocated) - free(type_env_allocated); - - if (fd_env_allocated) - free(fd_env_allocated); - - *REAL(__errno)() = saved_errno; - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -static int import_fd_env(int verify) -{ - char *type_env_allocated = NULL; - char *fd_env_allocated = NULL; - char *type_token_saved_ptr; - char *fd_token_saved_ptr; - enum filefd_type fd_type; - char *type_env, *fd_env; - int saved_errno; - char *type_token; - char *fd_token; - int rv = 0; - int fd; - - ALOGV("%s:(verify:%d) {", __func__, verify); - - saved_errno = *REAL(__errno)(); - - /* - * get file descriptor environment pointer and make a - * a copy of the string. - */ - fd_env = getenv(fd_env_name); - if (fd_env == NULL) { - ALOGV("%s: fd_env = NULL = getenv('%s');", __func__, - fd_env_name); - goto done; - } else { - ALOGV("%s: fd_env = '%s' = getenv('%s');", __func__, - fd_env, fd_env_name); - - fd_env_allocated = malloc(strlen(fd_env)+1); - if (fd_env_allocated == NULL) { - ALOGE("%s: fd_env_allocated = NULL; malloc failed", __func__); - goto done; - } - strcpy(fd_env_allocated, fd_env); - } - - /* - * get file descriptor environment pointer and make a copy of - * the string to our stack. - */ - type_env = getenv(type_env_name); - if (type_env == NULL) { - ALOGV("%s: type_env = NULL = getenv(type_env_name:'%s');", __func__, - type_env_name); - goto done; - } else { - ALOGV("%s: type_env = '%s' = getenv(type_env_name:'%s');", __func__, - type_env, type_env_name); - - type_env_allocated = malloc(strlen(type_env)+1); - if (type_env_allocated == NULL) { - ALOGE("%s: type_env_allocated = NULL; malloc failed", __func__); - goto done; - } - strcpy(type_env_allocated, type_env); - } - - /* - * Setup strtok_r(), use it to parse the env tokens, and - * initialise the filefd_mapped_file array. - */ - fd_token = strtok_r(fd_env_allocated, ",", &fd_token_saved_ptr); - type_token = strtok_r(type_env_allocated, ",", &type_token_saved_ptr); - while (fd_token && type_token) { - fd = atoi(fd_token); - ASSERT(fd >= 0 ); - ASSERT(fd < __FD_SETSIZE); - - fd_type = (enum filefd_type) atoi(type_token); - ASSERT(fd_type > UNUSED_FD_TYPE); - ASSERT(fd_type < MAX_FD_TYPE); - - if (fd >= 0 && fd < __FD_SETSIZE) { - if (fd_type > UNUSED_FD_TYPE && fd_type < MAX_FD_TYPE) { - if (verify) { - ASSERT(filefd_mapped_file[fd] == fd_type); - ALOGV("%s: filefd_mapped_file[fd:%d] == fd_type:%d;", __func__, - fd, fd_type); - } else { - ASSERT(filefd_mapped_file[fd] == UNUSED_FD_TYPE); - - __sync_fetch_and_add(&filefd_mapped_files, 1); - ALOGV("%s: ++filefd_mapped_files:%d;", __func__, - filefd_mapped_files); - - filefd_mapped_file[fd] = fd_type; - ALOGV("%s: filefd_mapped_file[fd:%d] = fd_type:%d;", __func__, - fd, fd_type); - } - } - } - - fd_token = strtok_r(NULL, ",", &fd_token_saved_ptr); - type_token = strtok_r(NULL, ",", &type_token_saved_ptr); - } - -done: - if (type_env_allocated) - free(type_env_allocated); - if (fd_env_allocated) - free(fd_env_allocated); - - *REAL(__errno)() = saved_errno; - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -/* - * This function will get run by the linker when the library is loaded. - */ -static void __attribute__ ((constructor)) linker_import_fd_env(void) -{ - int rv; - int verify_consistancy = 0; - - ALOGV(" "); - ALOGV("%s() {", __func__); - - rv = import_fd_env(verify_consistancy); /* File type table not verified. */ - - ALOGV("%s: }", __func__); -} - - -__hidden void filefd_opened(int fd, enum filefd_type fd_type) -{ - ALOGV("%s(fd:%d) {", __func__, fd); - - if (fd >= 0 && fd < __FD_SETSIZE) { - if (filefd_mapped_file[fd] == UNUSED_FD_TYPE) { - __sync_fetch_and_add(&filefd_mapped_files, 1); - filefd_mapped_file[fd] = fd_type; - } - ASSERT(filefd_mapped_file[fd] == fd_type); - } - - ALOGV("%s: }", __func__); -} - -__hidden void filefd_closed(int fd) -{ - ALOGV("%s(fd:%d) {", __func__, fd); - - if (fd >= 0 && fd < __FD_SETSIZE) { - if (filefd_mapped_file[fd] != UNUSED_FD_TYPE) { - filefd_mapped_file[fd] = UNUSED_FD_TYPE; - filefd_FD_CLOEXEC_file[fd] = 0; - __sync_fetch_and_sub(&filefd_mapped_files, 1); - } - } - ALOGV("%s: }", __func__); -} - - -__hidden void filefd_CLOEXEC_enabled(int fd) -{ - ALOGV("%s:(fd:%d) {", __func__, fd); - - if (fd >= 0 && fd < __FD_SETSIZE) { - filefd_FD_CLOEXEC_file[fd] = 1; - } - - ALOGV("%s: }", __func__); -} - -__hidden void filefd_CLOEXEC_disabled(int fd) -{ - ALOGV("%s:(fd:%d) {", __func__, fd); - - if (fd >= 0 && fd < __FD_SETSIZE) { - filefd_FD_CLOEXEC_file[fd] = 0; - } - - ALOGV("%s: }", __func__); -} - - -__hidden void filefd_disable_mapping() -{ - ALOGV("%s:() {", __func__); - - filefd_enabled = 0; - - ALOGV("%s: }", __func__); -} - - -int WRAP(close)(int fd) -{ - int rv; - - ALOGV(" "); - ALOGV("%s(fd:%d) {", __func__, fd); - - rv = REAL(close)(fd); - filefd_closed(fd); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(read)(int fd, void *buf, size_t count) -{ - int rv; - enum filefd_type fd_type; - - ALOGV(" "); - ALOGV("%s(fd:%d, buf:0x%p, count:%d) {", __func__, - fd, buf, count); - - fd_type = filefd_mapped_file[fd]; - ALOGV("%s:fd_type:%d", __func__, - fd_type); - - switch (fd_type) { - /* Reads on these descriptors are portable; no need to be mapped. */ - case UNUSED_FD_TYPE: - case EVENT_FD_TYPE: - case INOTIFY_FD_TYPE: - case TIMER_FD_TYPE: - rv = REAL(read)(fd, buf, count); - break; - - /* The read() of a signalfd() file descriptor needs to be mapped. */ - case SIGNAL_FD_TYPE: - if (filefd_enabled) { - rv = read_signalfd_mapper(fd, buf, count); - } else { - rv = REAL(read)(fd, buf, count); - } - break; - - default: - ALOGE("Unknown fd_type:%d!", fd_type); - rv = REAL(read)(fd, buf, count); - break; - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -/* - * Export PORTABLE environment variables before execve(). - * Tries a second time if it detects an extremely unlikely - * race condition. - */ -int WRAP(execve)(const char *filename, char *const argv[], char *const envp[]) -{ - int rv; - int mapped_files = filefd_mapped_files; - int verify_consistancy = 1; - - ALOGV(" "); - ALOGV("%s(filename:%p, argv:%p, envp:%p) {", __func__, - filename, argv, envp); - - export_fd_env(); - - if (mapped_files != filefd_mapped_files) { - export_fd_env(); - } - import_fd_env(verify_consistancy); /* File type table consistancy verified. */ - - rv = REAL(execve)(filename, argv, envp); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - diff --git a/ndk/sources/android/libportable/arch-mips/inotify.c b/ndk/sources/android/libportable/arch-mips/inotify.c deleted file mode 100644 index 76b1cac4d..000000000 --- a/ndk/sources/android/libportable/arch-mips/inotify.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include -#include - -#include -#include - -#include - - -#define PORTABLE_TAG "inotify_portable" -#include - -extern int syscall(int, ...); - - -/* - * NOTE: LTP defaults to using O_CLOEXEC for IN_CLOEXEC, - * and 02000000 if O_CLOEXEC isn't defined. - */ - - -/* - * Portable to Native event flags mapper. - */ -static inline int in_flags_pton(int portable_flags) -{ - int native_flags = 0; - - ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags); - - if (portable_flags & IN_NONBLOCK_PORTABLE) { - native_flags |= IN_NONBLOCK; - } - - if (portable_flags & IN_CLOEXEC_PORTABLE) { - native_flags |= IN_CLOEXEC; - } - - ALOGV("%s: return(native_flags:%d); }", __func__, native_flags); - return native_flags; -} - - -int WRAP(inotify_init1)(int portable_flags) { - int rv; - int native_flags; - - ALOGV(" "); - ALOGV("%s(portable_flags:%d) {", __func__, - portable_flags); - - native_flags = in_flags_pton(portable_flags); - - rv = syscall(__NR_inotify_init1, native_flags); - if (rv >= 0) { - if (native_flags & IN_CLOEXEC) { - filefd_CLOEXEC_enabled(rv); - } - filefd_opened(rv, INOTIFY_FD_TYPE); - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - diff --git a/ndk/sources/android/libportable/arch-mips/ioctl.c b/ndk/sources/android/libportable/arch-mips/ioctl.c deleted file mode 100644 index 7e82a6a52..000000000 --- a/ndk/sources/android/libportable/arch-mips/ioctl.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include - -#if FIONREAD_PORTABLE==FIONREAD -#error Bad build environment -#endif - -static inline int mips_change_request(int request) -{ - switch(request) { - case TCGETS_PORTABLE: - return TCGETS; - case TCSETS_PORTABLE: - return TCSETS; - case TCSETSW_PORTABLE: - return TCSETSW; - case TCSETSF_PORTABLE: - return TCSETSF; - case TCGETA_PORTABLE: - return TCGETA; - case TCSETA_PORTABLE: - return TCSETA; - case TCSETAW_PORTABLE: - return TCSETAW; - case TCSETAF_PORTABLE: - return TCSETAF; - case TCSBRK_PORTABLE: - return TCSBRK; - case TCXONC_PORTABLE: - return TCXONC; - case TCFLSH_PORTABLE: - return TCFLSH; - case TIOCEXCL_PORTABLE: - return TIOCEXCL; - case TIOCNXCL_PORTABLE: - return TIOCNXCL; - case TIOCSCTTY_PORTABLE: - return TIOCSCTTY; - case TIOCGPGRP_PORTABLE: - return TIOCGPGRP; - case TIOCSPGRP_PORTABLE: - return TIOCSPGRP; - case TIOCOUTQ_PORTABLE: - return TIOCOUTQ; - case TIOCSTI_PORTABLE: - return TIOCSTI; - case TIOCGWINSZ_PORTABLE: - return TIOCGWINSZ; - case TIOCSWINSZ_PORTABLE: - return TIOCSWINSZ; - case TIOCMGET_PORTABLE: - return TIOCMGET; - case TIOCMBIS_PORTABLE: - return TIOCMBIS; - case TIOCMBIC_PORTABLE: - return TIOCMBIC; - case TIOCMSET_PORTABLE: - return TIOCMSET; - case TIOCGSOFTCAR_PORTABLE: - return TIOCGSOFTCAR; - case TIOCSSOFTCAR_PORTABLE: - return TIOCSSOFTCAR; - case FIONREAD_PORTABLE: - return FIONREAD; - /* case TIOCINQ_PORTABLE: // same as FIONREAD_PORTABLE - return TIOCINQ; */ - case TIOCLINUX_PORTABLE: - return TIOCLINUX; - case TIOCCONS_PORTABLE: - return TIOCCONS; - case TIOCGSERIAL_PORTABLE: - return TIOCGSERIAL; - case TIOCSSERIAL_PORTABLE: - return TIOCSSERIAL; - case TIOCPKT_PORTABLE: - return TIOCPKT; - case FIONBIO_PORTABLE: - return FIONBIO; - case TIOCNOTTY_PORTABLE: - return TIOCNOTTY; - case TIOCSETD_PORTABLE: - return TIOCSETD; - case TIOCGETD_PORTABLE: - return TIOCGETD; - case TCSBRKP_PORTABLE: - return TCSBRKP; - case TIOCSBRK_PORTABLE: - return TIOCSBRK; - case TIOCCBRK_PORTABLE: - return TIOCCBRK; - case TIOCGSID_PORTABLE: - return TIOCGSID; - case FIONCLEX_PORTABLE: - return FIONCLEX; - case FIOCLEX_PORTABLE: - return FIOCLEX; - case FIOASYNC_PORTABLE: - return FIOASYNC; - case TIOCSERCONFIG_PORTABLE: - return TIOCSERCONFIG; - case TIOCSERGWILD_PORTABLE: - return TIOCSERGWILD; - case TIOCSERSWILD_PORTABLE: - return TIOCSERSWILD; - case TIOCGLCKTRMIOS_PORTABLE: - return TIOCGLCKTRMIOS; - case TIOCSLCKTRMIOS_PORTABLE: - return TIOCSLCKTRMIOS; - case TIOCSERGSTRUCT_PORTABLE: - return TIOCSERGSTRUCT; - case TIOCSERGETLSR_PORTABLE: - return TIOCSERGETLSR; - case TIOCSERGETMULTI_PORTABLE: - return TIOCSERGETMULTI; - case TIOCSERSETMULTI_PORTABLE: - return TIOCSERSETMULTI; - case TIOCMIWAIT_PORTABLE: - return TIOCMIWAIT; - case TIOCGICOUNT_PORTABLE: - return TIOCGICOUNT; - case FIOQSIZE_PORTABLE: - return FIOQSIZE; - case TIOCPKT_DATA_PORTABLE: - return TIOCPKT_DATA; - case TIOCPKT_FLUSHREAD_PORTABLE: - return TIOCPKT_FLUSHREAD; - case TIOCPKT_FLUSHWRITE_PORTABLE: - return TIOCPKT_FLUSHWRITE; - case TIOCPKT_STOP_PORTABLE: - return TIOCPKT_STOP; - case TIOCPKT_START_PORTABLE: - return TIOCPKT_START; - case TIOCPKT_NOSTOP_PORTABLE: - return TIOCPKT_NOSTOP; - case TIOCPKT_DOSTOP_PORTABLE: - return TIOCPKT_DOSTOP; - /* case TIOCSER_TEMT_PORTABLE: // = 1 same as TIOCPKT_FLUSHREAD_PORTABLE - return TIOCSER_TEMT; */ - case TIOCGPTN_PORTABLE: - return TIOCGPTN; - case TIOCSPTLCK_PORTABLE: - return TIOCSPTLCK; -#ifdef USE_OLD_TTY - case TIOCGETD_PORTABLE: - return TIOCGETD; - case TIOCSETD_PORTABLE: - return TIOCSETD; -#else - case OTIOCGETD_PORTABLE: - return OTIOCGETD; - case OTIOCSETD_PORTABLE: - return OTIOCSETD; -#endif - case TIOCHPCL_PORTABLE: - return TIOCHPCL; - case TIOCGETP_PORTABLE: - return TIOCGETP; - case TIOCSETP_PORTABLE: - return TIOCSETP; - case TIOCSETN_PORTABLE: - return TIOCSETN; - case TIOCSETC_PORTABLE: - return TIOCSETC; - case TIOCGETC_PORTABLE: - return TIOCGETC; - case TIOCLBIS_PORTABLE: - return TIOCLBIS; - case TIOCLBIC_PORTABLE: - return TIOCLBIC; - case TIOCLSET_PORTABLE: - return TIOCLSET; - case TIOCLGET_PORTABLE: - return TIOCLGET; - case TIOCSLTC_PORTABLE: - return TIOCSLTC; - case TIOCGLTC_PORTABLE: - return TIOCGLTC; - case OTIOCCONS_PORTABLE: - return OTIOCCONS; - case FIOSETOWN_PORTABLE: - return FIOSETOWN; - case SIOCSPGRP_PORTABLE: - return SIOCSPGRP; - case FIOGETOWN_PORTABLE: - return FIOGETOWN; - case SIOCGPGRP_PORTABLE: - return SIOCGPGRP; - case SIOCATMARK_PORTABLE: - return SIOCATMARK; - case SIOCGSTAMP_PORTABLE: - return SIOCGSTAMP; - } - return request; -} - -extern int __ioctl(int, int, void *); -int WRAP(ioctl)(int fd, int request, ...) -{ - va_list ap; - void * arg; - - va_start(ap, request); - arg = va_arg(ap, void *); - va_end(ap); - - return __ioctl(fd, mips_change_request(request), arg); -} diff --git a/ndk/sources/android/libportable/arch-mips/jboffsets.h b/ndk/sources/android/libportable/arch-mips/jboffsets.h deleted file mode 100644 index b43d77ac3..000000000 --- a/ndk/sources/android/libportable/arch-mips/jboffsets.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _JBOFFSETS_H_ -#define _JBOFFSETS_H_ - -/* - * Normally the same layout is used for saving the registers in jmp_buf - * as that used in struct sigcontext. For portability all of the registers need - * to be stored in the space available in a portable jmp_buf so this code - * packs the register together. - */ - -#define JB_MASK (0*REGSZ) -#define JB_PC (1*REGSZ) -#define JB_MAGIC (2*REGSZ) -#define JB_S0 (3*REGSZ) -#define JB_S1 (4*REGSZ) -#define JB_S2 (5*REGSZ) -#define JB_S3 (6*REGSZ) -#define JB_S4 (7*REGSZ) -#define JB_S5 (8*REGSZ) -#define JB_S6 (9*REGSZ) -#define JB_S7 (10*REGSZ) -#define JB_S8 (11*REGSZ) -#define JB_GP (12*REGSZ) -#define JB_SP (13*REGSZ) -#define JB_SAVEMASK (14*REGSZ) -#define JB_FPUSED (15*REGSZ) -#define JB_FSR (16*REGSZ) -#define JB_FPBASE (18*REGSZ) -#define JB_F20 (JB_FPBASE+0*REGSZ_FP) -#define JB_F21 (JB_FPBASE+1*REGSZ_FP) -#define JB_F22 (JB_FPBASE+2*REGSZ_FP) -#define JB_F23 (JB_FPBASE+3*REGSZ_FP) -#define JB_F24 (JB_FPBASE+4*REGSZ_FP) -#define JB_F25 (JB_FPBASE+5*REGSZ_FP) -#define JB_F26 (JB_FPBASE+6*REGSZ_FP) -#define JB_F27 (JB_FPBASE+7*REGSZ_FP) -#define JB_F28 (JB_FPBASE+8*REGSZ_FP) -#define JB_F29 (JB_FPBASE+9*REGSZ_FP) -#define JB_F30 (JB_FPBASE+10*REGSZ_FP) -#define JB_F31 (JB_FPBASE+11*REGSZ_FP) - -/* Use different magic numbers to avoid misuse of native vs portable contexts */ -#define MAGIC_SETJMP 0xACEDBEAD -#define MAGIC__SETJMP 0xBEAD1CAB - -#endif /* _JBOFFSETS_H_ */ diff --git a/ndk/sources/android/libportable/arch-mips/mmap.c b/ndk/sources/android/libportable/arch-mips/mmap.c deleted file mode 100644 index f2c3a1a8f..000000000 --- a/ndk/sources/android/libportable/arch-mips/mmap.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#if MAP_ANONYMOUS_PORTABLE==MAP_ANONYMOUS -#error Bad build environment -#endif - -#define PORTABLE_TAG "mmap_portable" -#include - -static inline int mmap_prot_pton(int portable_prot) -{ - int native_prot = portable_prot; - - ALOGV("%s(portable_prot:0x%x) {", __func__, portable_prot); - - /* Only PROT_SEM is different */ - if (portable_prot & PROT_SEM_PORTABLE) { - native_prot &= ~PROT_SEM_PORTABLE; - native_prot |= PROT_SEM; - } - - ALOGV("%s: return(native_prot:0x%x); }", __func__, native_prot); - return native_prot; -} - - -static inline int mmap_flags_pton(int portable_flags) -{ - int native_flags = 0; - - ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags); - - if (portable_flags & MAP_SHARED_PORTABLE) { - native_flags |= MAP_SHARED; - } - if (portable_flags & MAP_PRIVATE_PORTABLE) { - native_flags |= MAP_PRIVATE; - } - if (portable_flags & MAP_FIXED_PORTABLE) { - native_flags |= MAP_FIXED; - } - if (portable_flags & MAP_ANONYMOUS_PORTABLE) { - native_flags |= MAP_ANONYMOUS; - } - if (portable_flags & MAP_GROWSDOWN_PORTABLE) { - native_flags |= MAP_GROWSDOWN; - } - if (portable_flags & MAP_DENYWRITE_PORTABLE) { - native_flags |= MAP_DENYWRITE; - } - if (portable_flags & MAP_EXECUTABLE_PORTABLE) { - native_flags |= MAP_EXECUTABLE; - } - if (portable_flags & MAP_LOCKED_PORTABLE) { - native_flags |= MAP_LOCKED; - } - if (portable_flags & MAP_NORESERVE_PORTABLE) { - native_flags |= MAP_NORESERVE; - } - if (portable_flags & MAP_POPULATE_PORTABLE) { - native_flags |= MAP_POPULATE; - } - if (portable_flags & MAP_NONBLOCK_PORTABLE) { - native_flags |= MAP_NONBLOCK; - } - - ALOGV("%s: return(native_flags:0x%x); }", __func__, native_flags); - return native_flags; -} - -extern void* REAL(mmap)(void *, size_t, int, int, int, off_t); -void *WRAP(mmap)(void *addr, size_t size, int prot, int flags, int fd, long byte_offset) -{ - int native_prot, native_flags; - int saved_errno; - void *ret_addr; - - ALOGV(" "); - ALOGV("%s(addr:%p, size:%d, prot:0x%x, flags:0x%x, fd:%d, byte_offset:0x%lx) {", __func__, - addr, size, prot, flags, fd, byte_offset); - - native_prot = mmap_prot_pton(prot); - native_flags = mmap_flags_pton(flags); - - ret_addr = REAL(mmap)(addr, size, native_prot, native_flags, fd, byte_offset); - - ALOGV("%s: return(ret_addr:%p); }", __func__, ret_addr); - return ret_addr; -} - - -extern int mprotect(const void *, size_t, int); - -int WRAP(mprotect)(const void *addr, size_t size, int portable_prot) -{ - int rv; - int native_prot; - - ALOGV(" "); - ALOGV("%s(addr:%p, size:%d, portable_prot:0x%x); {", __func__, - addr, size, portable_prot); - - native_prot = mmap_prot_pton(portable_prot); - - rv = REAL(mprotect)(addr, size, native_prot); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} diff --git a/ndk/sources/android/libportable/arch-mips/open.c b/ndk/sources/android/libportable/arch-mips/open.c deleted file mode 100644 index ac306d62e..000000000 --- a/ndk/sources/android/libportable/arch-mips/open.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define PORTABLE_TAG "open_portable" -#include - - -#if O_CREAT_PORTABLE==O_CREAT -#error Bad build environment -#endif - - -static inline int open_flags_pton(int flags) -{ - int mipsflags = flags & O_ACCMODE_PORTABLE; - - ALOGV("%s(flags:0x%x) {", __func__, flags); - - if (flags & O_CREAT_PORTABLE) - mipsflags |= O_CREAT; - if (flags & O_EXCL_PORTABLE) - mipsflags |= O_EXCL; - if (flags & O_NOCTTY_PORTABLE) - mipsflags |= O_NOCTTY; - if (flags & O_TRUNC_PORTABLE) - mipsflags |= O_TRUNC; - if (flags & O_APPEND_PORTABLE) - mipsflags |= O_APPEND; - if (flags & O_NONBLOCK_PORTABLE) - mipsflags |= O_NONBLOCK; - if (flags & O_SYNC_PORTABLE) - mipsflags |= O_SYNC; - if (flags & FASYNC_PORTABLE) - mipsflags |= FASYNC; - if (flags & O_DIRECT_PORTABLE) - mipsflags |= O_DIRECT; - if (flags & O_LARGEFILE_PORTABLE) - mipsflags |= O_LARGEFILE; - if (flags & O_DIRECTORY_PORTABLE) - mipsflags |= O_DIRECTORY; - if (flags & O_NOFOLLOW_PORTABLE) - mipsflags |= O_NOFOLLOW; - if (flags & O_NOATIME_PORTABLE) - mipsflags |= O_NOATIME; - if (flags & O_NDELAY_PORTABLE) - mipsflags |= O_NDELAY; - - ALOGV("%s: return(mipsflags:0x%x); }", __func__, mipsflags); - return mipsflags; -} - - -extern int __openat(int, const char*, int, int); - -int WRAP(open)(const char *pathname, int flags, ...) -{ - mode_t mode = 0; - if ((flags & O_CREAT_PORTABLE) != 0) { - va_list args; - va_start(args, flags); - mode = (mode_t) va_arg(args, int); - va_end(args); - } - flags |= O_LARGEFILE_PORTABLE; - flags = open_flags_pton(flags); - - return __openat(AT_FDCWD, pathname, flags, mode); -} - -int WRAP(openat)(int dirfd, const char *pathname, int flags, ...) -{ - mode_t mode = 0; - if ((flags & O_CREAT_PORTABLE) != 0) { - va_list args; - va_start(args, flags); - mode = (mode_t) va_arg(args, int); - va_end(args); - } - flags |= O_LARGEFILE_PORTABLE; - flags = open_flags_pton(flags); - - return __openat(dirfd, pathname, flags, mode); -} diff --git a/ndk/sources/android/libportable/arch-mips/pipe.c b/ndk/sources/android/libportable/arch-mips/pipe.c deleted file mode 100644 index fa8026676..000000000 --- a/ndk/sources/android/libportable/arch-mips/pipe.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define _GNU_SOURCE /* GLibc compatibility to declare pipe2(2) */ -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - - -#define PORTABLE_TAG "pipe_portable" -#include - -extern int syscall(int, ...); - - -/* NOTE: LTP defaults to using O_NONBLOCK even if O_NONBLOCK is defined */ - - -/* - * Portable to Native event flags mapper. - */ -static inline int tdf_flags_pton(int portable_flags) -{ - int native_flags = 0; - - ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags); - - if (portable_flags & O_NONBLOCK_PORTABLE) { - native_flags |= O_NONBLOCK; - } - - if (portable_flags & O_CLOEXEC_PORTABLE) { - native_flags |= O_CLOEXEC; - } - - ALOGV("%s: return(native_flags:%d); }", __func__, native_flags); - return native_flags; -} - - -int WRAP(pipe2)(int pipefd[2], int portable_flags) { - int native_flags; - int rv; - - ALOGV(" "); - ALOGV("%s(pipefd[2]:%p, portable_flags:0x%x) {", __func__, - pipefd, portable_flags); - - native_flags = tdf_flags_pton(portable_flags); - - rv = REAL(pipe2)(pipefd, native_flags); - if (rv >= 0) { - ALOGV("%s: pipe2() returned pipefd[0]:%d, pipefd[1]:%d", __func__, - pipefd[0], pipefd[1]); - - if (native_flags & O_CLOEXEC) { - filefd_CLOEXEC_enabled(pipefd[0]); - filefd_CLOEXEC_enabled(pipefd[1]); - } - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - diff --git a/ndk/sources/android/libportable/arch-mips/poll.c b/ndk/sources/android/libportable/arch-mips/poll.c deleted file mode 100644 index 54059ddf5..000000000 --- a/ndk/sources/android/libportable/arch-mips/poll.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -/* - *_XOPEN_SOURCE added the ability to not only poll for data coming in or out - * but now also the ability to poll for high priority input and output. Though - * the normal priority is equivalent to the original I/O it was assigned new bits: - * POLLIN Equivalent to POLLRDNORM - * POLLOUT Equivalent to POLLWRNORM - * - * The Linux kernel sets both POLLIN and POLLRDNORM when data is available and sets - * both POLLOUT and POLLWRNORM when data can be written; so the new priority BAND bits - * just supplement the meaning of the prior POLLIN and POLLOUT bits as well as the - * new POLLRDNORM and POLLWRNORM bits. - * - * The DECNet Protocol can set the poll in priority flag, POLLRDBAND. - * ATM as well as a whole bunch of other protocols can set the poll out priority flag, - * POLLWRBAND. - * - * MIPS and SPARC likely assigned the new XOPEN poll out event flags in UNIX well before - * UNIX was ported to X86. It appears that Intel chose different bits and that was - * established by Linus as the the generic case and later also chosen by ARM. - * - * POLLWRNORM:0x100 - MIPS used POLLOUT:0x0004, which is equivalent in meaning. - * - * POLLWRBAND:0x200 - MIPS used 0x0100. which is POLLWRNORM:0x100. - * - * Summary: - * ======== - * Both Normal and Priority flags can be mapped to MIPS flags (left to right below). - * Only the Priority poll out flag can be mapped back to portable because MIPS - * is using the same number as POLLOUT for POLLWRNORM (right to left below). - * - * ARM/GENERIC/PORTABLE MIPS - * ==================== ====== - * POLLIN 0x0001 0x0001 - * POLLPRI 0x0002 0x0002 - * POLLOUT 0x0004 <-----+ 0x0004 - * POLLERR 0x0008 \ 0x0008 - * POLLHUP 0x0010 \ 0x0010 - * POLLNVAL 0x0020 \ 0x0020 - * POLLRDNORM 0x0040 \ 0x0040 - * POLLRDBAND 0x0080 \ 0x0080 - * POLLWRNORM 0x0100 -----------+<----> 0x0004 - * POLLWRBAND 0x0200 <-----------------> 0x0100 - * POLLMSG 0x0400 0x0400 - * POLLREMOVE 0x1000 0x1000 - * POLLRDHUP 0x2000 0x2000 - * - * The loss of the high priority notice for the polling - * of output data is likely minor as it was only being used - * in DECNet. Also, the poll system call and device poll - * implementations processes POLLOUT and POLLWRNORM event - * flags the same. - */ - -#if POLLWRNORM_PORTABLE==POLLWRNORM -#error Bad build environment -#endif - -static inline short mips_change_portable_events(short portable_events) -{ - /* MIPS has different POLLWRNORM and POLLWRBAND. */ - if (portable_events & POLLWRNORM_PORTABLE) { - portable_events &= ~POLLWRNORM_PORTABLE; - portable_events |= POLLWRNORM; - } - if (portable_events & POLLWRBAND_PORTABLE) { - portable_events &= ~POLLWRBAND_PORTABLE; - portable_events |= POLLWRBAND; - } - - return portable_events; -} - -static inline short change_mips_events(short mips_events) -{ - /* - * MIPS POLLWRNORM equals MIPS POLLOUT, which is the same as POLLOUT_PORTABLE; - * so we just map POLLWRBAND to POLLWRBAND_PORTABLE. - */ - if (mips_events & POLLWRBAND) { - mips_events &= ~POLLWRBAND; - mips_events |= POLLWRBAND_PORTABLE; - } - - return mips_events; -} - -extern int poll(struct pollfd *, nfds_t, int); - -int WRAP(poll)(struct pollfd *fds, nfds_t nfds, int timeout) -{ - nfds_t i; - int ret; - - for (i = 0; i < nfds; i++) - fds->events = mips_change_portable_events(fds->events); - - ret = REAL(poll)(fds, nfds, timeout); - - for (i = 0; i < nfds; i++) { - fds->events = change_mips_events(fds->events); - fds->revents = change_mips_events(fds->revents); - } - - return ret; -} diff --git a/ndk/sources/android/libportable/arch-mips/pthread.c b/ndk/sources/android/libportable/arch-mips/pthread.c deleted file mode 100644 index 5f92fb04f..000000000 --- a/ndk/sources/android/libportable/arch-mips/pthread.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define PORTABLE_TAG "pthread_portable" -#include - -/* - * Macros for STRIP_PARENS() which is used below in PTHREAD_WRAPPER(); cpp magic from: - * http://boost.2283326.n4.nabble.com/preprocessor-removing-parentheses-td2591973.html - */ -#define CAT(x, y) CAT_I(x, y) -#define CAT_I(x, y) x ## y - -#define APPLY(macro, args) APPLY_I(macro, args) -#define APPLY_I(macro, args) macro args - -#define STRIP_PARENS(x) EVAL((STRIP_PARENS_I x), x) -#define STRIP_PARENS_I(...) 1,1 - -#define EVAL(test, x) EVAL_I(test, x) -#define EVAL_I(test, x) MAYBE_STRIP_PARENS(TEST_ARITY test, x) - -#define TEST_ARITY(...) APPLY(TEST_ARITY_I, (__VA_ARGS__, 2, 1)) -#define TEST_ARITY_I(a,b,c,...) c - -#define MAYBE_STRIP_PARENS(cond, x) MAYBE_STRIP_PARENS_I(cond, x) -#define MAYBE_STRIP_PARENS_I(cond, x) CAT(MAYBE_STRIP_PARENS_, cond)(x) - -#define MAYBE_STRIP_PARENS_1(x) x -#define MAYBE_STRIP_PARENS_2(x) APPLY(MAYBE_STRIP_PARENS_2_I, x) -#define MAYBE_STRIP_PARENS_2_I(...) __VA_ARGS__ - -/* - * Call pthread function and convert return value (a native errno) to portable error number. - */ -#define PTHREAD_WRAPPER(fn, DECLARGS, CALLARGS, fmt) \ - int WRAP(fn) DECLARGS \ - { \ - int rv, portable_rv; \ - \ - ALOGV(" "); \ - ALOGV("%s" fmt, __func__, STRIP_PARENS(CALLARGS)); \ - rv = REAL(fn) CALLARGS; \ - portable_rv = errno_ntop(rv); \ - ALOGV("%s: return(portable_rv:%d); rv:%d;", __func__, \ - portable_rv, rv); \ - return portable_rv; \ - } - -PTHREAD_WRAPPER(pthread_attr_init, (pthread_attr_t *attr), (attr), "(attr:%p)"); - -PTHREAD_WRAPPER(pthread_attr_destroy, (pthread_attr_t *attr), (attr), "(attr:%p)"); - -PTHREAD_WRAPPER(pthread_attr_setdetachstate, (pthread_attr_t *attr, int state), (attr, state), - "(attr:%p, state:%d)"); - -PTHREAD_WRAPPER(pthread_attr_getdetachstate, (pthread_attr_t const *attr, int *state), - (attr, state), "(attr:%p, state:%p)"); - -PTHREAD_WRAPPER(pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy), (attr, policy), - "(attr:%p, policy:%d)"); - -PTHREAD_WRAPPER(pthread_attr_getschedpolicy, (pthread_attr_t const *attr, int *policy), - (attr, policy), "(attr:%p, policy:%p)"); - -PTHREAD_WRAPPER(pthread_attr_setschedparam, - (pthread_attr_t *attr, struct sched_param const *param), (attr, param), - "(attr:%p, param:%p)"); - -PTHREAD_WRAPPER(pthread_attr_getschedparam, - (pthread_attr_t const *attr, struct sched_param *param), (attr, param), - "(attr:%p, param:%p)"); - -PTHREAD_WRAPPER(pthread_attr_setstacksize, (pthread_attr_t *attr, size_t stack_size), - (attr, stack_size), "(attr:%p, stack_size:%d)"); - -PTHREAD_WRAPPER(pthread_attr_getstacksize, (pthread_attr_t const *attr, size_t *stack_size), - (attr, stack_size), "(attr:%p, stack_size:%p)"); - -PTHREAD_WRAPPER(pthread_attr_setstack, (pthread_attr_t *attr, void *stackaddr, size_t stack_size), - (attr, stackaddr, stack_size), "(attr:%p, stackaddr:%p, stack_size:%d)"); - -PTHREAD_WRAPPER(pthread_attr_getstack, (pthread_attr_t const *attr, void **stackaddr, - size_t *stack_size), (attr, stackaddr, stack_size), - "(attr:%p, stackaddr:%p stack_size:%p)"); - -PTHREAD_WRAPPER(pthread_attr_setguardsize, (pthread_attr_t *attr, size_t guard_size), - (attr, guard_size), "(attr:%p, guard_size:%d)"); - -PTHREAD_WRAPPER(pthread_attr_getguardsize, (pthread_attr_t const *attr, size_t *guard_size), - (attr, guard_size), "(attr:%p, guard_size:%p)"); - -PTHREAD_WRAPPER(pthread_attr_setscope, (pthread_attr_t *attr, int scope), (attr, scope), - "(attr:%p, scope:%d)"); - -PTHREAD_WRAPPER(pthread_attr_getscope, (pthread_attr_t const *attr, int* scope), (attr, scope), "(attr:%p, scope:%p)"); - -PTHREAD_WRAPPER(pthread_getattr_np, (pthread_t thid, pthread_attr_t *attr), (thid, attr), - "(thid:%lx, attr:%p)"); - -PTHREAD_WRAPPER(pthread_create, (pthread_t *thread, const pthread_attr_t *attr, - void *(*start_routine) (void *), void *arg), - (thread, attr, start_routine, arg), - "(thread:%p attr:%p, start_routine:%p, arg:%p)"); - -// void pthread_exit(void * retval); -PTHREAD_WRAPPER(pthread_join, (pthread_t thid, void **ret_val), (thid, ret_val), - "(thid:%lx, ret_val:%p)"); - -PTHREAD_WRAPPER(pthread_detach, (pthread_t thid), (thid), "(thid:%lx)"); - -// pthread_t pthread_self(void); -// int pthread_equal(pthread_t one, pthread_t two); - -PTHREAD_WRAPPER(pthread_getschedparam, (pthread_t thid, int *policy, struct sched_param *param), - (thid, policy, param), "(thid:%lx, policy:%p, param:%p)"); - -PTHREAD_WRAPPER(pthread_setschedparam, (pthread_t thid, int policy, - struct sched_param const *param), (thid, policy, param), - "(thid:%lx, policy:%d, param:%p)"); - -PTHREAD_WRAPPER(pthread_mutexattr_init, (pthread_mutexattr_t *attr), (attr), "(attr:%p)"); - -PTHREAD_WRAPPER(pthread_mutexattr_destroy, (pthread_mutexattr_t *attr), (attr), "(attr:%p)"); - -PTHREAD_WRAPPER(pthread_mutexattr_gettype, (const pthread_mutexattr_t *attr, int *type), - (attr, type), "(attr:%p, type:%p)"); - -PTHREAD_WRAPPER(pthread_mutexattr_settype, (pthread_mutexattr_t *attr, int type), (attr, type), - "(attr:%p, type:%d)"); - -PTHREAD_WRAPPER(pthread_mutexattr_setpshared, (pthread_mutexattr_t *attr, int pshared), - (attr, pshared), "(attr:%p, pshared:%d)"); - -PTHREAD_WRAPPER(pthread_mutexattr_getpshared, (pthread_mutexattr_t *attr, int *pshared), - (attr, pshared), "(attr:%p, pshared:%p)"); - -PTHREAD_WRAPPER(pthread_mutex_init, (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr), - (mutex, attr), "(mutex:%p, attr:%p)"); - -PTHREAD_WRAPPER(pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)"); - -PTHREAD_WRAPPER(pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)"); - -PTHREAD_WRAPPER(pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)"); - -PTHREAD_WRAPPER(pthread_mutex_trylock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)"); - -#if 0 /* MISSING FROM BIONIC */ -PTHREAD_WRAPPER(pthread_mutex_timedlock, (pthread_mutex_t *mutex, struct timespec *ts), - (mutex, ts), "(mutex:%p, ts:%p)"); -#endif /* MISSING */ - -PTHREAD_WRAPPER(pthread_condattr_init, (pthread_condattr_t *attr), (attr), "(attr:%p)"); - -PTHREAD_WRAPPER(pthread_condattr_getpshared, (pthread_condattr_t *attr, int *pshared), - (attr, pshared), "(attr:%p, pshared:%p)"); - -PTHREAD_WRAPPER(pthread_condattr_setpshared, (pthread_condattr_t* attr, int pshared), - (attr, pshared), "(attr:%p, pshared:%d)"); - -PTHREAD_WRAPPER(pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), "(attr:%p)"); - -PTHREAD_WRAPPER(pthread_cond_init, (pthread_cond_t *cond, const pthread_condattr_t *attr), - (cond, attr), "(cond:%p, attr:%p)"); - -PTHREAD_WRAPPER(pthread_cond_destroy, (pthread_cond_t *cond), (cond), "(cond:%p)"); - -PTHREAD_WRAPPER(pthread_cond_broadcast, (pthread_cond_t *cond), (cond), "(cond:%p)"); - -PTHREAD_WRAPPER(pthread_cond_signal, (pthread_cond_t *cond), (cond), "(cond:%p)"); - -PTHREAD_WRAPPER(pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex), - (cond, mutex), "(cond:%p, mutex:%p)"); - -PTHREAD_WRAPPER(pthread_cond_timedwait, (pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime), (cond, mutex, abstime), - "(cond:%p, mutex:%p, abstime:%p)"); - -PTHREAD_WRAPPER(pthread_cond_timedwait_monotonic_np, (pthread_cond_t *cond, - pthread_mutex_t *mutex, const struct timespec *abstime), - (cond, mutex, abstime), "(cond:%p, mutex:%p, abstime:%p)"); - -PTHREAD_WRAPPER(pthread_cond_timedwait_monotonic, (pthread_cond_t *cond, pthread_mutex_t - *mutex, const struct timespec *abstime), - (cond, mutex, abstime), "(cond:%p, mutex:%p, abstime:%p)"); - -PTHREAD_WRAPPER(pthread_cond_timedwait_relative_np, (pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *reltime), (cond, mutex, reltime), - "(cond:%p, mutex:%p, reltime:%p)"); - -PTHREAD_WRAPPER(pthread_cond_timeout_np, (pthread_cond_t *cond, pthread_mutex_t *mutex, - unsigned msecs), (cond, mutex, msecs), "(cond:%p, mutex:%p, msecs:%u)"); - -PTHREAD_WRAPPER(pthread_rwlockattr_init, (pthread_rwlockattr_t *attr), (attr), "(attr:%p)"); - -PTHREAD_WRAPPER(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *attr), (attr), "(attr:%p)"); - -PTHREAD_WRAPPER(pthread_rwlockattr_setpshared, (pthread_rwlockattr_t *attr, int pshared), - (attr, pshared), "(attr:%p, pshared:%d)"); - -PTHREAD_WRAPPER(pthread_rwlockattr_getpshared, (pthread_rwlockattr_t *attr, int *pshared), - (attr, pshared), "(attr:%p, pshared:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_init, (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr), - (rwlock, attr), "(rwlock:%p, attr:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_destroy, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_rdlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_tryrdlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_timedrdlock, (pthread_rwlock_t *rwlock, - const struct timespec *abs_timeout), - (rwlock, abs_timeout), "(rwlock:%p, abs_timeout:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_wrlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_trywrlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_timedwrlock, (pthread_rwlock_t *rwlock, - const struct timespec *abs_timeout), (rwlock, abs_timeout), - "(rwlock:%p, abs_timeout:%p)"); - -PTHREAD_WRAPPER(pthread_rwlock_unlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)"); - -PTHREAD_WRAPPER(pthread_key_create, (pthread_key_t *key, void (*destructor_function)(void *)), - (key, destructor_function), "(key:%p, destructor_function:%p)"); - -PTHREAD_WRAPPER(pthread_key_delete , (pthread_key_t key), (key), "(key:%x)"); - -PTHREAD_WRAPPER(pthread_setspecific, (pthread_key_t key, const void *value), (key, value), - "(key:%x, value:%p)"); - -// void *pthread_getspecific(pthread_key_t key); - -int WRAP(pthread_kill)(pthread_t thread, int portable_signum) -{ - char *portable_signame = map_portable_signum_to_name(portable_signum); - int mips_signum; - int portable_ret, ret; - - ALOGV("%s(thread:%lx, portable_signum:%d)", __func__, thread, portable_signum); - - mips_signum = signum_pton(portable_signum); - - if ((portable_signum != 0) && (mips_signum == 0)) { - /* A signal MIPS doesn't support; all we can do is ignore it. */ - ret = 0; - } else { - ALOGV("%s: calling pthread_kill(thread:%lx, mips_signum:%d);", __func__, - thread, mips_signum); - ret = REAL(pthread_kill)(thread, mips_signum); - } - portable_ret = errno_ntop(ret); - - ALOGV("%s: return portable_ret:%d; ret:%d;", __func__, - portable_ret, ret); - - return portable_ret; -} - -int WRAP(pthread_sigmask)(int portable_how, const sigset_portable_t *portable_sigset, - sigset_portable_t *portable_oldset) -{ - extern int REAL(pthread_sigmask)(int how, const sigset_t *set, sigset_t *oset); - int portable_ret, ret; - - ALOGV(" "); - ALOGV("%s(portable_how:%d portable_sigset:%p, portable_oldset:%p)", __func__, - portable_how, portable_sigset, portable_oldset); - - ret = do_sigmask(portable_how, portable_sigset, portable_oldset, REAL(pthread_sigmask), NULL); - - portable_ret = errno_ntop(ret); - - ALOGV("%s: return portable_ret:%d; ret:%d;", __func__, - portable_ret, ret); - - return portable_ret; -} - -PTHREAD_WRAPPER(pthread_getcpuclockid, (pthread_t tid, clockid_t *clockid), (tid, clockid), - "(tid:%lx, clockid:%p)"); - -PTHREAD_WRAPPER(pthread_once, (pthread_once_t *once_control, void (*init_routine)(void)), - (once_control, init_routine), "(once_control:%p, init_routine:%p)"); - -PTHREAD_WRAPPER(pthread_setname_np, (pthread_t thid, const char *thname), (thid, thname), - "(thid:%lx, thname:\"%s\")"); diff --git a/ndk/sources/android/libportable/arch-mips/resource.c b/ndk/sources/android/libportable/arch-mips/resource.c deleted file mode 100644 index 91b473d3f..000000000 --- a/ndk/sources/android/libportable/arch-mips/resource.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#if RLIMIT_NOFILE_PORTABLE==RLIMIT_NOFILE -#error Bad build environment -#endif - -static inline int mips_change_resource(int resource) -{ - switch(resource) { - case RLIMIT_NOFILE_PORTABLE: - return RLIMIT_NOFILE; - case RLIMIT_AS_PORTABLE: - return RLIMIT_AS; - case RLIMIT_RSS_PORTABLE: - return RLIMIT_RSS; - case RLIMIT_NPROC_PORTABLE: - return RLIMIT_NPROC; - case RLIMIT_MEMLOCK_PORTABLE: - return RLIMIT_MEMLOCK; - } - return resource; -} - -extern int REAL(getrlimit)(int resource, struct rlimit *rlp); -int WRAP(getrlimit)(int resource, struct rlimit *rlp) -{ - return REAL(getrlimit)(mips_change_resource(resource), rlp); -} - -extern int REAL(setrlimit)(int resource, const struct rlimit *rlp); -int WRAP(setrlimit)(int resource, const struct rlimit *rlp) -{ - return REAL(setrlimit)(mips_change_resource(resource), rlp); -} diff --git a/ndk/sources/android/libportable/arch-mips/setjmp.S b/ndk/sources/android/libportable/arch-mips/setjmp.S deleted file mode 100644 index fcfccec2b..000000000 --- a/ndk/sources/android/libportable/arch-mips/setjmp.S +++ /dev/null @@ -1,217 +0,0 @@ -/* Derived from: $OpenBSD: setjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */ - -/* - * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Opsycon AB nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#include -#include -#include - -#include "jboffsets.h" - -/* - * setjmp, longjmp implementation for libc. - */ - -FRAMESZ= MKFSIZ(2,6) -A1OFF= FRAMESZ-4*REGSZ -A0OFF= FRAMESZ-3*REGSZ -GPOFF= FRAMESZ-2*REGSZ -RAOFF= FRAMESZ-1*REGSZ - -#define FPREG64_S(FPR, OFF, BASE) \ - swc1 FPR, OFF(BASE) ; \ - mfhc1 t0, FPR ; \ - sw t0, OFF+4(BASE) ; - -#define FPREG64_L(FPR, OFF, BASE) \ - lw t0, OFF+4(BASE) ; \ - lw t1, OFF(BASE) ; \ - mtc1 t1, FPR ; \ - mthc1 t0, FPR ; \ - - - -NON_LEAF(WRAP(setjmp), FRAMESZ, ra) - .mask 0x80000000, RAOFF - PTR_SUBU sp, FRAMESZ # allocate stack frame - SETUP_GP64(GPOFF, WRAP(setjmp)) - SAVE_GP(GPOFF) - .set reorder - REG_S ra, RAOFF(sp) # save state - REG_S a0, A0OFF(sp) - - move a0, zero # get current signal mask - jal sigblock - - REG_L v1, A0OFF(sp) # v1 = jmpbuf - REG_S v0, JB_MASK(v1) # save sc_mask = sigblock(0) - - REG_L a0, A0OFF(sp) # restore jmpbuf - REG_L ra, RAOFF(sp) - REG_S ra, JB_PC(a0) # sc_pc = return address -#if defined(__mips64) - dli v0, MAGIC_SETJMP -#else - li v0, MAGIC_SETJMP -#endif - REG_S v0, JB_MAGIC(a0) - REG_S s0, JB_S0(a0) - REG_S s1, JB_S1(a0) - REG_S s2, JB_S2(a0) - REG_S s3, JB_S3(a0) - REG_S s4, JB_S4(a0) - REG_S s5, JB_S5(a0) - REG_S s6, JB_S6(a0) - REG_S s7, JB_S7(a0) - REG_S s8, JB_S8(a0) - REG_L v0, GPOFF(sp) - REG_S v0, JB_GP(a0) - PTR_ADDU v0, sp, FRAMESZ - REG_S v0, JB_SP(a0) - -#if !defined(SOFTFLOAT) - /* - * Would be nice if we could tell if the FP registers are currently being used. - * Assume they are, and use pointer to jmp_buf in a0 to save FP registers and the - * jmp_buf.fpused flag. - */ - li v0, 1 # v0 = 1 - REG_S v0, JB_FPUSED(a0) # a0->jb_fpused = v0:1 - cfc1 v0, $31 -#if _MIPS_FPSET == 32 - FPREG64_S($f20, JB_F20, a0) - FPREG64_S($f21, JB_F21, a0) - FPREG64_S($f22, JB_F22, a0) - FPREG64_S($f23, JB_F23, a0) - FPREG64_S($f24, JB_F24, a0) - FPREG64_S($f25, JB_F25, a0) - FPREG64_S($f26, JB_F26, a0) - FPREG64_S($f27, JB_F27, a0) - FPREG64_S($f28, JB_F28, a0) - FPREG64_S($f29, JB_F29, a0) - FPREG64_S($f30, JB_F30, a0) - FPREG64_S($f31, JB_F31, a0) -#else - swc1 $f20, JB_F20(a0) - swc1 $f21, JB_F21(a0) - swc1 $f22, JB_F22(a0) - swc1 $f23, JB_F23(a0) - swc1 $f24, JB_F24(a0) - swc1 $f25, JB_F25(a0) - swc1 $f26, JB_F26(a0) - swc1 $f27, JB_F27(a0) - swc1 $f28, JB_F28(a0) - swc1 $f29, JB_F29(a0) - swc1 $f30, JB_F30(a0) - swc1 $f31, JB_F31(a0) -#endif - REG_S v0, JB_FSR(a0) -#endif /* !SOFTFLOAT */ - move v0, zero - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ - j ra - -botch: - jal abort - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ -END(WRAP(setjmp)) - - -LEAF(WRAP(longjmp), FRAMESZ) - PTR_SUBU sp, FRAMESZ - SETUP_GP64(GPOFF, WRAP(longjmp)) - SAVE_GP(GPOFF) - .set reorder - sw a1, A1OFF(sp) - sw a0, A0OFF(sp) - - lw a0, JB_MASK(a0) - jal sigsetmask - - lw a0, A0OFF(sp) - lw a1, A1OFF(sp) - - .set noreorder - REG_L v0, JB_MAGIC(a0) - bne v0, MAGIC_SETJMP, botch # jump if error - REG_L ra, JB_PC(a0) - REG_L s0, JB_S0(a0) - REG_L s1, JB_S1(a0) - REG_L s2, JB_S2(a0) - REG_L s3, JB_S3(a0) - REG_L s4, JB_S4(a0) - REG_L s5, JB_S5(a0) - REG_L s6, JB_S6(a0) - REG_L s7, JB_S7(a0) - REG_L s8, JB_S8(a0) - REG_L gp, JB_GP(a0) - REG_L sp, JB_SP(a0) - -#if !defined(SOFTFLOAT) - REG_L v0, JB_FSR(a0) - ctc1 v0, $31 -#if _MIPS_FPSET == 32 - FPREG64_L($f20, JB_F20, a0) - FPREG64_L($f21, JB_F21, a0) - FPREG64_L($f22, JB_F22, a0) - FPREG64_L($f23, JB_F23, a0) - FPREG64_L($f24, JB_F24, a0) - FPREG64_L($f25, JB_F25, a0) - FPREG64_L($f26, JB_F26, a0) - FPREG64_L($f27, JB_F27, a0) - FPREG64_L($f28, JB_F28, a0) - FPREG64_L($f29, JB_F29, a0) - FPREG64_L($f30, JB_F30, a0) - FPREG64_L($f31, JB_F31, a0) -#else - lwc1 $f20, JB_F20(a0) - lwc1 $f21, JB_F21(a0) - lwc1 $f22, JB_F22(a0) - lwc1 $f23, JB_F23(a0) - lwc1 $f24, JB_F24(a0) - lwc1 $f25, JB_F25(a0) - lwc1 $f26, JB_F26(a0) - lwc1 $f27, JB_F27(a0) - lwc1 $f28, JB_F28(a0) - lwc1 $f29, JB_F29(a0) - lwc1 $f30, JB_F30(a0) - lwc1 $f31, JB_F31(a0) -#endif -#endif /* !SOFTFLOAT */ - bne a1, zero, 1f - nop - li a1, 1 # never return 0! -1: - j ra - move v0, a1 - -END(WRAP(longjmp)) diff --git a/ndk/sources/android/libportable/arch-mips/signal.c b/ndk/sources/android/libportable/arch-mips/signal.c deleted file mode 100644 index ae3fcb475..000000000 --- a/ndk/sources/android/libportable/arch-mips/signal.c +++ /dev/null @@ -1,1813 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PORTABLE_TAG "signal_portable" -#include - -/* for build against old platforms when SIGRT* defined instead of __SIGRT* */ -#ifndef __SIGRTMIN -#define __SIGRTMIN SIGRTMIN -#endif -#ifndef __SIGRTMAX -#define __SIGRTMAX SIGRTMAX -#endif - -#if SIGBUS_PORTABLE == SIGBUS -#error Bad build environment -#endif - -typedef void (*sig3handler_t)(int, siginfo_t *, void *); - -static volatile int signal_handler_mapping_enabled = 1; - -extern int syscall(int, ...); - - -__hidden void signal_disable_mapping() -{ - ALOGV("%s(): signal_handler_mapping_enabled:%d = 0;", __func__, - signal_handler_mapping_enabled); - - signal_handler_mapping_enabled = 0; -} - - -/* - * The next five hidden functions are not exposed in the - * libportable shared object. They are used here and other - * functions, like waitpid(), which need to map signal numbers. - */ -__hidden char *map_portable_signum_to_name(int portable_signum) -{ - char *name; - - switch(portable_signum) { - case 0: name = "SIG_0_PORTABLE:0"; break; - case SIGHUP_PORTABLE: name = "SIGHUP_PORTABLE:1"; break; - case SIGINT_PORTABLE: name = "SIGINT_PORTABLE:2"; break; - case SIGQUIT_PORTABLE: name = "SIGQUIT_PORTABLE:3"; break; - case SIGILL_PORTABLE: name = "SIGILL_PORTABLE:4"; break; - case SIGTRAP_PORTABLE: name = "SIGTRAP_PORTABLE:5"; break; - case SIGABRT_PORTABLE: name = "SIGABRT_PORTABLE:6"; break; - case SIGBUS_PORTABLE: name = "SIGBUS_PORTABLE:7"; break; - case SIGFPE_PORTABLE: name = "SIGFPE_PORTABLE:8"; break; - case SIGKILL_PORTABLE: name = "SIGKILL_PORTABLE:9"; break; - case SIGUSR1_PORTABLE: name = "SIGUSR1_PORTABLE:10"; break; - case SIGSEGV_PORTABLE: name = "SIGSEGV_PORTABLE:11"; break; - case SIGUSR2_PORTABLE: name = "SIGUSR2_PORTABLE:12"; break; - case SIGPIPE_PORTABLE: name = "SIGPIPE_PORTABLE:13"; break; - case SIGALRM_PORTABLE: name = "SIGALRM_PORTABLE:14"; break; - case SIGTERM_PORTABLE: name = "SIGTERM_PORTABLE:15"; break; - case SIGSTKFLT_PORTABLE: name = "SIGSTKFLT_PORTABLE:16"; break; - case SIGCHLD_PORTABLE: name = "SIGCHLD_PORTABLE:17"; break; - case SIGCONT_PORTABLE: name = "SIGCONT_PORTABLE:18"; break; - case SIGSTOP_PORTABLE: name = "SIGSTOP_PORTABLE:19"; break; - case SIGTSTP_PORTABLE: name = "SIGTSTP_PORTABLE:20"; break; - case SIGTTIN_PORTABLE: name = "SIGTTIN_PORTABLE:21"; break; - case SIGTTOU_PORTABLE: name = "SIGTTOU_PORTABLE:22"; break; - case SIGURG_PORTABLE: name = "SIGURG_PORTABLE:23"; break; - case SIGXCPU_PORTABLE: name = "SIGXCPU_PORTABLE:24"; break; - case SIGXFSZ_PORTABLE: name = "SIGXFSZ_PORTABLE:25"; break; - case SIGVTALRM_PORTABLE: name = "SIGVTALRM_PORTABLE:26"; break; - case SIGPROF_PORTABLE: name = "SIGPROF_PORTABLE:27"; break; - case SIGWINCH_PORTABLE: name = "SIGWINCH_PORTABLE:28"; break; - case SIGIO_PORTABLE: name = "SIGIO_PORTABLE:29"; break; - case SIGPWR_PORTABLE: name = "SIGPWR_PORTABLE:30"; break; - case SIGSYS_PORTABLE: name = "SIGSYS_PORTABLE:31"; break; - case SIGRTMIN_PORTABLE: name = "SIGRTMIN_PORTABLE:32"; break; - - case SIGRT_1_PORTABLE: name = "SIGRT_1_PORTABLE:33"; break; - case SIGRT_2_PORTABLE: name = "SIGRT_2_PORTABLE:34"; break; - case SIGRT_3_PORTABLE: name = "SIGRT_3_PORTABLE:35"; break; - case SIGRT_4_PORTABLE: name = "SIGRT_4_PORTABLE:36"; break; - case SIGRT_5_PORTABLE: name = "SIGRT_5_PORTABLE:37"; break; - case SIGRT_6_PORTABLE: name = "SIGRT_6_PORTABLE:38"; break; - case SIGRT_7_PORTABLE: name = "SIGRT_7_PORTABLE:39"; break; - case SIGRT_8_PORTABLE: name = "SIGRT_8_PORTABLE:40"; break; - case SIGRT_9_PORTABLE: name = "SIGRT_9_PORTABLE:41"; break; - case SIGRT_10_PORTABLE: name = "SIGRT_10_PORTABLE:42"; break; - case SIGRT_11_PORTABLE: name = "SIGRT_11_PORTABLE:43"; break; - case SIGRT_12_PORTABLE: name = "SIGRT_12_PORTABLE:44"; break; - case SIGRT_13_PORTABLE: name = "SIGRT_13_PORTABLE:45"; break; - case SIGRT_14_PORTABLE: name = "SIGRT_14_PORTABLE:46"; break; - case SIGRT_15_PORTABLE: name = "SIGRT_15_PORTABLE:47"; break; - case SIGRT_16_PORTABLE: name = "SIGRT_16_PORTABLE:48"; break; - case SIGRT_17_PORTABLE: name = "SIGRT_17_PORTABLE:49"; break; - case SIGRT_18_PORTABLE: name = "SIGRT_18_PORTABLE:50"; break; - case SIGRT_19_PORTABLE: name = "SIGRT_19_PORTABLE:51"; break; - case SIGRT_20_PORTABLE: name = "SIGRT_20_PORTABLE:52"; break; - case SIGRT_21_PORTABLE: name = "SIGRT_21_PORTABLE:53"; break; - case SIGRT_22_PORTABLE: name = "SIGRT_22_PORTABLE:54"; break; - case SIGRT_23_PORTABLE: name = "SIGRT_23_PORTABLE:55"; break; - case SIGRT_24_PORTABLE: name = "SIGRT_24_PORTABLE:56"; break; - case SIGRT_25_PORTABLE: name = "SIGRT_25_PORTABLE:57"; break; - case SIGRT_26_PORTABLE: name = "SIGRT_26_PORTABLE:58"; break; - case SIGRT_27_PORTABLE: name = "SIGRT_27_PORTABLE:59"; break; - case SIGRT_28_PORTABLE: name = "SIGRT_28_PORTABLE:60"; break; - case SIGRT_29_PORTABLE: name = "SIGRT_29_PORTABLE:61"; break; - case SIGRT_30_PORTABLE: name = "SIGRT_30_PORTABLE:62"; break; - case SIGRT_31_PORTABLE: name = "SIGRT_31_PORTABLE:63"; break; - case SIGRTMAX_PORTABLE: name = "SIGRTMAX_PORTABLE:64"; break; - - default: name = "<>"; break; - } - return name; -} - - -__hidden char *map_mips_signum_to_name(int mips_signum) -{ - char *name; - - switch(mips_signum) { - case 0: name = "SIG_0:0"; break; - case SIGHUP: name = "SIGHUP:1"; break; - case SIGINT: name = "SIGINT:2"; break; - case SIGQUIT: name = "SIGQUIT:3"; break; - case SIGILL: name = "SIGILL:4"; break; - case SIGTRAP: name = "SIGTRAP:5"; break; - case SIGIOT: name = "SIGIOT:6"; break; - case SIGEMT: name = "SIGEMT:7"; break; - case SIGFPE: name = "SIGFPE:8"; break; - case SIGKILL: name = "SIGKILL:9"; break; - case SIGBUS: name = "SIGBUS:10"; break; - case SIGSEGV: name = "SIGSEGV:11"; break; - case SIGSYS: name = "SIGSYS:12"; break; - case SIGPIPE: name = "SIGPIPE:13"; break; - case SIGALRM: name = "SIGALRM:14"; break; - case SIGTERM: name = "SIGTERM:15"; break; - case SIGUSR1: name = "SIGUSR1:16"; break; - case SIGUSR2: name = "SIGUSR2:17"; break; - case SIGCHLD: name = "SIGCHLD:18"; break; - case SIGPWR: name = "SIGPWR:19"; break; - case SIGWINCH: name = "SIGWINCH:20"; break; - case SIGURG: name = "SIGURG:21"; break; - case SIGIO: name = "SIGIO:22"; break; - case SIGSTOP: name = "SIGSTOP:23"; break; - case SIGTSTP: name = "SIGTSTP:24"; break; - case SIGCONT: name = "SIGCONT:25"; break; - case SIGTTIN: name = "SIGTTIN:26"; break; - case SIGTTOU: name = "SIGTTOU:27"; break; - case SIGVTALRM: name = "SIGVTALRM:28"; break; - case SIGPROF: name = "SIGPROF:29"; break; - case SIGXCPU: name = "SIGXCPU:30"; break; - case SIGXFSZ: name = "SIGXFSZ:31"; break; - - case __SIGRTMIN: name = "SIGRTMIN:32"; break; - case SIGRT_1: name = "SIGRT_1:33"; break; - case SIGRT_2: name = "SIGRT_2:34"; break; - case SIGRT_3: name = "SIGRT_3:35"; break; - case SIGRT_4: name = "SIGRT_4:36"; break; - case SIGRT_5: name = "SIGRT_5:37"; break; - case SIGRT_6: name = "SIGRT_6:38"; break; - case SIGRT_7: name = "SIGRT_7:39"; break; - case SIGRT_8: name = "SIGRT_8:40"; break; - case SIGRT_9: name = "SIGRT_9:41"; break; - case SIGRT_10: name = "SIGRT_10:42"; break; - case SIGRT_11: name = "SIGRT_11:43"; break; - case SIGRT_12: name = "SIGRT_12:44"; break; - case SIGRT_13: name = "SIGRT_13:45"; break; - case SIGRT_14: name = "SIGRT_14:46"; break; - case SIGRT_15: name = "SIGRT_15:47"; break; - case SIGRT_16: name = "SIGRT_16:48"; break; - case SIGRT_17: name = "SIGRT_17:49"; break; - case SIGRT_18: name = "SIGRT_18:50"; break; - case SIGRT_19: name = "SIGRT_19:51"; break; - case SIGRT_20: name = "SIGRT_20:52"; break; - case SIGRT_21: name = "SIGRT_21:53"; break; - case SIGRT_22: name = "SIGRT_22:54"; break; - case SIGRT_23: name = "SIGRT_23:55"; break; - case SIGRT_24: name = "SIGRT_24:56"; break; - case SIGRT_25: name = "SIGRT_25:57"; break; - case SIGRT_26: name = "SIGRT_26:58"; break; - case SIGRT_27: name = "SIGRT_27:59"; break; - case SIGRT_28: name = "SIGRT_28:60"; break; - case SIGRT_29: name = "SIGRT_29:61"; break; - case SIGRT_30: name = "SIGRT_30:62"; break; - case SIGRT_31: name = "SIGRT_31:63"; break; - case SIGRT_32: name = "SIGRT_32:64"; break; - - /* NOTE: SIGRT_33...SIGRTMAX-1 Not printed */ - - case __SIGRTMAX: name = "SIGRTMAX:128"; break; - default: name = "<>"; break; - } - return name; -} - - -/* - * Maps a signal number from portable to native. - */ -__hidden int signum_pton(int portable_signum) -{ - int mips_signum = -1; - - switch(portable_signum) { - - case 0: /* 0 */ - return 0; - - case SIGHUP_PORTABLE: /* 1 */ - return SIGHUP; - - case SIGINT_PORTABLE: /* 2 */ - return SIGINT; - - case SIGQUIT_PORTABLE: /* 3 */ - return SIGQUIT; - - case SIGILL_PORTABLE: /* 4 */ - return SIGILL; - - case SIGTRAP_PORTABLE: /* 5 */ - return SIGTRAP; - - case SIGABRT_PORTABLE: /* 6 */ - return SIGABRT; - - case SIGBUS_PORTABLE: /* 7 --> 10 */ - return SIGBUS; - - case SIGFPE_PORTABLE: /* 8 */ - return SIGFPE; - - case SIGKILL_PORTABLE: /* 9 */ - return SIGKILL; - - case SIGUSR1_PORTABLE: /* 10 --> 16 */ - return SIGUSR1; - - case SIGSEGV_PORTABLE: /* 11 */ - return SIGSEGV; - - case SIGUSR2_PORTABLE: /* 12 --> 17 */ - return SIGUSR2; - - case SIGPIPE_PORTABLE: /* 13 */ - return SIGPIPE; - - case SIGALRM_PORTABLE: /* 14 */ - return SIGALRM; - - case SIGTERM_PORTABLE: /* 15 */ - return SIGTERM; - - case SIGSTKFLT_PORTABLE: /* 16 --> 7 */ - return SIGEMT; /* No native SIGSTKFLT exist ... - ... mapping it to SIGEMT. */ - - case SIGCHLD_PORTABLE: /* 17 --> 18 */ - return SIGCHLD; - - case SIGCONT_PORTABLE: /* 18 --> 25 */ - return SIGCONT; - - case SIGSTOP_PORTABLE: /* 19 --> 23 */ - return SIGSTOP; - - case SIGTSTP_PORTABLE: /* 20 --> 24 */ - return SIGTSTP; - - case SIGTTIN_PORTABLE: /* 21 --> 26 */ - return SIGTTIN; - - case SIGTTOU_PORTABLE: /* 22 --> 27 */ - return SIGTTOU; - - case SIGURG_PORTABLE: /* 23 --> 21 */ - return SIGURG; - - case SIGXCPU_PORTABLE: /* 24 --> 30 */ - return SIGXCPU; - - case SIGXFSZ_PORTABLE: /* 25 --> 31 */ - return SIGXFSZ; - - case SIGVTALRM_PORTABLE: /* 26 --> 28 */ - return SIGVTALRM; - - case SIGPROF_PORTABLE: /* 27 --> 29 */ - return SIGPROF; - - case SIGWINCH_PORTABLE: /* 28 --> 20 */ - return SIGWINCH; - - case SIGIO_PORTABLE: /* 29 --> 22 */ - return SIGIO; - - case SIGPWR_PORTABLE: /* 30 --> 19 */ - return SIGPWR; - - case SIGSYS_PORTABLE: /* 31 --> 12 */ - return SIGSYS; - /* - * Mapping lower 32 Real Time signals to identical Native signal numbers. - * NOTE: SIGRTMAX_PORTABLE == 64 but SIGRTMAX == 128. - */ - case SIGRTMIN_PORTABLE...SIGRTMAX_PORTABLE: /* 32 ... 64 */ - ASSERT(SIGRTMIN_PORTABLE == __SIGRTMIN); - ASSERT(SIGRTMAX_PORTABLE <= __SIGRTMAX); - return portable_signum; - - default: - ALOGE("%s: switch default: NOTE portable_signum:%d Not supported. Just a Test?", - __func__, portable_signum); - /* - * User could be LTP testing with bogus signal numbers, - * if so we mimic the test. - * - * If the signal is just outside the PORTABLE range - * we use a signal just outside the Native/MIPS range. - */ - if (portable_signum < 0) { - mips_signum = portable_signum; - } else if (portable_signum > NSIG_PORTABLE) { - mips_signum = (portable_signum - NSIG_PORTABLE) + NSIG; - } else { - ALOGE("%s: 0 < portable_signum:%d <= NSIG_PORTABLE:%d; Not supported, return(0);", - __func__, portable_signum, NSIG_PORTABLE); - - mips_signum = 0; - } - break; - } - ALOGV("%s(portable_signum:%d): return(mips_signum:%d);", __func__, - portable_signum, mips_signum); - - return mips_signum; -} - - -/* - * Maps a signal number from native to portable. - */ -__hidden int signum_ntop(int mips_signum) -{ - int portable_ssignum = -1; - - switch(mips_signum) { - case 0: /* 0 */ - return 0; - - case SIGHUP: /* 1 */ - return SIGHUP_PORTABLE; - - case SIGINT: /* 2 */ - return SIGINT_PORTABLE; - - case SIGQUIT: /* 3 */ - return SIGQUIT_PORTABLE; - - case SIGILL: /* 4 */ - return SIGILL_PORTABLE; - - case SIGTRAP: /* 5 */ - return SIGTRAP_PORTABLE; - - case SIGABRT: /* 6 */ - return SIGABRT_PORTABLE; - - case SIGBUS: /* 7 <-- 10 */ - return SIGBUS_PORTABLE; - - case SIGFPE: /* 8 */ - return SIGFPE_PORTABLE; - - case SIGKILL: /* 9 */ - return SIGKILL_PORTABLE; - - case SIGUSR1: /* 10 <-- 16 */ - return SIGUSR1_PORTABLE; - - case SIGSEGV: /* 11 */ - return SIGSEGV_PORTABLE; - - case SIGUSR2: /* 12 <-- 17 */ - return SIGUSR2_PORTABLE; - - case SIGPIPE: /* 13 */ - return SIGPIPE_PORTABLE; - - case SIGALRM: /* 14 */ - return SIGALRM_PORTABLE; - - case SIGTERM: /* 15 */ - return SIGTERM_PORTABLE; - - case SIGEMT: /* 16 <--- 7 */ - return SIGSTKFLT_PORTABLE; /* No native SIGSTKFLT exist ... - ... reverse mapping SIGEMT ... - ... back to SIGSTKFLT. */ - - case SIGCHLD: /* 17 <-- 18 */ - return SIGCHLD_PORTABLE; - - case SIGCONT: /* 18 <-- 15 */ - return SIGCONT_PORTABLE; - - case SIGSTOP: /* 19 <-- 23 */ - return SIGSTOP_PORTABLE; - - case SIGTSTP: /* 20 <-- 24 */ - return SIGTSTP_PORTABLE; - - case SIGTTIN: /* 21 <-- 26 */ - return SIGTTIN_PORTABLE; - - case SIGTTOU: /* 22 <-- 27 */ - return SIGTTOU_PORTABLE; - - case SIGURG: /* 23 <-- 21 */ - return SIGURG_PORTABLE; - - case SIGXCPU: /* 24 <-- 30 */ - return SIGXCPU_PORTABLE; - - case SIGXFSZ: /* 25 <-- 31 */ - return SIGXFSZ_PORTABLE; - - case SIGVTALRM: /* 26 <-- 28 */ - return SIGVTALRM_PORTABLE; - - case SIGPROF: /* 27 <-- 29 */ - return SIGPROF_PORTABLE; - - case SIGWINCH: /* 28 <-- 20 */ - return SIGWINCH_PORTABLE; - - case SIGIO: /* 29 <-- 22 */ - return SIGIO_PORTABLE; - - case SIGPWR: /* 30 <-- 19 */ - return SIGPWR_PORTABLE; - - case SIGSYS: /* 31 <-- 12 */ - return SIGSYS_PORTABLE; - - /* - * Mapping lower 32 Real Time signals to identical Portable signal numbers. - * NOTE: SIGRTMAX_PORTABLE == 64 but SIGRTMAX == 128. - */ - case __SIGRTMIN...SIGRTMAX_PORTABLE: /* 32 ... 64 */ - ASSERT(__SIGRTMIN == SIGRTMIN_PORTABLE); - ASSERT(__SIGRTMAX >= SIGRTMAX_PORTABLE); - return mips_signum; - - /* - * Mapping upper 63 Native Real Time signals to the last Portable signal number. - * Shouldn't even be possible to be using these signals. - */ - case (SIGRTMAX_PORTABLE+1)...__SIGRTMAX: /* 65 ... 128 */ - ASSERT(__SIGRTMIN == SIGRTMIN_PORTABLE); - ASSERT(__SIGRTMAX >= SIGRTMAX_PORTABLE); - - ALOGE("%s: mips_signum:%d Can't be mapped to a unique portable signal;", __func__, - mips_signum); - - ALOGE("%s: Mapping highest 63 Real Time Signals to the largest RT Portable SigNo.", - __func__); - - return SIGRTMAX_PORTABLE; - - - default: - ALOGE("%s: switch default: mips_signum:%d Not supported! return(0);", __func__, - mips_signum); -#if 0 - LOG_FATAL("%s: mips_signum:%d is not portable;", __func__, mips_signum); -#endif - return 0; - } - return portable_ssignum; -} - - -/* - * Deal with siginfo structure being a bit different. - * Need to swap errno and code fields. - */ -static void siginfo_pton(siginfo_portable_t *portable_sip, siginfo_t *native_sip) -{ - - ALOGV("%s(portable_sip:%p, native_sip:%p) {", __func__, - portable_sip, native_sip); - - ASSERT(sizeof(siginfo_portable_t) == sizeof(siginfo_t)); - - /* - * Default to the same structure members, - * code and errno are swapped between ARM and MIPS, - * and errno needs to be translated. - * - * The signal number isn't translated, as the kernel - * will fill it it when it delivers the signal. - */ - - *native_sip = *((siginfo_t *)portable_sip); - native_sip->si_signo = 0; - native_sip->si_code = portable_sip->si_code; - native_sip->si_errno = errno_pton(portable_sip->si_errno); - - ALOGV("%s: return; }", __func__); -} - - -static void siginfo_ntop(siginfo_t *native_sip, siginfo_portable_t *portable_sip) -{ - - ALOGV("%s(native_sip,:%p, portable_sip:%p) {", __func__, - native_sip, portable_sip); - - ASSERT(sizeof(siginfo_portable_t) == sizeof(siginfo_t)); - - /* - * Structure assignment to default to the same structure members, - * as only the code and errno are swapped in position between - * ARM and MIPS; errno and signal number also need to be translated. - */ - *portable_sip = *((siginfo_portable_t *)native_sip); - - portable_sip->si_signo = signum_ntop(native_sip->si_signo); - portable_sip->si_code = native_sip->si_code; - portable_sip->si_errno = errno_ntop(native_sip->si_errno); - - ALOGV("%s: return; }", __func__); -} - - -/* - * Array of signal handlers as the portable users expects they - * they have been registered in the kernel. Problem is we need - * to have our own handler to map the MIPS signal number to a - * portable signal number. - */ -static sig3handler_portable_t mips_portable_sighandler[NSIG_PORTABLE + 1] = { NULL }; - -static void mips_sigaction_handler(int mips_signum, siginfo_t *sip, void *ucp) -{ - int portable_signum; - char *portable_signame; - char *mips_signame = map_mips_signum_to_name(mips_signum); - sig3handler_portable_t portable_sighandler; - siginfo_portable_t portable_si; - siginfo_portable_t *portable_sip; - - ALOGV(" "); - ALOGV("%s(mips_signum:%d:'%s', sip:%p, ucp:%p) {", __func__, - mips_signum, - mips_signame, sip, ucp); - - portable_signum = signum_ntop(mips_signum); - portable_signame = map_portable_signum_to_name(portable_signum); - portable_sighandler = mips_portable_sighandler[portable_signum]; - - if (invalid_pointer(portable_sighandler)) { - /* - * If a portable/ARM application tries to set signals in the signal mask > 32 - * it results in a signal_handler being set to -1:SIG_ERR. Calling a function - * at location -1 doesn't produce very informative Android backtraces on MIPS. - */ - ALOGE("%s: invalid_pointer(portable_sighandler:%p); Likely about to Trap or Bus Error!", - __func__, portable_sighandler); - - ALOGE("%s: HINT: Likely best to use gdbserver and look at sigaction arguments.", __func__); - } - ASSERT(portable_sighandler != NULL); - ASSERT(portable_sighandler != (sig3handler_portable_t) SIG_DFL); - ASSERT(portable_sighandler != (sig3handler_portable_t) SIG_IGN); - - if (sip == NULL) { - portable_sip = NULL; - } else { - /* Map signinfo from native to portable format */ - portable_sip = &portable_si; - siginfo_ntop(sip, portable_sip); - } - - - ALOGV("%s: Calling portable_sighandler:%p(portable_signum:%d, portable_sip:%p, ucp:%p);", - __func__, portable_sighandler, portable_signum, portable_sip, ucp); - - portable_sighandler(portable_signum, portable_sip, ucp); - - ALOGV("%s: return; }", __func__); -} - - -static void mips_sighandler(int mips_signum) -{ - int portable_signum; - char *portable_signame; - char *mips_signame = map_mips_signum_to_name(mips_signum); - sig3handler_portable_t portable_sighandler; - - ALOGV(" "); - ALOGV("%s(mips_signum:%d:'%s') {", __func__, mips_signum, mips_signame); - - mips_sigaction_handler(mips_signum, NULL, NULL); - - ALOGV("%s: return; }", __func__); -} - - -static sighandler_t sighandler_pton(sighandler_portable_t portable_handler, int sigaction) -{ - sighandler_t mips_handler; - - ALOGV("%s(portable_handler:%p, sigaction:%d) {", __func__, - portable_handler, sigaction); - - switch((int) portable_handler) { - case (int) SIG_DFL: - case (int) SIG_IGN: - mips_handler = portable_handler; - break; - - default: /* NOTE: Includes SIG_ERR:-1 */ - if (invalid_pointer(portable_handler)) { - /* - * Calling sigaction() with a bogus signal handler doesn't fail, - * so we let the portable cases fail later as the native case would. - */ - ALOGE("%s: invalid_pointer(portable_handler:%p)!", __func__, portable_handler); - ALOGE("%s: HINT: Likely to cause a BUS Error ....", __func__); - ALOGE("%s: HINT: ... when the signal handler is called!", __func__); - } - - /* - * Signal Mapping can be disabled in the rare case of the clone - * flags not being compatble for VM and file descriptors. - */ - if (signal_handler_mapping_enabled) { - if (sigaction) - mips_handler = (sighandler_t) mips_sigaction_handler; - else - mips_handler = (sighandler_t) mips_sighandler; - } else { - mips_handler = portable_handler; /* Don't MAP */ - } - break; - } - - ALOGV("%s: return(mips_handler:%p); }", __func__, mips_handler); - return mips_handler; -} - - -/* - * This function maps the signal number and calls one of the low level mips signal() - * functions implemented in libc/unistd/signal.c: - * sysv_signal() - * bsd_signal() - * - * The last 2 parameters to this static function, mips_signal_fn*, specify which of - * these functions to call. We intercept the above to functions, as well as signal(), - * and call the associated *_portable() functions below. - * - * In addition, we intercept the signal_handler with our own handlers that map the - * signal number from the MIPS convention to the PORTABLE/ARM convention. - */ -static sighandler_portable_t -do_signal_portable(int portable_signum, sighandler_portable_t portable_handler, - __sighandler_t (mips_signal_fn)(int, __sighandler_t)) -{ - char *portable_signame = map_portable_signum_to_name(portable_signum); - int mips_signum; - sighandler_t mips_handler; - sighandler_portable_t rv; - sighandler_portable_t prev_portable_handler; - - ALOGV("%s(portable_signum:%d:%s, portable_handler:%p, mips_signal_fn:%p) {", __func__, - portable_signum, - portable_signame, portable_handler, mips_signal_fn); - - mips_signum = signum_pton(portable_signum); - - if ((mips_signum <= 0) || (mips_signum > NSIG)) { - /* - * Invalid signal number, perhaps zero. Let the kernel generate the - * proper return value and set errno. - */ - mips_handler = sighandler_pton(portable_handler, 0); - rv = mips_signal_fn(mips_signum, mips_handler); - } else { - /* - * We have a usable signal number, redirect it to our signal handler - * if a portable handler was provided so we can convert the signal number. - * Save our current mapped signal handler for likely return. - */ - prev_portable_handler = (sighandler_portable_t) mips_portable_sighandler[portable_signum]; - - mips_handler = sighandler_pton(portable_handler, 0); - if (mips_handler != portable_handler) { - mips_portable_sighandler[portable_signum] = (sig3handler_portable_t) portable_handler; - } - rv = mips_signal_fn(mips_signum, mips_handler); - - if ((rv == (sighandler_portable_t) mips_sighandler) || - (rv == (sighandler_portable_t) mips_sigaction_handler)) { - - rv = (sighandler_t) prev_portable_handler; - } - } - - ALOGV("%s: return(rv:%p); }", __func__, rv); - return rv; -} - - -/* - * signal() can't be called directly, due to an in-line function in signal.h which - * redirects the call to bsd_signal(). _signal() is a static function; not to be called - * directly. This function isn't actually needed. - */ -sighandler_portable_t WRAP(signal)(int portable_signum, sighandler_portable_t handler) -{ - extern __sighandler_t REAL(bsd_signal)(int, __sighandler_t); - sighandler_portable_t rv; - - ALOGV(" "); - ALOGV("%s(portable_signum:%d, handler:%p) {", __func__, - portable_signum, handler); - - /* bsd does a SA_RESTART */ - rv = do_signal_portable(portable_signum, handler, REAL(bsd_signal)); - - ALOGV("%s: return(ret:%p); }", __func__, rv); - return rv; -} - - -sighandler_portable_t WRAP(sysv_signal)(int portable_signum, sighandler_portable_t handler) -{ - extern __sighandler_t REAL(sysv_signal)(int, __sighandler_t); - sighandler_portable_t rv; - - ALOGV(" "); - ALOGV("%s(portable_signum:%d, handler:%p) {", __func__, - portable_signum, handler); - - /* sysv does a SA_RESETHAND */ - rv = do_signal_portable(portable_signum, handler, REAL(sysv_signal)); - - ALOGV("%s: return(ret:%p); }", __func__, rv); - return rv; -} - - -/* - * NOTE: - * handler is either the Bionic - * bsd_signal() signal handler - * or - * the sysv_signal() signal handler. - */ - -sighandler_portable_t WRAP(bsd_signal)(int portable_signum, sighandler_portable_t handler) -{ - extern __sighandler_t REAL(bsd_signal)(int, __sighandler_t); - sighandler_portable_t rv; - - ALOGV(" "); - ALOGV("%s(portable_signum:%d, handler:%p) {", __func__, - portable_signum, handler); - - /* bsd does a SA_RESTART */ - rv = do_signal_portable(portable_signum, handler, REAL(bsd_signal)); - - ALOGV("%s: return(ret:%p); }", __func__, rv); - return rv; -} - - -static int do_kill(int id, int portable_signum, int (*fn)(int, int)) -{ - char *portable_signame = map_portable_signum_to_name(portable_signum); - int mips_signum; - int rv; - - ALOGV("%s(id:%d, portable_signum:%d:'%s', fn:%p) {", __func__, - id, portable_signum, - portable_signame, fn); - - mips_signum = signum_pton(portable_signum); - - /* - * SIG_0 gets passed down to the kernel to test for the existence of a process. - * If a non-zero portable_signum has been mapped to 0, - * it's unsupported and will be ignored. - */ - if ((portable_signum != 0) && (mips_signum == 0)) { - rv = 0; - } else { - ALOGV("%s: Calling fn:%p(id:%d, mips_signum:%d);", __func__, - fn, id, mips_signum); - - rv = fn(id, mips_signum); - } - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(killpg)(int pgrp, int portable_signum) -{ - extern int REAL(killpg)(int pgrp, int sig); - int rv; - - ALOGV(" "); - ALOGV("%s(pgrp:%d, portable_signum:%d) {", __func__, - pgrp, portable_signum); - - rv = do_kill(pgrp, portable_signum, REAL(killpg)); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(kill)(pid_t pid, int portable_signum) -{ - extern int REAL(kill)(pid_t, int); - int rv; - - ALOGV(" "); - ALOGV("%s(pid:%d, portable_signum:%d) {", __func__, - pid, portable_signum); - - rv = do_kill(pid, portable_signum, REAL(kill)); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -/* tgkill is not exported from android-14 libc.so */ -#if 0 -int WRAP(tgkill)(int tgid, int tid, int portable_signum) -{ - extern int tgkill(int, int, int); - char *portable_signame = map_portable_signum_to_name(portable_signum); - int mips_signum; - int rv; - - ALOGV("%s(tgid:%d, tid:%d, portable_signum:%d:'%s') {", __func__, - tgid, tid, portable_signum, portable_signame); - - mips_signum = signum_pton(portable_signum); - - /* - * If a non-zero portable_signum has been mapped to 0, - * it is unsupported and will be ignored. - */ - if ((portable_signum != 0) && (mips_signum == 0)) - rv = 0; - else - rv = REAL(tgkill)(tgid, tid, mips_signum); - - ALOGV("%s: return rv:%d; }", __func__, rv); - return rv; -} -#endif - - -int WRAP(raise)(int portable_signum) -{ - char *portable_signame = map_portable_signum_to_name(portable_signum); - int mips_signum = signum_pton(portable_signum); - int rv; - - ALOGV("%s(portable_signum:%d:'%s') {", __func__, portable_signum, portable_signame); - - /* - * SIG_0 gets passed down to the kernel to test for the existence of a process. - * If a non-zero portable_signum has been mapped to 0, - * it's unsupported and will be ignored. - */ - if ((portable_signum != 0) && (mips_signum == 0)) - rv = 0; - else - rv = REAL(raise)(mips_signum); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -void sigset_pton(sigset_portable_t *portable_sigset, sigset_t *mips_sigset) -{ - int portable_signum; - - ASSERT(mips_sigset != NULL); - - ALOGV("%s(portable_sigset:%p, mips_sigset:%p) {", __func__, - portable_sigset, mips_sigset); - - sigemptyset(mips_sigset); - if (invalid_pointer((void *)portable_sigset)) { - ALOGE("%s: portable_sigset:%p is not valid; returning empty set.", __func__, - portable_sigset); - goto done; - } - - for(portable_signum = 1; portable_signum <= NSIG_PORTABLE; portable_signum++) { - - if (WRAP(sigismember)(portable_sigset, portable_signum)) { - char *portable_signame = map_portable_signum_to_name(portable_signum); - int mips_signum = signum_pton(portable_signum); - char *mips_signame; - - if (mips_signum != 0) { - int err; - - mips_signame = map_mips_signum_to_name(mips_signum); - ALOGV("%s: sigaddset(mips_sigset:%p, mips_signum:%d:'%s');", __func__, - mips_sigset, mips_signum, - mips_signame); - - err = sigaddset(mips_sigset, mips_signum); - if (err == -1) { - PERROR("sigaddset"); - } - } - } - } - -done: - ALOGV("%s: return; }", __func__); - return; -} - - -void -sigset_ntop(const sigset_t *const_mips_sigset, sigset_portable_t *portable_sigset) -{ - int mips_signum; - sigset_t *mips_sigset = (sigset_t *) const_mips_sigset; - - ALOGV("%s(const_mips_sigset:%p, portable_sigset:%p) {", __func__, - const_mips_sigset, portable_sigset); - - ASSERT(mips_sigset != NULL); - - if (invalid_pointer((void *)portable_sigset)) { - ALOGE("%s: portable_sigset:%p is not Valid; can't return sigset", __func__, - portable_sigset); - goto done; - } - WRAP(sigemptyset)(portable_sigset); - - for(mips_signum = 1; mips_signum <= NSIG; mips_signum++) { - if (sigismember(mips_sigset, mips_signum)) { - int portable_signum = signum_ntop(mips_signum); - - if (portable_signum != 0) - WRAP(sigaddset)(portable_sigset, portable_signum); - } - } - -done: - ALOGV("%s: return; }", __func__); - return; -} - - -static int sigaction_flags_pton(int portable_flags) -{ - int mips_flags = 0; - - if (portable_flags & SA_NOCLDSTOP_PORTABLE) { - mips_flags |= SA_NOCLDSTOP; - } - if (portable_flags & SA_NOCLDWAIT_PORTABLE) { - mips_flags |= SA_NOCLDWAIT; - } - if (portable_flags & SA_SIGINFO_PORTABLE) { - mips_flags |= SA_SIGINFO; - } - if (portable_flags & SA_THIRTYTWO_PORTABLE) { - ALOGV("%s: SA_THIRTYTWO_PORTABLE isn't SUPPORTED.", __func__); - } - if (portable_flags & SA_RESTORER_PORTABLE) { - ALOGV("%s: SA_RESTORER isn't SUPPORTED.", __func__); - } - if (portable_flags & SA_ONSTACK_PORTABLE) { - mips_flags |= SA_ONSTACK; - } - if (portable_flags & SA_RESTART_PORTABLE) { - mips_flags |= SA_RESTART; - } - if (portable_flags & SA_NODEFER_PORTABLE) { - mips_flags |= SA_NODEFER; - } - if (portable_flags & SA_RESETHAND_PORTABLE) { - mips_flags |= SA_RESETHAND; - } - - ALOGV("%s(portable_flags:0x%x) return(mips_flags:0x%x);", __func__, - portable_flags, mips_flags); - - return mips_flags; -} - - -int sigaction_flags_ntop(int mips_flags) -{ - int portable_flags = 0; - - if (mips_flags & SA_NOCLDSTOP) portable_flags |= SA_NOCLDSTOP_PORTABLE; - if (mips_flags & SA_NOCLDWAIT) portable_flags |= SA_NOCLDWAIT_PORTABLE; - if (mips_flags & SA_SIGINFO) portable_flags |= SA_SIGINFO_PORTABLE; -#ifdef SA_THIRTYTWO - if (mips_flags & SA_THIRTYTWO) portable_flags |= SA_THIRTYTWO_PORTABLE; -#endif - if (mips_flags & SA_ONSTACK) portable_flags |= SA_ONSTACK_PORTABLE; - if (mips_flags & SA_RESTART) portable_flags |= SA_RESTART_PORTABLE; - if (mips_flags & SA_NODEFER) portable_flags |= SA_NODEFER_PORTABLE; - if (mips_flags & SA_RESETHAND) portable_flags |= SA_RESETHAND_PORTABLE; - - ALOGV("%s(mips_flags:0x%x) return(portable_flags:0x%x);", __func__, - mips_flags, portable_flags); - - return portable_flags; -} - - -/* - * Called by portable/ARM code, which we map and do MIPS system calls. - * - * The incoming system call used a Portable/ARM sigaction structure: - * ------------------------------------------------------------------ - * struct sigaction_portable { - * union { - * __sighandler_portable_t _sa_handler; - * __sigaction_handler_portable_t _sa_sigaction; - * } _u; - * sigset_portable_t sa_mask; - * unsigned long sa_flags; - * void (*sa_restorer)(void); - * }; - * - * A similar, but different, structure is used in the MIPS/Native system call: - * --------------------------------------------------------------------------- - * struct sigaction { - * unsigned int sa_flags; - * union { - * __sighandler_t sa_handler; - * __sigaction_handler_portable_t _sa_sigaction; - * } __u; - * sigset_t sa_mask; - * }; - * - * This sigaction structure needs to be mapped before the MIPS systems call as well as after for - * returning the old/previous sigaction. Also, like signal_portable() above, we need to maintain - * a table of signal handlers that our intercepting handler can call after it converts the signal - * numbers. - */ -static int do_sigaction_portable(int portable_signum, const struct sigaction_portable *act, - struct sigaction_portable *oldact, sigaction_fn fn, - rt_sigaction_fn rt_fn) -{ - int mips_signum; - char *mips_signame; - struct sigaction mips_act; - struct sigaction *mips_act_ptr; - struct sigaction mips_oldact; - sighandler_t mips_handler; - sighandler_portable_t portable_handler; - sig3handler_portable_t prev_portable_handler; - char *portable_signame = map_portable_signum_to_name(portable_signum); - int rv; - - ALOGV("%s(portable_signum:%d:'%s', act:%p, oldact:%p, fn:%p, rt_fn:%p) {", __func__, - portable_signum, - portable_signame, act, oldact, fn, rt_fn); - - mips_signum = signum_pton(portable_signum); - mips_signame = map_mips_signum_to_name(mips_signum); - - /* - * If a non-zero portable_signum has been mapped to 0, - * it's unsupported and will be ignored. - */ - if ((portable_signum != 0) && (mips_signum == 0)) { - rv = 0; - goto done; - } - if (portable_signum > 0 && portable_signum <= NSIG_PORTABLE) - prev_portable_handler = mips_portable_sighandler[portable_signum]; - else - prev_portable_handler = NULL; - - memset(&mips_act, 0, sizeof(mips_act)); - - if (invalid_pointer((void *)act)) { - mips_act_ptr = (struct sigaction *)act; - } else { - /* - * Make the MIPS version of sigaction, which has no sa_restorer function pointer. - * Also the handler will be called with a pointer to a to a sigcontext structure - * which is totally non-portable. - */ - sigset_pton(((sigset_portable_t *)&act->sa_mask), - ((sigset_t *) &mips_act.sa_mask)); - - mips_act.sa_flags = sigaction_flags_pton(act->sa_flags); - - if (mips_act.sa_flags & SA_SIGINFO) { - /* - * Providing the three argument version of a signal handler. - */ - portable_handler = (sighandler_portable_t) act->sa_sigaction_portable; - if ((portable_signum <= 0) || (portable_signum > NSIG_PORTABLE)) { - /* - * Let the kernel generate the proper return value and set errno. - */ - mips_act.sa_sigaction = (sig3handler_t) portable_handler; - } else { - mips_handler = sighandler_pton(portable_handler, 1); - if (mips_handler != portable_handler) { - mips_portable_sighandler[portable_signum] = - (sig3handler_portable_t) portable_handler; - } - mips_act.sa_sigaction = (sig3handler_t) mips_handler; - } - } else { - /* - * Providing the classic single argument version of a signal handler. - */ - portable_handler = act->sa_handler_portable; - if ((portable_signum <= 0) || (portable_signum > NSIG_PORTABLE)) { - /* - * Let the kernel generate the proper return value and set errno. - */ - mips_act.sa_handler = (sighandler_t) portable_handler; - } else { - mips_handler = sighandler_pton(portable_handler, 1); - if (mips_handler != portable_handler) { - mips_portable_sighandler[portable_signum] = - (sig3handler_portable_t) portable_handler; - } - mips_act.sa_handler = mips_handler; - } - } - mips_act_ptr = &mips_act; - } - - if (fn != NULL) { - ASSERT(rt_fn == NULL); - rv = fn(mips_signum, mips_act_ptr, &mips_oldact); - } else { - ASSERT(rt_fn != NULL); - rv = rt_fn(mips_signum, mips_act_ptr, &mips_oldact, sizeof(sigset_t)); - } - - if (rv == 0 && oldact) { - if (mips_oldact.sa_sigaction == (__sigaction_handler_portable_t) mips_sigaction_handler || - mips_oldact.sa_sigaction == (__sigaction_handler_portable_t) mips_sighandler) { - - oldact->sa_sigaction_portable = - (__sigaction_handler_portable_t) prev_portable_handler; - } else { - oldact->sa_sigaction_portable = - (__sigaction_handler_portable_t) mips_oldact.sa_sigaction; - } - sigset_ntop((sigset_t *) &(mips_oldact.sa_mask), - (sigset_portable_t *) &(oldact->sa_mask)); - - oldact->sa_flags = sigaction_flags_ntop(mips_oldact.sa_flags); - oldact->sa_restorer = NULL; - } - -done: - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(sigaction)(int portable_signum, const struct sigaction_portable *act, - struct sigaction_portable *oldact) -{ - extern int REAL(sigaction)(int, const struct sigaction *, struct sigaction *); - int rv; - - ALOGV(" "); - ALOGV("%s(portable_signum:%d, act:%p, oldact:%p) {", __func__, - portable_signum, act, oldact); - - rv = do_sigaction_portable(portable_signum, act, oldact, REAL(sigaction), NULL); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -/* - * Currently signalfd() isn't supported by bionic with - * only the portable syscall.c code using this code by - * intercepting the syscall(__NR_signalfd4, ...) in bionic. - */ -__hidden int do_signalfd4_portable(int fd, const sigset_portable_t *portable_sigmask, - int portable_sigsetsize, int portable_flags) -{ - sigset_t native_sigmask; - int native_sigsetsize = sizeof(native_sigmask); - int native_flags = 0; - int rv; - - ALOGV("%s(fd:%d, portable_sigmask:%p, portable_sigsetsize:%d, portable_flags:0x%x) {", - __func__, fd, portable_sigmask, portable_sigsetsize, portable_flags); - - sigset_pton((sigset_portable_t *)portable_sigmask, &native_sigmask); - - if (portable_flags & SFD_NONBLOCK_PORTABLE) { - native_flags |= SFD_NONBLOCK; - } - if (portable_flags & SFD_CLOEXEC_PORTABLE) { - native_flags |= SFD_CLOEXEC; - } - rv = syscall(__NR_signalfd4, fd, &native_sigmask, native_sigsetsize, native_flags); - - if (rv >= 0) { - if (native_flags & SFD_CLOEXEC) { - filefd_CLOEXEC_enabled(rv); - } - - /* - * Reads on this file descriptor must be mapped to be portable. - * The mapping should survive a fork and most clones naturally. - * For the system call to be completely portable it has to propagate - * these mapped files after an execve(). Environment variables have - * been added to do that. See filefd.c for details. - */ - filefd_opened(rv, SIGNAL_FD_TYPE); - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -#if 0 -/* - * signalfd() isn't available in Bionic yet. When it is, it will be implemented like - * the glibc version where the sigsetsize is computed in the bionic code and passed - * down to the kernel with __NR_signalfd4. - * - * This function can't be called from bionic, so there isn't an entry in the experimental - * linker.cpp table for testing and this function. - */ -int WRAP(signalfd)(int fd, const sigset_portable_t *portable_sigmask, int portable_flags) -{ - int portable_sigsetsize = sizeof(sigset_portable_t); - int rv; - - ALOGV("%s(fd:%d, portable_sigmask:%p, portable_flags:0x%x) {", __func__, - fd, portable_sigmask, portable_flags); - - rv = do_signalfd4_portable(fd, portable_sigsetsize, portable_sigmask, portable_flags); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} -#endif - - -/* - * Called by read_portable() to do signalfd read() mapping. - */ -__hidden int read_signalfd_mapper(int fd, void *buf, size_t count) -{ - int rv; - - ALOGV("%s(fd:%d, buf:0x%p, count:%d) {", __func__, - fd, buf, count); - - rv = read(fd, buf, count); - if (rv > 0) { - int siginfos = rv/sizeof(struct signalfd_siginfo); - struct signalfd_siginfo *si = (struct signalfd_siginfo *) buf; - int i; - - /* Read signalfd_siginfo structure(s) if read is large enough */ - for (i = 0; i < siginfos; i++, si++) { - int ssi_signo; - - ssi_signo = si->ssi_signo; - si->ssi_signo = signum_ntop(si->ssi_signo); - ALOGV("%s: si->ssi_signo:%d = signum_ntop(si->ssi_signo:%d); i:%d", __func__, - si->ssi_signo, ssi_signo, i); - - si->ssi_errno = errno_ntop(si->ssi_errno); - - /* - * The ssi_codes appear to be generic; defined in - * the kernel in include/asm-generic/siginfo.h - */ - if (si->ssi_status > 0 && si->ssi_status <= NSIG) { - si->ssi_status = signum_ntop(si->ssi_status); - } - - /* - * The rest of the struct members, like - * ssi_trapno, ssi_int, ssi_ptr - * are not likely worth dealing with. - */ - } - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - -int WRAP(sigsuspend)(const sigset_portable_t *portable_sigmask) -{ - int rv; - sigset_t mips_sigmask; - - ALOGV("%s(portable_sigmask:%p) {", __func__, portable_sigmask); - - if (invalid_pointer((void *)portable_sigmask)) { - *REAL(__errno)() = EFAULT; - rv = -1; - } else { - sigset_pton((sigset_portable_t *)portable_sigmask, &mips_sigmask); - rv = REAL(sigsuspend)(&mips_sigmask); - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(sigpending)(sigset_portable_t *portable_sigset) -{ - int rv; - sigset_t mips_sigset; - - ALOGV("%s(portable_sigset:%p) {", __func__, - portable_sigset); - - if (invalid_pointer((void *)portable_sigset)) { - *REAL(__errno)() = EFAULT; - rv = -1; - } else { - rv = REAL(sigpending)(&mips_sigset); - sigset_ntop(&mips_sigset, portable_sigset); - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(sigwait)(const sigset_portable_t *portable_sigset, int *ptr_to_portable_sig) -{ - int rv; - sigset_t mips_sigset; - int mips_sig; - int portable_sig; - - ALOGV("%s(portable_sigset:%p, ptr_to_portable_sig:%p) {", __func__, - portable_sigset, ptr_to_portable_sig); - - if (invalid_pointer((void *)portable_sigset)) { - *REAL(__errno)() = EFAULT; - rv = -1; - } else { - sigset_pton((sigset_portable_t *)portable_sigset, &mips_sigset); - - rv = REAL(sigwait)(&mips_sigset, &mips_sig); - - portable_sig = signum_ntop(mips_sig); - *ptr_to_portable_sig = portable_sig; - } - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(siginterrupt)(int portable_signum, int flag) - -{ - int rv; - int mips_signum; - - ALOGV("%s(portable_signum:%d, flag:0x%x) {", __func__, - portable_signum, flag); - - mips_signum = signum_pton(portable_signum); - - /* - * If a non-zero portable_signum has been mapped to 0, - * it's unsupported and will be ignored. - */ - if ((portable_signum != 0) && (mips_signum == 0)) { - rv = 0; - } else { - rv = REAL(siginterrupt)(mips_signum, flag); - } - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -__hidden int do_sigmask(int portable_how, const sigset_portable_t *portable_sigset, - sigset_portable_t *portable_oldset, sigmask_fn fn, - rt_sigmask_fn rt_fn) -{ - int rv; - int how; - char *how_name; - sigset_t mips_sigset, *mips_sigset_p; - sigset_t mips_oldset, *mips_oldset_p; - - ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p, fn:%p, rt_fn:%p) {", - __func__, portable_how, portable_sigset, portable_oldset, fn, rt_fn); - - switch(portable_how) { - case SIG_BLOCK_PORTABLE: how = SIG_BLOCK; how_name = "SIG_BLOCK"; break; - case SIG_UNBLOCK_PORTABLE: how = SIG_UNBLOCK; how_name = "SIG_UNBLOCK"; break; - case SIG_SETMASK_PORTABLE: how = SIG_SETMASK; how_name = "SIG_SETMASK"; break; - - default: - ALOGE("%s: portable_how:%d NOT SUPPORTED!", __func__, portable_how); - how = -1; - break; - } - - if (invalid_pointer((void *)portable_sigset)) { - mips_sigset_p = (sigset_t *) portable_sigset; - } else { - mips_sigset_p = &mips_sigset; - memset(mips_sigset_p, 0, sizeof(mips_sigset)); - sigemptyset(mips_sigset_p); - sigset_pton((sigset_portable_t *)portable_sigset, &mips_sigset); - } - - if (invalid_pointer((void *)portable_oldset)) { - mips_oldset_p = (sigset_t *) portable_oldset; - } else { - mips_oldset_p = &mips_oldset; - memset(mips_oldset_p, 0, sizeof(mips_oldset)); - sigemptyset(mips_oldset_p); - } - - if (fn != NULL) { - ASSERT(rt_fn == NULL); - rv = fn(how, mips_sigset_p, mips_oldset_p); - } else { - ASSERT(rt_fn != NULL); - rv = rt_fn(how, mips_sigset_p, mips_oldset_p, sizeof(sigset_t)); - } - - if (rv == 0 && !invalid_pointer(portable_oldset)) { - /* Map returned mips_oldset to portable_oldset for return to caller */ - sigset_ntop(mips_oldset_p, portable_oldset); - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(sigprocmask)(int portable_how, const sigset_portable_t *portable_sigset, - sigset_portable_t *portable_oldset) -{ - extern int REAL(sigprocmask)(int, const sigset_t *, sigset_t *); - int rv; - - ALOGV(" "); - ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p) {", __func__, - portable_how, portable_sigset, portable_oldset); - - rv = do_sigmask(portable_how, portable_sigset, portable_oldset, REAL(sigprocmask), NULL); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(__rt_sigaction)(int portable_signum, const struct sigaction_portable *act, - struct sigaction_portable *oldact, size_t sigsetsize) -{ - extern int REAL(__rt_sigaction)(int , const struct sigaction *, struct sigaction *, size_t); - int rv; - - ALOGV(" "); - ALOGV("%s(portable_signum:%d, act:%p, oldset:%p, sigsetsize:%d) {", __func__, - portable_signum, act, oldact, sigsetsize); - - /* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */ - if (sigsetsize != (2* sizeof(long))) { - *REAL(__errno)() = EINVAL; - rv = -1; - goto done; - } - rv = do_sigaction_portable(portable_signum, act, oldact, NULL, REAL(__rt_sigaction)); - -done: - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - -int WRAP(__rt_sigprocmask)(int portable_how, - const sigset_portable_t *portable_sigset, - sigset_portable_t *portable_oldset, - size_t sigsetsize) -{ - extern int REAL(__rt_sigprocmask)(int, const sigset_t *, sigset_t *, size_t); - int rv; - - ALOGV(" "); - ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p, sigsetsize:%d) {", - __func__, portable_how, portable_sigset, portable_oldset, sigsetsize); - - /* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */ - if (sigsetsize != (2* sizeof(long))) { - *REAL(__errno)() = EINVAL; - rv = -1; - goto done; - } - rv = do_sigmask(portable_how, portable_sigset, portable_oldset, NULL, REAL(__rt_sigprocmask)); - - done: - ALOGV("%s: return(rv:%d); }", __func__, rv); - - return rv; -} - - -int WRAP(__rt_sigtimedwait)(const sigset_portable_t *portable_sigset, - siginfo_portable_t *portable_siginfo, - const struct timespec *timeout, - size_t portable_sigsetsize) -{ - extern int REAL(__rt_sigtimedwait)(const sigset_t *, siginfo_t *, const struct timespec *, size_t); - - sigset_t native_sigset_struct; - sigset_t *native_sigset = &native_sigset_struct; - siginfo_t native_siginfo_struct; - siginfo_t *native_siginfo; - int rv; - - ALOGV(" "); - ALOGV("%s(portable_sigset:%p, portable_siginfo:%p, timeout:%p, portable_sigsetsize:%d) {", - __func__, portable_sigset, portable_siginfo, timeout, portable_sigsetsize); - - /* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */ - if (portable_sigsetsize != (2* sizeof(long))) { - *REAL(__errno)() = EINVAL; - rv = -1; - goto done; - } - if (portable_sigset == NULL) { - native_sigset = NULL; - } else { - sigset_pton((sigset_portable_t *)portable_sigset, native_sigset); - } - if (portable_siginfo == NULL) { - native_siginfo = NULL; - } else { - native_siginfo = &native_siginfo_struct; - } - rv = REAL(__rt_sigtimedwait)(native_sigset, native_siginfo, timeout, sizeof(sigset_t)); - if (rv == 0 && native_siginfo != NULL) { - /* Map siginfo struct from native to portable format. */ - siginfo_ntop(native_siginfo, portable_siginfo); - } - -done: - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -#ifdef __NR_rt_sigqueueinfo - -#if 0 -/* - * sigqueue(): - * This function became available in UNIX GLIBC after 1993. - * It's not available in any versions of Android yet, and - * it can't be called via syscall(). It's been useful for - * testing with the LTP by the posix testsuite, and tests - * show that it works fine. - * - * NOTE: - * Android has in incorrect limit on the number of queueable signals - * defined in libc/unistd/sysconf.c: - * - * #define SYSTEM_SIGQUEUE_MAX 32 - * - * sigqueue() must return EAGAIN if exceeded and we don't on Android. - */ -int WRAP(sigqueue)(pid_t pid, int portable_sig, const union sigval value) -{ - siginfo_t native_siginfo; - siginfo_t *native_sip; - siginfo_portable_t portable_siginfo; - siginfo_portable_t *portable_sip; - int native_sig; - int rv; - - ALOGV(" "); - ALOGV("%s(pid:%d, portable_sig:%d, value:%p) {", __func__, - pid, portable_sig, value.sival_ptr); - - native_sig = signum_pton(portable_sig); - native_sip = &native_siginfo; - - portable_sip = &portable_siginfo; - portable_sip->si_signo = 0; /* Filled in by the kernel */ - portable_sip->si_code = SI_QUEUE; - portable_sip->si_pid = getpid(); /* Process ID of sender */ - portable_sip->si_uid = getuid(); /* Real UID of sender */ - portable_sip->si_value = value; /* Last arg supplied */ - - siginfo_pton(portable_sip, native_sip); - - /* - * man page says sigqueue() is implemented via rt_sigqueueinfo(). - */ - ALOGV("%s: calling syscall(__NR_rt_sigqueueinfo:%d, pid:%d, native_sig:%d, native_sip:%p);", - __func__, __NR_rt_sigqueueinfo, pid, native_sig, native_sip); - - rv = syscall(__NR_rt_sigqueueinfo, pid, native_sig, native_sip); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} -#endif - - -/* - * Real Time version of sigqueueinfo(). - */ -int WRAP(rt_sigqueueinfo)(pid_t pid, int portable_sig, siginfo_portable_t *portable_sip) -{ - int native_sig; - siginfo_t native_siginfo, *native_sip; - int rv; - - ALOGV(" "); - ALOGV("%s(pid:%d, portable_sig:%d, portable_sip:%p) {", __func__, - pid, portable_sig, portable_sip); - - native_sig = signum_pton(portable_sig); - - /* - * If a non-zero portable_signum has been mapped to 0, - * it's unsupported and will be ignored. - */ - if ((portable_sig != 0) && (native_sig == 0)) { - rv = 0; - goto done; - } - - if (portable_sip != NULL) { - native_sip = &native_siginfo; - siginfo_pton(portable_sip, native_sip); - } else { - native_sip = NULL; - } - rv = syscall(__NR_rt_sigqueueinfo, pid, native_sig, native_sip); - -done: - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} -#endif /* __NR_rt_sigqueueinfo */ - - -#ifdef __NR_rt_tgsigqueueinfo -/* - * Thread Group flavor of the real time version of sigqueueinfo(). - */ -int WRAP(rt_tgsigqueueinfo)(pid_t tgid, pid_t pid, int portable_sig, - siginfo_portable_t *portable_sip) -{ - siginfo_t native_siginfo, *native_sip; - int native_sig; - int rv; - - ALOGV(" "); - ALOGV("%s(tgid:%d, pid:%d, portable_sig:%d, portable_sip:%p) {", __func__, - tgid, pid, portable_sig, portable_sip); - - native_sig = signum_pton(portable_sig); - - /* - * If a non-zero portable_signum has been mapped to 0, - * it's unsupported and will be ignored. - */ - if ((portable_sig != 0) && (native_sig == 0)) { - rv = 0; - goto done; - } - if (portable_sip != NULL) { - native_sip = &native_siginfo; - siginfo_pton(portable_sip, native_sip); - } else { - native_sip = NULL; - } - rv = syscall(__NR_rt_tgsigqueueinfo, pid, native_sig, native_sip); - -done: - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} -#endif /* __NR_rt_tgsigqueueinfo */ - - -/* - * ss_flags and ss_size are located in different locations in stack_t structure: - * - * Incomming ARM/Portable stack_t: Outgoing MIPS stack_t: - * ------------------------------- ---------------------------- - * typedef struct sigaltstack { typedef struct sigaltstack { - * void __user *ss_sp; void *ss_sp; - * int ss_flags; size_t ss_size; - * size_t ss_size; int ss_flags; - * } stack_t; - * - */ -int WRAP(sigaltstack)(const portable_stack_t *ss, portable_stack_t *oss) -{ - int rv; - stack_t new_stack, *mips_ss; - stack_t old_stack, *mips_oss; - - ALOGV(" "); - ALOGV("%s(ss:%p, oss:%p) {", __func__, ss, oss); - - if (ss == NULL) { - mips_ss = NULL; - } else { - if (invalid_pointer((void *)ss)) { - ALOGE("%s: invalid_pointer(ss:%p): Let kernel set proper errno and set return value.", - __func__, ss); - - mips_ss = (stack_t *) ss; - } else { - memset(&new_stack, 0, sizeof(stack_t)); - new_stack.ss_sp = ss->ss_sp; - new_stack.ss_flags = ss->ss_flags; - new_stack.ss_size = ss->ss_size; - mips_ss = &new_stack; - } - } - if (oss == NULL) { - mips_oss = NULL; - } else { - if (invalid_pointer((void *)oss)) { - ALOGE("%s: invalid_pointer(oss:%p): Let kernel set proper errno and return value.", - __func__, oss); - - mips_oss = (stack_t *)oss; - } else { - memset(&old_stack, 0, sizeof(stack_t)); - mips_oss = &old_stack; - } - } - - rv = REAL(sigaltstack)(mips_ss, mips_oss); - - if (!invalid_pointer(oss)) { - oss->ss_sp = old_stack.ss_sp; - oss->ss_flags = old_stack.ss_flags; - oss->ss_size = old_stack.ss_size; - } - ALOGV("%s: return(rv:%d); }", __func__, rv); - - return rv; -} diff --git a/ndk/sources/android/libportable/arch-mips/sigsetjmp.S b/ndk/sources/android/libportable/arch-mips/sigsetjmp.S deleted file mode 100644 index 237d46b50..000000000 --- a/ndk/sources/android/libportable/arch-mips/sigsetjmp.S +++ /dev/null @@ -1,78 +0,0 @@ -/* Derived from: $OpenBSD: sigsetjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */ -/*- - * Copyright (c) 1991, 1993, 1995, - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Havard Eidnes. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -#include "jboffsets.h" - -/* - * trampolines for sigsetjmp and siglongjmp save and restore mask. - */ -FRAMESZ= MKFSIZ(1,1) -GPOFF= FRAMESZ-2*REGSZ - -LEAF(WRAP(sigsetjmp), FRAMESZ) - PTR_SUBU sp, FRAMESZ - SETUP_GP64(GPOFF, sigsetjmp) - .set reorder - REG_S a1, JB_SAVEMASK(a0) # save "savemask" - bne a1, 0x0, 1f # do saving of signal mask? - LA t9, _setjmp_portable - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ - jr t9 - -1: LA t9, WRAP(setjmp) - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ - jr t9 -END(WRAP(sigsetjmp)) - -LEAF(WRAP(siglongjmp), FRAMESZ) - PTR_SUBU sp, FRAMESZ - SETUP_GP64(GPOFF, WRAP(siglongjmp)) - .set reorder - REG_L t0, JB_SAVEMASK(a0) # get "savemask" - bne t0, 0x0, 1f # restore signal mask? - LA t9, _longjmp_portable - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ - jr t9 -1: - LA t9, WRAP(longjmp) - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ - jr t9 -END(WRAP(siglongjmp)) diff --git a/ndk/sources/android/libportable/arch-mips/socket.c b/ndk/sources/android/libportable/arch-mips/socket.c deleted file mode 100644 index be2c7e6ed..000000000 --- a/ndk/sources/android/libportable/arch-mips/socket.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define PORTABLE_TAG "socket_portable" -#include - - -#if SOCK_STREAM==SOCK_STREAM_PORTABLE -#error Bad build environment -#endif - -/* LTP defaults to using O_NONBLOCK if SOCK_NONBLOCK is not defined. */ -#ifndef SOCK_NONBLOCK_PORTABLE -# define SOCK_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE -#endif -#ifndef SOCK_NONBLOCK -# define SOCK_NONBLOCK O_NONBLOCK -#endif - -/* Current NDK headers do not define SOCK_CLOEXEC or O_CLOEXEC */ -#if !defined(SOCK_CLOEXEC_PORTABLE) && defined(O_CLOEXEC_PORTABLE) -# define SOCK_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE -#endif -#if !defined(SOCK_CLOEXEC) && defined(O_CLOEXEC) -# define SOCK_CLOEXEC O_CLOEXEC -#endif - - -/* - * Portable to Native socktype mapper. - */ -static inline int socktype_pton(int portable_type) -{ - int native_type = 0; - - ALOGV("%s(portable_type:0x%x) {", __func__, portable_type); - - if (portable_type & SOCK_NONBLOCK_PORTABLE) { - native_type |= SOCK_NONBLOCK; - portable_type &= ~SOCK_NONBLOCK_PORTABLE; - } - -#if defined(SOCK_CLOEXEC_PORTABLE) && defined(SOCK_CLOEXEC) - if (portable_type & SOCK_CLOEXEC_PORTABLE) { - native_type |= SOCK_CLOEXEC; - portable_type &= ~SOCK_CLOEXEC_PORTABLE; - } -#endif - - switch (portable_type) { - case SOCK_STREAM_PORTABLE: native_type |= SOCK_STREAM; break; - case SOCK_DGRAM_PORTABLE: native_type |= SOCK_DGRAM; break; - case SOCK_RAW_PORTABLE: native_type |= SOCK_RAW; break; - case SOCK_RDM_PORTABLE: native_type |= SOCK_RDM; break; - case SOCK_SEQPACKET_PORTABLE: native_type |= SOCK_SEQPACKET; break; - case SOCK_PACKET_PORTABLE: native_type |= SOCK_PACKET; break; - default: - ALOGE("%s: case default: native_type:0x%x |= portable_type:0x%x:[UNKNOWN!];", __func__, - native_type, portable_type); - - native_type |= portable_type; - break; - } - ALOGV("%s: return(native_type:%d); }", __func__, native_type); - return native_type; -} - - -/* - * Native to Portable socktype mapper. - */ -static inline int socktype_ntop(int native_type) -{ - int portable_type = 0; - - ALOGV("%s(native_type:0x%x) {", __func__, native_type); - - if (native_type & SOCK_NONBLOCK) { - portable_type |= SOCK_NONBLOCK_PORTABLE; - native_type &= ~SOCK_NONBLOCK; - } - -#if defined(SOCK_CLOEXEC_PORTABLE) && defined(SOCK_CLOEXEC) - if (native_type & SOCK_CLOEXEC) { - portable_type |= SOCK_CLOEXEC_PORTABLE; - native_type &= ~SOCK_CLOEXEC; - } -#endif - - switch (native_type) { - case SOCK_STREAM: portable_type |= SOCK_STREAM_PORTABLE; break; - case SOCK_DGRAM: portable_type |= SOCK_DGRAM_PORTABLE; break; - case SOCK_RAW: portable_type |= SOCK_RAW_PORTABLE; break; - case SOCK_RDM: portable_type |= SOCK_RDM_PORTABLE; break; - case SOCK_SEQPACKET: portable_type |= SOCK_SEQPACKET_PORTABLE; break; - case SOCK_PACKET: portable_type |= SOCK_PACKET_PORTABLE; break; - default: - portable_type |= native_type; - ALOGE("%s: case default: portable_type:0x%x |= native_type:0x%x:[UNKNOWN!];", __func__, - portable_type, native_type); - } - ALOGV("%s: return(portable_type:%d); }", __func__, portable_type); - return portable_type; -} - - -extern int REAL(socket)(int, int, int); - -int WRAP(socket)(int domain, int type, int protocol) { - int rv; - - ALOGV(" "); - ALOGV("%s(domain:%d, type:%d, protocol:%d) {", __func__, - domain, type, protocol); - - rv = REAL(socket)(domain, socktype_pton(type), protocol); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(socketpair)(int domain, int type, int protocol, int sv[2]) { - int rv; - - ALOGV(" "); - ALOGV("%s(domain:%d, type:%d, protocol:%d, sv[2]:%p) {", __func__, - domain, type, protocol, sv); - - rv = REAL(socketpair)(domain, socktype_pton(type), protocol, sv); - - if ((rv != 0) || invalid_pointer(sv)) { - ALOGV("%s: return(rv:%d); }", __func__, - rv); - } else { - ALOGV("%s: return(rv:%d); sv[0]:%d; sv[1]:%d;}", __func__, - rv, sv[0], sv[1]); - } - return rv; -} - -#define PRINT_ADDRINFO(p) { \ - ALOGV("%s: p:%p->{ai_flags:%d, ai_family:%d, ai_socktype:%d, ai_protocol:%d, ...", __func__, \ - p, p->ai_flags, p->ai_family, p->ai_socktype, p->ai_protocol); \ - \ - ALOGV("%s: p:%p->{... ai_addrlen:%d, ai_addr:%p, ai_canonname:%p, p->ai_next:%p);", __func__,\ - p, p->ai_addrlen, p->ai_addr, p->ai_canonname, p->ai_next); \ -} - -/* - * Returns a list of portable addrinfo structures that are - * later made free with a call to the portable version of - * freeaddrinfo(); which is written below this function. - */ -int WRAP(getaddrinfo)(const char *node, const char *service, - struct addrinfo_portable *portable_hints, - struct addrinfo_portable **portable_results) -{ - int rv; - struct addrinfo *native_hints; - struct addrinfo **native_results, *rp; - int saved_portable_socktype; - - ALOGV(" "); - ALOGV("%s(node:%p, service:%p, portable_hints:%p, portable_results:%p) {", __func__, - node, service, portable_hints, portable_results); - - PRINT_ADDRINFO(portable_hints); - - /* - * The only part of the addrinfo structure that needs to be modified - * between ARM and MIPS is the socktype; - */ - ASSERT(sizeof(struct addrinfo_portable) == sizeof(struct addrinfo)); - native_hints = ((struct addrinfo *) portable_hints); - if (native_hints != NULL) { - saved_portable_socktype = portable_hints->ai_socktype; - native_hints->ai_socktype = socktype_pton(saved_portable_socktype); - } - ASSERT(portable_results != NULL); - native_results = (struct addrinfo **) portable_results; - - rv = REAL(getaddrinfo)(node, service, native_hints, native_results); - - if (native_hints != NULL) { - portable_hints->ai_socktype = saved_portable_socktype; - } - - - /* - * Map socktypes in the return list of addrinfo structures from native to portable. - * Assuming getaddrinfo() has left structure writeable and the list is generated - * on each call. This seems to be true when looking at the man page and the code - * at: - * ./bionic/libc/netbsd/net/getaddrinfo.c - */ - for (rp = *native_results; rp != NULL; rp = rp->ai_next) { - PRINT_ADDRINFO(rp); - rp->ai_socktype = socktype_ntop(rp->ai_socktype); - } - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -/* - * Free the results list returned from a previous call - * to the portable version of getaddrinfo(). - */ -void WRAP(freeaddrinfo)(struct addrinfo_portable *portable_results) -{ - struct addrinfo *native_results, *rp; - - ALOGV(" "); - ALOGV("%s(portable_results:%p) {", __func__, portable_results); - - PRINT_ADDRINFO(portable_results); - - /* - * The only part of each addrinfo structure that needs to be modified - * between ARM and MIPS is the socktype; - * - * Map socktypes in the return list of iportable addrinfo structures back to native. - * Again, assuming getaddrinfo() has left structure writeable and the list is generated - * on each call. This seems to be true when looking at the man page and the code. - */ - ASSERT(sizeof(struct addrinfo_portable) == sizeof(struct addrinfo)); - native_results = ((struct addrinfo *) portable_results); - for (rp = native_results; rp != NULL; rp = rp->ai_next) { - PRINT_ADDRINFO(rp); - rp->ai_socktype = socktype_pton(rp->ai_socktype); /* Likely not really necessary */ - } - REAL(freeaddrinfo)(native_results); - - ALOGV("%s: return; }", __func__); - return; -} diff --git a/ndk/sources/android/libportable/arch-mips/sockopt.c b/ndk/sources/android/libportable/arch-mips/sockopt.c deleted file mode 100644 index 6c7ec51a8..000000000 --- a/ndk/sources/android/libportable/arch-mips/sockopt.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -#if SOL_SOCKET_PORTABLE==SOL_SOCKET -#error Build environment -#endif - -static inline int mips_change_level(int level) -{ - switch (level) { - case SOL_SOCKET_PORTABLE: - level = SOL_SOCKET; - break; - } - return level; -} - - -static inline int mips_change_optname(int optname) -{ - switch (optname) { - case SO_DEBUG_PORTABLE: - return SO_DEBUG; - case SO_REUSEADDR_PORTABLE: - return SO_REUSEADDR; - case SO_TYPE_PORTABLE: - return SO_TYPE; - case SO_ERROR_PORTABLE: - return SO_ERROR; - case SO_DONTROUTE_PORTABLE: - return SO_DONTROUTE; - case SO_BROADCAST_PORTABLE: - return SO_BROADCAST; - case SO_SNDBUF_PORTABLE: - return SO_SNDBUF; - case SO_RCVBUF_PORTABLE: - return SO_RCVBUF; - case SO_SNDBUFFORCE_PORTABLE: - return SO_SNDBUFFORCE; - case SO_RCVBUFFORCE_PORTABLE: - return SO_RCVBUFFORCE; - case SO_KEEPALIVE_PORTABLE: - return SO_KEEPALIVE; - case SO_OOBINLINE_PORTABLE: - return SO_OOBINLINE; - case SO_NO_CHECK_PORTABLE: - return SO_NO_CHECK; - case SO_PRIORITY_PORTABLE: - return SO_PRIORITY; - case SO_LINGER_PORTABLE: - return SO_LINGER; - case SO_BSDCOMPAT_PORTABLE: - return SO_BSDCOMPAT; - case SO_PASSCRED_PORTABLE: - return SO_PASSCRED; - case SO_PEERCRED_PORTABLE: - return SO_PEERCRED; - case SO_RCVLOWAT_PORTABLE: - return SO_RCVLOWAT; - case SO_SNDLOWAT_PORTABLE: - return SO_SNDLOWAT; - case SO_RCVTIMEO_PORTABLE: - return SO_RCVTIMEO; - case SO_SNDTIMEO_PORTABLE: - return SO_SNDTIMEO; - case SO_SECURITY_AUTHENTICATION_PORTABLE: - return SO_SECURITY_AUTHENTICATION; - case SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE: - return SO_SECURITY_ENCRYPTION_TRANSPORT; - case SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE: - return SO_SECURITY_ENCRYPTION_NETWORK; - case SO_BINDTODEVICE_PORTABLE: - return SO_BINDTODEVICE; - case SO_ATTACH_FILTER_PORTABLE: - return SO_ATTACH_FILTER; - case SO_DETACH_FILTER_PORTABLE: - return SO_DETACH_FILTER; - case SO_PEERNAME_PORTABLE: - return SO_PEERNAME; - case SO_TIMESTAMP_PORTABLE: - return SO_TIMESTAMP; - case SO_ACCEPTCONN_PORTABLE: - return SO_ACCEPTCONN; - case SO_PEERSEC_PORTABLE: - return SO_PEERSEC; - case SO_PASSSEC_PORTABLE: - return SO_PASSSEC; - } - return optname; -} - -extern int setsockopt(int, int, int, const void *, socklen_t); -int WRAP(setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen) -{ - return REAL(setsockopt)(s, mips_change_level(level), mips_change_optname(optname), optval, optlen); -} - -extern int getsockopt (int, int, int, void *, socklen_t *); -int WRAP(getsockopt)(int s, int level, int optname, void *optval, socklen_t *optlen) -{ - return REAL(getsockopt)(s, mips_change_level(level), mips_change_optname(optname), optval, optlen); -} diff --git a/ndk/sources/android/libportable/arch-mips/stat.c b/ndk/sources/android/libportable/arch-mips/stat.c index 8706f86e5..8a2a477bc 100644 --- a/ndk/sources/android/libportable/arch-mips/stat.c +++ b/ndk/sources/android/libportable/arch-mips/stat.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,64 +14,4 @@ * limitations under the License. */ -#include -#include -#include #include - -/* Note: The Portable Header will define stat to stat_portable */ -int WRAP(stat)(const char *path, struct stat_portable *s) -{ - struct stat mips_stat; - int ret; - - if (invalid_pointer(s)) { - *REAL(__errno)() = EFAULT; - return -1; - } - ret = REAL(stat)(path, &mips_stat); - stat_ntop(&mips_stat, s); - return ret; -} - -int WRAP(fstat)(int fd, struct stat_portable *s) -{ - struct stat mips_stat; - int ret; - - if (invalid_pointer(s)) { - *REAL(__errno)() = EFAULT; - return -1; - } - ret = REAL(fstat)(fd, &mips_stat); - stat_ntop(&mips_stat, s); - return ret; -} - -int WRAP(lstat)(const char *path, struct stat_portable *s) -{ - struct stat mips_stat; - int ret; - - if (invalid_pointer(s)) { - *REAL(__errno)() = EFAULT; - return -1; - } - ret = REAL(lstat)(path, &mips_stat); - stat_ntop(&mips_stat, s); - return ret; -} - -int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags) -{ - struct stat mips_stat; - int ret; - - if (invalid_pointer(s)) { - *REAL(__errno)() = EFAULT; - return -1; - } - ret = REAL(fstatat)(dirfd, path, &mips_stat, flags); - stat_ntop(&mips_stat, s); - return ret; -} diff --git a/ndk/sources/android/libportable/arch-mips/statfs.c b/ndk/sources/android/libportable/arch-mips/statfs.c deleted file mode 100644 index 013cde925..000000000 --- a/ndk/sources/android/libportable/arch-mips/statfs.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -static inline void statfs_ntop(struct statfs *n_statfs, struct statfs_portable *p_statfs) -{ - memset(p_statfs, '\0', sizeof(struct statfs_portable)); - p_statfs->f_type = n_statfs->f_type; - p_statfs->f_bsize = n_statfs->f_bsize; - p_statfs->f_blocks = n_statfs->f_blocks; - p_statfs->f_bfree = n_statfs->f_bfree; - p_statfs->f_bavail = n_statfs->f_bavail; - p_statfs->f_files = n_statfs->f_files; - p_statfs->f_ffree = n_statfs->f_ffree; - p_statfs->f_fsid = n_statfs->f_fsid; - p_statfs->f_namelen = n_statfs->f_namelen; - p_statfs->f_frsize = n_statfs->f_frsize; - p_statfs->f_flags = n_statfs->f_flags; -} - -int WRAP(statfs)(const char* path, struct statfs_portable* stat) -{ - struct statfs mips_stat; - int ret; - - if (invalid_pointer(stat)) { - *REAL(__errno)() = EFAULT; - return -1; - } - ret = REAL(statfs)(path, &mips_stat); - statfs_ntop(&mips_stat, stat); - return ret; -} - -int WRAP(fstatfs)(int fd, struct statfs_portable* stat) -{ - struct statfs mips_stat; - int ret; - - if (invalid_pointer(stat)) { - *REAL(__errno)() = EFAULT; - return -1; - } - ret = REAL(fstatfs)(fd, &mips_stat); - statfs_ntop(&mips_stat, stat); - return ret; -} diff --git a/ndk/sources/android/libportable/arch-mips/syscall.c b/ndk/sources/android/libportable/arch-mips/syscall.c deleted file mode 100644 index 13ac9385a..000000000 --- a/ndk/sources/android/libportable/arch-mips/syscall.c +++ /dev/null @@ -1,626 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PORTABLE_TAG "syscall_portable" -#include - -#if __NR_gettimeofday_portable == __NR_gettimeofday -#error "Bad build environment" -#endif - -/* - * Minimal syscall support for LTP testing. - * These are the system calls that LTP references explicitly. - * Not all of them are exported via bionic header so use #ifdef. - * - * TODO: - * Add existing portable system calls currently redirected from - * experimental Bionic linker code so that calls to them via - * syscall() are also processed. For example, LTP only calls open() - * directly and never does a syscall(__NR_open, ...). - */ - - -extern int REAL(syscall)(int, ...); - -#define MAXARGS 8 - -int WRAP(syscall)(int portable_number, ...) -{ - va_list ap; - int native_number, ret; - int i, nargs, args[MAXARGS]; - - ALOGV(" "); - ALOGV("%s(portable_number:%d, ...) {", __func__, portable_number); - - switch (portable_number) { -#ifdef __NR_add_key_portable - case __NR_add_key_portable: native_number = __NR_add_key; break; -#endif - -#ifdef __NR_cacheflush_portable - case __NR_cacheflush_portable: { - long start, end, flags; - - va_start(ap, portable_number); - start = va_arg(ap, long); - end = va_arg(ap, long); - flags = va_arg(ap, long); - va_end(ap); - - ret = cacheflush(start, end, flags); - goto done; - } -#endif - -#ifdef __NR_capget_portable - case __NR_capget_portable: native_number = __NR_capget; break; -#endif - -#ifdef __NR_capset_portable - case __NR_capset_portable: native_number = __NR_capset; break; -#endif - -#ifdef __NR_clock_getres_portable - case __NR_clock_getres_portable: native_number = __NR_clock_getres; break; -#endif - -#ifdef __NR_clock_nanosleep - case __NR_clock_nanosleep_portable: native_number = __NR_clock_nanosleep; break; -#endif - -#ifdef __NR_dup3_portable - case __NR_dup3_portable: native_number = __NR_dup3; break; -#endif - -#ifdef __NR_epoll_create_portable - case __NR_epoll_create_portable: native_number = __NR_epoll_create; break; -#endif - -#ifdef __NR_epoll_create1_portable - case __NR_epoll_create1_portable: native_number = __NR_epoll_create1; break; -#endif - -#ifdef __NR_eventfd_portable - /* - * Prior to 2.6.27 we only had this system call, - * which didn't have a flags argument. The kernel - * just provides a zero for flags when this system - * call number is used. - */ - case __NR_eventfd_portable: { - unsigned int initval; /* 64-bit counter initial value */ - int flags = 0; - - va_start(ap, portable_number); - - initval = va_arg(ap, int); - - va_end(ap); - - ret = WRAP(eventfd)(initval, flags); /* Android uses __NR_eventfd2 in eventfd() */ - goto done; - } -#endif - -#ifdef __NR_eventfd2_portable - /* - * Starting with Linux 2.6.27 a flags argument was added. - * Both Bionic and glibc implement the eventfd() now with - * the additional flags argument. - */ - case __NR_eventfd2_portable: { - unsigned int initval; /* 64-bit counter initial value */ - int flags; - - va_start(ap, portable_number); - - initval = va_arg(ap, int); - flags = va_arg(ap, int); - - va_end(ap); - - ret = WRAP(eventfd)(initval, flags); /* Android uses __NR_eventfd2 in eventfd() */ - goto done; - } -#endif - -#ifdef __NR_exit_group_portable - case __NR_exit_group_portable: native_number = __NR_exit_group; break; -#endif - -#ifdef __NR_faccessat_portable - case __NR_faccessat_portable: native_number = __NR_faccessat; break; -#endif - -#ifdef __NR_fallocate_portable - case __NR_fallocate_portable: native_number = __NR_fallocate; break; -#endif - -#ifdef __NR_fchmodat_portable - case __NR_fchmodat_portable: native_number = __NR_fchmodat; break; -#endif - -#ifdef __NR_fchownat_portable - case __NR_fchownat_portable: native_number = __NR_fchownat; break; -#endif - -#ifdef __NR_fstatat64_portable - case __NR_fstatat64_portable: native_number = __NR_fstatat64; break; -#endif - -#ifdef __NR_futimesat_portable - case __NR_futimesat_portable: native_number = __NR_futimesat; break; -#endif - -#ifdef __NR_getegid_portable - case __NR_getegid_portable: native_number = __NR_getegid; break; -#endif - -#ifdef __NR_geteuid_portable - case __NR_geteuid_portable: native_number = __NR_geteuid; break; -#endif - -#ifdef __NR_getgid_portable - case __NR_getgid_portable: native_number = __NR_getgid; break; -#endif - -#ifdef __NR_get_mempolicy_portable - case __NR_get_mempolicy_portable: native_number = __NR_get_mempolicy; break; -#endif - -#ifdef __NR_get_robust_list_portable - case __NR_get_robust_list_portable: native_number = __NR_get_robust_list; break; -#endif - -#ifdef __NR_gettid_portable - case __NR_gettid_portable: native_number = __NR_gettid; break; -#endif - -#ifdef __NR_gettimeofday_portable - case __NR_gettimeofday_portable: native_number = __NR_gettimeofday; break; -#endif - -#ifdef __NR_getuid_portable - case __NR_getuid_portable: native_number = __NR_getuid; break; -#endif - -#ifdef __NR_inotify_init_portable - case __NR_inotify_init_portable: native_number = __NR_inotify_init; break; -#endif - -#ifdef __NR_inotify_add_watch_portable - case __NR_inotify_add_watch_portable: native_number = __NR_inotify_add_watch; break; -#endif - -#ifdef __NR_inotify_init1_portable - case __NR_inotify_init1_portable: { - int portable_flags; - - va_start(ap, portable_number); - portable_flags = va_arg(ap, int); - va_end(ap); - - ret = WRAP(inotify_init1)(portable_flags); - goto done; - } -#endif - -#ifdef __NR_keyctl_portable - case __NR_keyctl_portable: native_number = __NR_keyctl; break; -#endif - -#ifdef __NR_linkat - case __NR_linkat_portable: native_number = __NR_linkat; break; -#endif - -#ifdef __NR_mbind_portable - case __NR_mbind_portable: native_number = __NR_mbind; break; -#endif - -#ifdef __NR_mkdirat_portable - case __NR_mkdirat_portable: native_number = __NR_mkdirat; break; -#endif - -#ifdef __NR_mknodat_portable - case __NR_mknodat_portable: native_number = __NR_mknodat; break; -#endif - -#ifdef __NR_openat_portable - case __NR_openat_portable: native_number = __NR_openat; break; -#endif - -#ifdef __NR_pipe2_portable - case __NR_pipe2_portable: { - int *pipefd_ptr; - int portable_flags; - - va_start(ap, portable_number); - pipefd_ptr = va_arg(ap, int *); - portable_flags = va_arg(ap, int); - va_end(ap); - - ret = WRAP(pipe2)(pipefd_ptr, portable_flags); - goto done; - } -#endif - -#ifdef __NR_readahead_portable - case __NR_readahead_portable: native_number = __NR_readahead; break; -#endif - -#ifdef __NR_readlinkat_portable - case __NR_readlinkat_portable: native_number = __NR_readlinkat; break; -#endif - -#ifdef __NR_renameat_portable - case __NR_renameat_portable: native_number = __NR_renameat; break; -#endif - -#ifdef __NR_rt_sigaction_portable - case __NR_rt_sigaction_portable: { - int sig; - struct sigaction_portable *act; - struct sigaction_portable *oact; - size_t sigsetsize; - - va_start(ap, portable_number); - sig = va_arg(ap, int); - act = va_arg(ap, struct sigaction_portable *); - oact = va_arg(ap, struct sigaction_portable *); - sigsetsize = va_arg(ap, size_t); - va_end(ap); - return WRAP(__rt_sigaction)(sig, act, oact, sigsetsize); - } -#endif - -#ifdef __NR_rt_sigprocmask_portable - case __NR_rt_sigprocmask_portable: { - int how; - const sigset_portable_t *set; - sigset_portable_t *oset; - size_t sigsetsize; - - va_start(ap, portable_number); - how = va_arg(ap, int); - set = va_arg(ap, sigset_portable_t *); - oset = va_arg(ap, sigset_portable_t *); - sigsetsize = va_arg(ap, size_t); - va_end(ap); - - ret = WRAP(__rt_sigprocmask)(how, set, oset, sigsetsize); - goto done; - } -#endif - -#ifdef __NR_rt_sigtimedwait_portable - case __NR_rt_sigtimedwait_portable: { - const sigset_portable_t *set; - siginfo_portable_t *info; - const struct timespec *timeout; - size_t sigsetsize; - - va_start(ap, portable_number); - set = va_arg(ap, sigset_portable_t *); - info = va_arg(ap, siginfo_portable_t *); - timeout = va_arg(ap, struct timespec *); - sigsetsize = va_arg(ap, size_t); - va_end(ap); - - ret = WRAP(__rt_sigtimedwait)(set, info, timeout, sigsetsize); - goto done; - } -#endif - -#ifdef __NR_rt_sigqueueinfo_portable - case __NR_rt_sigqueueinfo_portable: { - pid_t pid; - int sig; - siginfo_portable_t *uinfo; - - va_start(ap, portable_number); - pid = va_arg(ap, pid_t); - sig = va_arg(ap, int); - uinfo = va_arg(ap, siginfo_portable_t *); - va_end(ap); - - ret = WRAP(rt_sigqueueinfo)(pid, sig, uinfo); - goto done; - } -#endif - -#ifdef __NR_setgid_portable - case __NR_setgid_portable: native_number = __NR_setgid; break; -#endif - -#ifdef __NR_set_mempolicy_portable - case __NR_set_mempolicy_portable: native_number = __NR_set_mempolicy; break; -#endif - -#ifdef __NR_set_robust_list_portable - case __NR_set_robust_list_portable: native_number = __NR_set_robust_list; break; -#endif - -#ifdef __NR_set_tid_address_portable - case __NR_set_tid_address_portable: native_number = __NR_set_tid_address; break; -#endif - -#ifdef __NR_sgetmask_portable - case __NR_sgetmask_portable: native_number = __NR_sgetmask; break; -#endif - -#ifdef __NR_signalfd4_portable - case __NR_signalfd4_portable: { - int fd; - sigset_portable_t *portable_sigmask; - int sigsetsize; - int flags; - - va_start(ap, portable_number); - - fd = va_arg(ap, int); - portable_sigmask = va_arg(ap, sigset_portable_t *); - sigsetsize = va_arg(ap, int); - flags = va_arg(ap, int); - - va_end(ap); - - ret = do_signalfd4_portable(fd, (const sigset_portable_t *) portable_sigmask, sigsetsize, - flags); - goto done; - } -#endif - -#ifdef __NR_socketcall_portable - case __NR_socketcall_portable: native_number = __NR_socketcall; break; -#endif - -#ifdef __NR_splice_portable - case __NR_splice_portable: native_number = __NR_splice; break; -#endif - -/* REMIND - DOUBLE CHECK THIS ONE */ -#ifdef __NR_ssetmask_portable - case __NR_ssetmask_portable: native_number = __NR_ssetmask; break; -#endif - -#ifdef __NR_swapoff_portable - case __NR_swapoff_portable: native_number = __NR_swapoff; break; -#endif - -#ifdef __NR_swapon_portable - case __NR_swapon_portable: native_number = __NR_swapon; break; -#endif - -#ifdef __NR_symlinkat_portable - case __NR_symlinkat_portable: native_number = __NR_symlinkat; break; -#endif - -/* - * ARM uses the new, version 2, form of sync_file_range() which - * doesn't waste 32 bits between the 32 bit arg and the 64 bit arg. - * It does this by moving the last 32 bit arg and placing it with - * the 1st 32 bit arg. - * - * Here's the trivial mapping function in the kernel ARM code: - * - * sync_file_range2(int fd, unsigned int flags, loff_t offset, loff_t nbytes) { - * return sys_sync_file_range(fd, offset, nbytes, flags); - * } - * - * For portability we have to do a similar mapping for the native/MIPS system - * call but have to provide the alignment padding expected by the sync_file_range() - * system call. We avoid alignment issues while using varargs by avoiding the use - * of 64 bit args. - */ -#if defined( __NR_arm_sync_file_range_portable) - case __NR_arm_sync_file_range_portable: native_number = __NR_sync_file_range; { - int fd; - int flags; - int offset_low, offset_high; - int nbytes_low, nbytes_high; - int align_fill = 0; - - - va_start(ap, portable_number); - fd = va_arg(ap, int); - flags = va_arg(ap, int); - offset_low = va_arg(ap, int); - offset_high = va_arg(ap, int); - nbytes_low = va_arg(ap, int); - nbytes_high = va_arg(ap, int); - va_end(ap); - - ALOGV("%s: Calling syscall(native_number:%d:'sync_file_range', fd:%d, " - "align_fill:0x%x, offset_low:0x%x, offset_high:0x%x, " - "nbytes_low:0x%x, nbytes_high:0x%x, flags:0x%x);", __func__, - native_number, fd, align_fill, offset_low, offset_high, - nbytes_low, nbytes_high, flags); - - ret = REAL(syscall)(native_number, fd, align_fill, offset_low, offset_high, - nbytes_low, nbytes_high, flags); - - goto done; - } -#endif - - -#ifdef __NR__sysctl_portable - case __NR__sysctl_portable: native_number = __NR__sysctl; break; -#endif - -#ifdef __NR_sysfs_portable - case __NR_sysfs_portable: native_number = __NR_sysfs; break; -#endif - -#ifdef __NR_syslog_portable - case __NR_syslog_portable: native_number = __NR_syslog; break; -#endif - -#ifdef __NR_tee_portable - case __NR_tee_portable: native_number = __NR_tee; break; -#endif - -#ifdef __NR_timer_create_portable - case __NR_timer_create_portable: { - clockid_t clockid; - struct sigevent *evp; - timer_t *timerid; - - va_start(ap, portable_number); - clockid = va_arg(ap, clockid_t); - evp = va_arg(ap, struct sigevent *); - timerid = va_arg(ap, timer_t *); - va_end(ap); - - ret = WRAP(timer_create)(clockid, evp, timerid); - goto done; - } -#endif - -#ifdef __NR_timerfd_create_portable - case __NR_timerfd_create_portable: { - int clockid; - int flags; - - va_start(ap, portable_number); - clockid = va_arg(ap, int); /* clockid is portable */ - flags = va_arg(ap, int); /* flags need to be mapped */ - va_end(ap); - - ret = WRAP(timerfd_create)(clockid, flags); - goto done; - } -#endif - -#ifdef __NR_timerfd_gettime_portable - case __NR_timerfd_gettime_portable: native_number = __NR_timerfd_gettime; break; -#endif - -#ifdef __NR_timerfd_settime_portable - case __NR_timerfd_settime_portable: native_number = __NR_timerfd_settime; break; -#endif - -#ifdef __NR_timer_getoverrun_portable - case __NR_timer_getoverrun_portable: native_number = __NR_timer_getoverrun; break; -#endif - -#ifdef __NR_timer_gettime_portable - case __NR_timer_gettime_portable: native_number = __NR_timer_gettime; break; -#endif - -#ifdef __NR_timer_settime_portable - case __NR_timer_settime_portable: native_number = __NR_timer_settime; break; -#endif - -#ifdef __NR_rt_tgsigqueueinfo_portable - case __NR_rt_tgsigqueueinfo_portable: { - pid_t tgid; - pid_t pid; - int sig; - siginfo_portable_t *uinfo; - - va_start(ap, portable_number); - tgid = va_arg(ap, pid_t); - pid = va_arg(ap, pid_t); - sig = va_arg(ap, int); - uinfo = va_arg(ap, siginfo_portable_t *); - va_end(ap); - - ret = WRAP(rt_tgsigqueueinfo)(tgid, pid, sig, uinfo); - goto done; - } -#endif - -#ifdef __NR_uname_portable - case __NR_uname_portable: native_number = __NR_uname; break; -#endif - -#ifdef __NR_vmsplice_portable - case __NR_vmsplice_portable: native_number = __NR_vmsplice; break; -#endif - - default: - ALOGV("%s(portable_number:%d, ...): case default; native_number = -1; " - "[ERROR: ADD MISSING SYSTEM CALL]", __func__, portable_number); - - native_number = -1; - break; - } - - ALOGV("%s: native_number = %d", __func__, native_number); - - if (native_number <= 0) { - ALOGV("%s: native_number:%d <= 0; ret = -1; [ERROR: FIX SYSTEM CALL]", __func__, - native_number); - - *REAL(__errno)() = ENOSYS; - ret = -1; - goto done; - } - - /* - * Get the argument list - * This is pretty crappy: - * It assumes that the portable and native arguments are compatible - * It assumes that no more than MAXARGS arguments are passed - * - * Possible changes: - * o include the argument count for each mapped system call - * o map the syscall into the equivalent library call: - * eg syscall(__NR_gettimeofday_portable, struct timeval *tv, struct timezone *tz) => - * gettimeofday(struct timeval *tv, struct timezone *tz) - * - * second option is probably best as it allows argument remapping to take place if needed - * - */ - va_start(ap, portable_number); - /* For now assume all syscalls take MAXARGS arguments. */ - nargs = MAXARGS; - for (i = 0; i < nargs; i++) - args[i] = va_arg(ap, int); - va_end(ap); - - ALOGV("%s: Calling syscall(%d, %d, %d, %d, %d, %d, %d, %d, %d);", __func__, - native_number, args[0], args[1], args[2], args[3], args[4], - args[5], args[6], args[7]); - - ret = REAL(syscall)(native_number, args[0], args[1], args[2], args[3], - args[4], args[5], args[6], args[7]); - -done: - if (ret == -1) { - ALOGV("%s: ret == -1; errno:%d;", __func__, *REAL(__errno)()); - } - ALOGV("%s: return(ret:%d); }", __func__, ret); - return ret; -} diff --git a/ndk/sources/android/libportable/arch-mips/timer.c b/ndk/sources/android/libportable/arch-mips/timer.c deleted file mode 100644 index c2844e1b3..000000000 --- a/ndk/sources/android/libportable/arch-mips/timer.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -int WRAP(timer_create)(clockid_t clockid, struct sigevent *portable_evp, - timer_t *timerid) -{ - struct sigevent native_sigevent, *evp = portable_evp; - - if (!invalid_pointer(portable_evp) && - (evp->sigev_notify == SIGEV_SIGNAL || - evp->sigev_notify == SIGEV_THREAD_ID)) { - - native_sigevent = *portable_evp; - evp = &native_sigevent; - evp->sigev_signo = signum_pton(evp->sigev_signo); - } - return REAL(timer_create)(clockid, evp, timerid); -} diff --git a/ndk/sources/android/libportable/arch-mips/timerfd.c b/ndk/sources/android/libportable/arch-mips/timerfd.c deleted file mode 100644 index b57c3f277..000000000 --- a/ndk/sources/android/libportable/arch-mips/timerfd.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include -#include - -#include -#include - -#include - - -#define PORTABLE_TAG "timerfd_portable" -#include - -extern int syscall(int, ...); - - -/* NOTE: LTP defaults to using O_NONBLOCK even if TFD_NONBLOCK is defined */ - - -/* - * Portable to Native event flags mapper. - */ -static inline int tdf_flags_pton(int portable_flags) -{ - int native_flags = 0; - - ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags); - - if (portable_flags & TFD_NONBLOCK_PORTABLE) { - native_flags |= TFD_NONBLOCK; - } - - if (portable_flags & TFD_CLOEXEC_PORTABLE) { - native_flags |= TFD_CLOEXEC; - } - - ALOGV("%s: return(native_flags:%d); }", __func__, native_flags); - return native_flags; -} - - -int WRAP(timerfd_create)(int clockid, int portable_flags) { - int rv; - int native_flags; - - ALOGV(" "); - ALOGV("%s(clockid:%d, portable_flags:%d) {", __func__, - clockid, portable_flags); - - native_flags = tdf_flags_pton(portable_flags); - - rv = REAL(syscall)(__NR_timerfd_create, clockid, native_flags); - if (rv >= 0) { - if (native_flags & TFD_CLOEXEC) { - filefd_CLOEXEC_enabled(rv); - } - filefd_opened(rv, TIMER_FD_TYPE); - } - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - diff --git a/ndk/sources/android/libportable/arch-mips/vfs.c b/ndk/sources/android/libportable/arch-mips/vfs.c new file mode 100644 index 000000000..fe8becd43 --- /dev/null +++ b/ndk/sources/android/libportable/arch-mips/vfs.c @@ -0,0 +1,17 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include diff --git a/ndk/sources/android/libportable/arch-mips/waitpid.c b/ndk/sources/android/libportable/arch-mips/waitpid.c deleted file mode 100644 index f1d2bcf45..000000000 --- a/ndk/sources/android/libportable/arch-mips/waitpid.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define PORTABLE_TAG "waitpid_portable" -#include - -/* - * Converts native status information at *status to portable. - */ -static void status_ntop(int *status) -{ - int portable_status; - - ALOGV("%s(status:%p) {", __func__, - status); - - ASSERT(status != NULL); - - /* - * The interpretation of status is documented in the wait(2) manual page - * and the implementation is in bionic/libc/include/sys/wait.h - */ - if (WIFSIGNALED(*status)) - portable_status = (*status & ~0x7f) | signum_ntop(WTERMSIG(*status)); - else if (WIFSTOPPED(*status)) - portable_status = (*status & ~0xff00) | (signum_ntop(WSTOPSIG(*status)) << 8); - else - portable_status = *status; - - ALOGV("%s: (*status):0x%08x = portable_status:0x%08x", __func__, - *status, portable_status); - - *status = portable_status; - - ALOGV("%s: return; }", __func__); -} - - -pid_t WRAP(waitpid)(pid_t pid, int *status, int options) -{ - pid_t rv; - - ALOGV("%s(pid:%d, status:%p, options:0x%x) {", __func__, - pid, status, options); - - rv = REAL(waitpid)(pid, status, options); - if (rv > 0 && status) - status_ntop(status); - - ALOGV("%s: return rv:%d; }", __func__, rv); - return rv; -} - - -pid_t WRAP(wait)(int *status) -{ - pid_t rv; - - ALOGV("%s(status:%p) {", __func__, - status); - - rv = REAL(wait)(status); - if (rv > 0 && status) - status_ntop(status); - - ALOGV("%s: return rv:%d; }", __func__, rv); - return rv; -} - - -pid_t WRAP(wait3)(int *status, int options, struct rusage *rusage) -{ - pid_t rv; - - ALOGV("%s(status:%p, options:0x%x, rusage:%p) {", __func__, - status, options, rusage); - - rv = REAL(wait3)(status, options, rusage); - if (rv > 0 && status) - status_ntop(status); - - ALOGV("%s: return rv:%d; }", __func__, rv); - return rv; -} - -// FIXME: WORKAROUND after Android wait4 has been implemented -pid_t REAL(wait4)(pid_t p, int *s, int o, struct rusage *r) { - extern pid_t __wait4(pid_t, int *, int, struct rusage *); - return __wait4(p,s,o,r); -} - -pid_t WRAP(wait4)(pid_t pid, int *status, int options, struct rusage *rusage) -{ - pid_t rv; - - ALOGV("%s(pid:%d, status:%p, options:0x%x, rusage:%p) {", __func__, - pid, status, options, rusage); - - rv = REAL(wait4)(pid, status, options, rusage); - if (rv > 0 && status) - status_ntop(status); - - ALOGV("%s: return rv:%d; }", __func__, rv); - return rv; -} diff --git a/ndk/sources/android/libportable/arch-mips64/errno.c b/ndk/sources/android/libportable/arch-mips64/errno.c new file mode 100644 index 000000000..b9ed45657 --- /dev/null +++ b/ndk/sources/android/libportable/arch-mips64/errno.c @@ -0,0 +1,17 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include diff --git a/ndk/sources/android/libportable/arch-mips/flags.c b/ndk/sources/android/libportable/arch-mips64/fcntl.c similarity index 76% rename from ndk/sources/android/libportable/arch-mips/flags.c rename to ndk/sources/android/libportable/arch-mips64/fcntl.c index f0f75009d..de620c550 100644 --- a/ndk/sources/android/libportable/arch-mips/flags.c +++ b/ndk/sources/android/libportable/arch-mips64/fcntl.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,4 @@ * limitations under the License. */ -#include -#include -#include #include - -#define PORTABLE_TAG "flags_portable" -#include - - diff --git a/ndk/sources/android/libportable/arch-mips64/fenv.c b/ndk/sources/android/libportable/arch-mips64/fenv.c index 0721c6243..d3c18af07 100644 --- a/ndk/sources/android/libportable/arch-mips64/fenv.c +++ b/ndk/sources/android/libportable/arch-mips64/fenv.c @@ -1,5 +1,5 @@ /* - * Copyright 2013, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,147 +14,4 @@ * limitations under the License. */ -#include -#include -#include #include - -static inline int mips64_change_except(int flags) { - int mips64flags = 0; - int exception = flags & FE_ALL_EXCEPT_PORTABLE; - - // exception flags - if (exception & FE_INVALID_PORTABLE) - mips64flags |= FE_INVALID; - if (exception & FE_DIVBYZERO_PORTABLE) - mips64flags |= FE_DIVBYZERO; - if (exception & FE_OVERFLOW_PORTABLE) - mips64flags |= FE_OVERFLOW; - if (exception & FE_UNDERFLOW_PORTABLE) - mips64flags |= FE_UNDERFLOW; - if (exception & FE_INEXACT_PORTABLE) - mips64flags |= FE_INEXACT; - - return mips64flags; -} - -static inline int mips64_change_rounding(int flags) { - int mips64flags = 0; - int rounding = flags & 0x03; - - // rounding flags - switch(rounding) - { - case FE_TONEAREST_PORTABLE: - mips64flags = FE_TONEAREST; - break; - case FE_DOWNWARD_PORTABLE: - mips64flags = FE_DOWNWARD; - break; - case FE_UPWARD_PORTABLE: - mips64flags = FE_UPWARD; - break; - case FE_TOWARDZERO_PORTABLE: - mips64flags = FE_TOWARDZERO; - break; - } - return mips64flags; -} - -static inline int mips64_get_except(int mips64flags) { - int flags = 0; - int exception = mips64flags & FE_ALL_EXCEPT; - - // exception flags - if (exception & FE_INVALID) - flags |= FE_INVALID_PORTABLE; - if (exception & FE_DIVBYZERO) - flags |= FE_DIVBYZERO_PORTABLE; - if (exception & FE_OVERFLOW) - flags |= FE_OVERFLOW_PORTABLE; - if (exception & FE_UNDERFLOW) - flags |= FE_UNDERFLOW_PORTABLE; - if (exception & FE_INEXACT) - flags |= FE_INEXACT_PORTABLE; - return flags; -} - -static inline int mips64_get_rounding(int mips64flags) { - int flags = 0; - int rounding = mips64flags & _FCSR_RMASK; - - // rounding flags - switch(rounding) - { - case FE_TONEAREST: - flags = FE_TONEAREST_PORTABLE; - break; - case FE_DOWNWARD: - flags = FE_DOWNWARD_PORTABLE; - break; - case FE_UPWARD: - flags = FE_UPWARD_PORTABLE; - break; - case FE_TOWARDZERO: - flags = FE_TOWARDZERO_PORTABLE; - break; - } - return flags; -} - - -int WRAP(feclearexcept)(int flag) { - return REAL(feclearexcept)(mips64_change_except(flag)); -} - -int WRAP(fegetexceptflag)(fexcept_t_portable *obj, int flag) { - int ret = REAL(fegetexceptflag)((fexcept_t*)obj, mips64_change_except(flag)); - *obj = (fexcept_t_portable) mips64_get_except(*obj); - return ret; -} - -int WRAP(feraiseexcept)(int flag) { - return REAL(feraiseexcept)(mips64_change_except(flag)); -} - -int WRAP(fesetexceptflag)(const fexcept_t_portable *obj, int flag) { - const fexcept_t mips64obj = mips64_change_except(*obj); - int mips64flag = mips64_change_except(flag); - return REAL(fesetexceptflag)(&mips64obj, mips64flag); -} - -int WRAP(fetestexcept)(int flag) { - int ret = REAL(fetestexcept)(mips64_change_except(flag)); - return mips64_get_except(ret); -} - -int WRAP(fegetround)(void) { - int round = REAL(fegetround)(); - return mips64_get_rounding(round); -} - -int WRAP(fesetround)(int round) { - return REAL(fesetround)(mips64_change_rounding(round)); -} - -int WRAP(fegetenv)(fenv_t_portable *obj) { - return REAL(fegetenv)((fenv_t*)obj); -} - -int WRAP(feholdexcept)(fenv_t_portable *obj) { - return REAL(feholdexcept)((fenv_t*)obj); -} - -int WRAP(fesetenv)(const fenv_t_portable *obj) { - return REAL(fesetenv)((const fenv_t*)obj); -} - -int WRAP(feupdateenv)(const fenv_t_portable *obj) { - return REAL(feupdateenv)((const fenv_t*)obj); -} - -int WRAP(fegetexcept)(void) { - int flag = REAL(fegetexcept)(); - return mips64_get_except(flag); -} - diff --git a/ndk/sources/android/libportable/arch-mips64/socket.c b/ndk/sources/android/libportable/arch-mips64/socket.c deleted file mode 100644 index be2c7e6ed..000000000 --- a/ndk/sources/android/libportable/arch-mips64/socket.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define PORTABLE_TAG "socket_portable" -#include - - -#if SOCK_STREAM==SOCK_STREAM_PORTABLE -#error Bad build environment -#endif - -/* LTP defaults to using O_NONBLOCK if SOCK_NONBLOCK is not defined. */ -#ifndef SOCK_NONBLOCK_PORTABLE -# define SOCK_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE -#endif -#ifndef SOCK_NONBLOCK -# define SOCK_NONBLOCK O_NONBLOCK -#endif - -/* Current NDK headers do not define SOCK_CLOEXEC or O_CLOEXEC */ -#if !defined(SOCK_CLOEXEC_PORTABLE) && defined(O_CLOEXEC_PORTABLE) -# define SOCK_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE -#endif -#if !defined(SOCK_CLOEXEC) && defined(O_CLOEXEC) -# define SOCK_CLOEXEC O_CLOEXEC -#endif - - -/* - * Portable to Native socktype mapper. - */ -static inline int socktype_pton(int portable_type) -{ - int native_type = 0; - - ALOGV("%s(portable_type:0x%x) {", __func__, portable_type); - - if (portable_type & SOCK_NONBLOCK_PORTABLE) { - native_type |= SOCK_NONBLOCK; - portable_type &= ~SOCK_NONBLOCK_PORTABLE; - } - -#if defined(SOCK_CLOEXEC_PORTABLE) && defined(SOCK_CLOEXEC) - if (portable_type & SOCK_CLOEXEC_PORTABLE) { - native_type |= SOCK_CLOEXEC; - portable_type &= ~SOCK_CLOEXEC_PORTABLE; - } -#endif - - switch (portable_type) { - case SOCK_STREAM_PORTABLE: native_type |= SOCK_STREAM; break; - case SOCK_DGRAM_PORTABLE: native_type |= SOCK_DGRAM; break; - case SOCK_RAW_PORTABLE: native_type |= SOCK_RAW; break; - case SOCK_RDM_PORTABLE: native_type |= SOCK_RDM; break; - case SOCK_SEQPACKET_PORTABLE: native_type |= SOCK_SEQPACKET; break; - case SOCK_PACKET_PORTABLE: native_type |= SOCK_PACKET; break; - default: - ALOGE("%s: case default: native_type:0x%x |= portable_type:0x%x:[UNKNOWN!];", __func__, - native_type, portable_type); - - native_type |= portable_type; - break; - } - ALOGV("%s: return(native_type:%d); }", __func__, native_type); - return native_type; -} - - -/* - * Native to Portable socktype mapper. - */ -static inline int socktype_ntop(int native_type) -{ - int portable_type = 0; - - ALOGV("%s(native_type:0x%x) {", __func__, native_type); - - if (native_type & SOCK_NONBLOCK) { - portable_type |= SOCK_NONBLOCK_PORTABLE; - native_type &= ~SOCK_NONBLOCK; - } - -#if defined(SOCK_CLOEXEC_PORTABLE) && defined(SOCK_CLOEXEC) - if (native_type & SOCK_CLOEXEC) { - portable_type |= SOCK_CLOEXEC_PORTABLE; - native_type &= ~SOCK_CLOEXEC; - } -#endif - - switch (native_type) { - case SOCK_STREAM: portable_type |= SOCK_STREAM_PORTABLE; break; - case SOCK_DGRAM: portable_type |= SOCK_DGRAM_PORTABLE; break; - case SOCK_RAW: portable_type |= SOCK_RAW_PORTABLE; break; - case SOCK_RDM: portable_type |= SOCK_RDM_PORTABLE; break; - case SOCK_SEQPACKET: portable_type |= SOCK_SEQPACKET_PORTABLE; break; - case SOCK_PACKET: portable_type |= SOCK_PACKET_PORTABLE; break; - default: - portable_type |= native_type; - ALOGE("%s: case default: portable_type:0x%x |= native_type:0x%x:[UNKNOWN!];", __func__, - portable_type, native_type); - } - ALOGV("%s: return(portable_type:%d); }", __func__, portable_type); - return portable_type; -} - - -extern int REAL(socket)(int, int, int); - -int WRAP(socket)(int domain, int type, int protocol) { - int rv; - - ALOGV(" "); - ALOGV("%s(domain:%d, type:%d, protocol:%d) {", __func__, - domain, type, protocol); - - rv = REAL(socket)(domain, socktype_pton(type), protocol); - - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -int WRAP(socketpair)(int domain, int type, int protocol, int sv[2]) { - int rv; - - ALOGV(" "); - ALOGV("%s(domain:%d, type:%d, protocol:%d, sv[2]:%p) {", __func__, - domain, type, protocol, sv); - - rv = REAL(socketpair)(domain, socktype_pton(type), protocol, sv); - - if ((rv != 0) || invalid_pointer(sv)) { - ALOGV("%s: return(rv:%d); }", __func__, - rv); - } else { - ALOGV("%s: return(rv:%d); sv[0]:%d; sv[1]:%d;}", __func__, - rv, sv[0], sv[1]); - } - return rv; -} - -#define PRINT_ADDRINFO(p) { \ - ALOGV("%s: p:%p->{ai_flags:%d, ai_family:%d, ai_socktype:%d, ai_protocol:%d, ...", __func__, \ - p, p->ai_flags, p->ai_family, p->ai_socktype, p->ai_protocol); \ - \ - ALOGV("%s: p:%p->{... ai_addrlen:%d, ai_addr:%p, ai_canonname:%p, p->ai_next:%p);", __func__,\ - p, p->ai_addrlen, p->ai_addr, p->ai_canonname, p->ai_next); \ -} - -/* - * Returns a list of portable addrinfo structures that are - * later made free with a call to the portable version of - * freeaddrinfo(); which is written below this function. - */ -int WRAP(getaddrinfo)(const char *node, const char *service, - struct addrinfo_portable *portable_hints, - struct addrinfo_portable **portable_results) -{ - int rv; - struct addrinfo *native_hints; - struct addrinfo **native_results, *rp; - int saved_portable_socktype; - - ALOGV(" "); - ALOGV("%s(node:%p, service:%p, portable_hints:%p, portable_results:%p) {", __func__, - node, service, portable_hints, portable_results); - - PRINT_ADDRINFO(portable_hints); - - /* - * The only part of the addrinfo structure that needs to be modified - * between ARM and MIPS is the socktype; - */ - ASSERT(sizeof(struct addrinfo_portable) == sizeof(struct addrinfo)); - native_hints = ((struct addrinfo *) portable_hints); - if (native_hints != NULL) { - saved_portable_socktype = portable_hints->ai_socktype; - native_hints->ai_socktype = socktype_pton(saved_portable_socktype); - } - ASSERT(portable_results != NULL); - native_results = (struct addrinfo **) portable_results; - - rv = REAL(getaddrinfo)(node, service, native_hints, native_results); - - if (native_hints != NULL) { - portable_hints->ai_socktype = saved_portable_socktype; - } - - - /* - * Map socktypes in the return list of addrinfo structures from native to portable. - * Assuming getaddrinfo() has left structure writeable and the list is generated - * on each call. This seems to be true when looking at the man page and the code - * at: - * ./bionic/libc/netbsd/net/getaddrinfo.c - */ - for (rp = *native_results; rp != NULL; rp = rp->ai_next) { - PRINT_ADDRINFO(rp); - rp->ai_socktype = socktype_ntop(rp->ai_socktype); - } - ALOGV("%s: return(rv:%d); }", __func__, rv); - return rv; -} - - -/* - * Free the results list returned from a previous call - * to the portable version of getaddrinfo(). - */ -void WRAP(freeaddrinfo)(struct addrinfo_portable *portable_results) -{ - struct addrinfo *native_results, *rp; - - ALOGV(" "); - ALOGV("%s(portable_results:%p) {", __func__, portable_results); - - PRINT_ADDRINFO(portable_results); - - /* - * The only part of each addrinfo structure that needs to be modified - * between ARM and MIPS is the socktype; - * - * Map socktypes in the return list of iportable addrinfo structures back to native. - * Again, assuming getaddrinfo() has left structure writeable and the list is generated - * on each call. This seems to be true when looking at the man page and the code. - */ - ASSERT(sizeof(struct addrinfo_portable) == sizeof(struct addrinfo)); - native_results = ((struct addrinfo *) portable_results); - for (rp = native_results; rp != NULL; rp = rp->ai_next) { - PRINT_ADDRINFO(rp); - rp->ai_socktype = socktype_pton(rp->ai_socktype); /* Likely not really necessary */ - } - REAL(freeaddrinfo)(native_results); - - ALOGV("%s: return; }", __func__); - return; -} diff --git a/ndk/sources/android/libportable/arch-mips64/stat.c b/ndk/sources/android/libportable/arch-mips64/stat.c index 0bfd0ba14..8a2a477bc 100644 --- a/ndk/sources/android/libportable/arch-mips64/stat.c +++ b/ndk/sources/android/libportable/arch-mips64/stat.c @@ -14,52 +14,4 @@ * limitations under the License. */ -#include #include -#include - - -int WRAP(fstat)(int fd, struct stat_portable *s) { - struct stat mips64_stat; - int ret = REAL(fstat)(fd, &mips64_stat); - stat_ntop(&mips64_stat, s); - return ret; -} -static inline int WRAP(fstat64)(int fd, struct stat64_portable *s) { - return WRAP(fstat)(fd, (struct stat_portable*)s); -} - - -int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags) { - struct stat mips64_stat; - int ret = REAL(fstatat)(dirfd, path, &mips64_stat, flags); - stat_ntop(&mips64_stat, s); - return ret; -} -static inline int WRAP(fstatat64)(int dirfd, const char *path, - struct stat64_portable *s, int flags) { - return WRAP(fstatat)(dirfd, path, (struct stat_portable*)s, flags); -} - - -int WRAP(lstat)(const char *path, struct stat_portable *s) { - struct stat mips64_stat; - int ret = REAL(lstat)(path, &mips64_stat); - stat_ntop(&mips64_stat, s); - return ret; -} -static inline int WRAP(lstat64)(const char *path, struct stat64_portable *s) { - return WRAP(lstat)(path, (struct stat_portable*)s); -} - - -int WRAP(stat)(const char* path, struct stat_portable* s) { - struct stat mips64_stat; - int ret = REAL(stat)(path, &mips64_stat); - stat_ntop(&mips64_stat, s); - return ret; -} -static inline int WRAP(stat64)(const char* path, struct stat64_portable *s) { - return WRAP(stat)(path, (struct stat_portable*)s); -} - diff --git a/ndk/sources/android/libportable/arch-mips64/va_funcs.c b/ndk/sources/android/libportable/arch-mips64/va_funcs.c deleted file mode 100644 index d27aaa007..000000000 --- a/ndk/sources/android/libportable/arch-mips64/va_funcs.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2014, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include - -int WRAP(vfprintf)(FILE *stream, const char *format, va_list_portable *arg) { - return REAL(vfprintf)(stream, format, arg); -} - -int WRAP(vfscanf)(FILE *stream, const char *format, va_list_portable *arg) { - return REAL(vfscanf)(stream, format, arg); -} - -int WRAP(vprintf)(const char *format, va_list_portable *arg) { - return REAL(vprintf)(format, arg); -} - -int WRAP(vscanf)(const char *format, va_list_portable *arg) { - return REAL(vscanf)(format, arg); -} - -int WRAP(vsnprintf)(char *s, size_t n, const char *format, va_list_portable *arg) { - return REAL(vsnprintf)(s, n, format, arg); -} - -int WRAP(vsprintf)(char *s, const char *format, va_list_portable *arg) { - return REAL(vsprintf)(s, format, arg); -} - -int WRAP(vsscanf)(const char *s, const char *format, va_list_portable *arg) { - return REAL(vsscanf)(s, format, arg); -} - diff --git a/ndk/sources/android/libportable/arch-mips64/vfs.c b/ndk/sources/android/libportable/arch-mips64/vfs.c index 94d6793b3..fe8becd43 100644 --- a/ndk/sources/android/libportable/arch-mips64/vfs.c +++ b/ndk/sources/android/libportable/arch-mips64/vfs.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,5 +14,4 @@ * limitations under the License. */ -#include #include diff --git a/ndk/sources/android/libportable/arch-x86/epoll.c b/ndk/sources/android/libportable/arch-x86/epoll.c index c68344133..ef929af68 100644 --- a/ndk/sources/android/libportable/arch-x86/epoll.c +++ b/ndk/sources/android/libportable/arch-x86/epoll.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,4 @@ * limitations under the License. */ -#include -#include #include - -int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event_portable *event) -{ - struct epoll_event x86_epoll_event; - - x86_epoll_event.events = event->events; - x86_epoll_event.data = event->data; - - return REAL(epoll_ctl)(epfd, op, fd, &x86_epoll_event); -} - -int WRAP(epoll_wait)(int epfd, struct epoll_event_portable *events, int max, int timeout) -{ - struct epoll_event x86_epoll_event; - int ret = REAL(epoll_wait)(epfd, &x86_epoll_event, max, timeout); - - events->events = x86_epoll_event.events; - events->data = x86_epoll_event.data; - - return ret; -} - diff --git a/ndk/sources/android/libportable/arch-x86/fcntl.c b/ndk/sources/android/libportable/arch-x86/fcntl.c index 74b14c12b..de620c550 100644 --- a/ndk/sources/android/libportable/arch-x86/fcntl.c +++ b/ndk/sources/android/libportable/arch-x86/fcntl.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,40 +14,4 @@ * limitations under the License. */ -#include -#include -#include #include - -extern int __fcntl64(int, int, void *); - -int WRAP(fcntl)(int fd, int cmd, ...) -{ - va_list ap; - void * arg; - - va_start(ap, cmd); - arg = va_arg(ap, void *); - va_end(ap); - - if (cmd == F_GETLK64 || - cmd == F_SETLK64 || - cmd == F_SETLKW64) { - struct flock64 x86_flock64; - int result = __fcntl64(fd, cmd, (void *) &x86_flock64); - - struct flock64_portable * flock64 = (struct flock64_portable *) arg; - - flock64->l_type = x86_flock64.l_type; - flock64->l_whence = x86_flock64.l_whence; - flock64->l_start = x86_flock64.l_start; - flock64->l_len = x86_flock64.l_len; - flock64->l_pid = x86_flock64.l_pid; - - return result; - } - else { - return __fcntl64(fd, cmd, arg); - } -} - diff --git a/ndk/sources/android/libportable/arch-x86/fenv.c b/ndk/sources/android/libportable/arch-x86/fenv.c index 0f22d2f2e..d3c18af07 100644 --- a/ndk/sources/android/libportable/arch-x86/fenv.c +++ b/ndk/sources/android/libportable/arch-x86/fenv.c @@ -1,5 +1,5 @@ /* - * Copyright 2013, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,154 +14,4 @@ * limitations under the License. */ - -#include - -#include -#include -#include #include - -static inline int x86_change_except(int flags) -{ - int x86flags = 0; - int exception = flags & FE_ALL_EXCEPT_PORTABLE; - - // exception flags - if (exception & FE_INVALID_PORTABLE) - x86flags |= FE_INVALID; - if (exception & FE_DIVBYZERO_PORTABLE) - x86flags |= FE_DIVBYZERO; - if (exception & FE_OVERFLOW_PORTABLE) - x86flags |= FE_OVERFLOW; - if (exception & FE_UNDERFLOW_PORTABLE) - x86flags |= FE_UNDERFLOW; - if (exception & FE_INEXACT_PORTABLE) - x86flags |= FE_INEXACT; - - return x86flags; -} - -static inline int x86_change_rounding(int flags) -{ - int x86flags = 0; - int rounding = flags & 0x03; - - // rounding flags - switch(rounding) - { - case FE_TONEAREST_PORTABLE: - x86flags = FE_TONEAREST; - break; - case FE_DOWNWARD_PORTABLE: - x86flags = FE_DOWNWARD; - break; - case FE_UPWARD_PORTABLE: - x86flags = FE_UPWARD; - break; - case FE_TOWARDZERO_PORTABLE: - x86flags = FE_TOWARDZERO; - break; - } - return x86flags; -} - -static inline int x86_get_except(int x86flags) -{ - int flags = 0; - int exception = x86flags & FE_ALL_EXCEPT; - - // exception flags - if (exception & FE_INVALID) - flags |= FE_INVALID_PORTABLE; - if (exception & FE_DIVBYZERO) - flags |= FE_DIVBYZERO_PORTABLE; - if (exception & FE_OVERFLOW) - flags |= FE_OVERFLOW_PORTABLE; - if (exception & FE_UNDERFLOW) - flags |= FE_UNDERFLOW_PORTABLE; - if (exception & FE_INEXACT) - flags |= FE_INEXACT_PORTABLE; - - return flags; -} -static inline int x86_get_rounding(int x86flags) -{ - int flags = 0; - int rounding = x86flags & _ROUND_MASK; - - // rounding flags - switch(rounding) - { - case FE_TONEAREST: - flags = FE_TONEAREST_PORTABLE; - break; - case FE_DOWNWARD: - flags = FE_DOWNWARD_PORTABLE; - break; - case FE_UPWARD: - flags = FE_UPWARD_PORTABLE; - break; - case FE_TOWARDZERO: - flags = FE_TOWARDZERO_PORTABLE; - break; - } - - return flags; -} - -int -WRAP(fesetexceptflag)(const fexcept_t *flagp, int excepts) -{ - const fexcept_t flagp_ = x86_change_except(*flagp); - int excepts_ = x86_change_except(excepts); - return REAL(fesetexceptflag)(&flagp_, excepts_); -} - -int -WRAP(fegetexceptflag)(fexcept_t *flagp, int excepts) -{ - REAL(fegetexceptflag)(flagp, x86_change_except(excepts)); - *flagp = x86_get_except(*flagp); - return 0; -} - -int -WRAP(feraiseexcept)(int excepts) -{ - return REAL(feraiseexcept)(x86_change_except(excepts)); -} - -int -WRAP(feclearexcept)(int excepts) -{ - return REAL(feclearexcept)(x86_change_except(excepts)); -} - -int -WRAP(fetestexcept)(int excepts) -{ - int ret = REAL(fetestexcept)(x86_change_except(excepts)); - return x86_get_except(ret); -} - -int -WRAP(fegetround)(void) -{ - int round = REAL(fegetround)(); - return x86_get_rounding(round); -} - -int -WRAP(fesetround)(int round) -{ - return REAL(fesetround)(x86_change_rounding(round)); -} - -int -WRAP(fegetexcept)(void) -{ - int flags = REAL(fegetexcept)(); - return x86_get_except(flags); -} - diff --git a/ndk/sources/android/libportable/arch-x86/ioctl.c b/ndk/sources/android/libportable/arch-x86/ioctl.c deleted file mode 100644 index 01ddbcd50..000000000 --- a/ndk/sources/android/libportable/arch-x86/ioctl.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -#if FIOQSIZE_PORTABLE == FIOQSIZE -#error Bad build environment -#endif - -static inline int x86_change_request(int request) -{ - if (request == FIOQSIZE_PORTABLE) - return FIOQSIZE; - - return request; -} - -extern int __ioctl(int, int, void *); -int WRAP(ioctl)(int fd, int request, ...) -{ - va_list ap; - void * arg; - - va_start(ap, request); - arg = va_arg(ap, void *); - va_end(ap); - - return __ioctl(fd, x86_change_request(request), arg); -} diff --git a/ndk/sources/android/libportable/arch-x86/md_swap.c b/ndk/sources/android/libportable/arch-x86/md_swap.c index 60851d0ae..da3c29060 100644 --- a/ndk/sources/android/libportable/arch-x86/md_swap.c +++ b/ndk/sources/android/libportable/arch-x86/md_swap.c @@ -1,5 +1,5 @@ /* - * Copyright 2013, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ndk/sources/android/libportable/arch-x86/stat.c b/ndk/sources/android/libportable/arch-x86/stat.c index 1d1737838..8a2a477bc 100644 --- a/ndk/sources/android/libportable/arch-x86/stat.c +++ b/ndk/sources/android/libportable/arch-x86/stat.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,38 +14,4 @@ * limitations under the License. */ -#include #include - -/* Note: The Portable Header will define stat to stat_portable */ -int WRAP(stat)(const char *path, struct stat_portable *s) -{ - struct stat x86_stat; - int ret = REAL(stat)(path, &x86_stat); - stat_ntop(&x86_stat, s); - return ret; -} - -int WRAP(fstat)(int fd, struct stat_portable *s) -{ - struct stat x86_stat; - int ret = REAL(fstat)(fd, &x86_stat); - stat_ntop(&x86_stat, s); - return ret; -} - -int WRAP(lstat)(const char *path, struct stat_portable *s) -{ - struct stat x86_stat; - int ret = REAL(lstat)(path, &x86_stat); - stat_ntop(&x86_stat, s); - return ret; -} - -int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags) -{ - struct stat x86_stat; - int ret = REAL(fstatat)(dirfd, path, &x86_stat, flags); - stat_ntop(&x86_stat, s); - return ret; -} diff --git a/ndk/sources/android/libportable/arch-x86/vfs.c b/ndk/sources/android/libportable/arch-x86/vfs.c new file mode 100644 index 000000000..fe8becd43 --- /dev/null +++ b/ndk/sources/android/libportable/arch-x86/vfs.c @@ -0,0 +1,17 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include diff --git a/ndk/sources/android/libportable/arch-mips/epoll.c b/ndk/sources/android/libportable/arch-x86_64/epoll.c similarity index 60% rename from ndk/sources/android/libportable/arch-mips/epoll.c rename to ndk/sources/android/libportable/arch-x86_64/epoll.c index ef75695df..ef929af68 100644 --- a/ndk/sources/android/libportable/arch-mips/epoll.c +++ b/ndk/sources/android/libportable/arch-x86_64/epoll.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,16 +14,4 @@ * limitations under the License. */ -#include -#include - -int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event *event) -{ - return REAL(epoll_ctl)(epfd, op, fd, event); -} - -int WRAP(epoll_wait)(int epfd, struct epoll_event *events, int max, int timeout) -{ - return REAL(epoll_wait)(epfd, events, max, timeout); -} - +#include diff --git a/ndk/sources/android/libportable/arch-x86_64/fcntl.c b/ndk/sources/android/libportable/arch-x86_64/fcntl.c new file mode 100644 index 000000000..de620c550 --- /dev/null +++ b/ndk/sources/android/libportable/arch-x86_64/fcntl.c @@ -0,0 +1,17 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include diff --git a/ndk/sources/android/libportable/arch-x86_64/fenv.c b/ndk/sources/android/libportable/arch-x86_64/fenv.c index f1a55da42..d3c18af07 100644 --- a/ndk/sources/android/libportable/arch-x86_64/fenv.c +++ b/ndk/sources/android/libportable/arch-x86_64/fenv.c @@ -14,169 +14,4 @@ * limitations under the License. */ - -#include - -#include -#include -#include #include - -#ifndef _ROUND_MASK -#define FE_TONEAREST 0x0000 -#define FE_DOWNWARD 0x0400 -#define FE_UPWARD 0x0800 -#define FE_TOWARDZERO 0x0c00 -#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ - FE_UPWARD | FE_TOWARDZERO) -#endif - -static inline int x86_64_change_except(int flag) { - int x86_64flag = 0; - int exception = flag & FE_ALL_EXCEPT_PORTABLE; - - if (exception & FE_INVALID_PORTABLE) - x86_64flag |= FE_INVALID; - if (exception & FE_DIVBYZERO_PORTABLE) - x86_64flag |= FE_DIVBYZERO; - if (exception & FE_OVERFLOW_PORTABLE) - x86_64flag |= FE_OVERFLOW; - if (exception & FE_UNDERFLOW_PORTABLE) - x86_64flag |= FE_UNDERFLOW; - if (exception & FE_INEXACT_PORTABLE) - x86_64flag |= FE_INEXACT; - - return x86_64flag; -} - -static inline int x86_64_change_rounding(int flag) { - int x86_64flag = 0; - int rounding = flag & 0x03; - - switch(rounding) { - case FE_TONEAREST_PORTABLE: { - x86_64flag = FE_TONEAREST; - break; - } - case FE_DOWNWARD_PORTABLE: { - x86_64flag = FE_DOWNWARD; - break; - } - case FE_UPWARD_PORTABLE: { - x86_64flag = FE_UPWARD; - break; - } - case FE_TOWARDZERO_PORTABLE: { - x86_64flag = FE_TOWARDZERO; - break; - } - } - - return x86_64flag; -} - -static inline int x86_64_get_except(int x86_64flag) { - int flag = 0; - int exception = x86_64flag & FE_ALL_EXCEPT; - - if (exception & FE_INVALID) - flag |= FE_INVALID_PORTABLE; - if (exception & FE_DIVBYZERO) - flag |= FE_DIVBYZERO_PORTABLE; - if (exception & FE_OVERFLOW) - flag |= FE_OVERFLOW_PORTABLE; - if (exception & FE_UNDERFLOW) - flag |= FE_UNDERFLOW_PORTABLE; - if (exception & FE_INEXACT) - flag |= FE_INEXACT_PORTABLE; - - return flag; -} - -static inline int x86_64_get_rounding(int x86_64flag) { - int flag = 0; - int rounding = x86_64flag & _ROUND_MASK; - - switch(rounding) { - case FE_TONEAREST: { - flag = FE_TONEAREST_PORTABLE; - break; - } - case FE_DOWNWARD: { - flag = FE_DOWNWARD_PORTABLE; - break; - } - case FE_UPWARD: { - flag = FE_UPWARD_PORTABLE; - break; - } - case FE_TOWARDZERO: { - flag = FE_TOWARDZERO_PORTABLE; - break; - } - } - - return flag; -} - - -int WRAP(feclearexcept)(int flag) { - return REAL(feclearexcept)(x86_64_change_except(flag)); -} - -#ifdef __LP64__ -int WRAP(fegetexceptflag)(fexcept_t_portable *obj, int flag) { - int ret = REAL(fegetexceptflag)((fexcept_t*)obj, x86_64_change_except(flag)); - *obj = (fexcept_t_portable) x86_64_get_except(*obj); - return ret; -} - -int WRAP(fesetexceptflag)(const fexcept_t_portable *obj, int flag) { - const fexcept_t x86_64obj = x86_64_change_except(*obj); - int x86_64flag = x86_64_change_except(flag); - return REAL(fesetexceptflag)(&x86_64obj, x86_64flag); -} -#endif - -int WRAP(feraiseexcept)(int flag) { - return REAL(feraiseexcept)(x86_64_change_except(flag)); -} - - -int WRAP(fetestexcept)(int flag) { - int ret = REAL(fetestexcept)(x86_64_change_except(flag)); - return x86_64_get_except(ret); -} - -int WRAP(fegetround)(void) { - int round = REAL(fegetround)(); - return x86_64_get_rounding(round); -} - -int WRAP(fesetround)(int round) { - return REAL(fesetround)(x86_64_change_rounding(round)); -} - -#ifdef __LP64__ -int WRAP(fegetenv)(fenv_t_portable *obj) { - return REAL(fegetenv)((fenv_t*)obj); -} - -int WRAP(feholdexcept)(fenv_t_portable *obj) { - return REAL(feholdexcept)((fenv_t*)obj); -} - -int WRAP(fesetenv)(const fenv_t_portable *obj) { - return REAL(fesetenv)((const fenv_t*)obj); -} - -int WRAP(feupdateenv)(const fenv_t_portable *obj) { - return REAL(feupdateenv)((const fenv_t*)obj); -} -#endif - -int WRAP(fegetexcept)(void) { - int flag = REAL(fegetexcept)(); - return x86_64_get_except(flag); -} - diff --git a/ndk/sources/android/libportable/arch-x86_64/stat.c b/ndk/sources/android/libportable/arch-x86_64/stat.c index dd128bce9..8a2a477bc 100644 --- a/ndk/sources/android/libportable/arch-x86_64/stat.c +++ b/ndk/sources/android/libportable/arch-x86_64/stat.c @@ -14,52 +14,4 @@ * limitations under the License. */ -#include #include -#include - - -int WRAP(fstat)(int fd, struct stat_portable *s) { - struct stat x86_64_stat; - int ret = REAL(fstat)(fd, &x86_64_stat); - stat_ntop(&x86_64_stat, s); - return ret; -} -static inline int WRAP(fstat64)(int fd, struct stat64_portable *s) { - return WRAP(fstat)(fd, (struct stat_portable*)s); -} - - -int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags) { - struct stat x86_64_stat; - int ret = REAL(fstatat)(dirfd, path, &x86_64_stat, flags); - stat_ntop(&x86_64_stat, s); - return ret; -} -static inline int WRAP(fstatat64)(int dirfd, const char *path, - struct stat64_portable *s, int flags) { - return WRAP(fstatat)(dirfd, path, (struct stat_portable*)s, flags); -} - - -int WRAP(lstat)(const char *path, struct stat_portable *s) { - struct stat x86_64_stat; - int ret = REAL(lstat)(path, &x86_64_stat); - stat_ntop(&x86_64_stat, s); - return ret; -} -static inline int WRAP(lstat64)(const char *path, struct stat64_portable *s) { - return WRAP(lstat)(path, (struct stat_portable*)s); -} - - -int WRAP(stat)(const char* path, struct stat_portable* s) { - struct stat x86_64_stat; - int ret = REAL(stat)(path, &x86_64_stat); - stat_ntop(&x86_64_stat, s); - return ret; -} -static inline int WRAP(stat64)(const char* path, struct stat64_portable *s) { - return WRAP(stat)(path, (struct stat_portable*)s); -} - diff --git a/ndk/sources/android/libportable/arch-x86_64/va_funcs.c b/ndk/sources/android/libportable/arch-x86_64/va_funcs.c deleted file mode 100644 index d27aaa007..000000000 --- a/ndk/sources/android/libportable/arch-x86_64/va_funcs.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2014, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include - -int WRAP(vfprintf)(FILE *stream, const char *format, va_list_portable *arg) { - return REAL(vfprintf)(stream, format, arg); -} - -int WRAP(vfscanf)(FILE *stream, const char *format, va_list_portable *arg) { - return REAL(vfscanf)(stream, format, arg); -} - -int WRAP(vprintf)(const char *format, va_list_portable *arg) { - return REAL(vprintf)(format, arg); -} - -int WRAP(vscanf)(const char *format, va_list_portable *arg) { - return REAL(vscanf)(format, arg); -} - -int WRAP(vsnprintf)(char *s, size_t n, const char *format, va_list_portable *arg) { - return REAL(vsnprintf)(s, n, format, arg); -} - -int WRAP(vsprintf)(char *s, const char *format, va_list_portable *arg) { - return REAL(vsprintf)(s, format, arg); -} - -int WRAP(vsscanf)(const char *s, const char *format, va_list_portable *arg) { - return REAL(vsscanf)(s, format, arg); -} - diff --git a/ndk/sources/android/libportable/arch-x86_64/vfs.c b/ndk/sources/android/libportable/arch-x86_64/vfs.c index 94d6793b3..fe8becd43 100644 --- a/ndk/sources/android/libportable/arch-x86_64/vfs.c +++ b/ndk/sources/android/libportable/arch-x86_64/vfs.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,5 +14,4 @@ * limitations under the License. */ -#include #include diff --git a/ndk/sources/android/libportable/common/include/asm-generic/portability.h b/ndk/sources/android/libportable/common/include/asm-generic/portability.h deleted file mode 100644 index 31fcb079e..000000000 --- a/ndk/sources/android/libportable/common/include/asm-generic/portability.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _ASM_PORTABILITY_H_ -#define _ASM_PORTABILITY_H_ - -#if !defined(__HOST__) -#define WRAP(f) f ## _portable -#define REAL(f) f -#else -/* On host app link with libpportable.a with -Wl,--wrap=symbol, which resolves undefined symbol to __wrap_symbol, - * and undefined __real_symbol to the original symbol - */ -#define WRAP(f) __wrap_ ## f -#define REAL(f) __real_ ## f -#endif - -#if defined(__mips__) && !defined(END) -#define END(f) .cfi_endproc; .end f -#endif - -#endif /* _ASM_PORTABILITY_H_ */ diff --git a/ndk/sources/android/libportable/common/include/asm-generic/siginfo_portable.h b/ndk/sources/android/libportable/common/include/asm-generic/siginfo_portable.h deleted file mode 100644 index 1f13ad8ea..000000000 --- a/ndk/sources/android/libportable/common/include/asm-generic/siginfo_portable.h +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** - Derived from platforms/android-14/arch-arm/usr/include/asm-generic/siginfo.h - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _ASM_PORTABLE_GENERIC_SIGINFO_H -#define _ASM_PORTABLE_GENERIC_SIGINFO_H - -#include -#include - -typedef union sigval_portable { - int sival_int; - void __user *sival_ptr; -} sigval_portable_t; - -#ifndef __ARCH_SI_PREAMBLE_SIZE -#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) -#endif - -#define SI_MAX_SIZE 128 -#ifndef SI_PAD_SIZE -#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) -#endif - -#ifndef __ARCH_SI_UID_T -#define __ARCH_SI_UID_T uid_t -#endif - -#ifndef __ARCH_SI_BAND_T -#define __ARCH_SI_BAND_T long -#endif - -typedef struct siginfo_portable { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[SI_PAD_SIZE]; - - struct { - pid_t _pid; - __ARCH_SI_UID_T _uid; - } _kill; - - struct { - timer_t _tid; - int _overrun; - char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)]; - sigval_portable_t _sigval; - int _sys_private; - } _timer; - - struct { - pid_t _pid; - __ARCH_SI_UID_T _uid; - sigval_t _sigval; - } _rt; - - struct { - pid_t _pid; - __ARCH_SI_UID_T _uid; - int _status; - clock_t _utime; - clock_t _stime; - } _sigchld; - - struct { - void __user *_addr; -#ifdef __ARCH_SI_TRAPNO - int _trapno; -#endif - } _sigfault; - - struct { - __ARCH_SI_BAND_T _band; - int _fd; - } _sigpoll; - - } _sifields; -} siginfo_portable_t; - -#ifndef si_pid -#define si_pid _sifields._kill._pid -#define si_uid _sifields._kill._uid -#define si_tid _sifields._timer._tid -#define si_overrun _sifields._timer._overrun -#define si_sys_private _sifields._timer._sys_private -#define si_status _sifields._sigchld._status -#define si_utime _sifields._sigchld._utime -#define si_stime _sifields._sigchld._stime -#define si_value _sifields._rt._sigval -#define si_int _sifields._rt._sigval.sival_int -#define si_ptr _sifields._rt._sigval.sival_ptr -#define si_addr _sifields._sigfault._addr -#ifdef __ARCH_SI_TRAPNO -#define si_trapno _sifields._sigfault._trapno -#endif -#define si_band _sifields._sigpoll._band -#define si_fd _sifields._sigpoll._fd -#endif - -#ifndef __SI_KILL -#define __SI_KILL 0 -#define __SI_TIMER 0 -#define __SI_POLL 0 -#define __SI_FAULT 0 -#define __SI_CHLD 0 -#define __SI_RT 0 -#define __SI_MESGQ 0 -#define __SI_CODE(T,N) (N) -#endif - -#ifndef SI_USER -#define SI_USER 0 -#define SI_KERNEL 0x80 -#define SI_QUEUE -1 -#define SI_TIMER __SI_CODE(__SI_TIMER,-2) -#define SI_MESGQ __SI_CODE(__SI_MESGQ,-3) -#define SI_ASYNCIO -4 -#define SI_SIGIO -5 -#define SI_TKILL -6 -#define SI_DETHREAD -7 - -#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0) -#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0) -#endif - -#ifndef ILL_ILLOPC -#define ILL_ILLOPC (__SI_FAULT|1) -#define ILL_ILLOPN (__SI_FAULT|2) -#define ILL_ILLADR (__SI_FAULT|3) -#define ILL_ILLTRP (__SI_FAULT|4) -#define ILL_PRVOPC (__SI_FAULT|5) -#define ILL_PRVREG (__SI_FAULT|6) -#define ILL_COPROC (__SI_FAULT|7) -#define ILL_BADSTK (__SI_FAULT|8) -#define NSIGILL 8 -#endif - -#ifndef FPE_INTDIV -#define FPE_INTDIV (__SI_FAULT|1) -#define FPE_INTOVF (__SI_FAULT|2) -#define FPE_FLTDIV (__SI_FAULT|3) -#define FPE_FLTOVF (__SI_FAULT|4) -#define FPE_FLTUND (__SI_FAULT|5) -#define FPE_FLTRES (__SI_FAULT|6) -#define FPE_FLTINV (__SI_FAULT|7) -#define FPE_FLTSUB (__SI_FAULT|8) -#define NSIGFPE 8 - -#define SEGV_MAPERR (__SI_FAULT|1) -#define SEGV_ACCERR (__SI_FAULT|2) -#define NSIGSEGV 2 - -#define BUS_ADRALN (__SI_FAULT|1) -#define BUS_ADRERR (__SI_FAULT|2) -#define BUS_OBJERR (__SI_FAULT|3) -#define NSIGBUS 3 - -#define TRAP_BRKPT (__SI_FAULT|1) -#define TRAP_TRACE (__SI_FAULT|2) -#define NSIGTRAP 2 - -#define CLD_EXITED (__SI_CHLD|1) -#define CLD_KILLED (__SI_CHLD|2) -#define CLD_DUMPED (__SI_CHLD|3) -#define CLD_TRAPPED (__SI_CHLD|4) -#define CLD_STOPPED (__SI_CHLD|5) -#define CLD_CONTINUED (__SI_CHLD|6) -#define NSIGCHLD 6 - -#define POLL_IN (__SI_POLL|1) -#define POLL_OUT (__SI_POLL|2) -#define POLL_MSG (__SI_POLL|3) -#define POLL_ERR (__SI_POLL|4) -#define POLL_PRI (__SI_POLL|5) -#define POLL_HUP (__SI_POLL|6) -#define NSIGPOLL 6 - -#define SIGEV_SIGNAL 0 -#define SIGEV_NONE 1 -#define SIGEV_THREAD 2 -#define SIGEV_THREAD_ID 4 -#endif /* FPE_INTDIV */ - -#ifndef __ARCH_SIGEV_PREAMBLE_SIZE -#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_portable_t)) -#endif - -#define SIGEV_MAX_SIZE 64 -#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) / sizeof(int)) - -typedef struct sigevent_portable { - sigval_portable_t sigev_value; - int sigev_signo; - int sigev_notify; - union { - int _pad[SIGEV_PAD_SIZE]; - int _tid; - - struct { - void (*_function)(sigval_portable_t); - void *_attribute; - } _sigev_thread; - } _sigev_un; -} sigevent_portable_t; - -#define sigev_notify_function _sigev_un._sigev_thread._function -#define sigev_notify_attributes _sigev_un._sigev_thread._attribute -#define sigev_notify_thread_id _sigev_un._tid - -#endif diff --git a/ndk/sources/android/libportable/common/include/asm-generic/signal_portable.h b/ndk/sources/android/libportable/common/include/asm-generic/signal_portable.h deleted file mode 100644 index 97b1b405a..000000000 --- a/ndk/sources/android/libportable/common/include/asm-generic/signal_portable.h +++ /dev/null @@ -1,21 +0,0 @@ -/**************************************************************************** - Derived from platforms/android-14/arch-arm/usr/include/asm-generic/signal.h - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - **************************************************************************** - ****************************************************************************/ -#ifndef __ASM_GENERIC_SIGNAL_PORTABLE_H -#define __ASM_GENERIC_SIGNAL_PORTABLE_H - -#define SIG_BLOCK_PORTABLE 0 -#define SIG_UNBLOCK_PORTABLE 1 -#define SIG_SETMASK_PORTABLE 2 - -#endif - diff --git a/ndk/sources/android/libportable/common/include/asm/sigcontext_portable.h b/ndk/sources/android/libportable/common/include/asm/sigcontext_portable.h deleted file mode 100644 index 477b3e847..000000000 --- a/ndk/sources/android/libportable/common/include/asm/sigcontext_portable.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** - Derived from gdk/platforms/android-14/arch-arm/usr/include/asm/sigcontext.h - **************************************************************************** - *** - *** This header was ORIGINALLY automatically generated from a Linux kernel - *** header of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _ASMARM_SIGCONTEXT_PORTABLE_H -#define _ASMARM_SIGCONTEXT_PORTABLE_H - -struct sigcontext_portable { - unsigned long trap_no; - unsigned long error_code; - unsigned long oldmask; - unsigned long arm_r0; - unsigned long arm_r1; - unsigned long arm_r2; - unsigned long arm_r3; - unsigned long arm_r4; - unsigned long arm_r5; - unsigned long arm_r6; - unsigned long arm_r7; - unsigned long arm_r8; - unsigned long arm_r9; - unsigned long arm_r10; - unsigned long arm_fp; - unsigned long arm_ip; - unsigned long arm_sp; - unsigned long arm_lr; - unsigned long arm_pc; - unsigned long arm_cpsr; - unsigned long fault_address; -}; - -#endif diff --git a/ndk/sources/android/libportable/common/include/asm/siginfo_portable.h b/ndk/sources/android/libportable/common/include/asm/siginfo_portable.h deleted file mode 100644 index 283f23ece..000000000 --- a/ndk/sources/android/libportable/common/include/asm/siginfo_portable.h +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************** - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _ASM_PORTABLE_SIGINFO_H -#define _ASM_PORTABLE_SIGINFO_H - -#include - -#endif diff --git a/ndk/sources/android/libportable/common/include/asm/signal_portable.h b/ndk/sources/android/libportable/common/include/asm/signal_portable.h deleted file mode 100644 index 48d33f59a..000000000 --- a/ndk/sources/android/libportable/common/include/asm/signal_portable.h +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** - Derived from gdk/platforms/android-14/arch-arm/usr/include/asm/signal.h - **************************************************************************** - *** - *** This header was ORIGINALLY automatically generated from a Linux kernel - *** header of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _ASMARM_SIGNAL_PORTABLE_H -#define _ASMARM_SIGNAL_PORTABLE_H - -struct siginfo; /* TODO: Change to siginfo_portable */ - -#define NSIG_PORTABLE 64 -typedef unsigned long sigset_portable_t; - -#define SIGHUP_PORTABLE 1 -#define SIGINT_PORTABLE 2 -#define SIGQUIT_PORTABLE 3 -#define SIGILL_PORTABLE 4 -#define SIGTRAP_PORTABLE 5 -#define SIGABRT_PORTABLE 6 -#define SIGIOT_PORTABLE 6 -#define SIGBUS_PORTABLE 7 -#define SIGFPE_PORTABLE 8 -#define SIGKILL_PORTABLE 9 -#define SIGUSR1_PORTABLE 10 -#define SIGSEGV_PORTABLE 11 -#define SIGUSR2_PORTABLE 12 -#define SIGPIPE_PORTABLE 13 -#define SIGALRM_PORTABLE 14 -#define SIGTERM_PORTABLE 15 -#define SIGSTKFLT_PORTABLE 16 -#define SIGCHLD_PORTABLE 17 -#define SIGCONT_PORTABLE 18 -#define SIGSTOP_PORTABLE 19 -#define SIGTSTP_PORTABLE 20 -#define SIGTTIN_PORTABLE 21 -#define SIGTTOU_PORTABLE 22 -#define SIGURG_PORTABLE 23 -#define SIGXCPU_PORTABLE 24 -#define SIGXFSZ_PORTABLE 25 -#define SIGVTALRM_PORTABLE 26 -#define SIGPROF_PORTABLE 27 -#define SIGWINCH_PORTABLE 28 -#define SIGIO_PORTABLE 29 -#define SIGPOLL_PORTABLE SIGIO - -#define SIGPWR_PORTABLE 30 -#define SIGSYS_PORTABLE 31 -#define SIGUNUSED_PORTABLE 31 - -#define SIGSWI_PORTABLE 32 -#define SIGRTMIN_PORTABLE 32 - -#define SIGRT_1_PORTABLE (SIGRTMIN_PORTABLE + 1) -#define SIGRT_2_PORTABLE (SIGRTMIN_PORTABLE + 2) -#define SIGRT_3_PORTABLE (SIGRTMIN_PORTABLE + 3) -#define SIGRT_4_PORTABLE (SIGRTMIN_PORTABLE + 4) -#define SIGRT_5_PORTABLE (SIGRTMIN_PORTABLE + 5) -#define SIGRT_5_PORTABLE (SIGRTMIN_PORTABLE + 5) -#define SIGRT_6_PORTABLE (SIGRTMIN_PORTABLE + 6) -#define SIGRT_7_PORTABLE (SIGRTMIN_PORTABLE + 7) -#define SIGRT_8_PORTABLE (SIGRTMIN_PORTABLE + 8) -#define SIGRT_9_PORTABLE (SIGRTMIN_PORTABLE + 9) -#define SIGRT_10_PORTABLE (SIGRTMIN_PORTABLE + 10) -#define SIGRT_11_PORTABLE (SIGRTMIN_PORTABLE + 11) -#define SIGRT_12_PORTABLE (SIGRTMIN_PORTABLE + 12) -#define SIGRT_13_PORTABLE (SIGRTMIN_PORTABLE + 13) -#define SIGRT_14_PORTABLE (SIGRTMIN_PORTABLE + 14) -#define SIGRT_15_PORTABLE (SIGRTMIN_PORTABLE + 15) -#define SIGRT_15_PORTABLE (SIGRTMIN_PORTABLE + 15) -#define SIGRT_16_PORTABLE (SIGRTMIN_PORTABLE + 16) -#define SIGRT_17_PORTABLE (SIGRTMIN_PORTABLE + 17) -#define SIGRT_18_PORTABLE (SIGRTMIN_PORTABLE + 18) -#define SIGRT_19_PORTABLE (SIGRTMIN_PORTABLE + 19) -#define SIGRT_20_PORTABLE (SIGRTMIN_PORTABLE + 20) -#define SIGRT_20_PORTABLE (SIGRTMIN_PORTABLE + 20) -#define SIGRT_21_PORTABLE (SIGRTMIN_PORTABLE + 21) -#define SIGRT_22_PORTABLE (SIGRTMIN_PORTABLE + 22) -#define SIGRT_23_PORTABLE (SIGRTMIN_PORTABLE + 23) -#define SIGRT_24_PORTABLE (SIGRTMIN_PORTABLE + 24) -#define SIGRT_25_PORTABLE (SIGRTMIN_PORTABLE + 25) -#define SIGRT_25_PORTABLE (SIGRTMIN_PORTABLE + 25) -#define SIGRT_26_PORTABLE (SIGRTMIN_PORTABLE + 26) -#define SIGRT_27_PORTABLE (SIGRTMIN_PORTABLE + 27) -#define SIGRT_28_PORTABLE (SIGRTMIN_PORTABLE + 28) -#define SIGRT_29_PORTABLE (SIGRTMIN_PORTABLE + 29) -#define SIGRT_30_PORTABLE (SIGRTMIN_PORTABLE + 30) -#define SIGRT_31_PORTABLE (SIGRTMIN_PORTABLE + 31) -#define SIGRT_32_PORTABLE (SIGRTMIN_PORTABLE + 32) - -#define SIGRTMAX_PORTABLE NSIG_PORTABLE - -/* - * Define MIPS/Native Real Time Signal Names for debugging. - * NOTE: - * Currently only defining the 32 RT signals that the - * lib-portable application can interact with. MIPS has - * an additional 63 signals. - */ - -#ifndef __SIGRTMIN -#define __SIGRTMIN SIGRTMIN -#endif -#ifndef __SIGRTMAX -#define __SIGRTMAX SIGRTMAX -#endif - -#define SIGRT_1 (__SIGRTMIN + 1) -#define SIGRT_2 (__SIGRTMIN + 2) -#define SIGRT_3 (__SIGRTMIN + 3) -#define SIGRT_4 (__SIGRTMIN + 4) -#define SIGRT_5 (__SIGRTMIN + 5) -#define SIGRT_5 (__SIGRTMIN + 5) -#define SIGRT_6 (__SIGRTMIN + 6) -#define SIGRT_7 (__SIGRTMIN + 7) -#define SIGRT_8 (__SIGRTMIN + 8) -#define SIGRT_9 (__SIGRTMIN + 9) -#define SIGRT_10 (__SIGRTMIN + 10) -#define SIGRT_11 (__SIGRTMIN + 11) -#define SIGRT_12 (__SIGRTMIN + 12) -#define SIGRT_13 (__SIGRTMIN + 13) -#define SIGRT_14 (__SIGRTMIN + 14) -#define SIGRT_15 (__SIGRTMIN + 15) -#define SIGRT_15 (__SIGRTMIN + 15) -#define SIGRT_16 (__SIGRTMIN + 16) -#define SIGRT_17 (__SIGRTMIN + 17) -#define SIGRT_18 (__SIGRTMIN + 18) -#define SIGRT_19 (__SIGRTMIN + 19) -#define SIGRT_20 (__SIGRTMIN + 20) -#define SIGRT_20 (__SIGRTMIN + 20) -#define SIGRT_21 (__SIGRTMIN + 21) -#define SIGRT_22 (__SIGRTMIN + 22) -#define SIGRT_23 (__SIGRTMIN + 23) -#define SIGRT_24 (__SIGRTMIN + 24) -#define SIGRT_25 (__SIGRTMIN + 25) -#define SIGRT_25 (__SIGRTMIN + 25) -#define SIGRT_26 (__SIGRTMIN + 26) -#define SIGRT_27 (__SIGRTMIN + 27) -#define SIGRT_28 (__SIGRTMIN + 28) -#define SIGRT_29 (__SIGRTMIN + 29) -#define SIGRT_30 (__SIGRTMIN + 30) -#define SIGRT_31 (__SIGRTMIN + 31) -#define SIGRT_32 (__SIGRTMIN + 32) -/* - * NOTE: Native signals SIGRT_33 ... SIGRTMAX - * can't be used by a lib-portable application. - */ - -#define SA_NOCLDSTOP_PORTABLE 0x00000001 -#define SA_NOCLDWAIT_PORTABLE 0x00000002 -#define SA_SIGINFO_PORTABLE 0x00000004 -#define SA_THIRTYTWO_PORTABLE 0x02000000 -#define SA_RESTORER_PORTABLE 0x04000000 -#define SA_ONSTACK_PORTABLE 0x08000000 -#define SA_RESTART_PORTABLE 0x10000000 -#define SA_NODEFER_PORTABLE 0x40000000 -#define SA_RESETHAND_PORTABLE 0x80000000 - -#define SA_NOMASK_PORTSBLE SA_NODEFER_PORTABLE -#define SA_ONESHOT_PORTABLE SA_RESETHAND_PORABLE - - -#include - -typedef __signalfn_t __user *__sighandler_portable_t; -typedef void (*__sigaction_handler_portable_t)(int, struct siginfo *, void *); - -struct sigaction_portable { - union { - __sighandler_portable_t _sa_handler; - __sigaction_handler_portable_t _sa_sigaction; - } _u; - sigset_portable_t sa_mask; - unsigned long sa_flags; - void (*sa_restorer)(void); -}; - -#define sa_handler_portable _u._sa_handler -#define sa_sigaction_portable _u._sa_sigaction - -typedef struct sigaltstack_portable { - void __user *ss_sp; - int ss_flags; - size_t ss_size; -} portable_stack_t; - -#endif diff --git a/ndk/sources/android/libportable/common/include/asm/unistd-portable.h b/ndk/sources/android/libportable/common/include/asm/unistd-portable.h deleted file mode 100644 index a542e9244..000000000 --- a/ndk/sources/android/libportable/common/include/asm/unistd-portable.h +++ /dev/null @@ -1,401 +0,0 @@ -#ifndef __ASM_UNISTD_PORTABLE_H -#define __ASM_UNISTD_PORTABLE_H - -/* Derived from android-14/arch-arm/usr/include/asm/unistd.h */ - -#define __NR_SYSCALL_BASE_portable 0 - -#define __NR_restart_syscall_portable (__NR_SYSCALL_BASE_portable+ 0) -#define __NR_exit_portable (__NR_SYSCALL_BASE_portable+ 1) -#define __NR_fork_portable (__NR_SYSCALL_BASE_portable+ 2) -#define __NR_read_portable (__NR_SYSCALL_BASE_portable+ 3) -#define __NR_write_portable (__NR_SYSCALL_BASE_portable+ 4) -#define __NR_open_portable (__NR_SYSCALL_BASE_portable+ 5) -#define __NR_close_portable (__NR_SYSCALL_BASE_portable+ 6) - -#define __NR_creat_portable (__NR_SYSCALL_BASE_portable+ 8) -#define __NR_link_portable (__NR_SYSCALL_BASE_portable+ 9) -#define __NR_unlink_portable (__NR_SYSCALL_BASE_portable+ 10) -#define __NR_execve_portable (__NR_SYSCALL_BASE_portable+ 11) -#define __NR_chdir_portable (__NR_SYSCALL_BASE_portable+ 12) -#define __NR_time_portable (__NR_SYSCALL_BASE_portable+ 13) -#define __NR_mknod_portable (__NR_SYSCALL_BASE_portable+ 14) -#define __NR_chmod_portable (__NR_SYSCALL_BASE_portable+ 15) -#define __NR_lchown_portable (__NR_SYSCALL_BASE_portable+ 16) - -#define __NR_lseek_portable (__NR_SYSCALL_BASE_portable+ 19) -#define __NR_getpid_portable (__NR_SYSCALL_BASE_portable+ 20) -#define __NR_mount_portable (__NR_SYSCALL_BASE_portable+ 21) -#define __NR_umount_portable (__NR_SYSCALL_BASE_portable+ 22) -#define __NR_setuid_portable (__NR_SYSCALL_BASE_portable+ 23) -#define __NR_getuid_portable (__NR_SYSCALL_BASE_portable+ 24) -#define __NR_stime_portable (__NR_SYSCALL_BASE_portable+ 25) -#define __NR_ptrace_portable (__NR_SYSCALL_BASE_portable+ 26) -#define __NR_alarm_portable (__NR_SYSCALL_BASE_portable+ 27) - -#define __NR_pause_portable (__NR_SYSCALL_BASE_portable+ 29) -#define __NR_utime_portable (__NR_SYSCALL_BASE_portable+ 30) - -#define __NR_access_portable (__NR_SYSCALL_BASE_portable+ 33) -#define __NR_nice_portable (__NR_SYSCALL_BASE_portable+ 34) - -#define __NR_sync_portable (__NR_SYSCALL_BASE_portable+ 36) -#define __NR_kill_portable (__NR_SYSCALL_BASE_portable+ 37) -#define __NR_rename_portable (__NR_SYSCALL_BASE_portable+ 38) -#define __NR_mkdir_portable (__NR_SYSCALL_BASE_portable+ 39) -#define __NR_rmdir_portable (__NR_SYSCALL_BASE_portable+ 40) -#define __NR_dup_portable (__NR_SYSCALL_BASE_portable+ 41) -#define __NR_pipe_portable (__NR_SYSCALL_BASE_portable+ 42) -#define __NR_times_portable (__NR_SYSCALL_BASE_portable+ 43) - -#define __NR_brk_portable (__NR_SYSCALL_BASE_portable+ 45) -#define __NR_setgid_portable (__NR_SYSCALL_BASE_portable+ 46) -#define __NR_getgid_portable (__NR_SYSCALL_BASE_portable+ 47) - -#define __NR_geteuid_portable (__NR_SYSCALL_BASE_portable+ 49) -#define __NR_getegid_portable (__NR_SYSCALL_BASE_portable+ 50) -#define __NR_acct_portable (__NR_SYSCALL_BASE_portable+ 51) -#define __NR_umount2_portable (__NR_SYSCALL_BASE_portable+ 52) - -#define __NR_ioctl_portable (__NR_SYSCALL_BASE_portable+ 54) -#define __NR_fcntl_portable (__NR_SYSCALL_BASE_portable+ 55) - -#define __NR_setpgid_portable (__NR_SYSCALL_BASE_portable+ 57) - -#define __NR_umask_portable (__NR_SYSCALL_BASE_portable+ 60) -#define __NR_chroot_portable (__NR_SYSCALL_BASE_portable+ 61) -#define __NR_ustat_portable (__NR_SYSCALL_BASE_portable+ 62) -#define __NR_dup2_portable (__NR_SYSCALL_BASE_portable+ 63) -#define __NR_getppid_portable (__NR_SYSCALL_BASE_portable+ 64) -#define __NR_getpgrp_portable (__NR_SYSCALL_BASE_portable+ 65) -#define __NR_setsid_portable (__NR_SYSCALL_BASE_portable+ 66) -#define __NR_sigaction_portable (__NR_SYSCALL_BASE_portable+ 67) - -#define __NR_setreuid_portable (__NR_SYSCALL_BASE_portable+ 70) -#define __NR_setregid_portable (__NR_SYSCALL_BASE_portable+ 71) -#define __NR_sigsuspend_portable (__NR_SYSCALL_BASE_portable+ 72) -#define __NR_sigpending_portable (__NR_SYSCALL_BASE_portable+ 73) -#define __NR_sethostname_portable (__NR_SYSCALL_BASE_portable+ 74) -#define __NR_setrlimit_portable (__NR_SYSCALL_BASE_portable+ 75) -#define __NR_getrlimit_portable (__NR_SYSCALL_BASE_portable+ 76) -#define __NR_getrusage_portable (__NR_SYSCALL_BASE_portable+ 77) -#define __NR_gettimeofday_portable (__NR_SYSCALL_BASE_portable+ 78) -#define __NR_settimeofday_portable (__NR_SYSCALL_BASE_portable+ 79) -#define __NR_getgroups_portable (__NR_SYSCALL_BASE_portable+ 80) -#define __NR_setgroups_portable (__NR_SYSCALL_BASE_portable+ 81) -#define __NR_select_portable (__NR_SYSCALL_BASE_portable+ 82) -#define __NR_symlink_portable (__NR_SYSCALL_BASE_portable+ 83) - -#define __NR_readlink_portable (__NR_SYSCALL_BASE_portable+ 85) -#define __NR_uselib_portable (__NR_SYSCALL_BASE_portable+ 86) -#define __NR_swapon_portable (__NR_SYSCALL_BASE_portable+ 87) -#define __NR_reboot_portable (__NR_SYSCALL_BASE_portable+ 88) -#define __NR_readdir_portable (__NR_SYSCALL_BASE_portable+ 89) -#define __NR_mmap_portable (__NR_SYSCALL_BASE_portable+ 90) -#define __NR_munmap_portable (__NR_SYSCALL_BASE_portable+ 91) -#define __NR_truncate_portable (__NR_SYSCALL_BASE_portable+ 92) -#define __NR_ftruncate_portable (__NR_SYSCALL_BASE_portable+ 93) -#define __NR_fchmod_portable (__NR_SYSCALL_BASE_portable+ 94) -#define __NR_fchown_portable (__NR_SYSCALL_BASE_portable+ 95) -#define __NR_getpriority_portable (__NR_SYSCALL_BASE_portable+ 96) -#define __NR_setpriority_portable (__NR_SYSCALL_BASE_portable+ 97) - -#define __NR_statfs_portable (__NR_SYSCALL_BASE_portable+ 99) -#define __NR_fstatfs_portable (__NR_SYSCALL_BASE_portable+100) - -#define __NR_socketcall_portable (__NR_SYSCALL_BASE_portable+102) -#define __NR_syslog_portable (__NR_SYSCALL_BASE_portable+103) -#define __NR_setitimer_portable (__NR_SYSCALL_BASE_portable+104) -#define __NR_getitimer_portable (__NR_SYSCALL_BASE_portable+105) -#define __NR_stat_portable (__NR_SYSCALL_BASE_portable+106) -#define __NR_lstat_portable (__NR_SYSCALL_BASE_portable+107) -#define __NR_fstat_portable (__NR_SYSCALL_BASE_portable+108) - -#define __NR_vhangup_portable (__NR_SYSCALL_BASE_portable+111) - -#define __NR_syscall_portable (__NR_SYSCALL_BASE_portable+113) -#define __NR_wait4_portable (__NR_SYSCALL_BASE_portable+114) -#define __NR_swapoff_portable (__NR_SYSCALL_BASE_portable+115) -#define __NR_sysinfo_portable (__NR_SYSCALL_BASE_portable+116) -#define __NR_ipc_portable (__NR_SYSCALL_BASE_portable+117) -#define __NR_fsync_portable (__NR_SYSCALL_BASE_portable+118) -#define __NR_sigreturn_portable (__NR_SYSCALL_BASE_portable+119) -#define __NR_clone_portable (__NR_SYSCALL_BASE_portable+120) -#define __NR_setdomainname_portable (__NR_SYSCALL_BASE_portable+121) -#define __NR_uname_portable (__NR_SYSCALL_BASE_portable+122) - -#define __NR_adjtimex_portable (__NR_SYSCALL_BASE_portable+124) -#define __NR_mprotect_portable (__NR_SYSCALL_BASE_portable+125) -#define __NR_sigprocmask_portable (__NR_SYSCALL_BASE_portable+126) - -#define __NR_init_module_portable (__NR_SYSCALL_BASE_portable+128) -#define __NR_delete_module_portable (__NR_SYSCALL_BASE_portable+129) - -#define __NR_quotactl_portable (__NR_SYSCALL_BASE_portable+131) -#define __NR_getpgid_portable (__NR_SYSCALL_BASE_portable+132) -#define __NR_fchdir_portable (__NR_SYSCALL_BASE_portable+133) -#define __NR_bdflush_portable (__NR_SYSCALL_BASE_portable+134) -#define __NR_sysfs_portable (__NR_SYSCALL_BASE_portable+135) -#define __NR_personality_portable (__NR_SYSCALL_BASE_portable+136) - -#define __NR_setfsuid_portable (__NR_SYSCALL_BASE_portable+138) -#define __NR_setfsgid_portable (__NR_SYSCALL_BASE_portable+139) -#define __NR__llseek_portable (__NR_SYSCALL_BASE_portable+140) -#define __NR_getdents_portable (__NR_SYSCALL_BASE_portable+141) -#define __NR__newselect_portable (__NR_SYSCALL_BASE_portable+142) -#define __NR_flock_portable (__NR_SYSCALL_BASE_portable+143) -#define __NR_msync_portable (__NR_SYSCALL_BASE_portable+144) -#define __NR_readv_portable (__NR_SYSCALL_BASE_portable+145) -#define __NR_writev_portable (__NR_SYSCALL_BASE_portable+146) -#define __NR_getsid_portable (__NR_SYSCALL_BASE_portable+147) -#define __NR_fdatasync_portable (__NR_SYSCALL_BASE_portable+148) -#define __NR__sysctl_portable (__NR_SYSCALL_BASE_portable+149) -#define __NR_mlock_portable (__NR_SYSCALL_BASE_portable+150) -#define __NR_munlock_portable (__NR_SYSCALL_BASE_portable+151) -#define __NR_mlockall_portable (__NR_SYSCALL_BASE_portable+152) -#define __NR_munlockall_portable (__NR_SYSCALL_BASE_portable+153) -#define __NR_sched_setparam_portable (__NR_SYSCALL_BASE_portable+154) -#define __NR_sched_getparam_portable (__NR_SYSCALL_BASE_portable+155) -#define __NR_sched_setscheduler_portable (__NR_SYSCALL_BASE_portable+156) -#define __NR_sched_getscheduler_portable (__NR_SYSCALL_BASE_portable+157) -#define __NR_sched_yield_portable (__NR_SYSCALL_BASE_portable+158) -#define __NR_sched_get_priority_max_portable (__NR_SYSCALL_BASE_portable+159) -#define __NR_sched_get_priority_min_portable (__NR_SYSCALL_BASE_portable+160) -#define __NR_sched_rr_get_interval_portable (__NR_SYSCALL_BASE_portable+161) -#define __NR_nanosleep_portable (__NR_SYSCALL_BASE_portable+162) -#define __NR_mremap_portable (__NR_SYSCALL_BASE_portable+163) -#define __NR_setresuid_portable (__NR_SYSCALL_BASE_portable+164) -#define __NR_getresuid_portable (__NR_SYSCALL_BASE_portable+165) - -#define __NR_poll_portable (__NR_SYSCALL_BASE_portable+168) -#define __NR_nfsservctl_portable (__NR_SYSCALL_BASE_portable+169) -#define __NR_setresgid_portable (__NR_SYSCALL_BASE_portable+170) -#define __NR_getresgid_portable (__NR_SYSCALL_BASE_portable+171) -#define __NR_prctl_portable (__NR_SYSCALL_BASE_portable+172) -#define __NR_rt_sigreturn_portable (__NR_SYSCALL_BASE_portable+173) -#define __NR_rt_sigaction_portable (__NR_SYSCALL_BASE_portable+174) -#define __NR_rt_sigprocmask_portable (__NR_SYSCALL_BASE_portable+175) -#define __NR_rt_sigpending_portable (__NR_SYSCALL_BASE_portable+176) -#define __NR_rt_sigtimedwait_portable (__NR_SYSCALL_BASE_portable+177) -#define __NR_rt_sigqueueinfo_portable (__NR_SYSCALL_BASE_portable+178) -#define __NR_rt_sigsuspend_portable (__NR_SYSCALL_BASE_portable+179) -#define __NR_pread64_portable (__NR_SYSCALL_BASE_portable+180) -#define __NR_pwrite64_portable (__NR_SYSCALL_BASE_portable+181) -#define __NR_chown_portable (__NR_SYSCALL_BASE_portable+182) -#define __NR_getcwd_portable (__NR_SYSCALL_BASE_portable+183) -#define __NR_capget_portable (__NR_SYSCALL_BASE_portable+184) -#define __NR_capset_portable (__NR_SYSCALL_BASE_portable+185) -#define __NR_sigaltstack_portable (__NR_SYSCALL_BASE_portable+186) -#define __NR_sendfile_portable (__NR_SYSCALL_BASE_portable+187) - -#define __NR_vfork_portable (__NR_SYSCALL_BASE_portable+190) -#define __NR_ugetrlimit_portable (__NR_SYSCALL_BASE_portable+191) -#define __NR_mmap2_portable (__NR_SYSCALL_BASE_portable+192) -#define __NR_truncate64_portable (__NR_SYSCALL_BASE_portable+193) -#define __NR_ftruncate64_portable (__NR_SYSCALL_BASE_portable+194) -#define __NR_stat64_portable (__NR_SYSCALL_BASE_portable+195) -#define __NR_lstat64_portable (__NR_SYSCALL_BASE_portable+196) -#define __NR_fstat64_portable (__NR_SYSCALL_BASE_portable+197) -#define __NR_lchown32_portable (__NR_SYSCALL_BASE_portable+198) -#define __NR_getuid32_portable (__NR_SYSCALL_BASE_portable+199) -#define __NR_getgid32_portable (__NR_SYSCALL_BASE_portable+200) -#define __NR_geteuid32_portable (__NR_SYSCALL_BASE_portable+201) -#define __NR_getegid32_portable (__NR_SYSCALL_BASE_portable+202) -#define __NR_setreuid32_portable (__NR_SYSCALL_BASE_portable+203) -#define __NR_setregid32_portable (__NR_SYSCALL_BASE_portable+204) -#define __NR_getgroups32_portable (__NR_SYSCALL_BASE_portable+205) -#define __NR_setgroups32_portable (__NR_SYSCALL_BASE_portable+206) -#define __NR_fchown32_portable (__NR_SYSCALL_BASE_portable+207) -#define __NR_setresuid32_portable (__NR_SYSCALL_BASE_portable+208) -#define __NR_getresuid32_portable (__NR_SYSCALL_BASE_portable+209) -#define __NR_setresgid32_portable (__NR_SYSCALL_BASE_portable+210) -#define __NR_getresgid32_portable (__NR_SYSCALL_BASE_portable+211) -#define __NR_chown32_portable (__NR_SYSCALL_BASE_portable+212) -#define __NR_setuid32_portable (__NR_SYSCALL_BASE_portable+213) -#define __NR_setgid32_portable (__NR_SYSCALL_BASE_portable+214) -#define __NR_setfsuid32_portable (__NR_SYSCALL_BASE_portable+215) -#define __NR_setfsgid32_portable (__NR_SYSCALL_BASE_portable+216) -#define __NR_getdents64_portable (__NR_SYSCALL_BASE_portable+217) -#define __NR_pivot_root_portable (__NR_SYSCALL_BASE_portable+218) -#define __NR_mincore_portable (__NR_SYSCALL_BASE_portable+219) -#define __NR_madvise_portable (__NR_SYSCALL_BASE_portable+220) -#define __NR_fcntl64_portable (__NR_SYSCALL_BASE_portable+221) - -#define __NR_gettid_portable (__NR_SYSCALL_BASE_portable+224) -#define __NR_readahead_portable (__NR_SYSCALL_BASE_portable+225) -#define __NR_setxattr_portable (__NR_SYSCALL_BASE_portable+226) -#define __NR_lsetxattr_portable (__NR_SYSCALL_BASE_portable+227) -#define __NR_fsetxattr_portable (__NR_SYSCALL_BASE_portable+228) -#define __NR_getxattr_portable (__NR_SYSCALL_BASE_portable+229) -#define __NR_lgetxattr_portable (__NR_SYSCALL_BASE_portable+230) -#define __NR_fgetxattr_portable (__NR_SYSCALL_BASE_portable+231) -#define __NR_listxattr_portable (__NR_SYSCALL_BASE_portable+232) -#define __NR_llistxattr_portable (__NR_SYSCALL_BASE_portable+233) -#define __NR_flistxattr_portable (__NR_SYSCALL_BASE_portable+234) -#define __NR_removexattr_portable (__NR_SYSCALL_BASE_portable+235) -#define __NR_lremovexattr_portable (__NR_SYSCALL_BASE_portable+236) -#define __NR_fremovexattr_portable (__NR_SYSCALL_BASE_portable+237) -#define __NR_tkill_portable (__NR_SYSCALL_BASE_portable+238) -#define __NR_sendfile64_portable (__NR_SYSCALL_BASE_portable+239) -#define __NR_futex_portable (__NR_SYSCALL_BASE_portable+240) -#define __NR_sched_setaffinity_portable (__NR_SYSCALL_BASE_portable+241) -#define __NR_sched_getaffinity_portable (__NR_SYSCALL_BASE_portable+242) -#define __NR_io_setup_portable (__NR_SYSCALL_BASE_portable+243) -#define __NR_io_destroy_portable (__NR_SYSCALL_BASE_portable+244) -#define __NR_io_getevents_portable (__NR_SYSCALL_BASE_portable+245) -#define __NR_io_submit_portable (__NR_SYSCALL_BASE_portable+246) -#define __NR_io_cancel_portable (__NR_SYSCALL_BASE_portable+247) -#define __NR_exit_group_portable (__NR_SYSCALL_BASE_portable+248) -#define __NR_lookup_dcookie_portable (__NR_SYSCALL_BASE_portable+249) -#define __NR_epoll_create_portable (__NR_SYSCALL_BASE_portable+250) -#define __NR_epoll_ctl_portable (__NR_SYSCALL_BASE_portable+251) -#define __NR_epoll_wait_portable (__NR_SYSCALL_BASE_portable+252) -#define __NR_remap_file_pages_portable (__NR_SYSCALL_BASE_portable+253) - -#define __NR_set_tid_address_portable (__NR_SYSCALL_BASE_portable+256) -#define __NR_timer_create_portable (__NR_SYSCALL_BASE_portable+257) -#define __NR_timer_settime_portable (__NR_SYSCALL_BASE_portable+258) -#define __NR_timer_gettime_portable (__NR_SYSCALL_BASE_portable+259) -#define __NR_timer_getoverrun_portable (__NR_SYSCALL_BASE_portable+260) -#define __NR_timer_delete_portable (__NR_SYSCALL_BASE_portable+261) -#define __NR_clock_settime_portable (__NR_SYSCALL_BASE_portable+262) -#define __NR_clock_gettime_portable (__NR_SYSCALL_BASE_portable+263) -#define __NR_clock_getres_portable (__NR_SYSCALL_BASE_portable+264) -#define __NR_clock_nanosleep_portable (__NR_SYSCALL_BASE_portable+265) -#define __NR_statfs64_portable (__NR_SYSCALL_BASE_portable+266) -#define __NR_fstatfs64_portable (__NR_SYSCALL_BASE_portable+267) -#define __NR_tgkill_portable (__NR_SYSCALL_BASE_portable+268) -#define __NR_utimes_portable (__NR_SYSCALL_BASE_portable+269) -#define __NR_arm_fadvise64_64_portable (__NR_SYSCALL_BASE_portable+270) -#define __NR_pciconfig_iobase_portable (__NR_SYSCALL_BASE_portable+271) -#define __NR_pciconfig_read_portable (__NR_SYSCALL_BASE_portable+272) -#define __NR_pciconfig_write_portable (__NR_SYSCALL_BASE_portable+273) -#define __NR_mq_open_portable (__NR_SYSCALL_BASE_portable+274) -#define __NR_mq_unlink_portable (__NR_SYSCALL_BASE_portable+275) -#define __NR_mq_timedsend_portable (__NR_SYSCALL_BASE_portable+276) -#define __NR_mq_timedreceive_portable (__NR_SYSCALL_BASE_portable+277) -#define __NR_mq_notify_portable (__NR_SYSCALL_BASE_portable+278) -#define __NR_mq_getsetattr_portable (__NR_SYSCALL_BASE_portable+279) -#define __NR_waitid_portable (__NR_SYSCALL_BASE_portable+280) -#define __NR_socket_portable (__NR_SYSCALL_BASE_portable+281) -#define __NR_bind_portable (__NR_SYSCALL_BASE_portable+282) -#define __NR_connect_portable (__NR_SYSCALL_BASE_portable+283) -#define __NR_listen_portable (__NR_SYSCALL_BASE_portable+284) -#define __NR_accept_portable (__NR_SYSCALL_BASE_portable+285) -#define __NR_getsockname_portable (__NR_SYSCALL_BASE_portable+286) -#define __NR_getpeername_portable (__NR_SYSCALL_BASE_portable+287) -#define __NR_socketpair_portable (__NR_SYSCALL_BASE_portable+288) -#define __NR_send_portable (__NR_SYSCALL_BASE_portable+289) -#define __NR_sendto_portable (__NR_SYSCALL_BASE_portable+290) -#define __NR_recv_portable (__NR_SYSCALL_BASE_portable+291) -#define __NR_recvfrom_portable (__NR_SYSCALL_BASE_portable+292) -#define __NR_shutdown_portable (__NR_SYSCALL_BASE_portable+293) -#define __NR_setsockopt_portable (__NR_SYSCALL_BASE_portable+294) -#define __NR_getsockopt_portable (__NR_SYSCALL_BASE_portable+295) -#define __NR_sendmsg_portable (__NR_SYSCALL_BASE_portable+296) -#define __NR_recvmsg_portable (__NR_SYSCALL_BASE_portable+297) -#define __NR_semop_portable (__NR_SYSCALL_BASE_portable+298) -#define __NR_semget_portable (__NR_SYSCALL_BASE_portable+299) -#define __NR_semctl_portable (__NR_SYSCALL_BASE_portable+300) -#define __NR_msgsnd_portable (__NR_SYSCALL_BASE_portable+301) -#define __NR_msgrcv_portable (__NR_SYSCALL_BASE_portable+302) -#define __NR_msgget_portable (__NR_SYSCALL_BASE_portable+303) -#define __NR_msgctl_portable (__NR_SYSCALL_BASE_portable+304) -#define __NR_shmat_portable (__NR_SYSCALL_BASE_portable+305) -#define __NR_shmdt_portable (__NR_SYSCALL_BASE_portable+306) -#define __NR_shmget_portable (__NR_SYSCALL_BASE_portable+307) -#define __NR_shmctl_portable (__NR_SYSCALL_BASE_portable+308) -#define __NR_add_key_portable (__NR_SYSCALL_BASE_portable+309) -#define __NR_request_key_portable (__NR_SYSCALL_BASE_portable+310) -#define __NR_keyctl_portable (__NR_SYSCALL_BASE_portable+311) -#define __NR_semtimedop_portable (__NR_SYSCALL_BASE_portable+312) -#define __NR_vserver_portable (__NR_SYSCALL_BASE_portable+313) -#define __NR_ioprio_set_portable (__NR_SYSCALL_BASE_portable+314) -#define __NR_ioprio_get_portable (__NR_SYSCALL_BASE_portable+315) -#define __NR_inotify_init_portable (__NR_SYSCALL_BASE_portable+316) -#define __NR_inotify_add_watch_portable (__NR_SYSCALL_BASE_portable+317) -#define __NR_inotify_rm_watch_portable (__NR_SYSCALL_BASE_portable+318) -#define __NR_mbind_portable (__NR_SYSCALL_BASE_portable+319) -#define __NR_get_mempolicy_portable (__NR_SYSCALL_BASE_portable+320) -#define __NR_set_mempolicy_portable (__NR_SYSCALL_BASE_portable+321) - -#define __NR_openat_portable (__NR_SYSCALL_BASE_portable+322) -#define __NR_mkdirat_portable (__NR_SYSCALL_BASE_portable+323) -#define __NR_mknodat_portable (__NR_SYSCALL_BASE_portable+324) -#define __NR_fchownat_portable (__NR_SYSCALL_BASE_portable+325) -#define __NR_futimesat_portable (__NR_SYSCALL_BASE_portable+326) -#define __NR_fstatat64_portable (__NR_SYSCALL_BASE_portable+327) -#define __NR_unlinkat_portable (__NR_SYSCALL_BASE_portable+328) -#define __NR_renameat_portable (__NR_SYSCALL_BASE_portable+329) -#define __NR_linkat_portable (__NR_SYSCALL_BASE_portable+330) -#define __NR_symlinkat_portable (__NR_SYSCALL_BASE_portable+331) -#define __NR_readlinkat_portable (__NR_SYSCALL_BASE_portable+332) -#define __NR_fchmodat_portable (__NR_SYSCALL_BASE_portable+333) -#define __NR_faccessat_portable (__NR_SYSCALL_BASE_portable+334) -#define __NR_pselect6_portable (__NR_SYSCALL_BASE_portable+335) -#define __NR_ppoll_portable (__NR_SYSCALL_BASE_portable+336) -#define __NR_unshare_portable (__NR_SYSCALL_BASE_portable+337) -#define __NR_set_robust_list_portable (__NR_SYSCALL_BASE_portable+338) -#define __NR_get_robust_list_portable (__NR_SYSCALL_BASE_portable+339) -#define __NR_splice_portable (__NR_SYSCALL_BASE_portable+340) -#define __NR_arm_sync_file_range_portable (__NR_SYSCALL_BASE_portable+341) -#define __NR_tee_portable (__NR_SYSCALL_BASE_portable+342) -#define __NR_vmsplice_portable (__NR_SYSCALL_BASE_portable+343) -#define __NR_move_pages_portable (__NR_SYSCALL_BASE_portable+344) -#define __NR_getcpu_portable (__NR_SYSCALL_BASE_portable+345) -#define __NR_epoll_pwait_portable (__NR_SYSCALL_BASE_portable+346) -#define __NR_kexec_load_portable (__NR_SYSCALL_BASE_portable+347) -#define __NR_utimensat_portable (__NR_SYSCALL_BASE_portable+348) -#define __NR_signalfd_portable (__NR_SYSCALL_BASE_portable+349) -#define __NR_timerfd_create_portable (__NR_SYSCALL_BASE_portable+350) -#define __NR_eventfd_portable (__NR_SYSCALL_BASE_portable+351) -#define __NR_fallocate_portable (__NR_SYSCALL_BASE_portable+352) -#define __NR_timerfd_settime_portable (__NR_SYSCALL_BASE_portable+353) -#define __NR_timerfd_gettime_portable (__NR_SYSCALL_BASE_portable+354) -#define __NR_signalfd4_portable (__NR_SYSCALL_BASE_portable+355) -#define __NR_eventfd2_portable (__NR_SYSCALL_BASE_portable+356) -#define __NR_epoll_create1_portable (__NR_SYSCALL_BASE_portable+357) -#define __NR_dup3_portable (__NR_SYSCALL_BASE_portable+358) -#define __NR_pipe2_portable (__NR_SYSCALL_BASE_portable+359) -#define __NR_inotify_init1_portable (__NR_SYSCALL_BASE_portable+360) -#define __NR_preadv_portable (__NR_SYSCALL_BASE_portable+361) -#define __NR_pwritev_portable (__NR_SYSCALL_BASE_portable+362) -#define __NR_rt_tgsigqueueinfo_portable (__NR_SYSCALL_BASE_portable+363) -#define __NR_perf_event_open_portable (__NR_SYSCALL_BASE_portable+364) -#define __NR_recvmmsg_portable (__NR_SYSCALL_BASE_portable+365) -#define __NR_accept4_portable (__NR_SYSCALL_BASE_portable+366) -#define __NR_fanotify_init_portable (__NR_SYSCALL_BASE_portable+367) -#define __NR_fanotify_mark_portable (__NR_SYSCALL_BASE_portable+368) -#define __NR_prlimit64_portable (__NR_SYSCALL_BASE_portable+369) -#define __NR_name_to_handle_at_portable (__NR_SYSCALL_BASE_portable+370) -#define __NR_open_by_handle_at_portable (__NR_SYSCALL_BASE_portable+371) -#define __NR_clock_adjtime_portable (__NR_SYSCALL_BASE_portable+372) -#define __NR_syncfs_portable (__NR_SYSCALL_BASE_portable+373) -#define __NR_sendmmsg_portable (__NR_SYSCALL_BASE_portable+374) -#define __NR_setns_portable (__NR_SYSCALL_BASE_portable+375) -#define __NR_process_vm_readv_portable (__NR_SYSCALL_BASE_portable+376) -#define __NR_process_vm_writev_portable (__NR_SYSCALL_BASE_portable+377) - - -#define __ARM_NR_BASE_portable (__NR_SYSCALL_BASE_portable+0x0f0000) -#define __ARM_NR_breakpoint_portable (__ARM_NR_BASE_portable+1) -#define __ARM_NR_cacheflush_portable (__ARM_NR_BASE_portable+2) -#define __ARM_NR_usr26_portable (__ARM_NR_BASE_portable+3) -#define __ARM_NR_usr32_portable (__ARM_NR_BASE_portable+4) -#define __ARM_NR_set_tls_portable (__ARM_NR_BASE_portable+5) - -/* Apparently these are not callable using syscall on ARM... */ -#undef __NR_time_portable -#undef __NR_umount_portable -#undef __NR_stime_portable -#undef __NR_alarm_portable -#undef __NR_utime_portable -#undef __NR_getrlimit_portable -#undef __NR_select_portable -#undef __NR_readdir_portable -#undef __NR_mmap_portable -#undef __NR_socketcall_portable -#undef __NR_syscall_portable -#undef __NR_ipc_portable - -#endif diff --git a/ndk/sources/android/libportable/common/include/epoll_portable.h b/ndk/sources/android/libportable/common/include/epoll_portable.h index 9007ba6bc..ebf4389d0 100644 --- a/ndk/sources/android/libportable/common/include/epoll_portable.h +++ b/ndk/sources/android/libportable/common/include/epoll_portable.h @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,17 +17,49 @@ #ifndef _EPOLL_PORTABLE_H_ #define _EPOLL_PORTABLE_H_ -/* - * GDK's compiler generates paddings to guarantee 8-byte alignment on - * struct and 64bit POD types. If compilers on your platform have no such - * alignment rule, please use the following struct and convert it into your - * native struct form. - */ +#include +#include +#include +#include + struct epoll_event_portable { - unsigned int events; - unsigned char __padding[4]; + uint32_t events; + uint8_t __padding[4]; epoll_data_t data; }; + +int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event_portable *event) +{ + struct epoll_event machine_epoll_event; + + machine_epoll_event.events = event->events; + machine_epoll_event.data = event->data; + + return REAL(epoll_ctl)(epfd, op, fd, &machine_epoll_event); +} + +int WRAP(epoll_wait)(int epfd, struct epoll_event_portable *events, int max, int timeout) +{ + struct epoll_event machine_epoll_event; + int ret = REAL(epoll_wait)(epfd, &machine_epoll_event, max, timeout); + + events->events = machine_epoll_event.events; + events->data = machine_epoll_event.data; + + return ret; +} + +int WRAP(epoll_pwait)(int fd, struct epoll_event_portable* events, int max_events, int timeout, const sigset_t* ss) +{ + struct epoll_event machine_epoll_event; + int ret = REAL(epoll_pwait)(fd, &machine_epoll_event, max_events, timeout, ss); + + events->events = machine_epoll_event.events; + events->data = machine_epoll_event.data; + + return ret; +} + #endif /* _EPOLL_PORTABLE_H */ diff --git a/ndk/sources/android/libportable/common/include/errno_portable.h b/ndk/sources/android/libportable/common/include/errno_portable.h index 61888c614..8742bb4ee 100644 --- a/ndk/sources/android/libportable/common/include/errno_portable.h +++ b/ndk/sources/android/libportable/common/include/errno_portable.h @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,13 +18,10 @@ #define _ERRNO_PORTABLE_H_ #include +#include +#include +#include -/* - * Derived from development/ndk/platforms/android-3/include/asm-generic/errno.h - * NOTE: - * Base errno #defines from 1...35 are ARCH independent and not defined; - * they are defined in ./asm-generic/errno-base.h - */ #define EDEADLK_PORTABLE 35 #define ENAMETOOLONG_PORTABLE 36 #define ENOLCK_PORTABLE 37 @@ -126,10 +123,350 @@ #define EOWNERDEAD_PORTABLE 130 #define ENOTRECOVERABLE_PORTABLE 131 +#define ERFKILL_PORTABLE 132 +#define EHWPOISON_PORTABLE 133 -extern __hidden int errno_ntop(int native_errno); -extern __hidden int errno_pton(int native_errno); +extern volatile int* REAL(__errno)(); -extern volatile int* REAL(__errno)(void); +static int errno_ntop(int native_errno) +{ + switch (native_errno) { + case ENAMETOOLONG: return ENAMETOOLONG_PORTABLE; + case ENOLCK: return ENOLCK_PORTABLE; + case ENOSYS: return ENOSYS_PORTABLE; + case ENOTEMPTY: return ENOTEMPTY_PORTABLE; + case ELOOP: return ELOOP_PORTABLE; + case EWOULDBLOCK: return EWOULDBLOCK_PORTABLE; + case ENOMSG: return ENOMSG_PORTABLE; + case EIDRM: return EIDRM_PORTABLE; + case ECHRNG: return ECHRNG_PORTABLE; + case EL2NSYNC: return EL2NSYNC_PORTABLE; + case EL3HLT: return EL3HLT_PORTABLE; + case EL3RST: return EL3RST_PORTABLE; + case ELNRNG: return ELNRNG_PORTABLE; + case EUNATCH: return EUNATCH_PORTABLE; + case ENOCSI: return ENOCSI_PORTABLE; + case EL2HLT: return EL2HLT_PORTABLE; + case EBADE: return EBADE_PORTABLE; + case EBADR: return EBADR_PORTABLE; + case EXFULL: return EXFULL_PORTABLE; + case ENOANO: return ENOANO_PORTABLE; + case EBADRQC: return EBADRQC_PORTABLE; + case EBADSLT: return EBADSLT_PORTABLE; + case EDEADLOCK: return EDEADLOCK_PORTABLE; + case EBFONT: return EBFONT_PORTABLE; + case ENOSTR: return ENOSTR_PORTABLE; + case ENODATA: return ENODATA_PORTABLE; + case ETIME: return ETIME_PORTABLE; + case ENOSR: return ENOSR_PORTABLE; + case ENONET: return ENONET_PORTABLE; + case ENOPKG: return ENOPKG_PORTABLE; + case EREMOTE: return EREMOTE_PORTABLE; + case ENOLINK: return ENOLINK_PORTABLE; + case EADV: return EADV_PORTABLE; + case ESRMNT: return ESRMNT_PORTABLE; + case ECOMM: return ECOMM_PORTABLE; + case EPROTO: return EPROTO_PORTABLE; + case EMULTIHOP: return EMULTIHOP_PORTABLE; + case EDOTDOT: return EDOTDOT_PORTABLE; + case EBADMSG: return EBADMSG_PORTABLE; + case EOVERFLOW: return EOVERFLOW_PORTABLE; + case ENOTUNIQ: return ENOTUNIQ_PORTABLE; + case EBADFD: return EBADFD_PORTABLE; + case EREMCHG: return EREMCHG_PORTABLE; + case ELIBACC: return ELIBACC_PORTABLE; + case ELIBBAD: return ELIBBAD_PORTABLE; + case ELIBSCN: return ELIBSCN_PORTABLE; + case ELIBMAX: return ELIBMAX_PORTABLE; + case ELIBEXEC: return ELIBEXEC_PORTABLE; + case EILSEQ: return EILSEQ_PORTABLE; + case ERESTART: return ERESTART_PORTABLE; + case ESTRPIPE: return ESTRPIPE_PORTABLE; + case EUSERS: return EUSERS_PORTABLE; + case ENOTSOCK: return ENOTSOCK_PORTABLE; + case EDESTADDRREQ: return EDESTADDRREQ_PORTABLE; + case EMSGSIZE: return EMSGSIZE_PORTABLE; + case EPROTOTYPE: return EPROTOTYPE_PORTABLE; + case ENOPROTOOPT: return ENOPROTOOPT_PORTABLE; + case EPROTONOSUPPORT: return EPROTONOSUPPORT_PORTABLE; + case ESOCKTNOSUPPORT: return ESOCKTNOSUPPORT_PORTABLE; + case EOPNOTSUPP: return EOPNOTSUPP_PORTABLE; + case EPFNOSUPPORT: return EPFNOSUPPORT_PORTABLE; + case EAFNOSUPPORT: return EAFNOSUPPORT_PORTABLE; + case EADDRINUSE: return EADDRINUSE_PORTABLE; + case EADDRNOTAVAIL: return EADDRNOTAVAIL_PORTABLE; + case ENETDOWN: return ENETDOWN_PORTABLE; + case ENETUNREACH: return ENETUNREACH_PORTABLE; + case ENETRESET: return ENETRESET_PORTABLE; + case ECONNABORTED: return ECONNABORTED_PORTABLE; + case ECONNRESET: return ECONNRESET_PORTABLE; + case ENOBUFS: return ENOBUFS_PORTABLE; + case EISCONN: return EISCONN_PORTABLE; + case ENOTCONN: return ENOTCONN_PORTABLE; + case ESHUTDOWN: return ESHUTDOWN_PORTABLE; + case ETOOMANYREFS: return ETOOMANYREFS_PORTABLE; + case ETIMEDOUT: return ETIMEDOUT_PORTABLE; + case ECONNREFUSED: return ECONNREFUSED_PORTABLE; + case EHOSTDOWN: return EHOSTDOWN_PORTABLE; + case EHOSTUNREACH: return EHOSTUNREACH_PORTABLE; + case EALREADY: return EALREADY_PORTABLE; + case EINPROGRESS: return EINPROGRESS_PORTABLE; + case ESTALE: return ESTALE_PORTABLE; + case EUCLEAN: return EUCLEAN_PORTABLE; + case ENOTNAM: return ENOTNAM_PORTABLE; + case ENAVAIL: return ENAVAIL_PORTABLE; + case EISNAM: return EISNAM_PORTABLE; + case EREMOTEIO: return EREMOTEIO_PORTABLE; + case EDQUOT: return EDQUOT_PORTABLE; + case ENOMEDIUM: return ENOMEDIUM_PORTABLE; + case EMEDIUMTYPE: return EMEDIUMTYPE_PORTABLE; + case ECANCELED: return ECANCELED_PORTABLE; + case ENOKEY: return ENOKEY_PORTABLE; + case EKEYEXPIRED: return EKEYEXPIRED_PORTABLE; + case EKEYREVOKED: return EKEYREVOKED_PORTABLE; + case EKEYREJECTED: return EKEYREJECTED_PORTABLE; + case EOWNERDEAD: return EOWNERDEAD_PORTABLE; + case ENOTRECOVERABLE: return ENOTRECOVERABLE_PORTABLE; + } + return native_errno; +} +static int errno_pton(int portable_errno) +{ + switch (portable_errno) { + case ENAMETOOLONG_PORTABLE: return ENAMETOOLONG; + case ENOLCK_PORTABLE: return ENOLCK; + case ENOSYS_PORTABLE: return ENOSYS; + case ENOTEMPTY_PORTABLE: return ENOTEMPTY; + case ELOOP_PORTABLE: return ELOOP; + case EWOULDBLOCK_PORTABLE: return EWOULDBLOCK; + case ENOMSG_PORTABLE: return ENOMSG; + case EIDRM_PORTABLE: return EIDRM; + case ECHRNG_PORTABLE: return ECHRNG; + case EL2NSYNC_PORTABLE: return EL2NSYNC; + case EL3HLT_PORTABLE: return EL3HLT; + case EL3RST_PORTABLE: return EL3RST; + case ELNRNG_PORTABLE: return ELNRNG; + case EUNATCH_PORTABLE: return EUNATCH; + case ENOCSI_PORTABLE: return ENOCSI; + case EL2HLT_PORTABLE: return EL2HLT; + case EBADE_PORTABLE: return EBADE; + case EBADR_PORTABLE: return EBADR; + case EXFULL_PORTABLE: return EXFULL; + case ENOANO_PORTABLE: return ENOANO; + case EBADRQC_PORTABLE: return EBADRQC; + case EBADSLT_PORTABLE: return EBADSLT; + case EDEADLOCK_PORTABLE: return EDEADLOCK; + case EBFONT_PORTABLE: return EBFONT; + case ENOSTR_PORTABLE: return ENOSTR; + case ENODATA_PORTABLE: return ENODATA; + case ETIME_PORTABLE: return ETIME; + case ENOSR_PORTABLE: return ENOSR; + case ENONET_PORTABLE: return ENONET; + case ENOPKG_PORTABLE: return ENOPKG; + case EREMOTE_PORTABLE: return EREMOTE; + case ENOLINK_PORTABLE: return ENOLINK; + case EADV_PORTABLE: return EADV; + case ESRMNT_PORTABLE: return ESRMNT; + case ECOMM_PORTABLE: return ECOMM; + case EPROTO_PORTABLE: return EPROTO; + case EMULTIHOP_PORTABLE: return EMULTIHOP; + case EDOTDOT_PORTABLE: return EDOTDOT; + case EBADMSG_PORTABLE: return EBADMSG; + case EOVERFLOW_PORTABLE: return EOVERFLOW; + case ENOTUNIQ_PORTABLE: return ENOTUNIQ; + case EBADFD_PORTABLE: return EBADFD; + case EREMCHG_PORTABLE: return EREMCHG; + case ELIBACC_PORTABLE: return ELIBACC; + case ELIBBAD_PORTABLE: return ELIBBAD; + case ELIBSCN_PORTABLE: return ELIBSCN; + case ELIBMAX_PORTABLE: return ELIBMAX; + case ELIBEXEC_PORTABLE: return ELIBEXEC; + case EILSEQ_PORTABLE: return EILSEQ; + case ERESTART_PORTABLE: return ERESTART; + case ESTRPIPE_PORTABLE: return ESTRPIPE; + case EUSERS_PORTABLE: return EUSERS; + case ENOTSOCK_PORTABLE: return ENOTSOCK; + case EDESTADDRREQ_PORTABLE: return EDESTADDRREQ; + case EMSGSIZE_PORTABLE: return EMSGSIZE; + case EPROTOTYPE_PORTABLE: return EPROTOTYPE; + case ENOPROTOOPT_PORTABLE: return ENOPROTOOPT; + case EPROTONOSUPPORT_PORTABLE: return EPROTONOSUPPORT; + case ESOCKTNOSUPPORT_PORTABLE: return ESOCKTNOSUPPORT; + case EOPNOTSUPP_PORTABLE: return EOPNOTSUPP; + case EPFNOSUPPORT_PORTABLE: return EPFNOSUPPORT; + case EAFNOSUPPORT_PORTABLE: return EAFNOSUPPORT; + case EADDRINUSE_PORTABLE: return EADDRINUSE; + case EADDRNOTAVAIL_PORTABLE: return EADDRNOTAVAIL; + case ENETDOWN_PORTABLE: return ENETDOWN; + case ENETUNREACH_PORTABLE: return ENETUNREACH; + case ENETRESET_PORTABLE: return ENETRESET; + case ECONNABORTED_PORTABLE: return ECONNABORTED; + case ECONNRESET_PORTABLE: return ECONNRESET; + case ENOBUFS_PORTABLE: return ENOBUFS; + case EISCONN_PORTABLE: return EISCONN; + case ENOTCONN_PORTABLE: return ENOTCONN; + case ESHUTDOWN_PORTABLE: return ESHUTDOWN; + case ETOOMANYREFS_PORTABLE: return ETOOMANYREFS; + case ETIMEDOUT_PORTABLE: return ETIMEDOUT; + case ECONNREFUSED_PORTABLE: return ECONNREFUSED; + case EHOSTDOWN_PORTABLE: return EHOSTDOWN; + case EHOSTUNREACH_PORTABLE: return EHOSTUNREACH; + case EALREADY_PORTABLE: return EALREADY; + case EINPROGRESS_PORTABLE: return EINPROGRESS; + case ESTALE_PORTABLE: return ESTALE; + case EUCLEAN_PORTABLE: return EUCLEAN; + case ENOTNAM_PORTABLE: return ENOTNAM; + case ENAVAIL_PORTABLE: return ENAVAIL; + case EISNAM_PORTABLE: return EISNAM; + case EREMOTEIO_PORTABLE: return EREMOTEIO; + case EDQUOT_PORTABLE: return EDQUOT; + case ENOMEDIUM_PORTABLE: return ENOMEDIUM; + case EMEDIUMTYPE_PORTABLE: return EMEDIUMTYPE; + case ECANCELED_PORTABLE: return ECANCELED; + case ENOKEY_PORTABLE: return ENOKEY; + case EKEYEXPIRED_PORTABLE: return EKEYEXPIRED; + case EKEYREVOKED_PORTABLE: return EKEYREVOKED; + case EKEYREJECTED_PORTABLE: return EKEYREJECTED; + case EOWNERDEAD_PORTABLE: return EOWNERDEAD; + case ENOTRECOVERABLE_PORTABLE: return ENOTRECOVERABLE; + } + return portable_errno; +} + +/* Key for the thread-specific portable errno */ +static pthread_key_t errno_key; + +/* Once-only initialisation of the key */ +static pthread_once_t errno_key_once = PTHREAD_ONCE_INIT; + +/* Free the thread-specific portable errno */ +static void errno_key_destroy(void *buf) +{ + if (buf) + free(buf); +} + +/* Allocate the key */ +static void errno_key_create(void) +{ + pthread_key_create(&errno_key, errno_key_destroy); +} + +struct errno_state { + int pshadow; /* copy of last portable errno */ + int perrno; /* portable errno that may be modified by app */ +}; + +/* Return the thread-specific portable errno */ +static struct errno_state *errno_key_data(void) +{ + struct errno_state *data; + static struct errno_state errno_state; + + pthread_once(&errno_key_once, errno_key_create); + data = (struct errno_state *)pthread_getspecific(errno_key); + if (data == NULL) { + data = malloc(sizeof(struct errno_state)); + pthread_setspecific(errno_key, data); + } + if (data == NULL) + data = &errno_state; + return data; +} + +/* + * Attempt to return a thread specific location containnig the portable errno. + * This can be assigned to without affecting the native errno. If the key + * allocation fails fall back to using the native errno location. + */ +volatile int* WRAP(__errno)() +{ + struct errno_state *p; + int save_errno; + + /* pthread_* calls may modify errno so use a copy */ + save_errno = *REAL(__errno)(); + + p = errno_key_data(); + + ALOGV(" "); + ALOGV("%s(): { save_errno = errno:%d, (p:%p)->{pshadow:%d, perrno:%d}", __func__, + save_errno, p, p->pshadow, p->perrno); + + if (save_errno == 0 && p->pshadow != p->perrno) { + /* + * portable errno has changed but native hasn't + * - copy portable error back to native + */ + p->pshadow = p->perrno; + save_errno = errno_pton(p->perrno); + } + else if (save_errno != 0 && p->pshadow == p->perrno) { + /* + * Native errno has changed but portable hasn't + * - copy native error to portable. + */ + p->pshadow = p->perrno = errno_ntop(save_errno); + save_errno = 0; + } + else if (save_errno != 0 && p->pshadow != p->perrno) { + /* + * Both native and portable errno values have changed + * so give priority to native errno + * - copy native error to portable + */ + p->pshadow = p->perrno = errno_ntop(save_errno); + save_errno = 0; + } + + ALOGV("%s: new save_errno:%d p:%p->{pshadow:%d, perrno:%d}", __func__, + save_errno, p, p->pshadow, p->perrno); + + *REAL(__errno)() = save_errno; + + ALOGV("%s: return (&p->perrno):%p; }", __func__, &p->perrno); + + /* return pointer to the modifiable portable errno value */ + return &p->perrno; +} + + +/* set portable errno */ +void WRAP(__set_errno)(int portable_errno) +{ + struct errno_state *p; + int save_errno; + + /* pthread_* calls may modify errno so use a copy */ + save_errno = *REAL(__errno)(); + + p = errno_key_data(); + + ALOGV("%s(): { save_errno = errno:%d, p:%p->{pshadow:%d, perrno:%d}", __func__, + save_errno, p, p->pshadow, p->perrno); + + p->pshadow = p->perrno = portable_errno; + + save_errno = errno_pton(portable_errno); + + ALOGV("%s: new save_errno:%d, p:%p->{pshadow:%d, perrno:%d}", __func__, + save_errno, p, p->pshadow, p->perrno); + + *REAL(__errno)() = save_errno; + + ALOGV("%s: return; }", __func__); +} + +extern char* REAL(strerror)(int); +char *WRAP(strerror)(int errnum) +{ + return REAL(strerror)(errno_p2on(errnum)); +} + +/* BSD style strerror_r */ +int WRAP(strerror_r)(int errnum, char *buf, size_t buflen) +{ + return REAL(strerror_r)(errno_pton(errnum), buf, buflen); +} #endif /* _ERRNO_PORTABLE_H */ diff --git a/ndk/sources/android/libportable/common/include/eventfd_portable.h b/ndk/sources/android/libportable/common/include/eventfd_portable.h deleted file mode 100644 index d72ca8dd3..000000000 --- a/ndk/sources/android/libportable/common/include/eventfd_portable.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Derived from bionic/libc/include/sys/eventfd.h - * - * Copyright (C) 2008 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#ifndef _SYS_EVENTFD_PORTABLE_H -#define _SYS_EVENTFD_PORTABLE_H - -#include -#include -#include - -__BEGIN_DECLS - -/* - * EFD_SEMAPHORE is defined in recent linux kernels; - * but isn't mentioned elsewhere. See linux 3.4 - * include/linux/eventfd.h for example. - */ -#define EFD_SEMAPHORE (1 << 0) - -#define EFD_SEMAPHORE_PORTABLE EFD_SEMAPHORE -#define EFD_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE -#define EFD_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE - -/* type of event counter */ -typedef uint64_t eventfd_portable_t; - -extern int WRAP(eventfd)(unsigned int initval, int flags); - -#if 0 -/* Compatibility with GLibc; libportable versions don't appear to be necessary */ -extern int eventfd_read(int fd, eventfd_t *counter); -extern int eventfd_write(int fd, const eventfd_t counter); -#endif - -__END_DECLS - -#endif /* _SYS_EVENTFD_H */ diff --git a/ndk/sources/android/libportable/common/include/fcntl_portable.h b/ndk/sources/android/libportable/common/include/fcntl_portable.h index 6e99c8b30..08b3b2bcc 100644 --- a/ndk/sources/android/libportable/common/include/fcntl_portable.h +++ b/ndk/sources/android/libportable/common/include/fcntl_portable.h @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,150 +16,71 @@ #ifndef _FCNTL_PORTABLE_H_ #define _FCNTL_PORTABLE_H_ - -/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/fcntl.h */ -/* NB x86 does not have these and only uses the generic definitions. */ -#define O_DIRECTORY_PORTABLE 040000 -#define O_NOFOLLOW_PORTABLE 0100000 -#define O_DIRECT_PORTABLE 0200000 -#define O_LARGEFILE_PORTABLE 0400000 - -/* Derived from development/ndk/platforms/android-3/include/asm-generic/fcntl.h */ -#define O_ACCMODE_PORTABLE 00000003 -#define O_RDONLY_PORTABLE 00000000 -#define O_WRONLY_PORTABLE 00000001 -#define O_RDWR_PORTABLE 00000002 -#ifndef O_CREAT_PORTABLE -#define O_CREAT_PORTABLE 00000100 -#endif -#ifndef O_EXCL_PORTABLE -#define O_EXCL_PORTABLE 00000200 -#endif -#ifndef O_NOCTTY_PORTABLE -#define O_NOCTTY_PORTABLE 00000400 -#endif -#ifndef O_TRUNC_PORTABLE -#define O_TRUNC_PORTABLE 00001000 -#endif -#ifndef O_APPEND_PORTABLE -#define O_APPEND_PORTABLE 00002000 -#endif -#ifndef O_NONBLOCK_PORTABLE -#define O_NONBLOCK_PORTABLE 00004000 -#endif -#ifndef O_SYNC_PORTABLE -#define O_SYNC_PORTABLE 00010000 -#endif -#ifndef FASYNC_PORTABLE -#define FASYNC_PORTABLE 00020000 -#endif -#ifndef O_DIRECT_PORTABLE -#define O_DIRECT_PORTABLE 00040000 -#endif -#ifndef O_LARGEFILE_PORTABLE -#define O_LARGEFILE_PORTABLE 00100000 -#endif -#ifndef O_DIRECTORY_PORTABLE -#define O_DIRECTORY_PORTABLE 00200000 -#endif -#ifndef O_NOFOLLOW_PORTABLE -#define O_NOFOLLOW_PORTABLE 00400000 -#endif -#ifndef O_NOATIME_PORTABLE -#define O_NOATIME_PORTABLE 01000000 -#endif -#ifndef O_NDELAY_PORTABLE -#define O_NDELAY_PORTABLE O_NONBLOCK_PORTABLE #endif -/* From Bionic libc/kernel/common/asm-generic/fcntl.h */ -#ifndef O_CLOEXEC_PORTABLE -#define O_CLOEXEC_PORTABLE 02000000 -#endif +#include +#include +#include -#ifndef __ARCH_FLOCK64_PAD -#define __ARCH_FLOCK64_PAD -#endif +#define O_DIRECTORY_PORTABLE 040000 +#define O_NOFOLLOW_PORTABLE 0100000 +#define O_DIRECT_PORTABLE 0200000 +#define O_LARGEFILE_PORTABLE 0400000 -/* - * For use with F_GETLK and F_SETLK - */ -struct flock_portable { - short l_type; - short l_whence; - off_t l_start; - off_t l_len; - pid_t l_pid; - __ARCH_FLOCK64_PAD -}; +static int flags_p2n(int p_flags) +{ + int machine_flags = p_flags; + if (p_flags & O_DIRECTORY_PORTABLE) { + machine_flags ^= O_DIRECTORY_PORTABLE; + machine_flags |= O_DIRECTORY; + } + if (p_flags & O_NOFOLLOW_PORTABLE) { + machine_flags ^= O_NOFOLLOW_PORTABLE; + machine_flags |= O_NOFOLLOW; + } + if (p_flags & O_DIRECT_PORTABLE) { + machine_flags ^= O_DIRECT_PORTABLE; + machine_flags |= O_DIRECT; + } + if (p_flags & O_LARGEFILE_PORTABLE) { + machine_flags ^= O_LARGEFILE_PORTABLE; + machine_flags |= O_LARGEFILE; + } -/* - * For use with F_GETLK64 and F_SETLK64 - */ -struct flock64_portable { - short l_type; - short l_whence; - unsigned char __padding[4]; - loff_t l_start; - loff_t l_len; - pid_t l_pid; - __ARCH_FLOCK64_PAD -}; + return machine_flags; +} -#if 0 -/* - * The X86 Version is - */ -struct flock64 { - short l_type; - short l_whence; - loff_t l_start; - loff_t l_len; - pid_t l_pid; - __ARCH_FLOCK64_PAD -}; -#endif /* 0 */ +#define FLAGS_VAARGS_TRANSLATE \ + flags = flags_p2n(flags); \ + mode_t mode = 0; \ + if ((flags & O_CREAT) != 0) { \ + va_list args; \ + va_start(args, flags); \ + mode = (mode_t) va_arg(args, int); \ + va_end(args);\ + } -#ifndef F_DUPFD_PORTABLE -#define F_DUPFD_PORTABLE 0 -#define F_GETFD_PORTABLE 1 -#define F_SETFD_PORTABLE 2 -#define F_GETFL_PORTABLE 3 -#define F_SETFL_PORTABLE 4 -#endif +int WRAP(openat)(int fd, const char* path, int flags, ...) +{ + FLAGS_VAARGS_TRANSLATE + return REAL(openat)(fd, path, flags, mode); +} -#ifndef F_GETLK_PORTABLE -#define F_GETLK_PORTABLE 5 -#define F_SETLK_PORTABLE 6 -#define F_SETLKW_PORTABLE 7 -#endif +int WRAP(openat64)(int fd, const char* path, int flags, ...) +{ + FLAGS_VAARGS_TRANSLATE + return REAL(openat64)(fd, path, flags, mode); +} -#ifndef F_SETOWN_PORTABLE -#define F_SETOWN_PORTABLE 8 -#define F_GETOWN_PORTABLE 9 -#endif +int WRAP(open)(const char* path, int flags, ...) +{ + FLAGS_VAARGS_TRANSLATE + return REAL(open)(path, flags, mode); +} -#ifndef F_SETSIG_PORTABLE -#define F_SETSIG_PORTABLE 10 -#define F_GETSIG_PORTABLE 11 -#endif - -#ifndef F_GETLK64_PORTABLE -#define F_GETLK64_PORTABLE 12 -#define F_SETLK64_PORTABLE 13 -#define F_SETLKW64_PORTABLE 14 -#endif - -/* This constant seems to be the same for all ARCH's */ -#define F_LINUX_SPECIFIC_BASE_PORTABLE 1024 - -#define F_SETLEASE_PORTABLE (F_LINUX_SPECIFIC_BASE+0) /* 1024 */ -#define F_GETLEASE_PORTABLE (F_LINUX_SPECIFIC_BASE+1) /* 1025 */ -#define F_NOTIFY_PORTABLE (F_LINUX_SPECIFIC_BASE+2) /* 1026 */ - -/* Currently these are only supported by X86_64 */ -#define F_CANCELLK_PORTABLE (F_LINUX_SPECIFIC_BASE+5) /* 1029 */ -#define F_DUPFD_CLOEXEC_PORTABLE (F_LINUX_SPECIFIC_BASE+6) /* 1030 */ - -#endif /* _FCNTL_PORTABLE_H */ +int WRAP(open64)(const char* path, int flags, ...) +{ + FLAGS_VAARGS_TRANSLATE + return REAL(open64)(path, flags, mode); +} diff --git a/ndk/sources/android/libportable/common/include/fenv_portable.h b/ndk/sources/android/libportable/common/include/fenv_portable.h index 1d1e500eb..04d9dcbc7 100644 --- a/ndk/sources/android/libportable/common/include/fenv_portable.h +++ b/ndk/sources/android/libportable/common/include/fenv_portable.h @@ -1,5 +1,5 @@ /* - * Copyright 2013, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,15 @@ #ifndef _FENV_PORTABLE_H_ #define _FENV_PORTABLE_H_ -#include +#include +#include +#include +#include -#ifdef __LP64__ typedef struct { - unsigned char a[28]; // x86_64 largest size + unsigned char a[128]; } fenv_t_portable; -typedef __uint32_t fexcept_t_portable; -#endif +typedef uint32_t fexcept_t_portable; /* Exception flags. */ #define FE_INVALID_PORTABLE 0x01 @@ -41,4 +42,154 @@ typedef __uint32_t fexcept_t_portable; #define FE_DOWNWARD_PORTABLE 0x2 #define FE_TOWARDZERO_PORTABLE 0x3 + +static inline int target_change_except(int flags) +{ + int targetflags = 0; + + if (flags & FE_INVALID_PORTABLE) + targetflags |= FE_INVALID; + if (flags & FE_DIVBYZERO_PORTABLE) + targetflags |= FE_DIVBYZERO; + if (flags & FE_OVERFLOW_PORTABLE) + targetflags |= FE_OVERFLOW; + if (flags & FE_UNDERFLOW_PORTABLE) + targetflags |= FE_UNDERFLOW; + if (flags & FE_INEXACT_PORTABLE) + targetflags |= FE_INEXACT; + + return targetflags; +} + +static inline int target_change_rounding(int flags) +{ + int targetflags = 0; + + switch(flags) + { + case FE_TONEAREST_PORTABLE: + targetflags = FE_TONEAREST; + break; + case FE_DOWNWARD_PORTABLE: + targetflags = FE_DOWNWARD; + break; + case FE_UPWARD_PORTABLE: + targetflags = FE_UPWARD; + break; + case FE_TOWARDZERO_PORTABLE: + targetflags = FE_TOWARDZERO; + break; + } + return targetflags; +} + +static inline int target_get_except(int targetflags) +{ + int flags = 0; + + if (targetflags & FE_INVALID) + flags |= FE_INVALID_PORTABLE; + if (targetflags & FE_DIVBYZERO) + flags |= FE_DIVBYZERO_PORTABLE; + if (targetflags & FE_OVERFLOW) + flags |= FE_OVERFLOW_PORTABLE; + if (targetflags & FE_UNDERFLOW) + flags |= FE_UNDERFLOW_PORTABLE; + if (targetflags & FE_INEXACT) + flags |= FE_INEXACT_PORTABLE; + return flags; +} + +static inline int target_get_rounding(int targetflags) +{ + int flags = 0; + + switch(targetflags) + { + case FE_TONEAREST: + flags = FE_TONEAREST_PORTABLE; + break; + case FE_DOWNWARD: + flags = FE_DOWNWARD_PORTABLE; + break; + case FE_UPWARD: + flags = FE_UPWARD_PORTABLE; + break; + case FE_TOWARDZERO: + flags = FE_TOWARDZERO_PORTABLE; + break; + } + return flags; +} + + +int WRAP(fegetenv)(fenv_t_portable* __envp) { + return REAL(fegetenv)((fenv_t*) __envp); +} + +int WRAP(fesetenv)(const fenv_t_portable* __envp) { + return REAL(fesetenv)((fenv_t*) __envp); +} + +int WRAP(feclearexcept)(int __excepts) { + __excepts = target_change_except(__excepts); + return REAL(feclearexcept)(__excepts); +} + +int WRAP(fegetexceptflag)(fexcept_t_portable* __flagp, int __excepts) { + __excepts = target_change_except(__excepts); + int ret = REAL(fegetexceptflag)((fexcept_t*) __flagp, __excepts); + *__flagp = target_get_except(*__flagp); + return ret; +} + +int WRAP(fesetexceptflag)(const fexcept_t_portable* __flagp, int __excepts) { + __excepts = target_change_except(__excepts); + return REAL(fesetexceptflag)((const fexcept_t*) __flagp, __excepts); +} + +int WRAP(feraiseexcept)(int __excepts) { + __excepts = target_change_except(__excepts); + return REAL(feraiseexcept)(__excepts); +} + +int WRAP(fetestexcept)(int __excepts) { + __excepts = target_change_except(__excepts); + return target_get_except(REAL(fetestexcept)(__excepts)); +} + +int WRAP(fegetround)(void) { + int rounding = REAL(fegetround)(); + return target_get_rounding(rounding); +} + +int WRAP(fesetround)(int __round) { + __round = target_change_rounding(__round); + return REAL(fesetround)(__round); +} + +int WRAP(feholdexcept)(fenv_t_portable* __envp) { + memset(__envp, '\0', sizeof(__envp)); + fenv_t env; + int ret = REAL(feholdexcept)(&env); + memcpy(__envp, &env, sizeof(env)); + return ret; +} + +int WRAP(feupdateenv)(const fenv_t_portable* __envp) { + fenv_t env; + memcpy(&env, __envp, sizeof(env)); + return REAL(feupdateenv)(&env); +} + +int WRAP(feenableexcept)(int __excepts) { + __excepts = target_change_except(__excepts); + return REAL(feenableexcept)(__excepts); +} + +int WRAP(fedisableexcept)(int __excepts) { + __excepts = target_change_except(__excepts); + return REAL(fedisableexcept)(__excepts); +} + #endif /* _FENV_PORTABLE_H_ */ diff --git a/ndk/sources/android/libportable/common/include/filefd_portable.h b/ndk/sources/android/libportable/common/include/filefd_portable.h deleted file mode 100644 index 76cd4b849..000000000 --- a/ndk/sources/android/libportable/common/include/filefd_portable.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _FILEFD_PORTABLE_H_ -#define _FILEFD_PORTABLE_H_ - -/* - * Maintaining a list of special file descriptors in lib-portable - * which are maintained across a execve() via environment variables. - * See portable/arch-mips/filefd.c for details. - */ -enum filefd_type { - UNUSED_FD_TYPE = 0, - EVENT_FD_TYPE, - INOTIFY_FD_TYPE, - SIGNAL_FD_TYPE, - TIMER_FD_TYPE, - MAX_FD_TYPE -}; - -extern __hidden void filefd_opened(int fd, enum filefd_type fd_type); -extern __hidden void filefd_closed(int fd); -extern __hidden void filefd_CLOEXEC_enabled(int fd); -extern __hidden void filefd_CLOEXEC_disabled(int fd); -extern __hidden void filefd_disable_mapping(void); - -extern int WRAP(close)(int fd); -extern int WRAP(read)(int fd, void *buf, size_t count); -extern int WRAP(pipe2)(int pipefd[2], int portable_flags); - -#endif /* _FILEFD_PORTABLE_H_ */ diff --git a/ndk/sources/android/libportable/common/include/inotify_portable.h b/ndk/sources/android/libportable/common/include/inotify_portable.h deleted file mode 100644 index 09d4d6400..000000000 --- a/ndk/sources/android/libportable/common/include/inotify_portable.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Derived from bionic/libc/include/sys/eventfd.h - * - * Copyright (C) 2008 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _SYS_INOTIFY_PORTABLE_H -#define _SYS_INOTIFY_PORTABLE_H - -#include -#include -#include -#include - -__BEGIN_DECLS - -#define IN_CLOEXEC O_CLOEXEC -#define IN_NONBLOCK O_NONBLOCK - -#define IN_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE -#define IN_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE - -extern int WRAP(inotify_init1)(int flags); - -__END_DECLS - -#endif /* _SYS_INOTIFY_H */ diff --git a/ndk/sources/android/libportable/common/include/ioctls_portable.h b/ndk/sources/android/libportable/common/include/ioctls_portable.h deleted file mode 100644 index 9c03f2568..000000000 --- a/ndk/sources/android/libportable/common/include/ioctls_portable.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -#ifndef _IOCTLS_PORTABLE_H_ -#define _IOCTLS_PORTABLE_H_ - -/* - * Derived from development/ndk/platforms/android-3/include/asm-generic/ioctl.h - */ -#define _IOC_NRBITS_PORTABLE 8 -#define _IOC_TYPEBITS_PORTABLE 8 -#define _IOC_SIZEBITS_PORTABLE 14 -#define _IOC_DIRBITS_PORTABLE 2 - -#define _IOC_NRMASK_PORTABLE ((1 << _IOC_NRBITS_PORTABLE)-1) -#define _IOC_TYPEMASK_PORTABLE ((1 << _IOC_TYPEBITS_PORTABLE)-1) -#define _IOC_SIZEMASK_PORTABLE ((1 << _IOC_SIZEBITS_PORTABLE)-1) -#define _IOC_DIRMASK_PORTABLE ((1 << _IOC_DIRBITS_PORTABLE)-1) - -#define _IOC_NRSHIFT_PORTABLE 0 -#define _IOC_TYPESHIFT_PORTABLE (_IOC_NRSHIFT_PORTABLE+_IOC_NRBITS_PORTABLE) -#define _IOC_SIZESHIFT_PORTABLE (_IOC_TYPESHIFT_PORTABLE+_IOC_TYPEBITS_PORTABLE) -#define _IOC_DIRSHIFT_PORTABLE (_IOC_SIZESHIFT_PORTABLE+_IOC_SIZEBITS_PORTABLE) - -#define _IOC_NONE_PORTABLE 0U -#define _IOC_WRITE_PORTABLE 1U -#define _IOC_READ_PORTABLE 2U - -#define _IOC_PORTABLE(dir, type, nr, size) ( \ - ((dir) << _IOC_DIRSHIFT_PORTABLE) | \ - ((type) << _IOC_TYPESHIFT_PORTABLE) | \ - ((nr) << _IOC_NRSHIFT_PORTABLE) | \ - ((size) << _IOC_SIZESHIFT_PORTABLE) \ -) - -extern unsigned int __invalid_size_argument_for_IOC; - -#define _IOC_TYPECHECK_PORTABLE(t) ( \ - (sizeof(t) == sizeof(t[1]) && sizeof(t) < (1 << _IOC_SIZEBITS_PORTABLE)) ? \ - sizeof(t) : \ - __invalid_size_argument_for_IOC \ -) - -#define _IO_PORTABLE(type, nr) _IOC_PORTABLE(_IOC_NONE_PORTABLE, (type), (nr), 0) - -#define _IOR_PORTABLE(type, nr, size) \ - _IOC_PORTABLE(_IOC_READ_PORTABLE, (type), (nr), (_IOC_TYPECHECK_PORTABLE(size))) - -#define _IOW_PORTABLE(type, nr, size) \ - _IOC_PORTABLE(_IOC_WRITE_PORTABLE, (type), (nr), (_IOC_TYPECHECK_PORTABLE(size))) - -#define _IOWR_PORTABLE(type, nr, size) \ - IOC_PORTABLE(_IOC_READ_PORTABLE | \ - _IOC_WRITE_PORTABLE, (type), (nr), (IOC_TYPECHECK_PORTABLE(size)) ) - - -/* - * Derived from development/ndk/platforms/android-3/arch-arm/include/asm/ioctls.h - */ -#define TCGETS_PORTABLE 0x5401 -#define TCSETS_PORTABLE 0x5402 -#define TCSETSW_PORTABLE 0x5403 -#define TCSETSF_PORTABLE 0x5404 -#define TCGETA_PORTABLE 0x5405 -#define TCSETA_PORTABLE 0x5406 -#define TCSETAW_PORTABLE 0x5407 -#define TCSETAF_PORTABLE 0x5408 -#define TCSBRK_PORTABLE 0x5409 -#define TCXONC_PORTABLE 0x540A -#define TCFLSH_PORTABLE 0x540B -#define TIOCEXCL_PORTABLE 0x540C -#define TIOCNXCL_PORTABLE 0x540D -#define TIOCSCTTY_PORTABLE 0x540E -#define TIOCGPGRP_PORTABLE 0x540F -#define TIOCSPGRP_PORTABLE 0x5410 -#define TIOCOUTQ_PORTABLE 0x5411 -#define TIOCSTI_PORTABLE 0x5412 -#define TIOCGWINSZ_PORTABLE 0x5413 -#define TIOCSWINSZ_PORTABLE 0x5414 -#define TIOCMGET_PORTABLE 0x5415 -#define TIOCMBIS_PORTABLE 0x5416 -#define TIOCMBIC_PORTABLE 0x5417 -#define TIOCMSET_PORTABLE 0x5418 -#define TIOCGSOFTCAR_PORTABLE 0x5419 -#define TIOCSSOFTCAR_PORTABLE 0x541A -#define FIONREAD_PORTABLE 0x541B -#define TIOCINQ_PORTABLE FIONREAD_PORTABLE -#define TIOCLINUX_PORTABLE 0x541C -#define TIOCCONS_PORTABLE 0x541D -#define TIOCGSERIAL_PORTABLE 0x541E -#define TIOCSSERIAL_PORTABLE 0x541F -#define TIOCPKT_PORTABLE 0x5420 -#define FIONBIO_PORTABLE 0x5421 -#define TIOCNOTTY_PORTABLE 0x5422 -#define TIOCSETD_PORTABLE 0x5423 -#define TIOCGETD_PORTABLE 0x5424 -#define TCSBRKP_PORTABLE 0x5425 -#define TIOCSBRK_PORTABLE 0x5427 -#define TIOCCBRK_PORTABLE 0x5428 -#define TIOCGSID_PORTABLE 0x5429 -#define TIOCGPTN_PORTABLE _IOR_PORTABLE('T',0x30, unsigned int) -#define TIOCSPTLCK_PORTABLE _IOW_PORTABLE('T',0x31, int) - -#define FIONCLEX_PORTABLE 0x5450 -#define FIOCLEX_PORTABLE 0x5451 -#define FIOASYNC_PORTABLE 0x5452 -#define TIOCSERCONFIG_PORTABLE 0x5453 -#define TIOCSERGWILD_PORTABLE 0x5454 -#define TIOCSERSWILD_PORTABLE 0x5455 -#define TIOCGLCKTRMIOS_PORTABLE 0x5456 -#define TIOCSLCKTRMIOS_PORTABLE 0x5457 -#define TIOCSERGSTRUCT_PORTABLE 0x5458 -#define TIOCSERGETLSR_PORTABLE 0x5459 -#define TIOCSERGETMULTI_PORTABLE 0x545A -#define TIOCSERSETMULTI_PORTABLE 0x545B - -#define TIOCMIWAIT_PORTABLE 0x545C -#define TIOCGICOUNT_PORTABLE 0x545D -#define FIOQSIZE_PORTABLE 0x545E /* x86 differs here */ - -#define TIOCPKT_DATA_PORTABLE 0 -#define TIOCPKT_FLUSHREAD_PORTABLE 1 -#define TIOCPKT_FLUSHWRITE_PORTABLE 2 -#define TIOCPKT_STOP_PORTABLE 4 -#define TIOCPKT_START_PORTABLE 8 -#define TIOCPKT_NOSTOP_PORTABLE 16 -#define TIOCPKT_DOSTOP_PORTABLE 32 - -#define TIOCSER_TEMT_PORTABLE 0x01 - -/* - * Derived from development/ndk/platforms/android-3/include/sys/ioctl_compat.h - */ -struct tchars_portable { - char t_intrc; /* interrupt */ - char t_quitc; /* quit */ - char t_startc; /* start output */ - char t_stopc; /* stop output */ - char t_eofc; /* end-of-file */ - char t_brkc; /* input delimiter (like nl) */ -}; - -struct ltchars_portable { - char t_suspc; /* stop process signal */ - char t_dsuspc; /* delayed stop process signal */ - char t_rprntc; /* reprint line */ - char t_flushc; /* flush output (toggles) */ - char t_werasc; /* word erase */ - char t_lnextc; /* literal next character */ -}; - -struct sgttyb_portable { - char sg_ispeed; /* input speed */ - char sg_ospeed; /* output speed */ - char sg_erase; /* erase character */ - char sg_kill; /* kill character */ - short sg_flags; /* mode flags */ -}; - -#ifdef USE_OLD_TTY -# define TIOCGETD_PORTABLE _IOR_PORTABLE('t', 0, int) /* get line discipline */ -# define TIOCSETD_PORTABLE _IOW_PORTABLE('t', 1, int) /* set line discipline */ -#else -# define OTIOCGETD_PORTABLE _IOR_PORTABLE('t', 0, int) /* get line discipline */ -# define OTIOCSETD_PORTABLE _IOW_PORTABLE('t', 1, int) /* set line discipline */ -#endif - -/* hang up on last close */ -#define TIOCHPCL_PORTABLE _IO_PORTABLE('t', 2) - -/* get parameters -- gtty */ -#define TIOCGETP_PORTABLE _IOR_PORTABLE('t', 8,struct sgttyb_portable) - -/* set parameters -- stty */ -#define TIOCSETP_PORTABLE _IOW_PORTABLE('t', 9,struct sgttyb_portable) - -/* as above, but no flushtty*/ -#define TIOCSETN_PORTABLE _IOW_PORTABLE('t',10,struct sgttyb_portable) - -/* set special characters */ -#define TIOCSETC_PORTABLE _IOW_PORTABLE('t',17,struct tchars_portable) - -/* get special characters */ -#define TIOCGETC_PORTABLE _IOR_PORTABLE('t',18,struct tchars_portable) - -/* bis local mode bits */ -#define TIOCLBIS_PORTABLE _IOW_PORTABLE('t', 127, int) - -/* bic local mode bits */ -#define TIOCLBIC_PORTABLE _IOW_PORTABLE('t', 126, int) - -/* set entire local mode word */ -#define TIOCLSET_PORTABLE _IOW_PORTABLE('t', 125, int) - -/* get local modes */ -#define TIOCLGET_PORTABLE _IOR_PORTABLE('t', 124, int) - -/* set local special chars*/ -#define TIOCSLTC_PORTABLE _IOW_PORTABLE('t',117,struct ltchars_portable) - -/* get local special chars*/ -#define TIOCGLTC_PORTABLE _IOR_PORTABLE('t',116,struct ltchars_portable) - - /* for hp300 -- sans int arg */ -#define OTIOCCONS_PORTABLE _IO_PORTABLE('t', 98) - -/* - * Derived from development/ndk/platforms/android-3/arch-arm/include/asm/sockios.h - */ -#define FIOSETOWN_PORTABLE 0x8901 -#define SIOCSPGRP_PORTABLE 0x8902 -#define FIOGETOWN_PORTABLE 0x8903 -#define SIOCGPGRP_PORTABLE 0x8904 -#define SIOCATMARK_PORTABLE 0x8905 -#define SIOCGSTAMP_PORTABLE 0x8906 - -#endif /* _IOCTLS_PORTABLE_H */ diff --git a/ndk/sources/android/libportable/common/include/log_portable.h b/ndk/sources/android/libportable/common/include/log_portable.h deleted file mode 100644 index 1a4fd435c..000000000 --- a/ndk/sources/android/libportable/common/include/log_portable.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * ALOG Levels: F - Fatal, E - Error, W - Warning, I - Info, D - Debug, V - Verbose - * - * Using them to work within the Android logcat logging mechanism: - * - * % logcat '*:v' [To display Verbose Logging] - * % logcat 'fcntl_portable:v' [To display just this fcntl logging] - * - * NOTE: This assumes you only use the 'PORTABLE_TAG'; which is the default. - * For debugging LTP it's been helpful to include the LTP program being tested; - * which is enabled below with #define EXTENDED_LOGGING. - * - * Logging routines also support ALOG*_IF() and ASSERT(); For details See: - * - * ${ANDROID_TOP}/system/core/include/cutils/log.h - * and - * http://developer.android.com/tools/debugging/debugging-log.html - * - * ALOGV is turned off by release builds: Use the #define below with LOG_NDEBUG=0 to enable. - * - * Strace works fine with ALOG out if a large max string size is used via the -s option; - * Example: - * - * strace -s 132 ./sigaction01 - * - * writev(3, [{"\2", 1}, - * {"./sigaction01`signal_portable\0", 30}, - * {"sigaction_portable(portable_signum:10:'SIGUSR1_PORTABLE:10', ... - * {"map_portable_sigset_to_mips(portable_sigset:0x7fe47a0c, ... - * ... - */ - - /* - * Enable LOG_NDEBUG to have debug code visible in logcat output by default. - * Also possible via the Lib-Portable Android.mk file. Example: - * - * # Have logging permanently enable during development. - * LOCAL_CFLAGS += -DLOG_NDEBUG=0 - */ -// # define LOG_NDEBUG 0 - - -// #define EXTENDED_LOGGING /* Include the current program name in the LOG_TAG */ -#ifdef EXTENDED_LOGGING -/* - * Inline function to put the current program name - * and this library into the logcat prefix. Example: - * - * V/./sigaction01`signal_portable(605): sigaction_portable(... ) { - * ----------------------------- - * - * Disabled by default in AOSP, enable by removing the // above. - * Useful when debugging more than one program; For example LTP has thousands. - */ -#define MAX_TAG_LEN 128 -static char my_portable_tag[MAX_TAG_LEN + 1]; - -static inline char *portable_tag() { - extern char *__progname; - - if (my_portable_tag[0] == '\000') { - strncat(&my_portable_tag[0], __progname, MAX_TAG_LEN); - strncat(&my_portable_tag[0], ".", MAX_TAG_LEN - strlen(my_portable_tag)); - strncat(&my_portable_tag[0], PORTABLE_TAG, MAX_TAG_LEN - strlen(my_portable_tag)); - } - return my_portable_tag; -} -#define LOG_TAG portable_tag() -#else /* !EXTENDED_LOGGING */ -#define LOG_TAG PORTABLE_TAG -#endif - -/* - * Override LOG_PRI() defined in ${AOSP}/system/core/include/cutils/log.h - * to preserve the value of errno while logging. - */ -#define LOG_PRI(priority, tag, ...) ({ \ - int _errno = *REAL(__errno)(); \ - int _rv = android_printLog(priority, tag, __VA_ARGS__); \ - *REAL(__errno)() = _errno; \ - _rv; /* Returned to caller */ \ -}) - -#if !defined(__HOST__) -#include - -# define PERROR(str) { \ - ALOGE("%s: PERROR('%s'): errno:%d:'%s'", __func__, str, *REAL(__errno)(), strerror(errno)); \ -} - -# define ASSERT(cond) ALOG_ASSERT(cond, "assertion failed:(%s), file: %s, line: %d:%s", \ - #cond, __FILE__, __LINE__, __func__); -#else -#include -# define PERROR(str) fprintf(stderr, "%s: PERROR('%s'): errno:%d:'%s'", __func__, str, *REAL(__errno)(), strerror(*REAL(__errno)())) -# define ASSERT(cond) assert(cond) -# define ALOGV(a,...) -# define ALOGW(a,...) -# define ALOGE(a,...) - -#endif \ No newline at end of file diff --git a/ndk/sources/android/libportable/common/include/mman_portable.h b/ndk/sources/android/libportable/common/include/mman_portable.h deleted file mode 100644 index a655cbaab..000000000 --- a/ndk/sources/android/libportable/common/include/mman_portable.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _MMAN_PORTABLE_H_ -#define _MMAN_PORTABLE_H_ - -/* Derived from development/ndk/platforms/android-3/include/asm-generic/mman.h */ -#define PROT_READ_PORTABLE 0x1 -#define PROT_WRITE_PORTABLE 0x2 -#define PROT_EXEC_PORTABLE 0x4 -#define PROT_SEM_PORTABLE 0x8 -#define PROT_NONE_PORTABLE 0x0 -#define PROT_GROWSDOWN_PORTABLE 0x01000000 -#define PROT_GROWSUP_PORTABLE 0x02000000 - -#define MAP_SHARED_PORTABLE 0x01 -#define MAP_PRIVATE_PORTABLE 0x02 -#define MAP_TYPE_PORTABLE 0x0f -#define MAP_FIXED_PORTABLE 0x10 -#define MAP_ANONYMOUS_PORTABLE 0x20 - -#define MS_ASYNC_PORTABLE 1 -#define MS_INVALIDATE_PORTABLE 2 -#define MS_SYNC_PORTABLE 4 - -#define MADV_NORMAL_PORTABLE 0 -#define MADV_RANDOM_PORTABLE 1 -#define MADV_SEQUENTIAL_PORTABLE 2 -#define MADV_WILLNEED_PORTABLE 3 -#define MADV_DONTNEED_PORTABLE 4 - -#define MADV_REMOVE_PORTABLE 9 -#define MADV_DONTFORK_PORTABLE 10 -#define MADV_DOFORK_PORTABLE 11 - -#define MAP_ANON_PORTABLE MAP_ANONYMOUS_PORTABLE -#define MAP_FILE_PORTABLE 0 - -/* Derived from development/ndk/platforms/android-3/include/asm-generic/mman.h */ -#define MAP_GROWSDOWN_PORTABLE 0x0100 -#define MAP_DENYWRITE_PORTABLE 0x0800 -#define MAP_EXECUTABLE_PORTABLE 0x1000 -#define MAP_LOCKED_PORTABLE 0x2000 -#define MAP_NORESERVE_PORTABLE 0x4000 -#define MAP_POPULATE_PORTABLE 0x8000 -#define MAP_NONBLOCK_PORTABLE 0x10000 - -#define MCL_CURRENT_PORTABLE 1 -#define MCL_FUTURE_PORTABLE 2 - -#endif /* _MMAN_PORTABLE_H */ diff --git a/ndk/sources/android/libportable/common/include/netdb_portable.h b/ndk/sources/android/libportable/common/include/netdb_portable.h deleted file mode 100644 index b3e652868..000000000 --- a/ndk/sources/android/libportable/common/include/netdb_portable.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Derived from android-14/arch-arm/usr/include/netdb.h - *- - * Copyright (c) 1980, 1983, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -/* - * @(#)netdb.h 8.1 (Berkeley) 6/2/93 - * From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $ - * $FreeBSD: /repoman/r/ncvs/src/include/netdb.h,v 1.41 2006/04/15 16:20:26 ume Exp $ - */ - -#ifndef _NETDB_PORTABLE_H_ -#define _NETDB_PORTABLE_H_ - -#if 0 -/* - * Most of the declararitions are not needed for addrinfo mapping. - * Diff of mips and arm code running through cpp show only the - * values of ai_socktype being different. - */ -#include -#include -#include - -#ifndef _PATH_HEQUIV -# define _PATH_HEQUIV "/system/etc/hosts.equiv" -#endif - -#define _PATH_HOSTS "/system/etc/hosts" -#define _PATH_NETWORKS "/system/etc/networks" -#define _PATH_PROTOCOLS "/system/etc/protocols" -#define _PATH_SERVICES "/system/etc/services" - -#define MAXHOSTNAMELEN 256 - - -/* - * Structures returned by network data base library. All addresses are - * supplied in host order, and returned in network order (suitable for - * use in system calls). - */ -struct hostent { - char *h_name; /* official name of host */ - char **h_aliases; /* alias list */ - int h_addrtype; /* host address type */ - int h_length; /* length of address */ - char **h_addr_list; /* list of addresses from name server */ -#define h_addr h_addr_list[0] /* address, for backward compatibility */ -}; - -struct netent { - char *n_name; /* official name of net */ - char **n_aliases; /* alias list */ - int n_addrtype; /* net address type */ - uint32_t n_net; /* network # */ -}; - -struct servent { - char *s_name; /* official service name */ - char **s_aliases; /* alias list */ - int s_port; /* port # */ - char *s_proto; /* protocol to use */ -}; - -struct protoent { - char *p_name; /* official protocol name */ - char **p_aliases; /* alias list */ - int p_proto; /* protocol # */ -}; -#endif - -/* - * For mapping MIPS and ARM these structures differ only in the - * ai_socktype values. - */ -struct addrinfo_portable { - int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ - int ai_family; /* PF_xxx */ - int ai_socktype; /* SOCK_xxx */ - int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ - socklen_t ai_addrlen; /* length of ai_addr */ - char *ai_canonname; /* canonical name for hostname */ - struct sockaddr *ai_addr; /* binary address */ - struct addrinfo *ai_next; /* next structure in linked list */ -}; - -#if 0 -/* - * Error return codes from gethostbyname() and gethostbyaddr() - * (left in h_errno). - */ - -#define NETDB_INTERNAL -1 /* see errno */ -#define NETDB_SUCCESS 0 /* no problem */ -#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ -#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */ -#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ -#define NO_DATA 4 /* Valid name, no data record of requested type */ -#define NO_ADDRESS NO_DATA /* no address, look for MX record */ - -/* - * Error return codes from getaddrinfo() - */ -#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ -#define EAI_AGAIN 2 /* temporary failure in name resolution */ -#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ -#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ -#define EAI_FAMILY 5 /* ai_family not supported */ -#define EAI_MEMORY 6 /* memory allocation failure */ -#define EAI_NODATA 7 /* no address associated with hostname */ -#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ -#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ -#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ -#define EAI_SYSTEM 11 /* system error returned in errno */ -#define EAI_BADHINTS 12 /* invalid value for hints */ -#define EAI_PROTOCOL 13 /* resolved protocol is unknown */ -#define EAI_OVERFLOW 14 /* argument buffer overflow */ -#define EAI_MAX 15 - -/* - * Flag values for getaddrinfo() - */ -#define AI_PASSIVE 0x00000001 /* get address to use bind() */ -#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ -#define AI_NUMERICHOST 0x00000004 /* prevent host name resolution */ -#define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */ -/* valid flags for addrinfo (not a standard def, apps should not use it) */ -#define AI_MASK \ - (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \ - AI_ADDRCONFIG) - -#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ -#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ -#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ -#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ -/* special recommended flags for getipnodebyname */ -#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) - -/* - * Constants for getnameinfo() - */ -#define NI_MAXHOST 1025 -#define NI_MAXSERV 32 - -/* - * Flag values for getnameinfo() - */ -#define NI_NOFQDN 0x00000001 -#define NI_NUMERICHOST 0x00000002 -#define NI_NAMEREQD 0x00000004 -#define NI_NUMERICSERV 0x00000008 -#define NI_DGRAM 0x00000010 -#if 0 /* obsolete */ -#define NI_WITHSCOPEID 0x00000020 -#endif - -/* - * Scope delimit character - */ -#define SCOPE_DELIMITER '%' - -__BEGIN_DECLS -/* BIONIC-BEGIN */ -#define h_errno (*__get_h_errno()) -int* __get_h_errno(void); -/* BIONIC-END */ -void endservent(void); -struct hostent *gethostbyaddr(const char *, int, int); -struct hostent *gethostbyname(const char *); -int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *); -struct hostent *gethostbyname2(const char *, int); -struct hostent *gethostent(void); -struct netent *getnetbyaddr(uint32_t, int); -struct netent *getnetbyname(const char *); -struct protoent *getprotobyname(const char *); -struct protoent *getprotobynumber(int); -struct servent *getservbyname(const char *, const char *); -struct servent *getservbyport(int, const char *); -struct servent *getservent(void); -void herror(const char *); -const char *hstrerror(int); -#endif - -int WRAP(getaddrinfo)(const char *, const char *, struct addrinfo_portable *, - struct addrinfo_portable **); - -void WRAP(freeaddrinfo)(struct addrinfo_portable *); - -#if 0 /* Not needed for addrinfo mapping */ -int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int); -const char *gai_strerror(int); -void setservent(int); - -#if 0 /* MISSING FROM BIONIC */ -void endhostent(void); -void endnetent(void); -void endnetgrent(void); -void endprotoent(void); -void freehostent(struct hostent *); - -int gethostbyaddr_r(const char *, int, int, struct hostent *, char *, size_t, - struct hostent **, int *); - -int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, - struct hostent **, int *); - -int gethostent_r(struct hostent *, char *, size_t, struct hostent **, int *); -struct hostent *getipnodebyaddr(const void *, size_t, int, int *); -struct hostent *getipnodebyname(const char *, int, int, int *); -int getnetbyaddr_r(uint32_t, int, struct netent *, char *, size_t, struct netent**, int *); -int getnetbyname_r(const char *, struct netent *, char *, size_t, struct netent **, int *); -int getnetent_r(struct netent *, char *, size_t, struct netent **, int *); -int getnetgrent(char **, char **, char **); -int getprotobyname_r(const char *, struct protoent *, char *, size_t, struct protoent **); -int getprotobynumber_r(int, struct protoent *, char *, size_t, struct protoent **); -struct protoent *getprotoent(void); -int getprotoent_r(struct protoent *, char *, size_t, struct protoent **); -int innetgr(const char *, const char *, const char *, const char *); -void sethostent(int); -void setnetent(int); -void setprotoent(int); -struct netent *getnetent(void); -void setnetgrent(const char *); -#endif /* MISSING FROM BIONIC */ -#endif /* Not needed for addrinfo mapping */ - - -__END_DECLS - -#endif /* !_NETDB_H_ */ diff --git a/ndk/sources/android/libportable/common/include/poll_portable.h b/ndk/sources/android/libportable/common/include/poll_portable.h deleted file mode 100644 index 4004d1887..000000000 --- a/ndk/sources/android/libportable/common/include/poll_portable.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _POLL_PORTABLE_H_ -#define _POLL_PORTABLE_H_ - -/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/poll.h */ - -#define POLLIN_PORTABLE 0x0001 -#define POLLPRI_PORTABLE 0x0002 -#define POLLOUT_PORTABLE 0x0004 -#define POLLERR_PORTABLE 0x0008 -#define POLLHUP_PORTABLE 0x0010 -#define POLLNVAL_PORTABLE 0x0020 - -#define POLLRDNORM_PORTABLE 0x0040 -#define POLLRDBAND_PORTABLE 0x0080 -#define POLLWRNORM_PORTABLE 0x0100 -#define POLLWRBAND_PORTABLE 0x0200 -#define POLLMSG_PORTABLE 0x0400 -#define POLLREMOVE_PORTABLE 0x1000 -#define POLLRDHUP_PORTABLE 0x2000 - -#endif /* _POLL_PORTABLE_H_ */ diff --git a/ndk/sources/android/libportable/common/include/portability.h b/ndk/sources/android/libportable/common/include/portability.h index b15764571..21bcb5090 100644 --- a/ndk/sources/android/libportable/common/include/portability.h +++ b/ndk/sources/android/libportable/common/include/portability.h @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,34 +17,22 @@ #ifndef _PORTABILITY_H_ #define _PORTABILITY_H_ -#include -#include "asm-generic/portability.h" -/* - * Common portability helper routines - */ - -/* - * Check a portable pointer before we access it - * Well behaved programs should not be passing bad pointers - * to the kernel but this routine can be used to check a pointer - * if we need to use it before calling the kernel - * - * It does not catch every possible case but it is sufficient for LTP - */ -inline static int invalid_pointer(void *p) -{ - return p == 0 - || p == (void *)-1 -#ifdef __mips__ - || (intptr_t)p < 0 -#endif - ; -} - /* * Hidden functions are exposed while linking the libportable shared object * but are not exposed thereafter. */ #define __hidden __attribute__((visibility("hidden"))) +#if !defined(__HOST__) +#define WRAP(f) f ## _portable +#define REAL(f) f +#else +/* On host app link with libpportable.a with -Wl,--wrap=symbol, which resolves undefined symbol to __wrap_symbol, + * and undefined __real_symbol to the original symbol + */ +#define WRAP(f) __wrap_ ## f +#define REAL(f) __real_ ## f +#endif + + #endif /* _PORTABILITY_H_ */ diff --git a/ndk/sources/android/libportable/common/include/resource_portable.h b/ndk/sources/android/libportable/common/include/resource_portable.h deleted file mode 100644 index a0486d97e..000000000 --- a/ndk/sources/android/libportable/common/include/resource_portable.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _RESOURCE_PORTABLE_H_ -#define _RESOURCE_PORTABLE_H_ - -/* Derived from development/ndk/platforms/android-3/include/asm-generic/resource.h */ - -#define RLIMIT_CPU_PORTABLE 0 -#define RLIMIT_FSIZE_PORTABLE 1 -#define RLIMIT_DATA_PORTABLE 2 -#define RLIMIT_STACK_PORTABLE 3 -#define RLIMIT_CORE_PORTABLE 4 - -#ifndef RLIMIT_RSS_PORTABLE -#define RLIMIT_RSS_PORTABLE 5 -#endif - -#ifndef RLIMIT_NPROC_PORTABLE -#define RLIMIT_NPROC_PORTABLE 6 -#endif - -#ifndef RLIMIT_NOFILE_PORTABLE -#define RLIMIT_NOFILE_PORTABLE 7 -#endif - -#ifndef RLIMIT_MEMLOCK_PORTABLE -#define RLIMIT_MEMLOCK_PORTABLE 8 -#endif - -#ifndef RLIMIT_AS_PORTABLE -#define RLIMIT_AS_PORTABLE 9 -#endif - -#define RLIMIT_LOCKS_PORTABLE 10 -#define RLIMIT_SIGPENDING_PORTABLE 11 -#define RLIMIT_MSGQUEUE_PORTABLE 12 -#define RLIMIT_NICE_PORTABLE 13 -#define RLIMIT_RTPRIO_PORTABLE 14 -#define RLIMIT_RTTIME_PORTABLE 15 - -#define RLIM_NLIMITS_PORTABLE 16 - -#ifndef RLIM_INFINITY_PORTABLE -#define RLIM_INFINITY_PORTABLE (~0UL) -#endif - -#ifndef _STK_LIM_MAX_PORTABLE -#define _STK_LIM_MAX_PORTABLE RLIM_INFINITY_PORTABLE -#endif - -#endif /* _RESOURCE_PORTABLE_H_ */ diff --git a/ndk/sources/android/libportable/common/include/signal_portable.h b/ndk/sources/android/libportable/common/include/signal_portable.h deleted file mode 100644 index 3ea8de1a6..000000000 --- a/ndk/sources/android/libportable/common/include/signal_portable.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Derived from gdk/platforms/android-14/arch-arm/usr/include/signal.h - * - * Copyright (C) 2008 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#ifndef _SIGNAL_PORTABLE_H_ -#define _SIGNAL_PORTABLE_H_ - -#include -#include -#include /* For LONG_BIT */ -#include /* For memset() */ -#include -#include -#include -#include -#include - -#define __ARCH_SI_UID_T __kernel_uid32_t -#include -#undef __ARCH_SI_UID_T - -__BEGIN_DECLS - -typedef int sig_atomic_t; - -#if 0 -/* _NSIG is used by the SIGRTMAX definition under , however - * its definition is part of a #if __KERNEL__ .. #endif block in the original - * kernel headers and is thus not part of our cleaned-up versions. - * - * Looking at the current kernel sources, it is defined as 64 for all - * architectures except for the 'mips' one which set it to 128. - */ -#ifndef _NSIG_PORTABLE -# define _NSIG_PORTABLE 64 -#endif -#endif - -extern const char * const sys_siglist[]; -extern const char * const sys_signame[]; - -static __inline__ int WRAP(sigismember)(sigset_portable_t *set, int signum) -{ - unsigned long *local_set = (unsigned long *)set; - signum--; - return (int)((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1); -} - - -static __inline__ int WRAP(sigaddset)(sigset_portable_t *set, int signum) -{ - unsigned long *local_set = (unsigned long *)set; - signum--; - local_set[signum/LONG_BIT] |= 1UL << (signum%LONG_BIT); - return 0; -} - - -static __inline__ int WRAP(sigdelset)(sigset_portable_t *set, int signum) -{ - unsigned long *local_set = (unsigned long *)set; - signum--; - local_set[signum/LONG_BIT] &= ~(1UL << (signum%LONG_BIT)); - return 0; -} - - -static __inline__ int WRAP(sigemptyset)(sigset_portable_t *set) -{ - memset(set, 0, sizeof *set); - return 0; -} - -static __inline__ int WRAP(sigfillset)(sigset_portable_t *set) -{ - memset(set, ~0, sizeof *set); - return 0; -} - -/* compatibility types */ -typedef void (*sig_portable_t)(int); -typedef sig_portable_t sighandler_portable_t; - -/* Extended compatibility types, for processing a siginfo_t argument */ -typedef void (*sig3_portable_t)(int, siginfo_portable_t *, void *); -typedef sig3_portable_t sig3handler_portable_t; - -/* differentiater between sysv and bsd behaviour 8*/ -extern __sighandler_t sysv_signal(int, __sighandler_portable_t); -extern __sighandler_t bsd_signal(int, __sighandler_portable_t); - -#if 0 -/* the default is bsd */ -static __inline__ __sighandler_portable_t WRAP(signal)(int s, sighandler_portable_t f) -{ - return bsd_signal(s,f); -} -#endif - -/* the portable mapped syscall itself */ -extern __sighandler_portable_t WRAP(__signal)(int, __sighandler_portable_t); - -extern int WRAP(sigprocmask)(int, const sigset_portable_t *, sigset_portable_t *); - -extern int WRAP(sigaction)(int, const struct sigaction_portable *, - struct sigaction_portable *); - -extern int WRAP(sigpending)(sigset_portable_t *); -extern int WRAP(sigsuspend)(const sigset_portable_t *); -extern int WRAP(sigwait)(const sigset_portable_t *set, int *sig); -extern int WRAP(siginterrupt)(int sig, int flag); - -extern int WRAP(raise)(int); -extern int WRAP(kill)(pid_t, int); -extern int WRAP(killpg)(int pgrp, int sig); -extern int WRAP(tkill)(int tid, int portable_signum); -extern int WRAP(sigaltstack)(const portable_stack_t *ss, portable_stack_t *oss); -extern int WRAP(timer_create)(clockid_t, struct sigevent *, timer_t *); - -#if 0 -extern int WRAP(signalfd)(int fd, const sigset_portable_t *portable_sigmask, int flags); -#endif - -extern __hidden int do_signalfd4_portable(int fd, const sigset_portable_t *portable_sigmask, - int portable_sigsetsize, int flags); - -extern __hidden int read_signalfd_mapper(int fd, void *buf, size_t count); -extern __hidden char *map_portable_signum_to_name(int portable_signum); -extern __hidden char *map_mips_signum_to_name(int mips_signum); -extern __hidden int signum_pton(int portable_signum); -extern __hidden int signum_ntop(int mips_signum); - -typedef int (*sigmask_fn)(int, const sigset_t *, sigset_t *); -typedef int (*rt_sigmask_fn)(int, const sigset_t *, sigset_t *, size_t); -typedef int (*sigaction_fn)(int, const struct sigaction *, struct sigaction *); -typedef int (*rt_sigaction_fn)(int, const struct sigaction *, struct sigaction *, size_t); - - -extern __hidden int do_sigmask(int portable_how, const sigset_portable_t *portable_sigset, - sigset_portable_t *portable_oldset, sigmask_fn fn, - rt_sigmask_fn rt_fn); - - -/* These functions are called from syscall.c and experimental Bionic linker. */ -extern int WRAP(__rt_sigaction)(int portable_signum, - const struct sigaction_portable *act, - struct sigaction_portable *oldact, - size_t sigsetsize); - -extern int WRAP(__rt_sigprocmask)(int portable_how, - const sigset_portable_t *portable_sigset, - sigset_portable_t *portable_oldset, - size_t sigsetsize); - -extern int WRAP(__rt_sigtimedwait)(const sigset_portable_t *portable_sigset, - siginfo_portable_t *portable_siginfo, - const struct timespec *timeout, - size_t portable_sigsetsize); - - -/* These functions are only called from syscall.c; not experimental Bionic linker. */ -extern __hidden int WRAP(rt_sigqueueinfo)(pid_t pid, int sig, siginfo_portable_t *uinfo); - -extern __hidden int WRAP(rt_tgsigqueueinfo)(pid_t tgid, pid_t pid, int sig, - siginfo_portable_t *uinfo); - - -/* Called by clone when memory and signal handlers aren't compatable. */ -extern __hidden void signal_disable_mapping(void); - -__END_DECLS - -#endif /* _SIGNAL_PORTABLE_H_ */ diff --git a/ndk/sources/android/libportable/common/include/signalfd_portable.h b/ndk/sources/android/libportable/common/include/signalfd_portable.h deleted file mode 100644 index 54ff47061..000000000 --- a/ndk/sources/android/libportable/common/include/signalfd_portable.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Derived from Goldfish include/linux/signalfd.h - * - * Copyright (C) 2007 Davide Libenzi - * - */ - -#ifndef _LINUX_SIGNALFD_PORTABLE_H -#define _LINUX_SIGNALFD_PORTABLE_H - -#include -#include - -/* Flags for signalfd4. */ -#define SFD_CLOEXEC O_CLOEXEC -#define SFD_NONBLOCK O_NONBLOCK - -/* For O_CLOEXEC_PORTABLE and O_NONBLOCK_PORTABLE */ -#include "fcntl_portable.h" - -#define SFD_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE -#define SFD_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE - -/* - * This structure is the same for Native and Portable. - * However for MIPS ssi_signo and ssi_errno differ in their - * values and need to be mapped. - */ -struct signalfd_siginfo { - __u32 ssi_signo; - __s32 ssi_errno; - __s32 ssi_code; - __u32 ssi_pid; - __u32 ssi_uid; - __s32 ssi_fd; - __u32 ssi_tid; - __u32 ssi_band; - __u32 ssi_overrun; - __u32 ssi_trapno; - __s32 ssi_status; - __s32 ssi_int; - __u64 ssi_ptr; - __u64 ssi_utime; - __u64 ssi_stime; - __u64 ssi_addr; - - /* - * Pad structure to 128 bytes. Remember to update the - * pad size when you add new members. We use a fixed - * size structure to avoid compatibility problems with - * future versions, and we leave extra space for additional - * members. We use fixed size members because this structure - * comes out of a read(2) and we really don't want to have - * a compat (sp?) on read(2). - */ - __u8 __pad[48]; -}; - -#endif /* _LINUX_SIGNALFD_PORTABLE_H */ - diff --git a/ndk/sources/android/libportable/common/include/socket_portable.h b/ndk/sources/android/libportable/common/include/socket_portable.h deleted file mode 100644 index ff1f9c420..000000000 --- a/ndk/sources/android/libportable/common/include/socket_portable.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _SOCKET_PORTABLE_H_ -#define _SOCKET_PORTABLE_H_ - -/* Derived from development/ndk/platforms/android-3/include/sys/socket.h */ -#define SOCK_STREAM_PORTABLE 1 -#define SOCK_DGRAM_PORTABLE 2 -#define SOCK_RAW_PORTABLE 3 -#define SOCK_RDM_PORTABLE 4 -#define SOCK_SEQPACKET_PORTABLE 5 -#define SOCK_PACKET_PORTABLE 10 - - -/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/socket.h */ - -#define SOL_SOCKET_PORTABLE 1 - -#define SO_DEBUG_PORTABLE 1 -#define SO_REUSEADDR_PORTABLE 2 -#define SO_TYPE_PORTABLE 3 -#define SO_ERROR_PORTABLE 4 -#define SO_DONTROUTE_PORTABLE 5 -#define SO_BROADCAST_PORTABLE 6 -#define SO_SNDBUF_PORTABLE 7 -#define SO_RCVBUF_PORTABLE 8 -#define SO_SNDBUFFORCE_PORTABLE 32 -#define SO_RCVBUFFORCE_PORTABLE 33 -#define SO_KEEPALIVE_PORTABLE 9 -#define SO_OOBINLINE_PORTABLE 10 -#define SO_NO_CHECK_PORTABLE 11 -#define SO_PRIORITY_PORTABLE 12 -#define SO_LINGER_PORTABLE 13 -#define SO_BSDCOMPAT_PORTABLE 14 - -#define SO_PASSCRED_PORTABLE 16 -#define SO_PEERCRED_PORTABLE 17 -#define SO_RCVLOWAT_PORTABLE 18 -#define SO_SNDLOWAT_PORTABLE 19 -#define SO_RCVTIMEO_PORTABLE 20 -#define SO_SNDTIMEO_PORTABLE 21 - -#define SO_SECURITY_AUTHENTICATION_PORTABLE 22 -#define SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE 23 -#define SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE 24 - -#define SO_BINDTODEVICE_PORTABLE 25 - -#define SO_ATTACH_FILTER_PORTABLE 26 -#define SO_DETACH_FILTER_PORTABLE 27 - -#define SO_PEERNAME_PORTABLE 28 -#define SO_TIMESTAMP_PORTABLE 29 -#define SCM_TIMESTAMP_PORTABLE SO_TIMESTAMP_PORTABLE - -#define SO_ACCEPTCONN_PORTABLE 30 - -#define SO_PEERSEC_PORTABLE 31 -#define SO_PASSSEC_PORTABLE 34 - -#endif /* _SOCKET_PORTABLE_H */ diff --git a/ndk/sources/android/libportable/common/include/stat_portable.h b/ndk/sources/android/libportable/common/include/stat_portable.h index fb9671de8..f42f57c47 100644 --- a/ndk/sources/android/libportable/common/include/stat_portable.h +++ b/ndk/sources/android/libportable/common/include/stat_portable.h @@ -1,5 +1,5 @@ /* - * Copyright 2012, The Android Open Source Project + * Copyright 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,23 +17,23 @@ #ifndef _STAT_PORTABLE_H_ #define _STAT_PORTABLE_H_ +#include +#include +#include #include -#include - -#ifdef __LP64__ #define __STAT64_BODY_PORTABLE \ unsigned long st_dev; \ unsigned long st_ino; \ - unsigned int st_mode; \ - unsigned int st_nlink; \ - uid_t st_uid; \ - gid_t st_gid; \ + unsigned long st_mode; \ + unsigned long st_nlink; \ + uid_t st_uid; /* 32-bit uid_t */ \ + unsigned char padding[4]; \ + gid_t st_gid; /* 32-bit gid_t */ \ + unsigned char padding2[4]; \ unsigned long st_rdev; \ - unsigned long __pad1; \ long st_size; \ - int st_blksize; \ - int __pad2; \ + long st_blksize; \ long st_blocks; \ long st_atime; \ unsigned long st_atime_nsec; \ @@ -41,166 +41,82 @@ unsigned long st_mtime_nsec; \ long st_ctime; \ unsigned long st_ctime_nsec; \ - unsigned int __unused4; \ - unsigned int __unused5; \ - unsigned long __unused_for_largest_size; \ - + unsigned char padding3[8]; struct stat_portable { __STAT64_BODY_PORTABLE }; -struct stat64_portable { __STAT64_BODY_PORTABLE }; +#define stat64_portable stat_portable -static inline -void stat_ntop(struct stat *n_stat, struct stat_portable *p_stat) +static inline void stat_n2p(struct stat* pn, struct stat_portable* pp) { - memset(p_stat, '\0', sizeof(struct stat_portable)); - p_stat->st_dev = n_stat->st_dev; - p_stat->st_ino = n_stat->st_ino; - p_stat->st_mode = n_stat->st_mode; - p_stat->st_nlink = n_stat->st_nlink; - p_stat->st_uid = n_stat->st_uid; - p_stat->st_gid = n_stat->st_gid; - p_stat->st_rdev = n_stat->st_rdev; - p_stat->st_size = n_stat->st_size; - p_stat->st_blksize = n_stat->st_blksize; - p_stat->st_blocks = n_stat->st_blocks; - p_stat->st_atime = n_stat->st_atime; - p_stat->st_atime_nsec = n_stat->st_atime_nsec; - p_stat->st_mtime = n_stat->st_mtime; - p_stat->st_mtime_nsec = n_stat->st_mtime_nsec; - p_stat->st_ctime = n_stat->st_ctime; - p_stat->st_ctime_nsec = n_stat->st_ctime_nsec; + memset(pp, '\0', sizeof(struct stat_portable)); + pp->st_dev = pn->st_dev; + pp->st_ino = pn->st_ino; + pp->st_mode = pn->st_mode; + pp->st_nlink = pn->st_nlink; + pp->st_uid = pn->st_uid; + pp->st_gid = pn->st_gid; + pp->st_rdev = pn->st_rdev; + pp->st_size = pn->st_size; + pp->st_blksize = pn->st_blksize; + pp->st_blocks = pn->st_blocks; + pp->st_atime = pn->st_atime; + pp->st_atime_nsec = pn->st_atime_nsec; + pp->st_mtime = pn->st_mtime; + pp->st_mtime_nsec = pn->st_mtime_nsec; + pp->st_ctime = pn->st_ctime; + pp->st_ctime_nsec = pn->st_ctime_nsec; } -#else // ! __LP64__ - -/* It's easy to change kernel to support stat */ -struct stat_portable { - unsigned long long st_dev; - unsigned char __pad0[4]; - - unsigned long __st_ino; - unsigned int st_mode; - unsigned int st_nlink; - - unsigned long st_uid; - unsigned long st_gid; - - unsigned long long st_rdev; - unsigned char __pad3[4]; - - unsigned char __pad4[4]; - long long st_size; - unsigned long st_blksize; - unsigned char __pad5[4]; - unsigned long long st_blocks; - - unsigned long st_atime; - unsigned long st_atime_nsec; - - unsigned long st_mtime; - unsigned long st_mtime_nsec; - - unsigned long st_ctime; - unsigned long st_ctime_nsec; - - unsigned long long st_ino; -}; - -/* -The X86 Version is -struct stat { - unsigned long long st_dev; - unsigned char __pad0[4]; - - unsigned long __st_ino; - unsigned int st_mode; - unsigned int st_nlink; - - unsigned long st_uid; - unsigned long st_gid; - - unsigned long long st_rdev; - unsigned char __pad3[4]; - - long long st_size; - unsigned long st_blksize; - unsigned long long st_blocks; - - unsigned long st_atime; - unsigned long st_atime_nsec; - - unsigned long st_mtime; - unsigned long st_mtime_nsec; - - unsigned long st_ctime; - unsigned long st_ctime_nsec; - - unsigned long long st_ino; -}; -*/ - -/* -The MIPS Version is -struct stat { - unsigned long st_dev; - unsigned long __pad0[3]; - - unsigned long long st_ino; - - unsigned int st_mode; - unsigned int st_nlink; - - unsigned long st_uid; - unsigned long st_gid; - - unsigned long st_rdev; - unsigned long __pad1[3]; - - long long st_size; - - unsigned long st_atime; - unsigned long st_atime_nsec; - - unsigned long st_mtime; - unsigned long st_mtime_nsec; - - unsigned long st_ctime; - unsigned long st_ctime_nsec; - - unsigned long st_blksize; - unsigned long __pad2; - - unsigned long long st_blocks; -}; -*/ - -static inline void stat_ntop(struct stat *n_stat, struct stat_portable *p_stat) +int WRAP(fstat)(int a, struct stat_portable* p) { - memset(p_stat, '\0', sizeof(struct stat_portable)); - p_stat->st_dev = n_stat->st_dev; -#if defined(__mips__) - /* MIPS doesn't have __st_ino */ - p_stat->__st_ino = 0; -#else - p_stat->__st_ino = n_stat->__st_ino; -#endif - p_stat->st_mode = n_stat->st_mode; - p_stat->st_nlink = n_stat->st_nlink; - p_stat->st_uid = n_stat->st_uid; - p_stat->st_gid = n_stat->st_gid; - p_stat->st_rdev = n_stat->st_rdev; - p_stat->st_size = n_stat->st_size; - p_stat->st_blksize = n_stat->st_blksize; - p_stat->st_blocks = n_stat->st_blocks; - p_stat->st_atime = n_stat->st_atime; - p_stat->st_atime_nsec = n_stat->st_atime_nsec; - p_stat->st_mtime = n_stat->st_mtime; - p_stat->st_mtime_nsec = n_stat->st_mtime_nsec; - p_stat->st_ctime = n_stat->st_ctime; - p_stat->st_ctime_nsec = n_stat->st_ctime_nsec; - p_stat->st_ino = n_stat->st_ino; + struct stat target_stat_obj; + int ret = REAL(fstat)(a, &target_stat_obj); + stat_n2p(&target_stat_obj, p); + return ret; } -#endif // __LP64__ +int WRAP(fstat64)(int a, struct stat64_portable* p) +{ + return WRAP(fstat)(a, p); +} + +int WRAP(fstatat)(int a, const char* p1, struct stat_portable* p2, int b) +{ + struct stat target_stat_obj; + int ret = REAL(fstatat)(a, p1, &target_stat_obj, b); + stat_n2p(&target_stat_obj, p2); + return ret; +} + +int WRAP(fstatat64)(int a, const char* b, struct stat64_portable* c, int d) +{ + return WRAP(fstatat)(a, b, c, d); +} + +int WRAP(lstat)(const char* a, struct stat_portable* p) +{ + struct stat target_stat_obj; + int ret = REAL(lstat)(a, &target_stat_obj); + stat_n2p(&target_stat_obj, p); + return ret; +} + +int WRAP(lstat64)(const char* a, struct stat64_portable* p) +{ + return WRAP(lstat)(a, p); +} + +int WRAP(stat)(const char* a, struct stat_portable* p) +{ + struct stat target_stat_obj; + int ret = REAL(stat)(a, &target_stat_obj); + stat_n2p(&target_stat_obj, p); + return ret; +} + +int WRAP(stat64)(const char* a, struct stat64_portable* p) +{ + return WRAP(stat)(a, p); +} #endif /* _STAT_PORTABLE_H */ diff --git a/ndk/sources/android/libportable/common/include/statfs_portable.h b/ndk/sources/android/libportable/common/include/statfs_portable.h deleted file mode 100644 index 677469645..000000000 --- a/ndk/sources/android/libportable/common/include/statfs_portable.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _STATFS_PORTABLE_H_ -#define _STATFS_PORTABLE_H_ - -#include - -/* It's easy to change kernel to support statfs */ -struct statfs_portable { - uint32_t f_type; - uint32_t f_bsize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; - __fsid_t f_fsid; - uint32_t f_namelen; - uint32_t f_frsize; - uint32_t f_flags; - uint32_t f_spare[4]; -}; - -/* -The MIPS Version is -struct statfs { - uint32_t f_type; - uint32_t f_bsize; - uint32_t f_frsize; - uint32_t __pad; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_files; - uint64_t f_ffree; - uint64_t f_bavail; - __fsid_t f_fsid; - uint32_t f_namelen; - uint32_t f_flags; - uint32_t f_spare[5]; -}; -*/ -#endif /* _STATFS_PORTABLE_H_ */ diff --git a/ndk/sources/android/libportable/common/include/timerfd_portable.h b/ndk/sources/android/libportable/common/include/timerfd_portable.h deleted file mode 100644 index d6c294c2a..000000000 --- a/ndk/sources/android/libportable/common/include/timerfd_portable.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Derived from bionic/libc/include/sys/eventfd.h - * - * Copyright (C) 2008 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _SYS_TIMERFD_PORTABLE_H -#define _SYS_TIMERFD_PORTABLE_H - -#include -#include -#include -#include - -__BEGIN_DECLS - -#define TFD_CLOEXEC O_CLOEXEC -#define TFD_NONBLOCK O_NONBLOCK - -#define TFD_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE -#define TFD_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE - -extern int WRAP(timerfd_create)(int clockid, int flags); - -__END_DECLS - -#endif /* _SYS_TIMERFD_H */ diff --git a/ndk/sources/android/libportable/common/include/vfs_portable.h b/ndk/sources/android/libportable/common/include/vfs_portable.h index 762ce0c85..37bf1010d 100644 --- a/ndk/sources/android/libportable/common/include/vfs_portable.h +++ b/ndk/sources/android/libportable/common/include/vfs_portable.h @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef _VFS_PORTABLE_H -#define _VFS_PORTABLE_H +#ifndef _VFS_PORTABLE_H_ +#define _VFS_PORTABLE_H_ +#include +#include #include #include -/* The kernel's __kernel_fsid_t has a 'val' member but glibc uses '__val'. */ -typedef struct { int __val[2]; } __fsid_t_portable; -typedef __fsid_t_portable fsid_t_portable; +typedef __fsid_t fsid_t; #define __STATFS64_BODY_PORTABLE \ uint64_t f_type; \ @@ -32,65 +32,63 @@ typedef __fsid_t_portable fsid_t_portable; uint64_t f_bavail; \ uint64_t f_files; \ uint64_t f_ffree; \ - fsid_t_portable f_fsid; \ + fsid_t f_fsid; \ uint64_t f_namelen; \ uint64_t f_frsize; \ uint64_t f_flags; \ - uint64_t f_spare[5]; \ + uint64_t f_spare[5]; struct statfs_portable { __STATFS64_BODY_PORTABLE }; -struct statfs64_portable { __STATFS64_BODY_PORTABLE }; +#define statfs64_portable statfs_portable -static inline -void statfs_ntop(struct statfs *n_statfs, struct statfs_portable *p_statfs) { - memset(p_statfs, 0, sizeof(struct statfs_portable)); - p_statfs->f_type = n_statfs->f_type; - p_statfs->f_bsize = n_statfs->f_bsize; - p_statfs->f_blocks = n_statfs->f_blocks; - p_statfs->f_bfree = n_statfs->f_bfree; - p_statfs->f_bavail = n_statfs->f_bavail; - p_statfs->f_files = n_statfs->f_files; - p_statfs->f_ffree = n_statfs->f_ffree; - memcpy(&p_statfs->f_fsid, &n_statfs->f_fsid, sizeof(int)*2); - p_statfs->f_namelen = n_statfs->f_namelen; - p_statfs->f_frsize = n_statfs->f_frsize; - p_statfs->f_flags = n_statfs->f_flags; +#undef __STATFS64_BODY_PORTABLE + +static void statfs_n2p(const struct statfs* pn, struct statfs_portable* pp) +{ + memset(pp, '\0', sizeof(struct statfs_portable)); + pp->f_type = pn->f_type; + pp->f_bsize = pn->f_bsize; + pp->f_blocks = pn->f_blocks; + pp->f_bfree = pn->f_bfree; + pp->f_bavail = pn->f_bavail; + pp->f_files = pn->f_files; + pp->f_ffree = pn->f_ffree; + memcpy(&pp->f_fsid, &pn->f_fsid, sizeof(int)*2); + pp->f_namelen = pn->f_namelen; + pp->f_frsize = pn->f_frsize; + pp->f_flags = pn->f_flags; #ifdef __mips__ - memcpy(&p_statfs->f_spare, &n_statfs->f_spare, 4); + memcpy(&pp->f_spare, &pn->f_spare, 4); #else - memcpy(&p_statfs->f_spare, &n_statfs->f_spare, 5); + memcpy(&pp->f_spare, &pn->f_spare, 5); #endif } - -static inline -int WRAP(statfs)(const char* path, struct statfs_portable* stat) { - struct statfs native_stat; - - int ret = REAL(statfs)(path, &native_stat); - statfs_ntop(&native_stat, stat); +int WRAP(statfs)(const char* path, struct statfs_portable* stat) +{ + struct statfs target_stat; + int ret = REAL(statfs)(path, &target_stat); + statfs_n2p(&target_stat, stat); return ret; } -static inline -int WRAP(statfs64)(const char* path, struct statfs64_portable* stat) { - return WRAP(statfs)(path, (struct statfs_portable*)stat); +int WRAP(statfs64)(const char* path, struct statfs64_portable* stat) +{ + return WRAP(statfs)(path, stat); } - -static inline -int WRAP(fstatfs)(int fd, struct statfs_portable* stat) { - struct statfs native_stat; - - int ret = REAL(fstatfs)(fd, &native_stat); - statfs_ntop(&native_stat, stat); +int WRAP(fstatfs)(int fd, struct statfs_portable* stat) +{ + struct statfs target_stat; + int ret = REAL(fstatfs)(fd, &target_stat); + statfs_n2p(&target_stat, stat); return ret; } -static inline -int WRAP(fstatfs64)(int fd, struct statfs64_portable* stat) { - return WRAP(fstatfs)(fd, (struct statfs_portable*)stat); +int WRAP(fstatfs64)(int fd, struct statfs64_portable* stat) +{ + return WRAP(fstatfs)(fd, stat); } -#endif +#endif /* _VFS_PORTABLE_H */