am 13b81329: Merge "[MIPS] Tighten up code to fit within 100 characters lines."

* commit '13b81329385e1e8ec3ff55737f98bd1a9ededd74':
  [MIPS] Tighten up code to fit within 100 characters lines.
This commit is contained in:
Andrew Hsieh
2013-02-21 14:20:58 -08:00
committed by Android Git Automerger
10 changed files with 608 additions and 280 deletions

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
#include <sched.h> #include <sched.h>
#include <stdarg.h> #include <stdarg.h>
@@ -83,7 +84,7 @@ int clone_portable(int (*fn)(void *), void *child_stack, int port_flags, void *a
mips_flags = port_flags; mips_flags = port_flags;
} else { } else {
portable_term_signame = map_portable_signum_to_name(portable_term_signum); portable_term_signame = map_portable_signum_to_name(portable_term_signum);
mips_term_signum = map_portable_signum_to_mips(portable_term_signum); mips_term_signum = signum_pton(portable_term_signum);
mips_term_signame = map_mips_signum_to_name(mips_term_signum); mips_term_signame = map_mips_signum_to_name(mips_term_signum);
mips_flags = (port_flags & ~0xFF) | (mips_term_signum & 0xFF); mips_flags = (port_flags & ~0xFF) | (mips_term_signum & 0xFF);
} }

View File

@@ -217,7 +217,6 @@ extern int __fcntl64(int, int, void *);
* pid_t l_pid; pid_t l_pid; * pid_t l_pid; pid_t l_pid;
* } } * } }
*/ */
int fcntl_portable(int fd, int portable_cmd, ...) int fcntl_portable(int fd, int portable_cmd, ...)
{ {
va_list ap; va_list ap;
@@ -334,7 +333,10 @@ int fcntl_portable(int fd, int portable_cmd, ...)
/* /*
* This is likely a rare situation, abort() would hang fcntl13 LTP test. * This is likely a rare situation, abort() would hang fcntl13 LTP test.
*/ */
ALOGE("%s: mips_cmd:%d Doesn't appear to be supported; assume it doesn't need to be mapped!", __func__, mips_cmd); 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); result = __fcntl64(fd, mips_cmd, arg);
} }

View File

@@ -17,6 +17,59 @@
#include <poll.h> #include <poll.h>
#include <poll_portable.h> #include <poll_portable.h>
/*
*_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 #if POLLWRNORM_PORTABLE==POLLWRNORM
#error Bad build environment #error Bad build environment
#endif #endif
@@ -38,7 +91,10 @@ static inline short mips_change_portable_events(short portable_events)
static inline short change_mips_events(short mips_events) static inline short change_mips_events(short mips_events)
{ {
/* MIPS POLLWRNORM equals POLLOUT that is the same as POLLOUT_PORTABLE, so we just update POLLWRBNAD_PORTABLE. */ /*
* MIPS POLLWRNORM equals MIPS POLLOUT, which is the same as POLLOUT_PORTABLE;
* so we just map POLLWRBAND to POLLWRBAND_PORTABLE.
*/
if (mips_events & POLLWRBAND) { if (mips_events & POLLWRBAND) {
mips_events &= ~POLLWRBAND; mips_events &= ~POLLWRBAND;
mips_events |= POLLWRBAND_PORTABLE; mips_events |= POLLWRBAND_PORTABLE;

View File

@@ -58,6 +58,7 @@
{ \ { \
int rv, portable_rv; \ int rv, portable_rv; \
\ \
ALOGV(" "); \
ALOGV("%s" fmt, __func__, STRIP_PARENS(CALLARGS)); \ ALOGV("%s" fmt, __func__, STRIP_PARENS(CALLARGS)); \
rv = fn CALLARGS; \ rv = fn CALLARGS; \
portable_rv = ntop_errno(rv); \ portable_rv = ntop_errno(rv); \
@@ -67,99 +68,194 @@
} }
PTHREAD_WRAPPER(pthread_attr_init, (pthread_attr_t *attr), (attr), "(attr:%p)"); 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_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_setdetachstate, (pthread_attr_t *attr, int state), (attr, state),
PTHREAD_WRAPPER(pthread_attr_getdetachstate, (pthread_attr_t const *attr, int *state), (attr, state), "(attr:%p, state:%p)"); "(attr:%p, state:%d)");
PTHREAD_WRAPPER(pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy), (attr, policy), "(attr:%p, policy:%d)"); PTHREAD_WRAPPER(pthread_attr_getdetachstate, (pthread_attr_t const *attr, int *state),
PTHREAD_WRAPPER(pthread_attr_getschedpolicy, (pthread_attr_t const *attr, int *policy), (attr, policy), "(attr:%p, policy:%p)"); (attr, state), "(attr:%p, state:%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_setschedpolicy, (pthread_attr_t *attr, int policy), (attr, policy),
PTHREAD_WRAPPER(pthread_attr_getschedparam, (pthread_attr_t const *attr, struct sched_param *param), (attr, param), "(attr:%p, param:%p)"); "(attr:%p, policy:%d)");
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_getschedpolicy, (pthread_attr_t const *attr, int *policy),
PTHREAD_WRAPPER(pthread_attr_getstacksize, (pthread_attr_t const *attr, size_t *stack_size), (attr, stack_size), "(attr:%p, stach_size=%p)"); (attr, policy), "(attr:%p, policy:%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_setschedparam,
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_attr_t *attr, struct sched_param const *param), (attr, param),
"(attr:%p, param:%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_getschedparam,
PTHREAD_WRAPPER(pthread_attr_getguardsize, (pthread_attr_t const *attr, size_t *guard_size), (attr, guard_size), "(attr:%p, guard_size:%p)"); (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_setscope, (pthread_attr_t *attr, int scope), (attr, scope), "(attr:%p, scope:%d)");
PTHREAD_WRAPPER(pthread_attr_getscope, (pthread_attr_t const *attr), (attr), "(attr:%p)"); PTHREAD_WRAPPER(pthread_attr_getscope, (pthread_attr_t const *attr), (attr), "(attr:%p)");
PTHREAD_WRAPPER(pthread_getattr_np, (pthread_t thid, pthread_attr_t *attr), (thid, attr), "(thid:%lx, attr:%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)");
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); // 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_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_WRAPPER(pthread_detach, (pthread_t thid), (thid), "(thid:%lx)");
// pthread_t pthread_self(void); // pthread_t pthread_self(void);
// int pthread_equal(pthread_t one, pthread_t two); // 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_getschedparam, (pthread_t thid, int *policy, struct sched_param *param),
PTHREAD_WRAPPER(pthread_setschedparam, (pthread_t thid, int policy, struct sched_param const *param), (thid, policy, param), "(thid:%lx, policy:%d, param:%p)"); (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_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_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_destroy, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)");
PTHREAD_WRAPPER(pthread_mutex_lock, (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_unlock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)");
PTHREAD_WRAPPER(pthread_mutex_trylock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)"); PTHREAD_WRAPPER(pthread_mutex_trylock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)");
#if 0 /* MISSING FROM BIONIC */ #if 0 /* MISSING FROM BIONIC */
PTHREAD_WRAPPER(pthread_mutex_timedlock, (pthread_mutex_t *mutex, struct timespec *ts), (mutex, ts), "(mutex:%p, ts:%p)"); PTHREAD_WRAPPER(pthread_mutex_timedlock, (pthread_mutex_t *mutex, struct timespec *ts),
(mutex, ts), "(mutex:%p, ts:%p)");
#endif /* MISSING */ #endif /* MISSING */
PTHREAD_WRAPPER(pthread_condattr_init, (pthread_condattr_t *attr), (attr), "(attr:%p)"); 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_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_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_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_destroy, (pthread_cond_t *cond), (cond), "(cond:%p)");
PTHREAD_WRAPPER(pthread_cond_broadcast, (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_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_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
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)"); (cond, mutex), "(cond:%p, mutex:%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_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_mutex_lock_timeout_np, (pthread_mutex_t *mutex, unsigned msecs), (mutex, msecs), "(mutex:%p, msecs:%u)"); 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_mutex_lock_timeout_np, (pthread_mutex_t *mutex, unsigned msecs),
(mutex, msecs), "(mutex:%p, msecs:%u)");
PTHREAD_WRAPPER(pthread_rwlockattr_init, (pthread_rwlockattr_t *attr), (attr), "(attr:%p)"); 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_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_destroy, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)");
PTHREAD_WRAPPER(pthread_rwlock_rdlock, (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_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_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_wrlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)");
PTHREAD_WRAPPER(pthread_rwlock_trywrlock, (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_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_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_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_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)");
PTHREAD_WRAPPER(pthread_setspecific, (pthread_key_t key, const void *value), (key, value),
"(key:%x, value:%p)");
// void *pthread_getspecific(pthread_key_t key); // void *pthread_getspecific(pthread_key_t key);
int pthread_kill_portable(pthread_t thread, int portable_signum) int pthread_kill_portable(pthread_t thread, int portable_signum)
@@ -170,12 +266,14 @@ int pthread_kill_portable(pthread_t thread, int portable_signum)
ALOGV("%s(thread:%lx, portable_signum:%d)", __func__, thread, portable_signum); ALOGV("%s(thread:%lx, portable_signum:%d)", __func__, thread, portable_signum);
mips_signum = map_portable_signum_to_mips(portable_signum); mips_signum = signum_pton(portable_signum);
if ((portable_signum != 0) && (mips_signum == 0)) { if ((portable_signum != 0) && (mips_signum == 0)) {
/* A signal MIPS doesn't support; all we can do is ignore it. */ /* A signal MIPS doesn't support; all we can do is ignore it. */
ret = 0; ret = 0;
} else { } else {
ALOGV("%s: calling pthread_kill(thread:%lx, mips_signum:%d);", __func__,
thread, mips_signum);
ret = pthread_kill(thread, mips_signum); ret = pthread_kill(thread, mips_signum);
} }
portable_ret = ntop_errno(ret); portable_ret = ntop_errno(ret);
@@ -186,16 +284,17 @@ int pthread_kill_portable(pthread_t thread, int portable_signum)
return portable_ret; return portable_ret;
} }
int pthread_sigmask_portable(int portable_how, int pthread_sigmask_portable(int portable_how, const sigset_portable_t *portable_sigset,
const sigset_portable_t *portable_sigset,
sigset_portable_t *portable_oldset) sigset_portable_t *portable_oldset)
{ {
int portable_ret, ret; int portable_ret, ret;
ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p)", __func__, ALOGV(" ");
ALOGV("%s(portable_how:%d portable_sigset:%p, portable_oldset:%p)", __func__,
portable_how, portable_sigset, portable_oldset); portable_how, portable_sigset, portable_oldset);
ret = sigmask_helper(portable_how, portable_sigset, portable_oldset, pthread_sigmask, "pthread_sigmask"); ret = do_sigmask(portable_how, portable_sigset, portable_oldset, pthread_sigmask);
portable_ret = ntop_errno(ret); portable_ret = ntop_errno(ret);
ALOGV("%s: return portable_ret:%d; ret:%d;", __func__, ALOGV("%s: return portable_ret:%d; ret:%d;", __func__,
@@ -204,8 +303,12 @@ int pthread_sigmask_portable(int portable_how,
return portable_ret; return portable_ret;
} }
PTHREAD_WRAPPER(pthread_getcpuclockid, (pthread_t tid, clockid_t *clockid), (tid, clockid), "(tid:%lx, clockid:%p)"); 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_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\")");
PTHREAD_WRAPPER(pthread_setname_np, (pthread_t thid, const char *thname), (thid, thname), "(thid:%lx, thname:\"%s\")");

