Merge "[MIPS] Added missing _NR_* system call support and cleaned up."

This commit is contained in:
Andrew Hsieh
2013-02-21 04:47:42 +00:00
committed by Gerrit Code Review
5 changed files with 297 additions and 16 deletions

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
#include <signal.h>
@@ -22,6 +23,8 @@
#include <stdio.h>
#include <errno.h>
#include <errno_portable.h>
#include <asm/unistd-portable.h>
#include <asm/unistd.h>
#define PORTABLE_TAG "signal_portable"
#include <log_portable.h>
@@ -32,6 +35,7 @@
#endif
typedef void (*sig3handler_t)(int, siginfo_t *, void *);
extern int syscall(int, ...);
/*
* The next five hidden functions are not exposed in the
@@ -651,8 +655,14 @@ static int do_kill(int id, int portable_signum, int (*fn)(int, int))
mips_signum = signum_pton(portable_signum);
rv = fn(id, mips_signum);
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;
}

View File

@@ -40,7 +40,7 @@
extern int syscall(int, ...);
#define MAXARGS 6
#define MAXARGS 8
int syscall_portable(int portable_number, ...)
{
@@ -48,6 +48,9 @@ int syscall_portable(int portable_number, ...)
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;
@@ -63,68 +66,159 @@ int syscall_portable(int portable_number, ...)
flags = va_arg(ap, long);
va_end(ap);
return cacheflush(start, end, flags);
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
case __NR_eventfd_portable: native_number = __NR_eventfd; break;
#endif
#ifdef __NR_eventfd2_portable
case __NR_eventfd2_portable: native_number = __NR_eventfd2; break;
#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: native_number = __NR_inotify_init1; break;
#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: native_number = __NR_pipe2; break;
#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;
@@ -155,7 +249,9 @@ int syscall_portable(int portable_number, ...)
oset = va_arg(ap, sigset_portable_t *);
sigsetsize = va_arg(ap, size_t);
va_end(ap);
return __rt_sigprocmask_portable(how, set, oset, sigsetsize);
ret = __rt_sigprocmask_portable(how, set, oset, sigsetsize);
goto done;
}
#endif
@@ -172,7 +268,26 @@ int syscall_portable(int portable_number, ...)
timeout = va_arg(ap, struct timespec *);
sigsetsize = va_arg(ap, size_t);
va_end(ap);
return __rt_sigtimedwait_portable(set, info, timeout, sigsetsize);
ret = __rt_sigtimedwait_portable(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 = rt_sigqueueinfo_portable(pid, sig, uinfo);
goto done;
}
#endif
@@ -183,49 +298,113 @@ int syscall_portable(int portable_number, ...)
#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: native_number = __NR_signalfd4; break;
#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
#ifdef __NR_sync_file_range2_portable
case __NR_sync_file_range2_portable: native_number = __NR_sync_file_range2; break;
/*
* 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 = 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;
@@ -238,20 +417,35 @@ int syscall_portable(int portable_number, ...)
timerid = va_arg(ap, timer_t *);
va_end(ap);
return timer_create_portable(clockid, evp, timerid);
ret = timer_create_portable(clockid, evp, timerid);
goto done;
}
#endif
#ifdef __NR_timerfd_create_portable
case __NR_timerfd_create_portable: native_number = __NR_timerfd_create; break;
#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;
@@ -273,7 +467,6 @@ int syscall_portable(int portable_number, ...)
#ifdef __NR_tkill_portable
case __NR_tkill_portable: {
extern int tkill_portable(int, int);
int tid, sig;
va_start(ap, portable_number);
@@ -281,19 +474,33 @@ int syscall_portable(int portable_number, ...)
sig = va_arg(ap, int);
va_end(ap);
return tkill_portable(tid, sig);
ret = tkill_portable(tid, sig);
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(portable_number:%d, ...) { native_number = %d", __func__,
portable_number, native_number);
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);
if (native_number == -1) {
errno = ENOSYS;
ret = -1;
goto done;
@@ -321,11 +528,16 @@ int syscall_portable(int portable_number, ...)
args[i] = va_arg(ap, int);
va_end(ap);
ret = syscall(native_number, args[0], args[1], args[2], args[3], args[4], args[5]);
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 = syscall(native_number, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7]);
done:
if (ret == -1) {
ALOGE("%s: ret == -1; errno:%d;", __func__, errno);
ALOGV("%s: ret == -1; errno:%d;", __func__, errno);
}
ALOGV("%s: return(ret:%d); }", __func__, ret);
return ret;

View File

@@ -2,7 +2,7 @@
Derived from gdk/platforms/android-14/arch-arm/usr/include/asm/signal.h
****************************************************************************
***
*** This header was ORIGINALLY automatically generated from a Linux kernel
*** 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,

View File

@@ -319,6 +319,64 @@
#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)

View File

@@ -138,6 +138,7 @@ extern int siginterrupt_portable(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 *);