Merge "[MIPS] Add Support signal."

This commit is contained in:
Andrew Hsieh
2012-10-05 02:14:10 -07:00
committed by Gerrit Code Review
8 changed files with 1687 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ libportable_arch_src_files += \
arch-mips/open.c \
arch-mips/poll.c \
arch-mips/resource.c \
arch-mips/signal.c \
arch-mips/socket.c \
arch-mips/sockopt.c \
arch-mips/stat.c \

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,221 @@
/****************************************************************************
Derived from platforms/android-14/arch-arm/usr/include/asm-generic/siginfo.h
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef _ASM_PORTABLE_GENERIC_SIGINFO_H
#define _ASM_PORTABLE_GENERIC_SIGINFO_H
#include <linux/compiler.h>
#include <linux/types.h>
typedef union sigval_portable {
int sival_int;
void __user *sival_ptr;
} sigval_portable_t;
#ifndef __ARCH_SI_PREAMBLE_SIZE
#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
#endif
#define SI_MAX_SIZE 128
#ifndef SI_PAD_SIZE
#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
#endif
#ifndef __ARCH_SI_UID_T
#define __ARCH_SI_UID_T uid_t
#endif
#ifndef __ARCH_SI_BAND_T
#define __ARCH_SI_BAND_T long
#endif
typedef struct siginfo_portable {
int si_signo;
int si_errno;
int si_code;
union {
int _pad[SI_PAD_SIZE];
struct {
pid_t _pid;
__ARCH_SI_UID_T _uid;
} _kill;
struct {
timer_t _tid;
int _overrun;
char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
sigval_portable_t _sigval;
int _sys_private;
} _timer;
struct {
pid_t _pid;
__ARCH_SI_UID_T _uid;
sigval_t _sigval;
} _rt;
struct {
pid_t _pid;
__ARCH_SI_UID_T _uid;
int _status;
clock_t _utime;
clock_t _stime;
} _sigchld;
struct {
void __user *_addr;
#ifdef __ARCH_SI_TRAPNO
int _trapno;
#endif
} _sigfault;
struct {
__ARCH_SI_BAND_T _band;
int _fd;
} _sigpoll;
} _sifields;
} siginfo_portable_t;
#ifndef si_pid
#define si_pid _sifields._kill._pid
#define si_uid _sifields._kill._uid
#define si_tid _sifields._timer._tid
#define si_overrun _sifields._timer._overrun
#define si_sys_private _sifields._timer._sys_private
#define si_status _sifields._sigchld._status
#define si_utime _sifields._sigchld._utime
#define si_stime _sifields._sigchld._stime
#define si_value _sifields._rt._sigval
#define si_int _sifields._rt._sigval.sival_int
#define si_ptr _sifields._rt._sigval.sival_ptr
#define si_addr _sifields._sigfault._addr
#ifdef __ARCH_SI_TRAPNO
#define si_trapno _sifields._sigfault._trapno
#endif
#define si_band _sifields._sigpoll._band
#define si_fd _sifields._sigpoll._fd
#endif
#ifndef __SI_KILL
#define __SI_KILL 0
#define __SI_TIMER 0
#define __SI_POLL 0
#define __SI_FAULT 0
#define __SI_CHLD 0
#define __SI_RT 0
#define __SI_MESGQ 0
#define __SI_CODE(T,N) (N)
#endif
#ifndef SI_USER
#define SI_USER 0
#define SI_KERNEL 0x80
#define SI_QUEUE -1
#define SI_TIMER __SI_CODE(__SI_TIMER,-2)
#define SI_MESGQ __SI_CODE(__SI_MESGQ,-3)
#define SI_ASYNCIO -4
#define SI_SIGIO -5
#define SI_TKILL -6
#define SI_DETHREAD -7
#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
#endif
#ifndef ILL_ILLOPC
#define ILL_ILLOPC (__SI_FAULT|1)
#define ILL_ILLOPN (__SI_FAULT|2)
#define ILL_ILLADR (__SI_FAULT|3)
#define ILL_ILLTRP (__SI_FAULT|4)
#define ILL_PRVOPC (__SI_FAULT|5)
#define ILL_PRVREG (__SI_FAULT|6)
#define ILL_COPROC (__SI_FAULT|7)
#define ILL_BADSTK (__SI_FAULT|8)
#define NSIGILL 8
#endif
#ifndef FPE_INTDIV
#define FPE_INTDIV (__SI_FAULT|1)
#define FPE_INTOVF (__SI_FAULT|2)
#define FPE_FLTDIV (__SI_FAULT|3)
#define FPE_FLTOVF (__SI_FAULT|4)
#define FPE_FLTUND (__SI_FAULT|5)
#define FPE_FLTRES (__SI_FAULT|6)
#define FPE_FLTINV (__SI_FAULT|7)
#define FPE_FLTSUB (__SI_FAULT|8)
#define NSIGFPE 8
#define SEGV_MAPERR (__SI_FAULT|1)
#define SEGV_ACCERR (__SI_FAULT|2)
#define NSIGSEGV 2
#define BUS_ADRALN (__SI_FAULT|1)
#define BUS_ADRERR (__SI_FAULT|2)
#define BUS_OBJERR (__SI_FAULT|3)
#define NSIGBUS 3
#define TRAP_BRKPT (__SI_FAULT|1)
#define TRAP_TRACE (__SI_FAULT|2)
#define NSIGTRAP 2
#define CLD_EXITED (__SI_CHLD|1)
#define CLD_KILLED (__SI_CHLD|2)
#define CLD_DUMPED (__SI_CHLD|3)
#define CLD_TRAPPED (__SI_CHLD|4)
#define CLD_STOPPED (__SI_CHLD|5)
#define CLD_CONTINUED (__SI_CHLD|6)
#define NSIGCHLD 6
#define POLL_IN (__SI_POLL|1)
#define POLL_OUT (__SI_POLL|2)
#define POLL_MSG (__SI_POLL|3)
#define POLL_ERR (__SI_POLL|4)
#define POLL_PRI (__SI_POLL|5)
#define POLL_HUP (__SI_POLL|6)
#define NSIGPOLL 6
#define SIGEV_SIGNAL 0
#define SIGEV_NONE 1
#define SIGEV_THREAD 2
#define SIGEV_THREAD_ID 4
#endif /* FPE_INTDIV */
#ifndef __ARCH_SIGEV_PREAMBLE_SIZE
#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_portable_t))
#endif
#define SIGEV_MAX_SIZE 64
#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) / sizeof(int))
typedef struct sigevent_portable {
sigval_portable_t sigev_value;
int sigev_signo;
int sigev_notify;
union {
int _pad[SIGEV_PAD_SIZE];
int _tid;
struct {
void (*_function)(sigval_portable_t);
void *_attribute;
} _sigev_thread;
} _sigev_un;
} sigevent_portable_t;
#define sigev_notify_function _sigev_un._sigev_thread._function
#define sigev_notify_attributes _sigev_un._sigev_thread._attribute
#define sigev_notify_thread_id _sigev_un._tid
#endif

