aboutsummaryrefslogtreecommitdiff
path: root/linux-user/signal.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-30 22:37:07 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-30 22:37:07 +0000
commitf5545b5c3a734e28647c0b591addb66535d5490d (patch)
tree4991d6c53d5beeb965c73f3bbaafe1e0a3aef404 /linux-user/signal.c
parente1e3f30b029aca17ea6c7c6d99e90a6ec3b07d01 (diff)
downloadqemu-f5545b5c3a734e28647c0b591addb66535d5490d.zip
qemu-f5545b5c3a734e28647c0b591addb66535d5490d.tar.gz
qemu-f5545b5c3a734e28647c0b591addb66535d5490d.tar.bz2
Translate whole of target_sigset. Use host sigset accessors.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4631 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user/signal.c')
-rw-r--r--linux-user/signal.c68
1 files changed, 30 insertions, 38 deletions
diff --git a/linux-user/signal.c b/linux-user/signal.c
index c3b0cde..f054907 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -125,30 +125,35 @@ int target_to_host_signal(int sig)
return target_to_host_signal_table[sig];
}
+static inline void target_sigemptyset(target_sigset_t *set)
+{
+ memset(set, 0, sizeof(*set));
+}
+
+static inline void target_sigaddset(target_sigset_t *set, int signum)
+{
+ signum--;
+ abi_ulong mask = (abi_ulong)1 << (signum % TARGET_NSIG_BPW);
+ set->sig[signum / TARGET_NSIG_BPW] |= mask;
+}
+
+static inline int target_sigismember(const target_sigset_t *set, int signum)
+{
+ signum--;
+ abi_ulong mask = (abi_ulong)1 << (signum % TARGET_NSIG_BPW);
+ return ((set->sig[signum / TARGET_NSIG_BPW] & mask) != 0);
+}
+
static void host_to_target_sigset_internal(target_sigset_t *d,
const sigset_t *s)
{
int i;
- unsigned long sigmask;
- uint32_t target_sigmask;
-
- sigmask = ((unsigned long *)s)[0];
- target_sigmask = 0;
- for(i = 0; i < 32; i++) {
- if (sigmask & (1 << i))
- target_sigmask |= 1 << (host_to_target_signal(i + 1) - 1);
- }
-#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 32
- d->sig[0] = target_sigmask;
- for(i = 1;i < TARGET_NSIG_WORDS; i++) {
- d->sig[i] = ((unsigned long *)s)[i];
+ target_sigemptyset(d);
+ for (i = 1; i <= TARGET_NSIG; i++) {
+ if (sigismember(s, i)) {
+ target_sigaddset(d, host_to_target_signal(i));
+ }
}
-#elif TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 && TARGET_NSIG_WORDS == 2
- d->sig[0] = target_sigmask;
- d->sig[1] = sigmask >> 32;
-#else
- /* XXX: do it */
-#endif
}
void host_to_target_sigset(target_sigset_t *d, const sigset_t *s)
@@ -164,25 +169,12 @@ void host_to_target_sigset(target_sigset_t *d, const sigset_t *s)
void target_to_host_sigset_internal(sigset_t *d, const target_sigset_t *s)
{
int i;
- unsigned long sigmask;
- abi_ulong target_sigmask;
-
- target_sigmask = s->sig[0];
- sigmask = 0;
- for(i = 0; i < 32; i++) {
- if (target_sigmask & (1 << i))
- sigmask |= 1 << (target_to_host_signal(i + 1) - 1);
- }
-#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 32
- ((unsigned long *)d)[0] = sigmask;
- for(i = 1;i < TARGET_NSIG_WORDS; i++) {
- ((unsigned long *)d)[i] = s->sig[i];
- }
-#elif TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 && TARGET_NSIG_WORDS == 2
- ((unsigned long *)d)[0] = sigmask | ((unsigned long)(s->sig[1]) << 32);
-#else
- /* XXX: do it */
-#endif /* TARGET_ABI_BITS */
+ sigemptyset(d);
+ for (i = 1; i <= TARGET_NSIG; i++) {
+ if (target_sigismember(s, i)) {
+ sigaddset(d, target_to_host_signal(i));
+ }
+ }
}
void target_to_host_sigset(sigset_t *d, const target_sigset_t *s)