qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [4631] Translate whole of target_sigset.
@ 2008-05-30 22:37 Paul Brook
  0 siblings, 0 replies; only message in thread
From: Paul Brook @ 2008-05-30 22:37 UTC (permalink / raw)
  To: qemu-devel

Revision: 4631
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4631
Author:   pbrook
Date:     2008-05-30 22:37:07 +0000 (Fri, 30 May 2008)

Log Message:
-----------
Translate whole of target_sigset.  Use host sigset accessors.

Modified Paths:
--------------
    trunk/linux-user/signal.c

Modified: trunk/linux-user/signal.c
===================================================================
--- trunk/linux-user/signal.c	2008-05-30 21:53:38 UTC (rev 4630)
+++ trunk/linux-user/signal.c	2008-05-30 22:37:07 UTC (rev 4631)
@@ -125,30 +125,35 @@
     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);
+    target_sigemptyset(d);
+    for (i = 1; i <= TARGET_NSIG; i++) {
+        if (sigismember(s, i)) {
+            target_sigaddset(d, host_to_target_signal(i));
+        }
     }
-#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];
-    }
-#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 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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-30 22:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-30 22:37 [Qemu-devel] [4631] Translate whole of target_sigset Paul Brook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).