View File

@@ -0,0 +1,21 @@
/****************************************************************************
Derived from platforms/android-14/arch-arm/usr/include/asm-generic/signal.h
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_GENERIC_SIGNAL_PORTABLE_H
#define __ASM_GENERIC_SIGNAL_PORTABLE_H
#define SIG_BLOCK_PORTABLE 0
#define SIG_UNBLOCK_PORTABLE 1
#define SIG_SETMASK_PORTABLE 2
#endif

View File

@@ -0,0 +1,40 @@
/****************************************************************************
Derived from gdk/platforms/android-14/arch-arm/usr/include/asm/sigcontext.h
****************************************************************************
***
*** This header was ORIGINALLY automatically generated from a Linux kernel
*** header of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef _ASMARM_SIGCONTEXT_PORTABLE_H
#define _ASMARM_SIGCONTEXT_PORTABLE_H
struct sigcontext_portable {
unsigned long trap_no;
unsigned long error_code;
unsigned long oldmask;
unsigned long arm_r0;
unsigned long arm_r1;
unsigned long arm_r2;
unsigned long arm_r3;
unsigned long arm_r4;
unsigned long arm_r5;
unsigned long arm_r6;
unsigned long arm_r7;
unsigned long arm_r8;
unsigned long arm_r9;
unsigned long arm_r10;
unsigned long arm_fp;
unsigned long arm_ip;
unsigned long arm_sp;
unsigned long arm_lr;
unsigned long arm_pc;
unsigned long arm_cpsr;
unsigned long fault_address;
};
#endif

View File

@@ -0,0 +1,17 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef _ASM_PORTABLE_SIGINFO_H
#define _ASM_PORTABLE_SIGINFO_H
#include <asm-generic/siginfo_portable.h>
#endif

View File

@@ -0,0 +1,99 @@
/****************************************************************************
Derived from gdk/platforms/android-14/arch-arm/usr/include/asm/signal.h
****************************************************************************
***
*** This header was ORIGINALLY automatically generated from a Linux kernel
*** header of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef _ASMARM_SIGNAL_PORTABLE_H
#define _ASMARM_SIGNAL_PORTABLE_H
struct siginfo; /* TODO: Change to siginfo_portable */
#define NSIG_PORTABLE 32
typedef unsigned long sigset_portable_t;
#define SIGHUP_PORTABLE 1
#define SIGINT_PORTABLE 2
#define SIGQUIT_PORTABLE 3
#define SIGILL_PORTABLE 4
#define SIGTRAP_PORTABLE 5
#define SIGABRT_PORTABLE 6
#define SIGIOT_PORTABLE 6
#define SIGBUS_PORTABLE 7
#define SIGFPE_PORTABLE 8
#define SIGKILL_PORTABLE 9
#define SIGUSR1_PORTABLE 10
#define SIGSEGV_PORTABLE 11
#define SIGUSR2_PORTABLE 12
#define SIGPIPE_PORTABLE 13
#define SIGALRM_PORTABLE 14
#define SIGTERM_PORTABLE 15
#define SIGSTKFLT_PORTABLE 16
#define SIGCHLD_PORTABLE 17
#define SIGCONT_PORTABLE 18
#define SIGSTOP_PORTABLE 19
#define SIGTSTP_PORTABLE 20
#define SIGTTIN_PORTABLE 21
#define SIGTTOU_PORTABLE 22
#define SIGURG_PORTABLE 23
#define SIGXCPU_PORTABLE 24
#define SIGXFSZ_PORTABLE 25
#define SIGVTALRM_PORTABLE 26
#define SIGPROF_PORTABLE 27
#define SIGWINCH_PORTABLE 28
#define SIGIO_PORTABLE 29
#define SIGPOLL_PORTABLE SIGIO
#define SIGPWR_PORTABLE 30
#define SIGSYS_PORTABLE 31
#define SIGUNUSED_PORTABLE 31
#define SIGRTMIN_PORTABLE 32
#define SIGRTMAX_PORTABLE _NSIG_PORTABLE
#define SIGSWI_PORTABLE 32
#define SA_NOCLDSTOP_PORTABLE 0x00000001
#define SA_NOCLDWAIT_PORTABLE 0x00000002
#define SA_SIGINFO_PORTABLE 0x00000004
#define SA_THIRTYTWO_PORTABLE 0x02000000
#define SA_RESTORER_PORTABLE 0x04000000
#define SA_ONSTACK_PORTABLE 0x08000000
#define SA_RESTART_PORTABLE 0x10000000
#define SA_NODEFER_PORTABLE 0x40000000
#define SA_RESETHAND_PORTABLE 0x80000000
#define SA_NOMASK_PORTSBLE SA_NODEFER_PORTABLE
#define SA_ONESHOT_PORTABLE SA_RESETHAND_PORABLE
#include <asm-generic/signal_portable.h>
typedef __signalfn_t __user *__sighandler_portable_t;
typedef void (*__sigaction_handler_portable_t)(int, struct siginfo *, void *);
struct sigaction_portable {
union {
__sighandler_portable_t _sa_handler;
__sigaction_handler_portable_t _sa_sigaction;
} _u;
sigset_portable_t sa_mask;
unsigned long sa_flags;
void (*sa_restorer)(void);
};
#define sa_handler_portable _u._sa_handler
#define sa_sigaction_portable _u._sa_sigaction
typedef struct sigaltstack_portable {
void __user *ss_sp;
int ss_flags;
size_t ss_size;
} portable_stack_t;
#endif