View File

@@ -78,6 +78,7 @@ __hidden char *map_portable_signum_to_name(int portable_signum)
return name; return name;
} }
__hidden char *map_mips_signum_to_name(int mips_signum) __hidden char *map_mips_signum_to_name(int mips_signum)
{ {
char *name; char *name;
@@ -121,7 +122,11 @@ __hidden char *map_mips_signum_to_name(int mips_signum)
return name; return name;
} }
__hidden int map_portable_signum_to_mips(int portable_signum)
/*
* Maps a signal number from portable to native.
*/
__hidden int signum_pton(int portable_signum)
{ {
int mips_signum = -1; int mips_signum = -1;
@@ -171,9 +176,9 @@ __hidden int map_portable_signum_to_mips(int portable_signum)
case SIGTERM_PORTABLE: /* 15 */ case SIGTERM_PORTABLE: /* 15 */
return SIGTERM; return SIGTERM;
case SIGSTKFLT_PORTABLE: /* 16 --> VOID:0 */ case SIGSTKFLT_PORTABLE: /* 16 --> 7 */
/* No MIPS SIGSTKFLT Exits; try mapping it to zero */ return SIGEMT; /* No native SIGSTKFLT exist ...
return 0; ... mapping it to SIGEMT. */
case SIGCHLD_PORTABLE: /* 17 --> 18 */ case SIGCHLD_PORTABLE: /* 17 --> 18 */
return SIGCHLD; return SIGCHLD;
@@ -224,8 +229,8 @@ __hidden int map_portable_signum_to_mips(int portable_signum)
return SIGRTMIN; return SIGRTMIN;
default: default:
ALOGE("%s: switch default: NOTE portable_signum:%d not supported.", __func__, ALOGE("%s: switch default: NOTE portable_signum:%d Not supported. Just a Test?",
portable_signum); __func__, portable_signum);
/* /*
* User could be LTP testing with bogus signal numbers, * User could be LTP testing with bogus signal numbers,
* if so we mimic the test. * if so we mimic the test.
@@ -238,8 +243,9 @@ __hidden int map_portable_signum_to_mips(int portable_signum)
} else if (portable_signum > NSIG_PORTABLE) { } else if (portable_signum > NSIG_PORTABLE) {
mips_signum = (portable_signum - NSIG_PORTABLE) + NSIG; mips_signum = (portable_signum - NSIG_PORTABLE) + NSIG;
} else { } else {
ALOGE("%s: 0 <= portable_signum:%d <= NSIG_PORTABLE:%d; not supported, Return(0);", __func__, ALOGE("%s: 0 <= portable_signum:%d <= NSIG_PORTABLE:%d; Not supported, return(0);",
portable_signum, NSIG_PORTABLE); __func__, portable_signum, NSIG_PORTABLE);
mips_signum = 0; mips_signum = 0;
} }
break; break;
@@ -251,7 +257,10 @@ __hidden int map_portable_signum_to_mips(int portable_signum)
} }
__hidden int map_mips_signum_to_portable(int mips_signum) /*
* Maps a signal number from native to portable.
*/
__hidden int signum_ntop(int mips_signum)
{ {
int portable_ssignum = -1; int portable_ssignum = -1;
@@ -301,11 +310,10 @@ __hidden int map_mips_signum_to_portable(int mips_signum)
case SIGTERM_PORTABLE: /* 15 */ case SIGTERM_PORTABLE: /* 15 */
return SIGTERM; return SIGTERM;
#if defined(SIGSTKFLT) case SIGEMT: /* 16 <--- 7 */
case SIGSTKFLT: /* 16 <--- VOID; NOT SUPPORTED */ return SIGSTKFLT_PORTABLE; /* No native SIGSTKFLT exist ...
ASSERT(mips_signum != SIGSTKFLT_PORTABLE); ... reverse mapping SIGEMT ...
return -1; ... back to SIGSTKFLT. */
#endif
case SIGCHLD: /* 17 <-- 18 */ case SIGCHLD: /* 17 <-- 18 */
return SIGCHLD_PORTABLE; return SIGCHLD_PORTABLE;
@@ -356,7 +364,8 @@ __hidden int map_mips_signum_to_portable(int mips_signum)
return SIGRTMIN; return SIGRTMIN;
default: default:
ALOGE("%s: switch default: mips_signum:%d not supported! return(0);", __func__, mips_signum); ALOGE("%s: switch default: mips_signum:%d Not supported! return(0);", __func__,
mips_signum);
#if 0 #if 0
LOG_FATAL("%s: mips_signum:%d is not portable;", __func__, mips_signum); LOG_FATAL("%s: mips_signum:%d is not portable;", __func__, mips_signum);
#endif #endif
@@ -365,6 +374,7 @@ __hidden int map_mips_signum_to_portable(int mips_signum)
return portable_ssignum; return portable_ssignum;
} }
/* /*
* Array of signal handlers as the portable users expects they * Array of signal handlers as the portable users expects they
* they have been registered in the kernel. Problem is we need * they have been registered in the kernel. Problem is we need
@@ -382,11 +392,12 @@ static void mips_sigaction_handler(int mips_signum, siginfo_t *sip, void *ucp)
siginfo_portable_t portable_si; siginfo_portable_t portable_si;
siginfo_portable_t *portable_sip; siginfo_portable_t *portable_sip;
ALOGV(" ");
ALOGV("%s(mips_signum:%d:'%s', sip:%p, ucp:%p) {", __func__, ALOGV("%s(mips_signum:%d:'%s', sip:%p, ucp:%p) {", __func__,
mips_signum, mips_signum,
mips_signame, sip, ucp); mips_signame, sip, ucp);
portable_signum = map_mips_signum_to_portable(mips_signum); portable_signum = signum_ntop(mips_signum);
portable_signame = map_portable_signum_to_name(portable_signum); portable_signame = map_portable_signum_to_name(portable_signum);
portable_sighandler = mips_portable_sighandler[portable_signum]; portable_sighandler = mips_portable_sighandler[portable_signum];
@@ -406,7 +417,7 @@ static void mips_sigaction_handler(int mips_signum, siginfo_t *sip, void *ucp)
/* /*
* Map Structure members from MIPS to Portable. * Map Structure members from MIPS to Portable.
*/ */
portable_si_signo = map_mips_signum_to_portable(sip->si_signo); portable_si_signo = signum_ntop(sip->si_signo);
portable_si_signame = map_portable_signum_to_name(portable_si_signo); portable_si_signame = map_portable_signum_to_name(portable_si_signo);
portable_si_errno = ntop_errno(sip->si_errno); portable_si_errno = ntop_errno(sip->si_errno);
@@ -414,12 +425,13 @@ static void mips_sigaction_handler(int mips_signum, siginfo_t *sip, void *ucp)
/* /*
* Deal with siginfo structure being a bit different. * Deal with siginfo structure being a bit different.
* Default to the same structure members.
*/ */
ASSERT(sizeof(siginfo_portable_t) == sizeof(siginfo_t)); ASSERT(sizeof(siginfo_portable_t) == sizeof(siginfo_t));
memcpy(&portable_si, sip, sizeof(portable_si)); /* Default to the same structure members */ memcpy(&portable_si, sip, sizeof(portable_si));
portable_si.si_signo = portable_si_signo; portable_si.si_signo = portable_si_signo;
portable_si.si_code = sip->si_code; /* code and errno are swapped between ARM and MIPS ... */ portable_si.si_code = sip->si_code; /* code and errno are swapped and ... */
portable_si.si_errno = portable_si_errno; /* ... and errno needs to be translated. */ portable_si.si_errno = portable_si_errno; /* ... errno needs to be translated. */
portable_sip = &portable_si; portable_sip = &portable_si;
} /* if sip */ } /* if sip */
@@ -429,6 +441,7 @@ static void mips_sigaction_handler(int mips_signum, siginfo_t *sip, void *ucp)
ALOGV("%s: return; }", __func__); ALOGV("%s: return; }", __func__);
} }
static void mips_sighandler(int mips_signum) static void mips_sighandler(int mips_signum)
{ {
int portable_signum; int portable_signum;
@@ -436,6 +449,7 @@ static void mips_sighandler(int mips_signum)
char *mips_signame = map_mips_signum_to_name(mips_signum); char *mips_signame = map_mips_signum_to_name(mips_signum);
sig3handler_portable_t portable_sighandler; sig3handler_portable_t portable_sighandler;
ALOGV(" ");
ALOGV("%s(mips_signum:%d:'%s') {", __func__, mips_signum, mips_signame); ALOGV("%s(mips_signum:%d:'%s') {", __func__, mips_signum, mips_signame);
mips_sigaction_handler(mips_signum, NULL, NULL); mips_sigaction_handler(mips_signum, NULL, NULL);
@@ -443,7 +457,8 @@ static void mips_sighandler(int mips_signum)
ALOGV("%s: return; }", __func__); ALOGV("%s: return; }", __func__);
} }
static sighandler_t map_portable_sighandler_to_mips(sighandler_portable_t portable_handler, int sigaction)
static sighandler_t sighandler_pton(sighandler_portable_t portable_handler, int sigaction)
{ {
sighandler_t mips_handler; sighandler_t mips_handler;
@@ -472,38 +487,39 @@ static sighandler_t map_portable_sighandler_to_mips(sighandler_portable_t portab
/* /*
* This function maps the signal number and calls one of the low level mips signal() * This function maps the signal number and calls one of the low level mips signal()
* functions implemented in portable-jb/bionic/libc/unistd/signal.c: * functions implemented in libc/unistd/signal.c:
* sysv_signal() * sysv_signal()
* bsd_signal() * bsd_signal()
* *
* The last 2 parameters to this static function, mips_signal_fn*, specify which of these functions to call. * The last 2 parameters to this static function, mips_signal_fn*, specify which of
* We intercept the above to functions, as well as signal(), and call the associated *_portable() * these functions to call. We intercept the above to functions, as well as signal(),
* functions below. * functions below.
* *
* In addition, we intercept the signal_handler with our own handlers that map the signal number from * In addition, we intercept the signal_handler with our own handlers that map the
* the MIPS convention to the PORTABLE/ARM convention. * signal number from the MIPS convention to the PORTABLE/ARM convention.
*/ */
static sighandler_portable_t _signal_portable(int portable_signum, sighandler_portable_t portable_handler, static sighandler_portable_t
__sighandler_t (mips_signal_fn)(int, __sighandler_t), char *mips_signal_fn_name) 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); char *portable_signame = map_portable_signum_to_name(portable_signum);
int mips_signum; int mips_signum;
sighandler_t mips_handler; sighandler_t mips_handler;
sighandler_portable_t ret; sighandler_portable_t rv;
sighandler_portable_t prev_portable_handler; sighandler_portable_t prev_portable_handler;
ALOGV("%s(portable_signum:%d:%s, portable_handler:%p, mips_signal_fn:%p, mips_signal_fn_name:'%s') {", __func__, ALOGV("%s(portable_signum:%d:%s, portable_handler:%p, mips_signal_fn:%p) {", __func__,
portable_signum, portable_signame, portable_signum,
portable_handler, mips_signal_fn, mips_signal_fn_name); portable_signame, portable_handler, mips_signal_fn);
mips_signum = map_portable_signum_to_mips(portable_signum); mips_signum = signum_pton(portable_signum);
if ((portable_signum != 0) && ((mips_signum <= 0) || (mips_signum > NSIG))) { if ((portable_signum != 0) && ((mips_signum <= 0) || (mips_signum > NSIG))) {
/* /*
* Invalid request; Let the kernel generate the proper return value and set errno. * Invalid request; Let the kernel generate the proper return value and set errno.
*/ */
mips_handler = map_portable_sighandler_to_mips(portable_handler, 0); mips_handler = sighandler_pton(portable_handler, 0);
ret = mips_signal_fn(mips_signum, mips_handler); rv = mips_signal_fn(mips_signum, mips_handler);
} else { } else {
/* /*
* We have a usable signal number, redirect it to our signal handler * We have a usable signal number, redirect it to our signal handler
@@ -512,21 +528,24 @@ static sighandler_portable_t _signal_portable(int portable_signum, sighandler_po
*/ */
prev_portable_handler = (sighandler_portable_t) mips_portable_sighandler[portable_signum]; prev_portable_handler = (sighandler_portable_t) mips_portable_sighandler[portable_signum];
mips_handler = map_portable_sighandler_to_mips(portable_handler, 0); mips_handler = sighandler_pton(portable_handler, 0);
if (mips_handler != portable_handler) { if (mips_handler != portable_handler) {
mips_portable_sighandler[portable_signum] = (sig3handler_portable_t) portable_handler; mips_portable_sighandler[portable_signum] = (sig3handler_portable_t) portable_handler;
} }
ret = mips_signal_fn(mips_signum, mips_handler); rv = mips_signal_fn(mips_signum, mips_handler);
if ((ret == (sighandler_portable_t) mips_sighandler) || if ((rv == (sighandler_portable_t) mips_sighandler) ||
(ret == (sighandler_portable_t) mips_sigaction_handler)) { (rv == (sighandler_portable_t) mips_sigaction_handler)) {
ret = (sighandler_t) prev_portable_handler;
rv = (sighandler_t) prev_portable_handler;
} }
} }
ALOGV("%s: return(ret:%p); }", __func__, ret);
return ret; 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 * 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 * redirects the call to bsd_signal(). _signal() is a static function; not to be called
@@ -534,81 +553,124 @@ static sighandler_portable_t _signal_portable(int portable_signum, sighandler_po
*/ */
sighandler_portable_t signal_portable(int portable_signum, sighandler_portable_t handler) sighandler_portable_t signal_portable(int portable_signum, sighandler_portable_t handler)
{ {
sighandler_portable_t ret; sighandler_portable_t rv;
ALOGV(" ");
ALOGV("%s(portable_signum:%d, handler:%p);", __func__,
portable_signum, handler);
/* bsd does a SA_RESTART */
ret = _signal_portable(portable_signum, handler, bsd_signal, "bsd_signal");
ALOGV("%s: return(ret:%p); }", __func__, ret);
return ret;
}
sighandler_portable_t sysv_signal_portable(int portable_signum, sighandler_portable_t handler)
{
sighandler_portable_t ret;
ALOGV(" ");
ALOGV("%s(portable_signum:%d, handler:%p);", __func__,
portable_signum, handler);
/* sysv does a SA_RESETHAND */
ret = _signal_portable(portable_signum, handler, sysv_signal, "sysv_signal");
ALOGV("%s: return(ret:%p); }", __func__, ret);
return ret;
}
sighandler_portable_t bsd_signal_portable(int portable_signum, sighandler_portable_t handler)
{
sighandler_portable_t ret;
ALOGV(" "); ALOGV(" ");
ALOGV("%s(portable_signum:%d, handler:%p) {", __func__, ALOGV("%s(portable_signum:%d, handler:%p) {", __func__,
portable_signum, handler); portable_signum, handler);
/* bsd does a SA_RESTART */ /* bsd does a SA_RESTART */
ret = _signal_portable(portable_signum, handler, bsd_signal, "bsd_signal"); rv = do_signal_portable(portable_signum, handler, bsd_signal);
ALOGV("%s: return(ret:%p); }", __func__, ret); ALOGV("%s: return(ret:%p); }", __func__, rv);
return ret; return rv;
} }
static int kill_helper(int id, int portable_signum, int (*fn)(int, int), const char *name)
sighandler_portable_t sysv_signal_portable(int portable_signum, sighandler_portable_t handler)
{
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, 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 bsd_signal_portable(int portable_signum, sighandler_portable_t handler)
{
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, 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); char *portable_signame = map_portable_signum_to_name(portable_signum);
int mips_signum; int mips_signum;
int ret; int rv;
ALOGV("%s(id:%d, portable_signum:%d:'%s');", name, ALOGV("%s(id:%d, portable_signum:%d:'%s', fn:%p) {", __func__,
id, portable_signum, portable_signame); id, portable_signum,
portable_signame, fn);
mips_signum = map_portable_signum_to_mips(portable_signum); mips_signum = signum_pton(portable_signum);
if ((portable_signum != 0) && (mips_signum == 0)) rv = fn(id, mips_signum);
return 0;
return fn(id, mips_signum); ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv;
} }
int killpg_portable(int pgrp, int portable_signum) int killpg_portable(int pgrp, int portable_signum)
{ {
return kill_helper(pgrp, portable_signum, killpg, __func__); int rv;
ALOGV(" ");
ALOGV("%s(pgrp:%d, portable_signum:%d) {", __func__,
pgrp, portable_signum);
rv = do_kill(pgrp, portable_signum, killpg);
ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv;
} }
int kill_portable(pid_t pid, int portable_signum) int kill_portable(pid_t pid, int portable_signum)
{ {
return kill_helper(pid, portable_signum, kill, __func__); int rv;
ALOGV(" ");
ALOGV("%s(pid:%d, portable_signum:%d) {", __func__,
pid, portable_signum);
rv = do_kill(pid, portable_signum, kill);
ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv;
} }
int tkill_portable(int tid, int portable_signum) int tkill_portable(int tid, int portable_signum)
{ {
extern int tkill(int, int); extern int tkill(int, int);
return kill_helper(tid, portable_signum, tkill, __func__); int rv;
ALOGV(" ");
ALOGV("%s(tid:%d, portable_signum:%d) {", __func__,
tid, portable_signum);
rv = do_kill(tid, portable_signum, tkill);
ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv;
} }
/* tgkill is not exported from android-14 libc.so */ /* tgkill is not exported from android-14 libc.so */
#if 0 #if 0
int tgkill_portable(int tgid, int tid, int portable_signum) int tgkill_portable(int tgid, int tid, int portable_signum)
@@ -618,25 +680,26 @@ int tgkill_portable(int tgid, int tid, int portable_signum)
int mips_signum; int mips_signum;
int rv; int rv;
ALOGV("%s(tgid:%d, tid:%d, portable_signum:%d:'%s');", __func__, ALOGV("%s(tgid:%d, tid:%d, portable_signum:%d:'%s') {", __func__,
tgid, tid, portable_signum, portable_signame); tgid, tid, portable_signum, portable_signame);
mips_signum = map_portable_signum_to_mips(portable_signum); mips_signum = signum_pton(portable_signum);
if ((portable_signum != 0) && (mips_signum == 0)) if ((portable_signum != 0) && (mips_signum == 0))
rv = 0; rv = 0;
else else
rv = tgkill(tgid, tid, mips_signum); rv = tgkill(tgid, tid, mips_signum);
ALOGV("%s: return rv:%d;", __func__, rv); ALOGV("%s: return rv:%d; }", __func__, rv);
return rv; return rv;
} }
#endif #endif
int raise_portable(int portable_signum) int raise_portable(int portable_signum)
{ {
char *portable_signame = map_portable_signum_to_name(portable_signum); char *portable_signame = map_portable_signum_to_name(portable_signum);
int mips_signum = map_portable_signum_to_mips(portable_signum); int mips_signum = signum_pton(portable_signum);
int rv; int rv;
ALOGV("%s(portable_signum:%d:'%s') {", __func__, portable_signum, portable_signame); ALOGV("%s(portable_signum:%d:'%s') {", __func__, portable_signum, portable_signame);
@@ -651,7 +714,7 @@ int raise_portable(int portable_signum)
} }
void map_portable_sigset_to_mips(sigset_portable_t *portable_sigset, sigset_t *mips_sigset) void sigset_pton(sigset_portable_t *portable_sigset, sigset_t *mips_sigset)
{ {
int portable_signum; int portable_signum;
@@ -671,17 +734,16 @@ void map_portable_sigset_to_mips(sigset_portable_t *portable_sigset, sigset_t *m
if (sigismember_portable(portable_sigset, portable_signum)) { if (sigismember_portable(portable_sigset, portable_signum)) {
char *portable_signame = map_portable_signum_to_name(portable_signum); char *portable_signame = map_portable_signum_to_name(portable_signum);
int mips_signum = map_portable_signum_to_mips(portable_signum); int mips_signum = signum_pton(portable_signum);
char *mips_signame; char *mips_signame;
if (mips_signum != 0) { if (mips_signum != 0) {
int err; int err;
mips_signame = map_mips_signum_to_name(mips_signum); mips_signame = map_mips_signum_to_name(mips_signum);
ALOGV("%s: sigaddset(mips_sigset:%p, mips_signum:%d:'%s'); [portable_signum:%d:'%s']", __func__, ALOGV("%s: sigaddset(mips_sigset:%p, mips_signum:%d:'%s');", __func__,
mips_sigset, mips_signum, mips_sigset, mips_signum,
mips_signame, portable_signum, mips_signame);
portable_signame);
err = sigaddset(mips_sigset, mips_signum); err = sigaddset(mips_sigset, mips_signum);
if (err == -1) { if (err == -1) {
@@ -697,7 +759,8 @@ done:
} }
void map_mips_sigset_to_portable(const sigset_t *const_mips_sigset, sigset_portable_t *portable_sigset) void
sigset_ntop(const sigset_t *const_mips_sigset, sigset_portable_t *portable_sigset)
{ {
int mips_signum; int mips_signum;
sigset_t *mips_sigset = (sigset_t *) const_mips_sigset; sigset_t *mips_sigset = (sigset_t *) const_mips_sigset;
@@ -716,7 +779,7 @@ void map_mips_sigset_to_portable(const sigset_t *const_mips_sigset, sigset_porta
for(mips_signum = 1; mips_signum <= NSIG; mips_signum++) { for(mips_signum = 1; mips_signum <= NSIG; mips_signum++) {
if (sigismember(mips_sigset, mips_signum)) { if (sigismember(mips_sigset, mips_signum)) {
int portable_signum = map_mips_signum_to_portable(mips_signum); int portable_signum = signum_ntop(mips_signum);
if (portable_signum != 0) if (portable_signum != 0)
sigaddset_portable(portable_sigset, portable_signum); sigaddset_portable(portable_sigset, portable_signum);
@@ -729,36 +792,37 @@ done:
} }
static int map_portable_sigaction_flags_to_mips(int portable_flags) static int sigaction_flags_pton(int portable_flags)
{ {
int mips_flags = 0; int mips_flags = 0;
if (portable_flags & SA_NOCLDSTOP_PORTABLE) if (portable_flags & SA_NOCLDSTOP_PORTABLE) {
mips_flags |= SA_NOCLDSTOP; mips_flags |= SA_NOCLDSTOP;
}
if (portable_flags & SA_NOCLDWAIT_PORTABLE) if (portable_flags & SA_NOCLDWAIT_PORTABLE) {
mips_flags |= SA_NOCLDWAIT; mips_flags |= SA_NOCLDWAIT;
}
if (portable_flags & SA_SIGINFO_PORTABLE) if (portable_flags & SA_SIGINFO_PORTABLE) {
mips_flags |= SA_SIGINFO; mips_flags |= SA_SIGINFO;
}
if (portable_flags & SA_THIRTYTWO_PORTABLE) { if (portable_flags & SA_THIRTYTWO_PORTABLE) {
ALOGV("%s: SA_THIRTYTWO_PORTABLE isn't SUPPORTED.", __func__); ALOGV("%s: SA_THIRTYTWO_PORTABLE isn't SUPPORTED.", __func__);
} }
if (portable_flags & SA_RESTORER_PORTABLE) if (portable_flags & SA_RESTORER_PORTABLE) {
mips_flags |= SA_RESTORER; mips_flags |= SA_RESTORER;
}
if (portable_flags & SA_ONSTACK_PORTABLE) if (portable_flags & SA_ONSTACK_PORTABLE) {
mips_flags |= SA_ONSTACK; mips_flags |= SA_ONSTACK;
}
if (portable_flags & SA_RESTART_PORTABLE) if (portable_flags & SA_RESTART_PORTABLE) {
mips_flags |= SA_RESTART; mips_flags |= SA_RESTART;
}
if (portable_flags & SA_NODEFER_PORTABLE) if (portable_flags & SA_NODEFER_PORTABLE) {
mips_flags |= SA_NODEFER; mips_flags |= SA_NODEFER;
}
if (portable_flags & SA_RESETHAND_PORTABLE) if (portable_flags & SA_RESETHAND_PORTABLE) {
mips_flags |= SA_RESETHAND; mips_flags |= SA_RESETHAND;
}
ALOGV("%s(portable_flags:0x%x) return(mips_flags:0x%x);", __func__, ALOGV("%s(portable_flags:0x%x) return(mips_flags:0x%x);", __func__,
portable_flags, mips_flags); portable_flags, mips_flags);
@@ -766,7 +830,8 @@ static int map_portable_sigaction_flags_to_mips(int portable_flags)
return mips_flags; return mips_flags;
} }
int map_mips_sigaction_flags_to_portable(int mips_flags)
int sigaction_flags_ntop(int mips_flags)
{ {
int portable_flags = 0; int portable_flags = 0;
@@ -788,6 +853,7 @@ int map_mips_sigaction_flags_to_portable(int mips_flags)
return portable_flags; return portable_flags;
} }
/* /*
* Called by portable/ARM code, which we map and do MIPS system calls. * Called by portable/ARM code, which we map and do MIPS system calls.
* *
@@ -819,7 +885,8 @@ int map_mips_sigaction_flags_to_portable(int mips_flags)
* a table of signal handlers that our intercepting handler can call after it converts the signal * a table of signal handlers that our intercepting handler can call after it converts the signal
* numbers. * numbers.
*/ */
int sigaction_portable(int portable_signum, const struct sigaction_portable *act, struct sigaction_portable *oldact) static int do_sigaction_portable(int portable_signum, const struct sigaction_portable *act,
struct sigaction_portable *oldact)
{ {
int mips_signum; int mips_signum;
char *mips_signame; char *mips_signame;
@@ -831,13 +898,13 @@ int sigaction_portable(int portable_signum, const struct sigaction_portable *act
char *portable_signame = map_portable_signum_to_name(portable_signum); char *portable_signame = map_portable_signum_to_name(portable_signum);
int rv; int rv;
ALOGV(" ");
ALOGV("%s(portable_signum:%d:'%s', act:%p, oldact:%p) {", __func__, ALOGV("%s(portable_signum:%d:'%s', act:%p, oldact:%p) {", __func__,
portable_signum, portable_signum,
portable_signame, act, oldact); portable_signame, act, oldact);
mips_signum = map_portable_signum_to_mips(portable_signum); mips_signum = signum_pton(portable_signum);
mips_signame = map_mips_signum_to_name(mips_signum); mips_signame = map_mips_signum_to_name(mips_signum);
if ((portable_signum != 0) && (mips_signum == 0)) { if ((portable_signum != 0) && (mips_signum == 0)) {
/* We got a portable signum that we can't map; Ignore the request */ /* We got a portable signum that we can't map; Ignore the request */
rv = 0; rv = 0;
@@ -854,19 +921,22 @@ int sigaction_portable(int portable_signum, const struct sigaction_portable *act
rv = sigaction(mips_signum, (struct sigaction *)act, &mips_oldact); rv = sigaction(mips_signum, (struct sigaction *)act, &mips_oldact);
} else { } else {
/* /*
* Make the MIPS version of sigaction, which has no sa_restorer function pointer. Also the handler * Make the MIPS version of sigaction, which has no sa_restorer function pointer.
* will be called with a pointer to a to a sigcontext structure which is totally non-portable. * Also the handler will be called with a pointer to a to a sigcontext structure
* which is totally non-portable.
*/ */
map_portable_sigset_to_mips(((sigset_portable_t *)&act->sa_mask), ((sigset_t *) &mips_act.sa_mask)); sigset_pton(((sigset_portable_t *)&act->sa_mask),
((sigset_t *) &mips_act.sa_mask));
mips_act.sa_flags = map_portable_sigaction_flags_to_mips(act->sa_flags); mips_act.sa_flags = sigaction_flags_pton(act->sa_flags);
if (mips_act.sa_flags & SA_SIGINFO) { if (mips_act.sa_flags & SA_SIGINFO) {
/* /*
* Providing the three argument version of a signal handler. * Providing the three argument version of a signal handler.
*/ */
if (portable_signum >= 0 && portable_signum < NSIG_PORTABLE) { if (portable_signum >= 0 && portable_signum < NSIG_PORTABLE) {
mips_portable_sighandler[portable_signum] = (sig3handler_portable_t) act->sa_sigaction_portable; mips_portable_sighandler[portable_signum] =
(sig3handler_portable_t) act->sa_sigaction_portable;
mips_act.sa_sigaction = mips_sigaction_handler; mips_act.sa_sigaction = mips_sigaction_handler;
} }
@@ -884,9 +954,10 @@ int sigaction_portable(int portable_signum, const struct sigaction_portable *act
*/ */
mips_act.sa_handler = (sighandler_t) portable_handler; mips_act.sa_handler = (sighandler_t) portable_handler;
} else { } else {
mips_handler = map_portable_sighandler_to_mips(portable_handler, 1); mips_handler = sighandler_pton(portable_handler, 1);
if (mips_handler != portable_handler) { if (mips_handler != portable_handler) {
mips_portable_sighandler[portable_signum] = (sig3handler_portable_t) portable_handler; mips_portable_sighandler[portable_signum] =
(sig3handler_portable_t) portable_handler;
} }
mips_act.sa_handler = mips_handler; mips_act.sa_handler = mips_handler;
} }
@@ -895,15 +966,19 @@ int sigaction_portable(int portable_signum, const struct sigaction_portable *act
} }
if (oldact) { if (oldact) {
if ((mips_oldact.sa_sigaction == (__sigaction_handler_portable_t) mips_sighandler) || if (mips_oldact.sa_sigaction == (__sigaction_handler_portable_t) mips_sigaction_handler ||
(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;
}
map_mips_sigset_to_portable((sigset_t *) &(mips_oldact.sa_mask), (sigset_portable_t *) &(oldact->sa_mask));
oldact->sa_flags = map_mips_sigaction_flags_to_portable(mips_oldact.sa_flags); 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; oldact->sa_restorer = NULL;
} }
@@ -913,6 +988,22 @@ done:
} }
int sigaction_portable(int portable_signum, const struct sigaction_portable *act,
struct sigaction_portable *oldact)
{
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);
ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv;
}
#if 0 #if 0
/* /*
* So far it appears that signalfd() isn't supported by bionic * So far it appears that signalfd() isn't supported by bionic
@@ -922,7 +1013,7 @@ int signalfd_portable(int fd, const sigset_t *portable_sigmask, int flags)
{ {
sigset_t mips_sigmask; sigset_t mips_sigmask;
map_portable_sigset_to_mips(portable_sigmask, &mips_sigmask); sigset_pton(portable_sigmask, &mips_sigmask);
return signalfd(fd, &mips_sigmask, flags); return signalfd(fd, &mips_sigmask, flags);
} }
@@ -940,11 +1031,11 @@ int sigsuspend_portable(const sigset_portable_t *portable_sigmask)
errno = EFAULT; errno = EFAULT;
rv = -1; rv = -1;
} else { } else {
map_portable_sigset_to_mips((sigset_portable_t *)portable_sigmask, &mips_sigmask); sigset_pton((sigset_portable_t *)portable_sigmask, &mips_sigmask);
rv = sigsuspend(&mips_sigmask); rv = sigsuspend(&mips_sigmask);
} }
ALOGV("%s: return(rv:%d);", __func__, rv); ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv; return rv;
} }
@@ -962,10 +1053,10 @@ int sigpending_portable(sigset_portable_t *portable_sigset)
rv = -1; rv = -1;
} else { } else {
rv = sigpending(&mips_sigset); rv = sigpending(&mips_sigset);
map_mips_sigset_to_portable(&mips_sigset, portable_sigset); sigset_ntop(&mips_sigset, portable_sigset);
} }
ALOGV("%s: return(rv:%d);", __func__, rv); ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv; return rv;
} }
@@ -984,14 +1075,14 @@ int sigwait_portable(const sigset_portable_t *portable_sigset, int *ptr_to_porta
errno = EFAULT; errno = EFAULT;
rv = -1; rv = -1;
} else { } else {
map_portable_sigset_to_mips((sigset_portable_t *)portable_sigset, &mips_sigset); sigset_pton((sigset_portable_t *)portable_sigset, &mips_sigset);
rv = sigwait(&mips_sigset, &mips_sig); rv = sigwait(&mips_sigset, &mips_sig);
portable_sig = map_mips_signum_to_portable(mips_sig); portable_sig = signum_ntop(mips_sig);
*ptr_to_portable_sig = portable_sig; *ptr_to_portable_sig = portable_sig;
} }
ALOGV("%s: return(rv:%d);", __func__, rv); ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv; return rv;
} }
@@ -1005,7 +1096,7 @@ int siginterrupt_portable(int portable_signum, int flag)
ALOGV("%s(portable_signum:%d, flag:0x%x) {", __func__, ALOGV("%s(portable_signum:%d, flag:0x%x) {", __func__,
portable_signum, flag); portable_signum, flag);
mips_signum = map_portable_signum_to_mips(portable_signum); mips_signum = signum_pton(portable_signum);
if ((portable_signum != 0) && (mips_signum == 0)) { if ((portable_signum != 0) && (mips_signum == 0)) {
ALOGE("%s: Unsupported portable_signum:%d; Ignoring.", __func__, ALOGE("%s: Unsupported portable_signum:%d; Ignoring.", __func__,
@@ -1014,11 +1105,13 @@ int siginterrupt_portable(int portable_signum, int flag)
} else { } else {
rv = siginterrupt(mips_signum, flag); rv = siginterrupt(mips_signum, flag);
} }
ALOGV("%s: return(rv:%d);", __func__, rv); ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv; return rv;
} }
__hidden int sigmask_helper(int portable_how, const sigset_portable_t *portable_sigset, sigset_portable_t *portable_oldset, sigmask_fn fn, char *fname)
__hidden int do_sigmask(int portable_how, const sigset_portable_t *portable_sigset,
sigset_portable_t *portable_oldset, sigmask_fn fn)
{ {
int rv; int rv;
int how; int how;
@@ -1026,9 +1119,8 @@ __hidden int sigmask_helper(int portable_how, const sigset_portable_t *portable_
sigset_t mips_sigset, *mips_sigset_p; sigset_t mips_sigset, *mips_sigset_p;
sigset_t mips_oldset, *mips_oldset_p; sigset_t mips_oldset, *mips_oldset_p;
ALOGV(" "); ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p, fn:%p) {", __func__,
ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p) {", __func__, portable_how, portable_sigset, portable_oldset, fn);
portable_how, portable_sigset, portable_oldset);
switch(portable_how) { switch(portable_how) {
case SIG_BLOCK_PORTABLE: how = SIG_BLOCK; how_name = "SIG_BLOCK"; break; case SIG_BLOCK_PORTABLE: how = SIG_BLOCK; how_name = "SIG_BLOCK"; break;
@@ -1047,7 +1139,7 @@ __hidden int sigmask_helper(int portable_how, const sigset_portable_t *portable_
mips_sigset_p = &mips_sigset; mips_sigset_p = &mips_sigset;
memset(mips_sigset_p, 0, sizeof(mips_sigset)); memset(mips_sigset_p, 0, sizeof(mips_sigset));
sigemptyset(mips_sigset_p); sigemptyset(mips_sigset_p);
map_portable_sigset_to_mips((sigset_portable_t *)portable_sigset, &mips_sigset); sigset_pton((sigset_portable_t *)portable_sigset, &mips_sigset);
} }
if (invalid_pointer((void *)portable_oldset)) { if (invalid_pointer((void *)portable_oldset)) {
@@ -1062,20 +1154,32 @@ __hidden int sigmask_helper(int portable_how, const sigset_portable_t *portable_
if (rv == 0 && !invalid_pointer(portable_oldset)) { if (rv == 0 && !invalid_pointer(portable_oldset)) {
/* Map returned mips_oldset to portable_oldset for return to caller */ /* Map returned mips_oldset to portable_oldset for return to caller */
map_mips_sigset_to_portable(mips_oldset_p, portable_oldset); sigset_ntop(mips_oldset_p, portable_oldset);
} }
ALOGV("%s: return(rv:%d); }", __func__, rv); ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv; return rv;
} }
int sigprocmask_portable(int portable_how,
const sigset_portable_t *portable_sigset, int sigprocmask_portable(int portable_how, const sigset_portable_t *portable_sigset,
sigset_portable_t *portable_oldset) sigset_portable_t *portable_oldset)
{ {
return sigmask_helper(portable_how, portable_sigset, portable_oldset, sigprocmask, "sigprocmask"); 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);
ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv;
} }
/* /*
* ss_flags and ss_size are located in different locations in stack_t structure: * ss_flags and ss_size are located in different locations in stack_t structure:
* *
@@ -1101,8 +1205,9 @@ int sigaltstack_portable(const portable_stack_t *ss, portable_stack_t *oss)
mips_ss = NULL; mips_ss = NULL;
} else { } else {
if (invalid_pointer((void *)ss)) { if (invalid_pointer((void *)ss)) {
ALOGE("%s: invalid_pointer(ss:%p): Let kernel set proper errno and set return value.", __func__, ALOGE("%s: invalid_pointer(ss:%p): Let kernel set proper errno and set return value.",
ss); __func__, ss);
mips_ss = (stack_t *) ss; mips_ss = (stack_t *) ss;
} else { } else {
memset(&new_stack, 0, sizeof(stack_t)); memset(&new_stack, 0, sizeof(stack_t));
@@ -1116,8 +1221,9 @@ int sigaltstack_portable(const portable_stack_t *ss, portable_stack_t *oss)
mips_oss = NULL; mips_oss = NULL;
} else { } else {
if (invalid_pointer((void *)oss)) { if (invalid_pointer((void *)oss)) {
ALOGE("%s: invalid_pointer(oss:%p): Let kernel set proper errno and set return value.", __func__, ALOGE("%s: invalid_pointer(oss:%p): Let kernel set proper errno and return value.",
oss); __func__, oss);
mips_oss = (stack_t *)oss; mips_oss = (stack_t *)oss;
} else { } else {
memset(&old_stack, 0, sizeof(stack_t)); memset(&old_stack, 0, sizeof(stack_t));

View File

@@ -28,9 +28,10 @@ int timer_create_portable(clockid_t clockid, struct sigevent *portable_evp,
if (!invalid_pointer(portable_evp) && if (!invalid_pointer(portable_evp) &&
(evp->sigev_notify == SIGEV_SIGNAL || (evp->sigev_notify == SIGEV_SIGNAL ||
evp->sigev_notify == SIGEV_THREAD_ID)) { evp->sigev_notify == SIGEV_THREAD_ID)) {
native_sigevent = *portable_evp; native_sigevent = *portable_evp;
evp = &native_sigevent; evp = &native_sigevent;
evp->sigev_signo = map_portable_signum_to_mips(evp->sigev_signo); evp->sigev_signo = signum_pton(evp->sigev_signo);
} }
return timer_create(clockid, evp, timerid); return timer_create(clockid, evp, timerid);
} }

View File

@@ -31,13 +31,13 @@ pid_t waitpid_portable(pid_t pid, int *status, int options)
ret = waitpid(pid, status, options); ret = waitpid(pid, status, options);
if (status && ret > 0) { if (status && ret > 0) {
/* /*
* Status layout is identical so just the signal * Status layout is identical, so just the signal
* number needs to be changed. * number needs to be changed.
*/ */
if (WIFSIGNALED(*status)) if (WIFSIGNALED(*status))
*status = (*status & ~0x7f) | map_mips_signum_to_portable(WTERMSIG(*status)); *status = (*status & ~0x7f) | signum_ntop(WTERMSIG(*status));
else if (WIFSTOPPED(*status)) else if (WIFSTOPPED(*status))
*status = (*status & ~0xff00) | (map_mips_signum_to_portable(WSTOPSIG(*status)) << 8); *status = (*status & ~0xff00) | (signum_ntop(WSTOPSIG(*status)) << 8);
} }
return ret; return ret;

View File

@@ -17,8 +17,9 @@
#ifndef _IOCTLS_PORTABLE_H_ #ifndef _IOCTLS_PORTABLE_H_
#define _IOCTLS_PORTABLE_H_ #define _IOCTLS_PORTABLE_H_
/* Derived from development/ndk/platforms/android-3/include/asm-generic/ioctl.h */ /*
* Derived from development/ndk/platforms/android-3/include/asm-generic/ioctl.h
*/
#define _IOC_NRBITS_PORTABLE 8 #define _IOC_NRBITS_PORTABLE 8
#define _IOC_TYPEBITS_PORTABLE 8 #define _IOC_TYPEBITS_PORTABLE 8
#define _IOC_SIZEBITS_PORTABLE 14 #define _IOC_SIZEBITS_PORTABLE 14
@@ -38,18 +39,37 @@
#define _IOC_WRITE_PORTABLE 1U #define _IOC_WRITE_PORTABLE 1U
#define _IOC_READ_PORTABLE 2U #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)) #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; 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 _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 _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 _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 TCGETS_PORTABLE 0x5401
#define TCSETS_PORTABLE 0x5402 #define TCSETS_PORTABLE 0x5402
#define TCSETSW_PORTABLE 0x5403 #define TCSETSW_PORTABLE 0x5403
@@ -121,8 +141,9 @@ extern unsigned int __invalid_size_argument_for_IOC;
#define TIOCSER_TEMT_PORTABLE 0x01 #define TIOCSER_TEMT_PORTABLE 0x01
/* Derived from development/ndk/platforms/android-3/include/sys/ioctl_compat.h */ /*
* Derived from development/ndk/platforms/android-3/include/sys/ioctl_compat.h
*/
struct tchars_portable { struct tchars_portable {
char t_intrc; /* interrupt */ char t_intrc; /* interrupt */
char t_quitc; /* quit */ char t_quitc; /* quit */
@@ -156,23 +177,49 @@ struct sgttyb_portable {
# define OTIOCGETD_PORTABLE _IOR_PORTABLE('t', 0, int) /* get line discipline */ # define OTIOCGETD_PORTABLE _IOR_PORTABLE('t', 0, int) /* get line discipline */
# define OTIOCSETD_PORTABLE _IOW_PORTABLE('t', 1, int) /* set line discipline */ # define OTIOCSETD_PORTABLE _IOW_PORTABLE('t', 1, int) /* set line discipline */
#endif #endif
#define TIOCHPCL_PORTABLE _IO_PORTABLE('t', 2) /* hang up on last close */
#define TIOCGETP_PORTABLE _IOR_PORTABLE('t', 8,struct sgttyb_portable)/* get parameters -- gtty */
#define TIOCSETP_PORTABLE _IOW_PORTABLE('t', 9,struct sgttyb_portable)/* set parameters -- stty */
#define TIOCSETN_PORTABLE _IOW_PORTABLE('t',10,struct sgttyb_portable)/* as above, but no flushtty*/
#define TIOCSETC_PORTABLE _IOW_PORTABLE('t',17,struct tchars_portable)/* set special characters */
#define TIOCGETC_PORTABLE _IOR_PORTABLE('t',18,struct tchars_portable)/* get special characters */
#define TIOCLBIS_PORTABLE _IOW_PORTABLE('t', 127, int) /* bis local mode bits */ /* hang up on last close */
#define TIOCLBIC_PORTABLE _IOW_PORTABLE('t', 126, int) /* bic local mode bits */ #define TIOCHPCL_PORTABLE _IO_PORTABLE('t', 2)
#define TIOCLSET_PORTABLE _IOW_PORTABLE('t', 125, int) /* set entire local mode word */
#define TIOCLGET_PORTABLE _IOR_PORTABLE('t', 124, int) /* get local modes */
#define TIOCSLTC_PORTABLE _IOW_PORTABLE('t',117,struct ltchars_portable)/* set local special chars*/
#define TIOCGLTC_PORTABLE _IOR_PORTABLE('t',116,struct ltchars_portable)/* get local special chars*/
#define OTIOCCONS_PORTABLE _IO_PORTABLE('t', 98) /* for hp300 -- sans int arg */
/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/sockios.h */ /* 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 FIOSETOWN_PORTABLE 0x8901
#define SIOCSPGRP_PORTABLE 0x8902 #define SIOCSPGRP_PORTABLE 0x8902
#define FIOGETOWN_PORTABLE 0x8903 #define FIOGETOWN_PORTABLE 0x8903

View File

@@ -6,8 +6,9 @@
* % logcat '*:v' [To display Verbose Logging] * % logcat '*:v' [To display Verbose Logging]
* % logcat 'fcntl_portable:v' [To display just this fcntl logging] * % logcat 'fcntl_portable:v' [To display just this fcntl logging]
* *
* NOTE: This assumes you only use the portable TAG; which is the default. * 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. * 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: * Logging routines also support ALOG*_IF() and ASSERT(); For details See:
* *
@@ -17,35 +18,39 @@
* *
* ALOGV is turned off by release builds: Use the #define below with LOG_NDEBUG=0 to enable. * 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; Ex: * Strace works fine with ALOG out if a large max string size is used via the -s option;
* Example:
* *
* strace -s 132 ./sigaction01 * strace -s 132 ./sigaction01
* *
* writev(3, [{"\2", 1}, * writev(3, [{"\2", 1},
* {"./sigaction01`signal_portable\0", 30}, * {"./sigaction01`signal_portable\0", 30},
* {"sigaction_portable(portable_signum:10:'SIGUSR1_PORTABLE:10', act:0x7fe47a08, oldact:0x0) {\0", 91}], 3) = 122 * {"sigaction_portable(portable_signum:10:'SIGUSR1_PORTABLE:10', ...
* {"map_portable_sigset_to_mips(portable_sigset:0x7fe47a0c, mips_sigset:0x7fe479b8) {\0", 82}], 3) = 113 * {"map_portable_sigset_to_mips(portable_sigset:0x7fe47a0c, ...
* ... * ...
*/ */
/* /*
* Remove the // below to have debug code visible in logcat output by default. * Enable LOG_NDEBUG to have debug code visible in logcat output by default.
* It's Also possible via libportable/Android.mk: * Also possible via the Lib-Portable Android.mk file. Example:
*
* # Have logging permanently enable during development.
* LOCAL_CFLAGS += -DLOG_NDEBUG=0 * LOCAL_CFLAGS += -DLOG_NDEBUG=0
*/ */
// # define LOG_NDEBUG 0 // # define LOG_NDEBUG 0
// #define EXTENDED_LOGGING /* Include the current program name in the LOG_TAG */
// #define EXTENDED_LOGGING
#ifdef EXTENDED_LOGGING #ifdef EXTENDED_LOGGING
/* /*
* Inline function to put the current LTP program and this library into the logcat prefix; Ex: * Inline function to put the current program name
* and this library into the logcat prefix. Example:
* *
* V/./sigaction01`signal_portable(605): sigaction_portable(portable_signum:10:'SIGUSR1_PORTABLE:10', act:0x7fe47a08, oldact:0x0) { * V/./sigaction01`signal_portable(605): sigaction_portable(... ) {
* ----------------------------- * -----------------------------
* *
* Disabled by default, enable by removing the // above. Useful when debugging more than one program; Ex: LTP has thousands. * 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 #define MAX_TAG_LEN 128
static char my_portable_tag[MAX_TAG_LEN + 1]; static char my_portable_tag[MAX_TAG_LEN + 1];
@@ -54,7 +59,6 @@ static inline char *portable_tag() {
extern char *__progname; extern char *__progname;
if (my_portable_tag[0] == '\000') { if (my_portable_tag[0] == '\000') {
strncat(&my_portable_tag[0], __progname, MAX_TAG_LEN); 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], ".", MAX_TAG_LEN - strlen(my_portable_tag));
strncat(&my_portable_tag[0], PORTABLE_TAG, MAX_TAG_LEN - strlen(my_portable_tag)); strncat(&my_portable_tag[0], PORTABLE_TAG, MAX_TAG_LEN - strlen(my_portable_tag));
@@ -68,7 +72,9 @@ static inline char *portable_tag() {
# include <cutils/log.h> # include <cutils/log.h>
# define PERROR(str) { ALOGE("%s: PERROR('%s'): errno:%d:'%s'", __func__, str, errno, strerror(errno)); } # define PERROR(str) { \
ALOGE("%s: PERROR('%s'): errno:%d:'%s'", __func__, str, errno, strerror(errno)); \
}
# define ASSERT(cond) ALOG_ASSERT(cond, "assertion failed:(%s), file: %s, line: %d:%s", \ # define ASSERT(cond) ALOG_ASSERT(cond, "assertion failed:(%s), file: %s, line: %d:%s", \
#cond, __FILE__, __LINE__, __func__); #cond, __FILE__, __LINE__, __func__);

View File

@@ -124,7 +124,9 @@ static __inline__ __sighandler_portable_t signal_portable(int s, sighandler_port
extern __sighandler_portable_t __signal_portable(int, __sighandler_portable_t); extern __sighandler_portable_t __signal_portable(int, __sighandler_portable_t);
extern int sigprocmask_portable(int, const sigset_portable_t *, sigset_portable_t *); extern int sigprocmask_portable(int, const sigset_portable_t *, sigset_portable_t *);
extern int sigaction_portable(int, const struct sigaction_portable *, struct sigaction_portable *);
extern int sigaction_portable(int, const struct sigaction_portable *,
struct sigaction_portable *);
extern int sigpending_portable(sigset_portable_t *); extern int sigpending_portable(sigset_portable_t *);
extern int sigsuspend_portable(const sigset_portable_t *); extern int sigsuspend_portable(const sigset_portable_t *);
@@ -136,12 +138,16 @@ extern int kill_portable(pid_t, int);
extern int killpg_portable(int pgrp, int sig); extern int killpg_portable(int pgrp, int sig);
extern int sigaltstack_portable(const portable_stack_t *ss, portable_stack_t *oss); extern int sigaltstack_portable(const portable_stack_t *ss, portable_stack_t *oss);
extern __hidden char *map_portable_signum_to_name(int portable_signum); extern __hidden char *map_portable_signum_to_name(int portable_signum);
extern __hidden char *map_mips_signum_to_name(int mips_signum); extern __hidden char *map_mips_signum_to_name(int mips_signum);
extern __hidden int map_portable_signum_to_mips(int portable_signum); extern __hidden int signum_pton(int portable_signum);
extern __hidden int map_mips_signum_to_portable(int mips_signum); extern __hidden int signum_ntop(int mips_signum);
typedef int (*sigmask_fn)(int, const sigset_t *, sigset_t *); typedef int (*sigmask_fn)(int, const sigset_t *, sigset_t *);
extern __hidden int sigmask_helper(int portable_how, const sigset_portable_t *portable_sigset, sigset_portable_t *portable_oldset, sigmask_fn fn, char *fname);
extern __hidden int do_sigmask(int portable_how, const sigset_portable_t *portable_sigset,
sigset_portable_t *portable_oldset, sigmask_fn fn);
__END_DECLS __END_DECLS