Commit f5545b5c3a734e28647c0b591addb66535d5490d

Authored by pbrook
1 parent e1e3f30b

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
Showing 1 changed file with 30 additions and 38 deletions
linux-user/signal.c
... ... @@ -125,30 +125,35 @@ int target_to_host_signal(int sig)
125 125 return target_to_host_signal_table[sig];
126 126 }
127 127  
  128 +static inline void target_sigemptyset(target_sigset_t *set)
  129 +{
  130 + memset(set, 0, sizeof(*set));
  131 +}
  132 +
  133 +static inline void target_sigaddset(target_sigset_t *set, int signum)
  134 +{
  135 + signum--;
  136 + abi_ulong mask = (abi_ulong)1 << (signum % TARGET_NSIG_BPW);
  137 + set->sig[signum / TARGET_NSIG_BPW] |= mask;
  138 +}
  139 +
  140 +static inline int target_sigismember(const target_sigset_t *set, int signum)
  141 +{
  142 + signum--;
  143 + abi_ulong mask = (abi_ulong)1 << (signum % TARGET_NSIG_BPW);
  144 + return ((set->sig[signum / TARGET_NSIG_BPW] & mask) != 0);
  145 +}
  146 +
128 147 static void host_to_target_sigset_internal(target_sigset_t *d,
129 148 const sigset_t *s)
130 149 {
131 150 int i;
132   - unsigned long sigmask;
133   - uint32_t target_sigmask;
134   -
135   - sigmask = ((unsigned long *)s)[0];
136   - target_sigmask = 0;
137   - for(i = 0; i < 32; i++) {
138   - if (sigmask & (1 << i))
139   - target_sigmask |= 1 << (host_to_target_signal(i + 1) - 1);
140   - }
141   -#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 32
142   - d->sig[0] = target_sigmask;
143   - for(i = 1;i < TARGET_NSIG_WORDS; i++) {
144   - d->sig[i] = ((unsigned long *)s)[i];
  151 + target_sigemptyset(d);
  152 + for (i = 1; i <= TARGET_NSIG; i++) {
  153 + if (sigismember(s, i)) {
  154 + target_sigaddset(d, host_to_target_signal(i));
  155 + }
145 156 }
146   -#elif TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 && TARGET_NSIG_WORDS == 2
147   - d->sig[0] = target_sigmask;
148   - d->sig[1] = sigmask >> 32;
149   -#else
150   - /* XXX: do it */
151   -#endif
152 157 }
153 158  
154 159 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)
164 169 void target_to_host_sigset_internal(sigset_t *d, const target_sigset_t *s)
165 170 {
166 171 int i;
167   - unsigned long sigmask;
168   - abi_ulong target_sigmask;
169   -
170   - target_sigmask = s->sig[0];
171   - sigmask = 0;
172   - for(i = 0; i < 32; i++) {
173   - if (target_sigmask & (1 << i))
174   - sigmask |= 1 << (target_to_host_signal(i + 1) - 1);
175   - }
176   -#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 32
177   - ((unsigned long *)d)[0] = sigmask;
178   - for(i = 1;i < TARGET_NSIG_WORDS; i++) {
179   - ((unsigned long *)d)[i] = s->sig[i];
180   - }
181   -#elif TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 && TARGET_NSIG_WORDS == 2
182   - ((unsigned long *)d)[0] = sigmask | ((unsigned long)(s->sig[1]) << 32);
183   -#else
184   - /* XXX: do it */
185   -#endif /* TARGET_ABI_BITS */
  172 + sigemptyset(d);
  173 + for (i = 1; i <= TARGET_NSIG; i++) {
  174 + if (target_sigismember(s, i)) {
  175 + sigaddset(d, target_to_host_signal(i));
  176 + }
  177 + }
186 178 }
187 179  
188 180 void target_to_host_sigset(sigset_t *d, const target_sigset_t *s)
... ...