View File

@@ -0,0 +1,148 @@
/*
* Derived from gdk/platforms/android-14/arch-arm/usr/include/signal.h
*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _SIGNAL_PORTABLE_H_
#define _SIGNAL_PORTABLE_H_
#include <portability.h>
#include <sys/cdefs.h>
#include <limits.h> /* For LONG_BIT */
#include <string.h> /* For memset() */
#include <sys/types.h>
#include <asm/signal_portable.h>
#include <asm/sigcontext_portable.h>
#define __ARCH_SI_UID_T __kernel_uid32_t
#include <asm/siginfo_portable.h>
#undef __ARCH_SI_UID_T
__BEGIN_DECLS
typedef int sig_atomic_t;
#if 0
/* _NSIG is used by the SIGRTMAX definition under <asm/signal.h>, however
* its definition is part of a #if __KERNEL__ .. #endif block in the original
* kernel headers and is thus not part of our cleaned-up versions.
*
* Looking at the current kernel sources, it is defined as 64 for all
* architectures except for the 'mips' one which set it to 128.
*/
#ifndef _NSIG_PORTABLE
# define _NSIG_PORTABLE 64
#endif
#endif
extern const char * const sys_siglist[];
extern const char * const sys_signame[];
static __inline__ int sigismember_portable(sigset_portable_t *set, int signum)
{
unsigned long *local_set = (unsigned long *)set;
signum--;
return (int)((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1);
}
static __inline__ int sigaddset_portable(sigset_portable_t *set, int signum)
{
unsigned long *local_set = (unsigned long *)set;
signum--;
local_set[signum/LONG_BIT] |= 1UL << (signum%LONG_BIT);
return 0;
}
static __inline__ int sigdelset_portable(sigset_portable_t *set, int signum)
{
unsigned long *local_set = (unsigned long *)set;
signum--;
local_set[signum/LONG_BIT] &= ~(1UL << (signum%LONG_BIT));
return 0;
}
static __inline__ int sigemptyset_portable(sigset_portable_t *set)
{
memset(set, 0, sizeof *set);
return 0;
}
static __inline__ int sigfillset_portable(sigset_portable_t *set)
{
memset(set, ~0, sizeof *set);
return 0;
}
/* compatibility types */
typedef void (*sig_portable_t)(int);
typedef sig_portable_t sighandler_portable_t;
/* Extended compatibility types, for processing a siginfo_t argument */
typedef void (*sig3_portable_t)(int, siginfo_portable_t *, void *);
typedef sig3_portable_t sig3handler_portable_t;
/* differentiater between sysv and bsd behaviour 8*/
extern __sighandler_t sysv_signal(int, __sighandler_portable_t);
extern __sighandler_t bsd_signal(int, __sighandler_portable_t);
#if 0
/* the default is bsd */
static __inline__ __sighandler_portable_t signal_portable(int s, sighandler_portable_t f)
{
return bsd_signal(s,f);
}
#endif
/* the portable mapped syscall itself */
extern __sighandler_portable_t __signal_portable(int, __sighandler_portable_t);
extern 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 sigpending_portable(sigset_portable_t *);
extern int sigsuspend_portable(const sigset_portable_t *);
extern int sigwait_portable(const sigset_portable_t *set, int *sig);
extern int siginterrupt_portable(int sig, int flag);
extern int raise_portable(int);
extern int kill_portable(pid_t, int);
extern int killpg_portable(int pgrp, int sig);
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_mips_signum_to_name(int mips_signum);
extern __hidden int map_portable_signum_to_mips(int portable_signum);
extern __hidden int map_mips_signum_to_portable(int mips_signum);
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);
__END_DECLS
#endif /* _SIGNAL_PORTABLE_H_ */