diff --git a/ndk/sources/android/libportable/arch-arm/epoll.c b/ndk/sources/android/libportable/arch-arm/epoll.c index f703ba1d9..ef75695df 100644 --- a/ndk/sources/android/libportable/arch-arm/epoll.c +++ b/ndk/sources/android/libportable/arch-arm/epoll.c @@ -14,15 +14,16 @@ * limitations under the License. */ +#include #include -int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event) +int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event *event) { - return epoll_ctl(epfd, op, fd, event); + return REAL(epoll_ctl)(epfd, op, fd, event); } -int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout) +int WRAP(epoll_wait)(int epfd, struct epoll_event *events, int max, int timeout) { - return epoll_wait(epfd, events, max, timeout); + return REAL(epoll_wait)(epfd, events, max, timeout); } diff --git a/ndk/sources/android/libportable/arch-arm/errno.c b/ndk/sources/android/libportable/arch-arm/errno.c index ffa599892..776b12edc 100644 --- a/ndk/sources/android/libportable/arch-arm/errno.c +++ b/ndk/sources/android/libportable/arch-arm/errno.c @@ -14,8 +14,10 @@ * limitations under the License. */ -extern volatile int* __errno(void); -volatile int* __errno_portable() +#include + +extern volatile int* REAL(__errno)(void); +volatile int* WRAP(__errno)() { - return __errno(); + return REAL(__errno)(); } diff --git a/ndk/sources/android/libportable/arch-arm/socket.c b/ndk/sources/android/libportable/arch-arm/socket.c index 7e7ca9b38..72211c94b 100644 --- a/ndk/sources/android/libportable/arch-arm/socket.c +++ b/ndk/sources/android/libportable/arch-arm/socket.c @@ -14,10 +14,11 @@ * limitations under the License. */ +#include #include #include #include -int socket_portable(int domain, int type, int protocol) { - return socket(domain, type, protocol); +int WRAP(socket)(int domain, int type, int protocol) { + return REAL(socket)(domain, type, protocol); } diff --git a/ndk/sources/android/libportable/arch-arm/sockopt.c b/ndk/sources/android/libportable/arch-arm/sockopt.c index c86ded328..a9d208476 100644 --- a/ndk/sources/android/libportable/arch-arm/sockopt.c +++ b/ndk/sources/android/libportable/arch-arm/sockopt.c @@ -14,17 +14,18 @@ * limitations under the License. */ +#include #include #include extern int setsockopt(int, int, int, const void *, socklen_t); -int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen) +int WRAP(setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen) { - return setsockopt(s, level, optname, optval, optlen); + return REAL(setsockopt)(s, level, optname, optval, optlen); } extern int getsockopt (int, int, int, void *, socklen_t *); -int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen) +int WRAP(getsockopt)(int s, int level, int optname, void *optval, socklen_t *optlen) { - return getsockopt(s, level, optname, optval, optlen); + return REAL(getsockopt)(s, level, optname, optval, optlen); } diff --git a/ndk/sources/android/libportable/arch-arm/stat.c b/ndk/sources/android/libportable/arch-arm/stat.c index 20a34ad2a..be9ca6276 100644 --- a/ndk/sources/android/libportable/arch-arm/stat.c +++ b/ndk/sources/android/libportable/arch-arm/stat.c @@ -14,25 +14,26 @@ * limitations under the License. */ +#include #include /* Note: The Portable Header will define stat to stat_portable */ -int stat_portable(const char *path, struct stat_portable *s) +int WRAP(stat)(const char *path, struct stat_portable *s) { - return stat(path, s); + return REAL(stat)(path, s); } -int fstat_portable(int fd, struct stat_portable *s) +int WRAP(fstat)(int fd, struct stat_portable *s) { - return fstat(fd, s); -} - -int lstat_portable(const char *path, struct stat_portable *s) -{ - return lstat(path, s); + return REAL(fstat)(fd, s); } -int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags) +int WRAP(lstat)(const char *path, struct stat_portable *s) { - return fstatat(dirfd, path, s, flags); + return REAL(lstat)(path, s); +} + +int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags) +{ + return REAL(fstatat)(dirfd, path, s, flags); } diff --git a/ndk/sources/android/libportable/arch-arm/unwind.c b/ndk/sources/android/libportable/arch-arm/unwind.c index ddc034b75..99f2dacc4 100644 --- a/ndk/sources/android/libportable/arch-arm/unwind.c +++ b/ndk/sources/android/libportable/arch-arm/unwind.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include struct _Unwind_Context; @@ -55,25 +56,25 @@ _Unwind_VRS_Result _Unwind_VRS_Set(struct _Unwind_Context *context, #define UNWIND_STACK_REG 13 #define UNWIND_IP_REG 15 -uint64_t _Unwind_GetGR_portable(struct _Unwind_Context* ctx, int index) { +uint64_t WRAP(_Unwind_GetGR)(struct _Unwind_Context* ctx, int index) { uint32_t val; _Unwind_VRS_Get(ctx, _UVRSC_CORE, index, _UVRSD_UINT32, &val); return (uint64_t)val; } -void _Unwind_SetGR_portable(struct _Unwind_Context* ctx, int index, uint64_t new_value) { +void WRAP(_Unwind_SetGR)(struct _Unwind_Context* ctx, int index, uint64_t new_value) { uint32_t val = (uint32_t)new_value; _Unwind_VRS_Set(ctx, _UVRSC_CORE, index, _UVRSD_UINT32, &val); } -uint64_t _Unwind_GetIP_portable(struct _Unwind_Context* ctx) { - return _Unwind_GetGR_portable(ctx, UNWIND_IP_REG) & ~1; // thumb bit +uint64_t WRAP(_Unwind_GetIP)(struct _Unwind_Context* ctx) { + return WRAP(_Unwind_GetGR)(ctx, UNWIND_IP_REG) & ~1; // thumb bit } -void _Unwind_SetIP_portable(struct _Unwind_Context* ctx, uintptr_t new_value) { +void WRAP(_Unwind_SetIP)(struct _Unwind_Context* ctx, uintptr_t new_value) { uint32_t val = (uint32_t)new_value; // Propagate thumb bit to instruction pointer - uint32_t thumbState = _Unwind_GetGR_portable(ctx, UNWIND_IP_REG) & 1; + uint32_t thumbState = WRAP(_Unwind_GetGR)(ctx, UNWIND_IP_REG) & 1; uint64_t new_val = (uint64_t)(val | thumbState); - _Unwind_SetGR_portable(ctx, UNWIND_IP_REG, new_val); + WRAP(_Unwind_SetGR)(ctx, UNWIND_IP_REG, new_val); } diff --git a/ndk/sources/android/libportable/arch-mips/clone.c b/ndk/sources/android/libportable/arch-mips/clone.c index 2fc642168..7498ef635 100644 --- a/ndk/sources/android/libportable/arch-mips/clone.c +++ b/ndk/sources/android/libportable/arch-mips/clone.c @@ -15,6 +15,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -47,7 +48,7 @@ * If no signal is specified, then the parent process is not * signaled when the child terminates. */ -int clone_portable(int (*fn)(void *), void *child_stack, int port_flags, void *arg, ...) +int WRAP(clone)(int (*fn)(void *), void *child_stack, int port_flags, void *arg, ...) { va_list args; int ret; @@ -117,7 +118,7 @@ int clone_portable(int (*fn)(void *), void *child_stack, int port_flags, void *a 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 = clone(fn, child_stack, mips_flags, arg, parent_tidptr, + ret = REAL(clone)(fn, child_stack, mips_flags, arg, parent_tidptr, new_tls, child_tidptr); if (ret > 0) { diff --git a/ndk/sources/android/libportable/arch-mips/epoll.c b/ndk/sources/android/libportable/arch-mips/epoll.c index f703ba1d9..ef75695df 100644 --- a/ndk/sources/android/libportable/arch-mips/epoll.c +++ b/ndk/sources/android/libportable/arch-mips/epoll.c @@ -14,15 +14,16 @@ * limitations under the License. */ +#include #include -int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event) +int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event *event) { - return epoll_ctl(epfd, op, fd, event); + return REAL(epoll_ctl)(epfd, op, fd, event); } -int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout) +int WRAP(epoll_wait)(int epfd, struct epoll_event *events, int max, int timeout) { - return epoll_wait(epfd, events, max, timeout); + return REAL(epoll_wait)(epfd, events, max, timeout); } diff --git a/ndk/sources/android/libportable/arch-mips/errno.c b/ndk/sources/android/libportable/arch-mips/errno.c index 8adf248b9..6ccd5122f 100644 --- a/ndk/sources/android/libportable/arch-mips/errno.c +++ b/ndk/sources/android/libportable/arch-mips/errno.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -278,7 +279,7 @@ static struct errno_state *errno_key_data(void) * 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* __errno_portable() +volatile int* WRAP(__errno)() { struct errno_state *p; int save_errno; @@ -331,7 +332,7 @@ volatile int* __errno_portable() /* set portable errno */ -void __set_errno_portable(int portable_errno) +void WRAP(__set_errno)(int portable_errno) { struct errno_state *p; int save_errno; @@ -356,13 +357,14 @@ void __set_errno_portable(int portable_errno) ALOGV("%s: return; }", __func__); } -char *strerror_portable(int errnum) +extern char* REAL(strerror)(int); +char *WRAP(strerror)(int errnum) { - return strerror(errno_pton(errnum)); + return REAL(strerror)(errno_pton(errnum)); } /* BSD style strerror_r */ -int strerror_r_portable(int errnum, char *buf, size_t buflen) +int WRAP(strerror_r)(int errnum, char *buf, size_t buflen) { - return strerror_r(errno_pton(errnum), buf, 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 index c16d9bc2b..35285d96f 100644 --- a/ndk/sources/android/libportable/arch-mips/eventfd.c +++ b/ndk/sources/android/libportable/arch-mips/eventfd.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -71,7 +72,7 @@ static inline int efd_flags_pton(int portable_flags) * new eventfd2 system call number, so it likely best to just use * the Android eventfd() for both eventfd and eventfd2 system calls. */ -int eventfd_portable(unsigned int initval, int portable_flags) { +int WRAP(eventfd)(unsigned int initval, int portable_flags) { int rv; int native_flags; @@ -81,7 +82,7 @@ int eventfd_portable(unsigned int initval, int portable_flags) { native_flags = efd_flags_pton(portable_flags); - rv = eventfd(initval, native_flags); + rv = REAL(eventfd)(initval, native_flags); if (rv >= 0) { if (native_flags & EFD_CLOEXEC) { filefd_CLOEXEC_enabled(rv); diff --git a/ndk/sources/android/libportable/arch-mips/fcntl.c b/ndk/sources/android/libportable/arch-mips/fcntl.c index d7140169f..2ef83e5dc 100644 --- a/ndk/sources/android/libportable/arch-mips/fcntl.c +++ b/ndk/sources/android/libportable/arch-mips/fcntl.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -284,7 +285,7 @@ extern int __fcntl64(int, int, void *); * pid_t l_pid; pid_t l_pid; * } } */ -int fcntl_portable(int fd, int portable_cmd, ...) +int WRAP(fcntl)(int fd, int portable_cmd, ...) { int flags; va_list ap; diff --git a/ndk/sources/android/libportable/arch-mips/filefd.c b/ndk/sources/android/libportable/arch-mips/filefd.c index 4911ee1e8..f6e55fa46 100644 --- a/ndk/sources/android/libportable/arch-mips/filefd.c +++ b/ndk/sources/android/libportable/arch-mips/filefd.c @@ -14,10 +14,10 @@ * limitations under the License. */ +#include #include #include #include -#include #include #include #include @@ -415,14 +415,14 @@ __hidden void filefd_disable_mapping() } -int close_portable(int fd) +int WRAP(close)(int fd) { int rv; ALOGV(" "); ALOGV("%s(fd:%d) {", __func__, fd); - rv = close(fd); + rv = REAL(close)(fd); filefd_closed(fd); ALOGV("%s: return(rv:%d); }", __func__, rv); @@ -430,7 +430,7 @@ int close_portable(int fd) } -int read_portable(int fd, void *buf, size_t count) +int WRAP(read)(int fd, void *buf, size_t count) { int rv; enum filefd_type fd_type; @@ -449,7 +449,7 @@ int read_portable(int fd, void *buf, size_t count) case EVENT_FD_TYPE: case INOTIFY_FD_TYPE: case TIMER_FD_TYPE: - rv = read(fd, buf, count); + rv = REAL(read)(fd, buf, count); break; /* The read() of a signalfd() file descriptor needs to be mapped. */ @@ -457,13 +457,13 @@ int read_portable(int fd, void *buf, size_t count) if (filefd_enabled) { rv = read_signalfd_mapper(fd, buf, count); } else { - rv = read(fd, buf, count); + rv = REAL(read)(fd, buf, count); } break; default: ALOGE("Unknown fd_type:%d!", fd_type); - rv = read(fd, buf, count); + rv = REAL(read)(fd, buf, count); break; } @@ -477,7 +477,7 @@ int read_portable(int fd, void *buf, size_t count) * Tries a second time if it detects an extremely unlikely * race condition. */ -int execve_portable(const char *filename, char *const argv[], char *const envp[]) +int WRAP(execve)(const char *filename, char *const argv[], char *const envp[]) { int rv; int mapped_files = filefd_mapped_files; @@ -494,7 +494,7 @@ int execve_portable(const char *filename, char *const argv[], char *const envp[ } import_fd_env(verify_consistancy); /* File type table consistancy verified. */ - rv = execve(filename, argv, envp); + rv = REAL(execve)(filename, argv, envp); ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; diff --git a/ndk/sources/android/libportable/arch-mips/flags.c b/ndk/sources/android/libportable/arch-mips/flags.c index c55fe86a8..f18b8d952 100644 --- a/ndk/sources/android/libportable/arch-mips/flags.c +++ b/ndk/sources/android/libportable/arch-mips/flags.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -26,7 +27,7 @@ extern int __sflags(const char *, int *); int -__sflags_portable(const char *mode, int *optr) +WRAP(__sflags)(const char *mode, int *optr) { int rv; int nflags, pflags; diff --git a/ndk/sources/android/libportable/arch-mips/inotify.c b/ndk/sources/android/libportable/arch-mips/inotify.c index c417aa2e6..76b1cac4d 100644 --- a/ndk/sources/android/libportable/arch-mips/inotify.c +++ b/ndk/sources/android/libportable/arch-mips/inotify.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -60,7 +61,7 @@ static inline int in_flags_pton(int portable_flags) } -int inotify_init1_portable(int portable_flags) { +int WRAP(inotify_init1)(int portable_flags) { int rv; int native_flags; diff --git a/ndk/sources/android/libportable/arch-mips/ioctl.c b/ndk/sources/android/libportable/arch-mips/ioctl.c index cbd517f7a..7e82a6a52 100644 --- a/ndk/sources/android/libportable/arch-mips/ioctl.c +++ b/ndk/sources/android/libportable/arch-mips/ioctl.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -213,7 +214,7 @@ static inline int mips_change_request(int request) } extern int __ioctl(int, int, void *); -int ioctl_portable(int fd, int request, ...) +int WRAP(ioctl)(int fd, int request, ...) { va_list ap; void * arg; diff --git a/ndk/sources/android/libportable/arch-mips/mmap.c b/ndk/sources/android/libportable/arch-mips/mmap.c index ee44513f2..f2c3a1a8f 100644 --- a/ndk/sources/android/libportable/arch-mips/mmap.c +++ b/ndk/sources/android/libportable/arch-mips/mmap.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -87,8 +88,8 @@ static inline int mmap_flags_pton(int portable_flags) return native_flags; } - -void *mmap_portable(void *addr, size_t size, int prot, int flags, int fd, long byte_offset) +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; @@ -101,7 +102,7 @@ void *mmap_portable(void *addr, size_t size, int prot, int flags, int fd, long b native_prot = mmap_prot_pton(prot); native_flags = mmap_flags_pton(flags); - ret_addr = mmap(addr, size, native_prot, native_flags, fd, byte_offset); + 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; @@ -110,7 +111,7 @@ void *mmap_portable(void *addr, size_t size, int prot, int flags, int fd, long b extern int mprotect(const void *, size_t, int); -int mprotect_portable(const void *addr, size_t size, int portable_prot) +int WRAP(mprotect)(const void *addr, size_t size, int portable_prot) { int rv; int native_prot; @@ -121,7 +122,7 @@ int mprotect_portable(const void *addr, size_t size, int portable_prot) native_prot = mmap_prot_pton(portable_prot); - rv = mprotect(addr, size, native_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 index 4804f8880..99ed7f9a4 100644 --- a/ndk/sources/android/libportable/arch-mips/open.c +++ b/ndk/sources/android/libportable/arch-mips/open.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -72,7 +73,7 @@ static inline int open_flags_pton(int flags) extern int __open(const char*, int, int); -int open_portable(const char *pathname, int flags, ...) +int WRAP(open)(const char *pathname, int flags, ...) { mode_t mode = 0; int native_flags; @@ -113,7 +114,7 @@ int open_portable(const char *pathname, int flags, ...) extern int __openat(int, const char*, int, int); -int openat_portable(int dirfd, const char *pathname, int flags, ...) +int WRAP(openat)(int dirfd, const char *pathname, int flags, ...) { mode_t mode = 0; int native_flags; diff --git a/ndk/sources/android/libportable/arch-mips/pipe.c b/ndk/sources/android/libportable/arch-mips/pipe.c index 07d01a99c..fa8026676 100644 --- a/ndk/sources/android/libportable/arch-mips/pipe.c +++ b/ndk/sources/android/libportable/arch-mips/pipe.c @@ -15,6 +15,7 @@ */ #define _GNU_SOURCE /* GLibc compatibility to declare pipe2(2) */ +#include #include #include @@ -59,7 +60,7 @@ static inline int tdf_flags_pton(int portable_flags) } -int pipe2_portable(int pipefd[2], int portable_flags) { +int WRAP(pipe2)(int pipefd[2], int portable_flags) { int native_flags; int rv; @@ -69,7 +70,7 @@ int pipe2_portable(int pipefd[2], int portable_flags) { native_flags = tdf_flags_pton(portable_flags); - rv = pipe2(pipefd, native_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]); diff --git a/ndk/sources/android/libportable/arch-mips/poll.c b/ndk/sources/android/libportable/arch-mips/poll.c index 89e06c7e2..3f971760e 100644 --- a/ndk/sources/android/libportable/arch-mips/poll.c +++ b/ndk/sources/android/libportable/arch-mips/poll.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -105,7 +106,7 @@ static inline short change_mips_events(short mips_events) extern int poll(struct pollfd *, nfds_t, long); -int poll_portable(struct pollfd *fds, nfds_t nfds, long timeout) +int WRAP(poll)(struct pollfd *fds, nfds_t nfds, long timeout) { nfds_t i; int ret; @@ -113,7 +114,7 @@ int poll_portable(struct pollfd *fds, nfds_t nfds, long timeout) for (i = 0; i < nfds; i++) fds->events = mips_change_portable_events(fds->events); - ret = poll(fds, nfds, timeout); + ret = REAL(poll)(fds, nfds, timeout); for (i = 0; i < nfds; i++) { fds->events = change_mips_events(fds->events); diff --git a/ndk/sources/android/libportable/arch-mips/pthread.c b/ndk/sources/android/libportable/arch-mips/pthread.c index 3c8e0d48e..41d94786e 100644 --- a/ndk/sources/android/libportable/arch-mips/pthread.c +++ b/ndk/sources/android/libportable/arch-mips/pthread.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -54,13 +55,13 @@ * Call pthread function and convert return value (a native errno) to portable error number. */ #define PTHREAD_WRAPPER(fn, DECLARGS, CALLARGS, fmt) \ - int fn##_portable DECLARGS \ + int WRAP(fn) DECLARGS \ { \ int rv, portable_rv; \ \ ALOGV(" "); \ ALOGV("%s" fmt, __func__, STRIP_PARENS(CALLARGS)); \ - rv = fn CALLARGS; \ + rv = REAL(fn) CALLARGS; \ portable_rv = errno_ntop(rv); \ ALOGV("%s: return(portable_rv:%d); rv:%d;", __func__, \ portable_rv, rv); \ @@ -258,7 +259,7 @@ PTHREAD_WRAPPER(pthread_setspecific, (pthread_key_t key, const void *value), (ke // void *pthread_getspecific(pthread_key_t key); -int pthread_kill_portable(pthread_t thread, int portable_signum) +int WRAP(pthread_kill)(pthread_t thread, int portable_signum) { char *portable_signame = map_portable_signum_to_name(portable_signum); int mips_signum; @@ -274,7 +275,7 @@ int pthread_kill_portable(pthread_t thread, int portable_signum) } else { ALOGV("%s: calling pthread_kill(thread:%lx, mips_signum:%d);", __func__, thread, mips_signum); - ret = pthread_kill(thread, mips_signum); + ret = REAL(pthread_kill)(thread, mips_signum); } portable_ret = errno_ntop(ret); @@ -284,7 +285,7 @@ int pthread_kill_portable(pthread_t thread, int portable_signum) return portable_ret; } -int pthread_sigmask_portable(int portable_how, const sigset_portable_t *portable_sigset, +int WRAP(pthread_sigmask)(int portable_how, const sigset_portable_t *portable_sigset, sigset_portable_t *portable_oldset) { int portable_ret, ret; diff --git a/ndk/sources/android/libportable/arch-mips/resource.c b/ndk/sources/android/libportable/arch-mips/resource.c index 4119e79df..38ee79dfc 100644 --- a/ndk/sources/android/libportable/arch-mips/resource.c +++ b/ndk/sources/android/libportable/arch-mips/resource.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -39,13 +40,13 @@ static inline int mips_change_resource(int resource) } extern int getrlimit(int resource, struct rlimit *rlp); -int getrlimit_portable(int resource, struct rlimit *rlp) +int WRAP(getrlimit)(int resource, struct rlimit *rlp) { - return getrlimit(mips_change_resource(resource), rlp); + return REAL(getrlimit)(mips_change_resource(resource), rlp); } extern int setrlimit(int resource, const struct rlimit *rlp); -int setrlimit_portable(int resource, const struct rlimit *rlp) +int WRAP(setrlimit)(int resource, const struct rlimit *rlp) { - return setrlimit(mips_change_resource(resource), 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 index bf6c6b7e6..15329725e 100644 --- a/ndk/sources/android/libportable/arch-mips/setjmp.S +++ b/ndk/sources/android/libportable/arch-mips/setjmp.S @@ -29,6 +29,7 @@ * */ +#include #include #include @@ -57,10 +58,10 @@ RAOFF= FRAMESZ-1*REGSZ -NON_LEAF(setjmp_portable, FRAMESZ, ra) +NON_LEAF(WRAP(setjmp), FRAMESZ, ra) .mask 0x80000000, RAOFF PTR_SUBU sp, FRAMESZ # allocate stack frame - SETUP_GP64(GPOFF, setjmp_portable) + SETUP_GP64(GPOFF, WRAP(setjmp)) SAVE_GP(GPOFF) .set reorder REG_S ra, RAOFF(sp) # save state @@ -143,12 +144,12 @@ botch: jal abort RESTORE_GP64 PTR_ADDU sp, FRAMESZ -END(setjmp_portable) +END(WRAP(setjmp)) -LEAF(longjmp_portable, FRAMESZ) +LEAF(WRAP(longjmp), FRAMESZ) PTR_SUBU sp, FRAMESZ - SETUP_GP64(GPOFF, longjmp_portable) + SETUP_GP64(GPOFF, WRAP(longjmp)) SAVE_GP(GPOFF) .set reorder sw a1, A1OFF(sp) @@ -214,4 +215,4 @@ LEAF(longjmp_portable, FRAMESZ) j ra move v0, a1 -END(longjmp_portable) +END(WRAP(longjmp)) diff --git a/ndk/sources/android/libportable/arch-mips/signal.c b/ndk/sources/android/libportable/arch-mips/signal.c index 95ee8bca8..c96e898f1 100644 --- a/ndk/sources/android/libportable/arch-mips/signal.c +++ b/ndk/sources/android/libportable/arch-mips/signal.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -732,7 +733,7 @@ do_signal_portable(int portable_signum, sighandler_portable_t portable_handler, * 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 signal_portable(int portable_signum, sighandler_portable_t handler) +sighandler_portable_t WRAP(signal)(int portable_signum, sighandler_portable_t handler) { sighandler_portable_t rv; @@ -748,7 +749,7 @@ sighandler_portable_t signal_portable(int portable_signum, sighandler_portable_t } -sighandler_portable_t sysv_signal_portable(int portable_signum, sighandler_portable_t handler) +sighandler_portable_t WRAP(sysv_signal)(int portable_signum, sighandler_portable_t handler) { sighandler_portable_t rv; @@ -771,7 +772,8 @@ sighandler_portable_t sysv_signal_portable(int portable_signum, sighandler_porta * or * the sysv_signal() signal handler. */ -sighandler_portable_t bsd_signal_portable(int portable_signum, sighandler_portable_t handler) + +sighandler_portable_t WRAP(bsd_signal)(int portable_signum, sighandler_portable_t handler) { sighandler_portable_t rv; @@ -812,46 +814,48 @@ static int do_kill(int id, int portable_signum, int (*fn)(int, int)) } -int killpg_portable(int pgrp, int portable_signum) +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, killpg); + rv = do_kill(pgrp, portable_signum, REAL(killpg)); ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; } -int kill_portable(pid_t pid, int portable_signum) +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, kill); + rv = do_kill(pid, portable_signum, REAL(kill)); ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; } -int tkill_portable(int tid, int portable_signum) +int WRAP(tkill)(int tid, int portable_signum) { - extern int tkill(int, int); + extern int REAL(tkill)(int, int); int rv; ALOGV(" "); ALOGV("%s(tid:%d, portable_signum:%d) {", __func__, tid, portable_signum); - rv = do_kill(tid, portable_signum, tkill); + rv = do_kill(tid, portable_signum, REAL(tkill)); ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; @@ -860,7 +864,7 @@ int tkill_portable(int tid, int portable_signum) /* tgkill is not exported from android-14 libc.so */ #if 0 -int tgkill_portable(int tgid, int tid, int portable_signum) +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); @@ -875,7 +879,7 @@ int tgkill_portable(int tgid, int tid, int portable_signum) if ((portable_signum != 0) && (mips_signum == 0)) rv = 0; else - rv = tgkill(tgid, tid, mips_signum); + rv = REAL(tgkill)(tgid, tid, mips_signum); ALOGV("%s: return rv:%d; }", __func__, rv); return rv; @@ -883,7 +887,7 @@ int tgkill_portable(int tgid, int tid, int portable_signum) #endif -int raise_portable(int portable_signum) +int WRAP(raise)(int portable_signum) { char *portable_signame = map_portable_signum_to_name(portable_signum); int mips_signum = signum_pton(portable_signum); @@ -894,7 +898,7 @@ int raise_portable(int portable_signum) if ((portable_signum != 0) && (mips_signum == 0)) rv = 0; else - rv = raise(mips_signum); + rv = REAL(raise)(mips_signum); ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; @@ -919,7 +923,7 @@ void sigset_pton(sigset_portable_t *portable_sigset, sigset_t *mips_sigset) for(portable_signum = 1; portable_signum <= NSIG_PORTABLE; portable_signum++) { - if (sigismember_portable(portable_sigset, 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; @@ -962,14 +966,14 @@ sigset_ntop(const sigset_t *const_mips_sigset, sigset_portable_t *portable_sigse portable_sigset); goto done; } - sigemptyset_portable(portable_sigset); + 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) - sigaddset_portable(portable_sigset, portable_signum); + WRAP(sigaddset)(portable_sigset, portable_signum); } } @@ -1172,7 +1176,7 @@ static int do_sigaction_portable(int portable_signum, const struct sigaction_por mips_oldact.sa_sigaction == (__sigaction_handler_portable_t) mips_sighandler) { oldact->sa_sigaction_portable = - (__sigaction_handler_portable_t) prev_portable_handler; + (__sigaction_handler_portable_t) prev_portable_handler; } else { oldact->sa_sigaction_portable = (__sigaction_handler_portable_t) mips_oldact.sa_sigaction; @@ -1190,16 +1194,17 @@ done: } -int sigaction_portable(int portable_signum, const struct sigaction_portable *act, +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, sigaction, NULL); + rv = do_sigaction_portable(portable_signum, act, oldact, REAL(sigaction), NULL); ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; @@ -1261,7 +1266,7 @@ __hidden int do_signalfd4_portable(int fd, const sigset_portable_t *portable_sig * 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 signalfd_portable(int fd, const sigset_portable_t *portable_sigmask, int portable_flags) +int WRAP(signalfd)(int fd, const sigset_portable_t *portable_sigmask, int portable_flags) { int portable_sigsetsize = sizeof(sigset_portable_t); int rv; @@ -1325,7 +1330,7 @@ __hidden int read_signalfd_mapper(int fd, void *buf, size_t count) } -int sigsuspend_portable(const sigset_portable_t *portable_sigmask) +int WRAP(sigsuspend)(const sigset_portable_t *portable_sigmask) { int rv; sigset_t mips_sigmask; @@ -1337,7 +1342,7 @@ int sigsuspend_portable(const sigset_portable_t *portable_sigmask) rv = -1; } else { sigset_pton((sigset_portable_t *)portable_sigmask, &mips_sigmask); - rv = sigsuspend(&mips_sigmask); + rv = REAL(sigsuspend)(&mips_sigmask); } ALOGV("%s: return(rv:%d); }", __func__, rv); @@ -1345,7 +1350,7 @@ int sigsuspend_portable(const sigset_portable_t *portable_sigmask) } -int sigpending_portable(sigset_portable_t *portable_sigset) +int WRAP(sigpending)(sigset_portable_t *portable_sigset) { int rv; sigset_t mips_sigset; @@ -1357,7 +1362,7 @@ int sigpending_portable(sigset_portable_t *portable_sigset) errno = EFAULT; rv = -1; } else { - rv = sigpending(&mips_sigset); + rv = REAL(sigpending)(&mips_sigset); sigset_ntop(&mips_sigset, portable_sigset); } @@ -1366,7 +1371,7 @@ int sigpending_portable(sigset_portable_t *portable_sigset) } -int sigwait_portable(const sigset_portable_t *portable_sigset, int *ptr_to_portable_sig) +int WRAP(sigwait)(const sigset_portable_t *portable_sigset, int *ptr_to_portable_sig) { int rv; sigset_t mips_sigset; @@ -1382,7 +1387,7 @@ int sigwait_portable(const sigset_portable_t *portable_sigset, int *ptr_to_porta } else { sigset_pton((sigset_portable_t *)portable_sigset, &mips_sigset); - rv = sigwait(&mips_sigset, &mips_sig); + rv = REAL(sigwait)(&mips_sigset, &mips_sig); portable_sig = signum_ntop(mips_sig); *ptr_to_portable_sig = portable_sig; @@ -1392,7 +1397,7 @@ int sigwait_portable(const sigset_portable_t *portable_sigset, int *ptr_to_porta } -int siginterrupt_portable(int portable_signum, int flag) +int WRAP(siginterrupt)(int portable_signum, int flag) { int rv; @@ -1408,7 +1413,7 @@ int siginterrupt_portable(int portable_signum, int flag) portable_signum); rv = 0; } else { - rv = siginterrupt(mips_signum, flag); + rv = REAL(siginterrupt)(mips_signum, flag); } ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; @@ -1474,26 +1479,27 @@ __hidden int do_sigmask(int portable_how, const sigset_portable_t *portable_sigs } -int sigprocmask_portable(int portable_how, const sigset_portable_t *portable_sigset, +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, sigprocmask, NULL); + rv = do_sigmask(portable_how, portable_sigset, portable_oldset, REAL(sigprocmask), NULL); ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; } -int __rt_sigaction_portable(int portable_signum, const struct sigaction_portable *act, +int WRAP(__rt_sigaction)(int portable_signum, const struct sigaction_portable *act, struct sigaction_portable *oldact, size_t sigsetsize) { - extern int __rt_sigaction(int , const struct sigaction *, struct sigaction *, size_t); + extern int REAL(__rt_sigaction)(int , const struct sigaction *, struct sigaction *, size_t); int rv; ALOGV(" "); @@ -1506,19 +1512,19 @@ int __rt_sigaction_portable(int portable_signum, const struct sigaction_portable rv = -1; goto done; } - rv = do_sigaction_portable(portable_signum, act, oldact, NULL, __rt_sigaction); + rv = do_sigaction_portable(portable_signum, act, oldact, NULL, REAL(__rt_sigaction)); done: ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; } -int __rt_sigprocmask_portable(int portable_how, +int WRAP(__rt_sigprocmask)(int portable_how, const sigset_portable_t *portable_sigset, sigset_portable_t *portable_oldset, size_t sigsetsize) { - extern int __rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t); + extern int REAL(__rt_sigprocmask)(int, const sigset_t *, sigset_t *, size_t); int rv; ALOGV(" "); @@ -1531,7 +1537,7 @@ int __rt_sigprocmask_portable(int portable_how, rv = -1; goto done; } - rv = do_sigmask(portable_how, portable_sigset, portable_oldset, NULL, __rt_sigprocmask); + rv = do_sigmask(portable_how, portable_sigset, portable_oldset, NULL, REAL(__rt_sigprocmask)); done: ALOGV("%s: return(rv:%d); }", __func__, rv); @@ -1540,12 +1546,12 @@ int __rt_sigprocmask_portable(int portable_how, } -int __rt_sigtimedwait_portable(const sigset_portable_t *portable_sigset, +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 __rt_sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *, size_t); + 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; @@ -1573,7 +1579,7 @@ int __rt_sigtimedwait_portable(const sigset_portable_t *portable_sigset, } else { native_siginfo = &native_siginfo_struct; } - rv = __rt_sigtimedwait(native_sigset, native_siginfo, timeout, sizeof(sigset_t)); + 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); @@ -1604,7 +1610,7 @@ done: * * sigqueue() must return EAGAIN if exceeded and we don't on Android. */ -int sigqueue_portable(pid_t pid, int portable_sig, const union sigval value) +int WRAP(sigqueue)(pid_t pid, int portable_sig, const union sigval value) { siginfo_t native_siginfo; siginfo_t *native_sip; @@ -1646,7 +1652,7 @@ int sigqueue_portable(pid_t pid, int portable_sig, const union sigval value) /* * Real Time version of sigqueueinfo(). */ -int rt_sigqueueinfo_portable(pid_t pid, int portable_sig, siginfo_portable_t *portable_sip) +int WRAP(rt_sigqueueinfo)(pid_t pid, int portable_sig, siginfo_portable_t *portable_sip) { int native_sig; siginfo_t native_siginfo, *native_sip; @@ -1676,7 +1682,7 @@ int rt_sigqueueinfo_portable(pid_t pid, int portable_sig, siginfo_portable_t *po /* * Thread Group flavor of the real time version of sigqueueinfo(). */ -int rt_tgsigqueueinfo_portable(pid_t tgid, pid_t pid, int portable_sig, +int WRAP(rt_tgsigqueueinfo)(pid_t tgid, pid_t pid, int portable_sig, siginfo_portable_t *portable_sip) { siginfo_t native_siginfo, *native_sip; @@ -1715,7 +1721,7 @@ int rt_tgsigqueueinfo_portable(pid_t tgid, pid_t pid, int portable_sig, * } stack_t; * */ -int sigaltstack_portable(const portable_stack_t *ss, portable_stack_t *oss) +int WRAP(sigaltstack)(const portable_stack_t *ss, portable_stack_t *oss) { int rv; stack_t new_stack, *mips_ss; @@ -1754,7 +1760,7 @@ int sigaltstack_portable(const portable_stack_t *ss, portable_stack_t *oss) } } - rv = sigaltstack(mips_ss, mips_oss); + rv = REAL(sigaltstack)(mips_ss, mips_oss); if (!invalid_pointer(oss)) { oss->ss_sp = old_stack.ss_sp; diff --git a/ndk/sources/android/libportable/arch-mips/sigsetjmp.S b/ndk/sources/android/libportable/arch-mips/sigsetjmp.S index fa6aba9ed..237d46b50 100644 --- a/ndk/sources/android/libportable/arch-mips/sigsetjmp.S +++ b/ndk/sources/android/libportable/arch-mips/sigsetjmp.S @@ -31,6 +31,7 @@ * SUCH DAMAGE. */ +#include #include #include @@ -42,7 +43,7 @@ FRAMESZ= MKFSIZ(1,1) GPOFF= FRAMESZ-2*REGSZ -LEAF(sigsetjmp_portable, FRAMESZ) +LEAF(WRAP(sigsetjmp), FRAMESZ) PTR_SUBU sp, FRAMESZ SETUP_GP64(GPOFF, sigsetjmp) .set reorder @@ -53,15 +54,15 @@ LEAF(sigsetjmp_portable, FRAMESZ) PTR_ADDU sp, FRAMESZ jr t9 -1: LA t9, setjmp_portable +1: LA t9, WRAP(setjmp) RESTORE_GP64 PTR_ADDU sp, FRAMESZ jr t9 -END(sigsetjmp_portable) +END(WRAP(sigsetjmp)) -LEAF(siglongjmp_portable, FRAMESZ) +LEAF(WRAP(siglongjmp), FRAMESZ) PTR_SUBU sp, FRAMESZ - SETUP_GP64(GPOFF, siglongjmp_portable) + SETUP_GP64(GPOFF, WRAP(siglongjmp)) .set reorder REG_L t0, JB_SAVEMASK(a0) # get "savemask" bne t0, 0x0, 1f # restore signal mask? @@ -70,8 +71,8 @@ LEAF(siglongjmp_portable, FRAMESZ) PTR_ADDU sp, FRAMESZ jr t9 1: - LA t9, longjmp_portable + LA t9, WRAP(longjmp) RESTORE_GP64 PTR_ADDU sp, FRAMESZ jr t9 -END(siglongjmp_portable) +END(WRAP(siglongjmp)) diff --git a/ndk/sources/android/libportable/arch-mips/socket.c b/ndk/sources/android/libportable/arch-mips/socket.c index 32a31575c..be2c7e6ed 100644 --- a/ndk/sources/android/libportable/arch-mips/socket.c +++ b/ndk/sources/android/libportable/arch-mips/socket.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -127,30 +128,30 @@ static inline int socktype_ntop(int native_type) } -extern int socket(int, int, int); +extern int REAL(socket)(int, int, int); -int socket_portable(int domain, int type, int protocol) { +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 = socket(domain, socktype_pton(type), protocol); + rv = REAL(socket)(domain, socktype_pton(type), protocol); ALOGV("%s: return(rv:%d); }", __func__, rv); return rv; } -int socketpair_portable(int domain, int type, int protocol, int sv[2]) { +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 = socketpair(domain, socktype_pton(type), protocol, sv); + rv = REAL(socketpair)(domain, socktype_pton(type), protocol, sv); if ((rv != 0) || invalid_pointer(sv)) { ALOGV("%s: return(rv:%d); }", __func__, @@ -175,7 +176,7 @@ int socketpair_portable(int domain, int type, int protocol, int sv[2]) { * later made free with a call to the portable version of * freeaddrinfo(); which is written below this function. */ -int getaddrinfo_portable(const char *node, const char *service, +int WRAP(getaddrinfo)(const char *node, const char *service, struct addrinfo_portable *portable_hints, struct addrinfo_portable **portable_results) { @@ -203,7 +204,7 @@ int getaddrinfo_portable(const char *node, const char *service, ASSERT(portable_results != NULL); native_results = (struct addrinfo **) portable_results; - rv = getaddrinfo(node, service, native_hints, native_results); + rv = REAL(getaddrinfo)(node, service, native_hints, native_results); if (native_hints != NULL) { portable_hints->ai_socktype = saved_portable_socktype; @@ -230,7 +231,7 @@ int getaddrinfo_portable(const char *node, const char *service, * Free the results list returned from a previous call * to the portable version of getaddrinfo(). */ -void freeaddrinfo_portable(struct addrinfo_portable *portable_results) +void WRAP(freeaddrinfo)(struct addrinfo_portable *portable_results) { struct addrinfo *native_results, *rp; @@ -253,7 +254,7 @@ void freeaddrinfo_portable(struct addrinfo_portable *portable_results) PRINT_ADDRINFO(rp); rp->ai_socktype = socktype_pton(rp->ai_socktype); /* Likely not really necessary */ } - freeaddrinfo(native_results); + 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 index 6435cdce5..6c7ec51a8 100644 --- a/ndk/sources/android/libportable/arch-mips/sockopt.c +++ b/ndk/sources/android/libportable/arch-mips/sockopt.c @@ -14,11 +14,11 @@ * limitations under the License. */ +#include #include #include #include - #if SOL_SOCKET_PORTABLE==SOL_SOCKET #error Build environment #endif @@ -108,13 +108,13 @@ static inline int mips_change_optname(int optname) } extern int setsockopt(int, int, int, const void *, socklen_t); -int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen) +int WRAP(setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen) { - return setsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, 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 getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen) +int WRAP(getsockopt)(int s, int level, int optname, void *optval, socklen_t *optlen) { - return getsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, 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 f8322c185..06fb42df9 100644 --- a/ndk/sources/android/libportable/arch-mips/stat.c +++ b/ndk/sources/android/libportable/arch-mips/stat.c @@ -14,13 +14,12 @@ * limitations under the License. */ +#include #include #include -#include - /* Note: The Portable Header will define stat to stat_portable */ -int stat_portable(const char *path, struct stat_portable *s) +int WRAP(stat)(const char *path, struct stat_portable *s) { struct stat mips_stat; int ret; @@ -29,12 +28,12 @@ int stat_portable(const char *path, struct stat_portable *s) errno = EFAULT; return -1; } - ret = stat(path, &mips_stat); + ret = REAL(stat)(path, &mips_stat); stat_ntop(&mips_stat, s); return ret; } -int fstat_portable(int fd, struct stat_portable *s) +int WRAP(fstat)(int fd, struct stat_portable *s) { struct stat mips_stat; int ret; @@ -43,12 +42,12 @@ int fstat_portable(int fd, struct stat_portable *s) errno = EFAULT; return -1; } - ret = fstat(fd, &mips_stat); + ret = REAL(fstat)(fd, &mips_stat); stat_ntop(&mips_stat, s); return ret; } -int lstat_portable(const char *path, struct stat_portable *s) +int WRAP(lstat)(const char *path, struct stat_portable *s) { struct stat mips_stat; int ret; @@ -57,12 +56,12 @@ int lstat_portable(const char *path, struct stat_portable *s) errno = EFAULT; return -1; } - ret = lstat(path, &mips_stat); + ret = REAL(lstat)(path, &mips_stat); stat_ntop(&mips_stat, s); return ret; } -int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags) +int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags) { struct stat mips_stat; int ret; @@ -71,7 +70,7 @@ int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int f errno = EFAULT; return -1; } - ret = fstatat(dirfd, path, &mips_stat, flags); + 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 index 33ed1c66a..6c0e079f3 100644 --- a/ndk/sources/android/libportable/arch-mips/statfs.c +++ b/ndk/sources/android/libportable/arch-mips/statfs.c @@ -14,12 +14,11 @@ * 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)); @@ -35,7 +34,7 @@ static inline void statfs_ntop(struct statfs *n_statfs, struct statfs_portable * p_statfs->f_frsize = n_statfs->f_frsize; } -int statfs_portable(const char* path, struct statfs_portable* stat) +int WRAP(statfs)(const char* path, struct statfs_portable* stat) { struct statfs mips_stat; int ret; @@ -44,12 +43,12 @@ int statfs_portable(const char* path, struct statfs_portable* stat) errno = EFAULT; return -1; } - ret = statfs(path, &mips_stat); + ret = REAL(statfs)(path, &mips_stat); statfs_ntop(&mips_stat, stat); return ret; } -int fstatfs_portable(int fd, struct statfs_portable* stat) +int WRAP(fstatfs)(int fd, struct statfs_portable* stat) { struct statfs mips_stat; int ret; @@ -58,7 +57,7 @@ int fstatfs_portable(int fd, struct statfs_portable* stat) errno = EFAULT; return -1; } - ret = fstatfs(fd, &mips_stat); + 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 index aa145b9b7..39d15d90f 100644 --- a/ndk/sources/android/libportable/arch-mips/syscall.c +++ b/ndk/sources/android/libportable/arch-mips/syscall.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -48,11 +49,11 @@ */ -extern int syscall(int, ...); +extern int REAL(syscall)(int, ...); #define MAXARGS 8 -int syscall_portable(int portable_number, ...) +int WRAP(syscall)(int portable_number, ...) { va_list ap; int native_number, ret; @@ -126,7 +127,7 @@ int syscall_portable(int portable_number, ...) va_end(ap); - ret = eventfd_portable(initval, flags); /* Android uses __NR_eventfd2 in eventfd() */ + ret = WRAP(eventfd)(initval, flags); /* Android uses __NR_eventfd2 in eventfd() */ goto done; } #endif @@ -148,7 +149,7 @@ int syscall_portable(int portable_number, ...) va_end(ap); - ret = eventfd_portable(initval, flags); /* Android uses __NR_eventfd2 in eventfd() */ + ret = WRAP(eventfd)(initval, flags); /* Android uses __NR_eventfd2 in eventfd() */ goto done; } #endif @@ -229,7 +230,7 @@ int syscall_portable(int portable_number, ...) portable_flags = va_arg(ap, int); va_end(ap); - ret = inotify_init1_portable(portable_flags); + ret = WRAP(inotify_init1)(portable_flags); goto done; } #endif @@ -268,7 +269,7 @@ int syscall_portable(int portable_number, ...) portable_flags = va_arg(ap, int); va_end(ap); - ret = pipe2_portable(pipefd_ptr, portable_flags); + ret = WRAP(pipe2)(pipefd_ptr, portable_flags); goto done; } #endif @@ -298,7 +299,7 @@ int syscall_portable(int portable_number, ...) oact = va_arg(ap, struct sigaction_portable *); sigsetsize = va_arg(ap, size_t); va_end(ap); - return __rt_sigaction_portable(sig, act, oact, sigsetsize); + return WRAP(__rt_sigaction)(sig, act, oact, sigsetsize); } #endif @@ -316,7 +317,7 @@ int syscall_portable(int portable_number, ...) sigsetsize = va_arg(ap, size_t); va_end(ap); - ret = __rt_sigprocmask_portable(how, set, oset, sigsetsize); + ret = WRAP(__rt_sigprocmask)(how, set, oset, sigsetsize); goto done; } #endif @@ -335,7 +336,7 @@ int syscall_portable(int portable_number, ...) sigsetsize = va_arg(ap, size_t); va_end(ap); - ret = __rt_sigtimedwait_portable(set, info, timeout, sigsetsize); + ret = WRAP(__rt_sigtimedwait)(set, info, timeout, sigsetsize); goto done; } #endif @@ -352,7 +353,7 @@ int syscall_portable(int portable_number, ...) uinfo = va_arg(ap, siginfo_portable_t *); va_end(ap); - ret = rt_sigqueueinfo_portable(pid, sig, uinfo); + ret = WRAP(rt_sigqueueinfo)(pid, sig, uinfo); goto done; } #endif @@ -465,7 +466,7 @@ int syscall_portable(int portable_number, ...) native_number, fd, align_fill, offset_low, offset_high, nbytes_low, nbytes_high, flags); - ret = syscall(native_number, fd, align_fill, offset_low, offset_high, + ret = REAL(syscall)(native_number, fd, align_fill, offset_low, offset_high, nbytes_low, nbytes_high, flags); goto done; @@ -501,7 +502,7 @@ int syscall_portable(int portable_number, ...) timerid = va_arg(ap, timer_t *); va_end(ap); - ret = timer_create_portable(clockid, evp, timerid); + ret = WRAP(timer_create)(clockid, evp, timerid); goto done; } #endif @@ -516,7 +517,7 @@ int syscall_portable(int portable_number, ...) flags = va_arg(ap, int); /* flags need to be mapped */ va_end(ap); - ret = timerfd_create_portable(clockid, flags); + ret = WRAP(timerfd_create)(clockid, flags); goto done; } #endif @@ -555,7 +556,7 @@ int syscall_portable(int portable_number, ...) uinfo = va_arg(ap, siginfo_portable_t *); va_end(ap); - ret = rt_tgsigqueueinfo_portable(tgid, pid, sig, uinfo); + ret = WRAP(rt_tgsigqueueinfo)(tgid, pid, sig, uinfo); goto done; } #endif @@ -569,7 +570,7 @@ int syscall_portable(int portable_number, ...) sig = va_arg(ap, int); va_end(ap); - ret = tkill_portable(tid, sig); + ret = WRAP(tkill)(tid, sig); goto done; } #endif @@ -627,7 +628,7 @@ int syscall_portable(int portable_number, ...) native_number, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); - ret = syscall(native_number, args[0], args[1], args[2], args[3], + ret = REAL(syscall)(native_number, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); done: diff --git a/ndk/sources/android/libportable/arch-mips/timer.c b/ndk/sources/android/libportable/arch-mips/timer.c index 037a52459..c2844e1b3 100644 --- a/ndk/sources/android/libportable/arch-mips/timer.c +++ b/ndk/sources/android/libportable/arch-mips/timer.c @@ -14,13 +14,12 @@ * limitations under the License. */ +#include #include #include #include -#include - -int timer_create_portable(clockid_t clockid, struct sigevent *portable_evp, +int WRAP(timer_create)(clockid_t clockid, struct sigevent *portable_evp, timer_t *timerid) { struct sigevent native_sigevent, *evp = portable_evp; @@ -33,5 +32,5 @@ int timer_create_portable(clockid_t clockid, struct sigevent *portable_evp, evp = &native_sigevent; evp->sigev_signo = signum_pton(evp->sigev_signo); } - return timer_create(clockid, evp, timerid); + 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 index 3196d185b..b57c3f277 100644 --- a/ndk/sources/android/libportable/arch-mips/timerfd.c +++ b/ndk/sources/android/libportable/arch-mips/timerfd.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -57,7 +58,7 @@ static inline int tdf_flags_pton(int portable_flags) } -int timerfd_create_portable(int clockid, int portable_flags) { +int WRAP(timerfd_create)(int clockid, int portable_flags) { int rv; int native_flags; @@ -67,7 +68,7 @@ int timerfd_create_portable(int clockid, int portable_flags) { native_flags = tdf_flags_pton(portable_flags); - rv = syscall(__NR_timerfd_create, clockid, native_flags); + rv = REAL(syscall)(__NR_timerfd_create, clockid, native_flags); if (rv >= 0) { if (native_flags & TFD_CLOEXEC) { filefd_CLOEXEC_enabled(rv); diff --git a/ndk/sources/android/libportable/arch-mips/waitpid.c b/ndk/sources/android/libportable/arch-mips/waitpid.c index ae7a9b928..77e628387 100644 --- a/ndk/sources/android/libportable/arch-mips/waitpid.c +++ b/ndk/sources/android/libportable/arch-mips/waitpid.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -24,11 +25,11 @@ #define PORTABLE_TAG "waitpid_portable" #include -pid_t waitpid_portable(pid_t pid, int *status, int options) +pid_t WRAP(waitpid)(pid_t pid, int *status, int options) { pid_t ret; - ret = waitpid(pid, status, options); + ret = REAL(waitpid)(pid, status, options); if (status && ret > 0) { /* * Status layout is identical, so just the signal diff --git a/ndk/sources/android/libportable/arch-x86/epoll.c b/ndk/sources/android/libportable/arch-x86/epoll.c index e2f91f29f..c68344133 100644 --- a/ndk/sources/android/libportable/arch-x86/epoll.c +++ b/ndk/sources/android/libportable/arch-x86/epoll.c @@ -14,23 +14,24 @@ * limitations under the License. */ +#include #include #include -int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event_portable *event) +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 epoll_ctl(epfd, op, fd, &x86_epoll_event); + return REAL(epoll_ctl)(epfd, op, fd, &x86_epoll_event); } -int epoll_wait_portable(int epfd, struct epoll_event_portable *events, int max, int timeout) +int WRAP(epoll_wait)(int epfd, struct epoll_event_portable *events, int max, int timeout) { struct epoll_event x86_epoll_event; - int ret = epoll_wait(epfd, &x86_epoll_event, max, timeout); + int ret = REAL(epoll_wait)(epfd, &x86_epoll_event, max, timeout); events->events = x86_epoll_event.events; events->data = x86_epoll_event.data; diff --git a/ndk/sources/android/libportable/arch-x86/errno.c b/ndk/sources/android/libportable/arch-x86/errno.c index ffa599892..776b12edc 100644 --- a/ndk/sources/android/libportable/arch-x86/errno.c +++ b/ndk/sources/android/libportable/arch-x86/errno.c @@ -14,8 +14,10 @@ * limitations under the License. */ -extern volatile int* __errno(void); -volatile int* __errno_portable() +#include + +extern volatile int* REAL(__errno)(void); +volatile int* WRAP(__errno)() { - return __errno(); + return REAL(__errno)(); } diff --git a/ndk/sources/android/libportable/arch-x86/fcntl.c b/ndk/sources/android/libportable/arch-x86/fcntl.c index 7561f8546..74b14c12b 100644 --- a/ndk/sources/android/libportable/arch-x86/fcntl.c +++ b/ndk/sources/android/libportable/arch-x86/fcntl.c @@ -14,13 +14,14 @@ * limitations under the License. */ +#include #include #include #include extern int __fcntl64(int, int, void *); -int fcntl_portable(int fd, int cmd, ...) +int WRAP(fcntl)(int fd, int cmd, ...) { va_list ap; void * arg; diff --git a/ndk/sources/android/libportable/arch-x86/ioctl.c b/ndk/sources/android/libportable/arch-x86/ioctl.c index ea88c3099..01ddbcd50 100644 --- a/ndk/sources/android/libportable/arch-x86/ioctl.c +++ b/ndk/sources/android/libportable/arch-x86/ioctl.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -31,7 +32,7 @@ static inline int x86_change_request(int request) } extern int __ioctl(int, int, void *); -int ioctl_portable(int fd, int request, ...) +int WRAP(ioctl)(int fd, int request, ...) { va_list ap; void * arg; diff --git a/ndk/sources/android/libportable/arch-x86/open.c b/ndk/sources/android/libportable/arch-x86/open.c index a38f38c3d..dae578b3f 100644 --- a/ndk/sources/android/libportable/arch-x86/open.c +++ b/ndk/sources/android/libportable/arch-x86/open.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -56,7 +57,7 @@ static inline int x86_change_flags(int flags) } extern int __open(const char*, int, int); -int open_portable(const char *pathname, int flags, ...) +int WRAP(open)(const char *pathname, int flags, ...) { mode_t mode = 0; flags |= O_LARGEFILE; diff --git a/ndk/sources/android/libportable/arch-x86/socket.c b/ndk/sources/android/libportable/arch-x86/socket.c index 7e7ca9b38..72211c94b 100644 --- a/ndk/sources/android/libportable/arch-x86/socket.c +++ b/ndk/sources/android/libportable/arch-x86/socket.c @@ -14,10 +14,11 @@ * limitations under the License. */ +#include #include #include #include -int socket_portable(int domain, int type, int protocol) { - return socket(domain, type, protocol); +int WRAP(socket)(int domain, int type, int protocol) { + return REAL(socket)(domain, type, protocol); } diff --git a/ndk/sources/android/libportable/arch-x86/sockopt.c b/ndk/sources/android/libportable/arch-x86/sockopt.c index c86ded328..87d8b2fdc 100644 --- a/ndk/sources/android/libportable/arch-x86/sockopt.c +++ b/ndk/sources/android/libportable/arch-x86/sockopt.c @@ -14,17 +14,18 @@ * limitations under the License. */ +#include #include #include -extern int setsockopt(int, int, int, const void *, socklen_t); -int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen) +extern int REAL(setsockopt)(int, int, int, const void *, socklen_t); +int WRAP(setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen) { - return setsockopt(s, level, optname, optval, optlen); + return REAL(setsockopt)(s, level, optname, optval, optlen); } -extern int getsockopt (int, int, int, void *, socklen_t *); -int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen) +extern int REAL(getsockopt)(int, int, int, void *, socklen_t *); +int WRAP(getsockopt)(int s, int level, int optname, void *optval, socklen_t *optlen) { - return getsockopt(s, level, optname, optval, optlen); + return REAL(getsockopt)(s, level, optname, optval, optlen); } diff --git a/ndk/sources/android/libportable/arch-x86/stat.c b/ndk/sources/android/libportable/arch-x86/stat.c index 6b368c8db..1d1737838 100644 --- a/ndk/sources/android/libportable/arch-x86/stat.c +++ b/ndk/sources/android/libportable/arch-x86/stat.c @@ -14,37 +14,38 @@ * limitations under the License. */ +#include #include /* Note: The Portable Header will define stat to stat_portable */ -int stat_portable(const char *path, struct stat_portable *s) +int WRAP(stat)(const char *path, struct stat_portable *s) { struct stat x86_stat; - int ret = stat(path, &x86_stat); + int ret = REAL(stat)(path, &x86_stat); stat_ntop(&x86_stat, s); return ret; } -int fstat_portable(int fd, struct stat_portable *s) +int WRAP(fstat)(int fd, struct stat_portable *s) { struct stat x86_stat; - int ret = fstat(fd, &x86_stat); + int ret = REAL(fstat)(fd, &x86_stat); stat_ntop(&x86_stat, s); return ret; } -int lstat_portable(const char *path, struct stat_portable *s) +int WRAP(lstat)(const char *path, struct stat_portable *s) { struct stat x86_stat; - int ret = lstat(path, &x86_stat); + int ret = REAL(lstat)(path, &x86_stat); stat_ntop(&x86_stat, s); return ret; } -int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags) +int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags) { struct stat x86_stat; - int ret = fstatat(dirfd, path, &x86_stat, flags); + int ret = REAL(fstatat)(dirfd, path, &x86_stat, flags); stat_ntop(&x86_stat, s); return ret; } diff --git a/ndk/sources/android/libportable/common/include/asm-generic/portability.h b/ndk/sources/android/libportable/common/include/asm-generic/portability.h new file mode 100644 index 000000000..8d91854fe --- /dev/null +++ b/ndk/sources/android/libportable/common/include/asm-generic/portability.h @@ -0,0 +1,31 @@ +/* + * 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 resolve symbol symbol to __wrap_symbol, + * and __real_symbol refer to the original symbol + */ +#define WRAP(f) __wrap_ ## f +#define REAL(f) __real_ ## f +#endif + +#endif /* _ASM_PORTABILITY_H_ */ diff --git a/ndk/sources/android/libportable/common/include/eventfd_portable.h b/ndk/sources/android/libportable/common/include/eventfd_portable.h index 7572fc56a..d72ca8dd3 100644 --- a/ndk/sources/android/libportable/common/include/eventfd_portable.h +++ b/ndk/sources/android/libportable/common/include/eventfd_portable.h @@ -30,8 +30,8 @@ #ifndef _SYS_EVENTFD_PORTABLE_H #define _SYS_EVENTFD_PORTABLE_H -#include #include +#include #include __BEGIN_DECLS @@ -50,7 +50,7 @@ __BEGIN_DECLS /* type of event counter */ typedef uint64_t eventfd_portable_t; -extern int eventfd_portable(unsigned int initval, int flags); +extern int WRAP(eventfd)(unsigned int initval, int flags); #if 0 /* Compatibility with GLibc; libportable versions don't appear to be necessary */ diff --git a/ndk/sources/android/libportable/common/include/filefd_portable.h b/ndk/sources/android/libportable/common/include/filefd_portable.h index 10c7b566f..76cd4b849 100644 --- a/ndk/sources/android/libportable/common/include/filefd_portable.h +++ b/ndk/sources/android/libportable/common/include/filefd_portable.h @@ -37,8 +37,8 @@ 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 close_portable(int fd); -extern int read_portable(int fd, void *buf, size_t count); -extern int pipe2_portable(int pipefd[2], int portable_flags); +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 index 2f080479f..09d4d6400 100644 --- a/ndk/sources/android/libportable/common/include/inotify_portable.h +++ b/ndk/sources/android/libportable/common/include/inotify_portable.h @@ -31,8 +31,8 @@ #ifndef _SYS_INOTIFY_PORTABLE_H #define _SYS_INOTIFY_PORTABLE_H -#include #include +#include #include #include @@ -44,7 +44,7 @@ __BEGIN_DECLS #define IN_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE #define IN_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE -extern int inotify_init1_portable(int flags); +extern int WRAP(inotify_init1)(int flags); __END_DECLS diff --git a/ndk/sources/android/libportable/common/include/log_portable.h b/ndk/sources/android/libportable/common/include/log_portable.h index 27f521e62..79baa62d6 100644 --- a/ndk/sources/android/libportable/common/include/log_portable.h +++ b/ndk/sources/android/libportable/common/include/log_portable.h @@ -81,7 +81,7 @@ static inline char *portable_tag() { _rv; /* Returned to caller */ \ }) -#if !defined(HAS_NO_LOG_H) +#if !defined(__HOST__) #include # define PERROR(str) { \ @@ -91,8 +91,11 @@ static inline char *portable_tag() { # 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, errno, strerror(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/netdb_portable.h b/ndk/sources/android/libportable/common/include/netdb_portable.h index 53db942e9..b3e652868 100644 --- a/ndk/sources/android/libportable/common/include/netdb_portable.h +++ b/ndk/sources/android/libportable/common/include/netdb_portable.h @@ -232,10 +232,10 @@ void herror(const char *); const char *hstrerror(int); #endif -int getaddrinfo_portable(const char *, const char *, struct addrinfo_portable *, +int WRAP(getaddrinfo)(const char *, const char *, struct addrinfo_portable *, struct addrinfo_portable **); -void freeaddrinfo_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); diff --git a/ndk/sources/android/libportable/common/include/portability.h b/ndk/sources/android/libportable/common/include/portability.h index 4293d9d54..54f140618 100644 --- a/ndk/sources/android/libportable/common/include/portability.h +++ b/ndk/sources/android/libportable/common/include/portability.h @@ -17,6 +17,7 @@ #ifndef _PORTABILITY_H_ #define _PORTABILITY_H_ +#include "asm-generic/portability.h" /* * Common portability helper routines */ @@ -31,7 +32,7 @@ */ inline static int invalid_pointer(void *p) { - return p == NULL + return p == 0 || p == (void *)-1 #ifdef __mips__ || (int)p < 0 diff --git a/ndk/sources/android/libportable/common/include/signal_portable.h b/ndk/sources/android/libportable/common/include/signal_portable.h index abb99873d..3ea8de1a6 100644 --- a/ndk/sources/android/libportable/common/include/signal_portable.h +++ b/ndk/sources/android/libportable/common/include/signal_portable.h @@ -64,7 +64,7 @@ typedef int sig_atomic_t; extern const char * const sys_siglist[]; extern const char * const sys_signame[]; -static __inline__ int sigismember_portable(sigset_portable_t *set, int signum) +static __inline__ int WRAP(sigismember)(sigset_portable_t *set, int signum) { unsigned long *local_set = (unsigned long *)set; signum--; @@ -72,7 +72,7 @@ static __inline__ int sigismember_portable(sigset_portable_t *set, int signum) } -static __inline__ int sigaddset_portable(sigset_portable_t *set, int signum) +static __inline__ int WRAP(sigaddset)(sigset_portable_t *set, int signum) { unsigned long *local_set = (unsigned long *)set; signum--; @@ -81,7 +81,7 @@ static __inline__ int sigaddset_portable(sigset_portable_t *set, int signum) } -static __inline__ int sigdelset_portable(sigset_portable_t *set, int signum) +static __inline__ int WRAP(sigdelset)(sigset_portable_t *set, int signum) { unsigned long *local_set = (unsigned long *)set; signum--; @@ -90,13 +90,13 @@ static __inline__ int sigdelset_portable(sigset_portable_t *set, int signum) } -static __inline__ int sigemptyset_portable(sigset_portable_t *set) +static __inline__ int WRAP(sigemptyset)(sigset_portable_t *set) { memset(set, 0, sizeof *set); return 0; } -static __inline__ int sigfillset_portable(sigset_portable_t *set) +static __inline__ int WRAP(sigfillset)(sigset_portable_t *set) { memset(set, ~0, sizeof *set); return 0; @@ -116,34 +116,34 @@ extern __sighandler_t bsd_signal(int, __sighandler_portable_t); #if 0 /* the default is bsd */ -static __inline__ __sighandler_portable_t signal_portable(int s, sighandler_portable_t f) +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 __signal_portable(int, __sighandler_portable_t); +extern __sighandler_portable_t WRAP(__signal)(int, __sighandler_portable_t); -extern int sigprocmask_portable(int, const sigset_portable_t *, sigset_portable_t *); +extern int WRAP(sigprocmask)(int, const sigset_portable_t *, sigset_portable_t *); -extern int sigaction_portable(int, const struct sigaction_portable *, +extern int WRAP(sigaction)(int, const struct sigaction_portable *, struct sigaction_portable *); -extern int sigpending_portable(sigset_portable_t *); -extern int sigsuspend_portable(const sigset_portable_t *); -extern int sigwait_portable(const sigset_portable_t *set, int *sig); -extern int siginterrupt_portable(int sig, int flag); +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 raise_portable(int); -extern int kill_portable(pid_t, int); -extern int killpg_portable(int pgrp, int sig); -extern int tkill_portable(int tid, int portable_signum); -extern int sigaltstack_portable(const portable_stack_t *ss, portable_stack_t *oss); -extern int timer_create_portable(clockid_t, struct sigevent *, timer_t *); +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 signalfd_portable(int fd, const sigset_portable_t *portable_sigmask, int flags); +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, @@ -167,26 +167,26 @@ extern __hidden int do_sigmask(int portable_how, const sigset_portable_t *portab /* These functions are called from syscall.c and experimental Bionic linker. */ -extern int __rt_sigaction_portable(int portable_signum, - const struct sigaction_portable *act, - struct sigaction_portable *oldact, - size_t sigsetsize); +extern int WRAP(__rt_sigaction)(int portable_signum, + const struct sigaction_portable *act, + struct sigaction_portable *oldact, + size_t sigsetsize); -extern int __rt_sigprocmask_portable(int portable_how, - const sigset_portable_t *portable_sigset, - sigset_portable_t *portable_oldset, - 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 __rt_sigtimedwait_portable(const sigset_portable_t *portable_sigset, - siginfo_portable_t *portable_siginfo, - const struct timespec *timeout, - size_t portable_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 rt_sigqueueinfo_portable(pid_t pid, int sig, siginfo_portable_t *uinfo); +extern __hidden int WRAP(rt_sigqueueinfo)(pid_t pid, int sig, siginfo_portable_t *uinfo); -extern __hidden int rt_tgsigqueueinfo_portable(pid_t tgid, pid_t pid, int sig, +extern __hidden int WRAP(rt_tgsigqueueinfo)(pid_t tgid, pid_t pid, int sig, siginfo_portable_t *uinfo); diff --git a/ndk/sources/android/libportable/common/include/timerfd_portable.h b/ndk/sources/android/libportable/common/include/timerfd_portable.h index f83c0edee..d6c294c2a 100644 --- a/ndk/sources/android/libportable/common/include/timerfd_portable.h +++ b/ndk/sources/android/libportable/common/include/timerfd_portable.h @@ -31,8 +31,8 @@ #ifndef _SYS_TIMERFD_PORTABLE_H #define _SYS_TIMERFD_PORTABLE_H -#include #include +#include #include #include @@ -44,7 +44,7 @@ __BEGIN_DECLS #define TFD_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE #define TFD_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE -extern int timerfd_create_portable(int clockid, int flags); +extern int WRAP(timerfd_create)(int clockid, int flags); __END_DECLS