diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:05 -0400 |
commit | ba180fd437156f7fd8cfb2fdd021d949eeef08d6 (patch) | |
tree | b9f38b9cdd7a5b1aacf00341d1948314663c5871 /arch/um/os-Linux/signal.c | |
parent | 77bf4400319db9d2a8af6b00c2be6faa0f3d07cb (diff) |
uml: style fixes pass 3
Formatting changes in the files which have been changed in the course
of folding foo_skas functions into their callers. These include:
copyright updates
header file trimming
style fixes
adding severity to printks
These changes should be entirely non-functional.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/os-Linux/signal.c')
-rw-r--r-- | arch/um/os-Linux/signal.c | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 583424b9797d..49c113b576b7 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c | |||
@@ -1,24 +1,21 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2004 PathScale, Inc | 2 | * Copyright (C) 2004 PathScale, Inc |
3 | * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | 4 | * Licensed under the GPL |
4 | */ | 5 | */ |
5 | 6 | ||
6 | #include <signal.h> | ||
7 | #include <stdio.h> | ||
8 | #include <unistd.h> | ||
9 | #include <stdlib.h> | 7 | #include <stdlib.h> |
10 | #include <errno.h> | ||
11 | #include <stdarg.h> | 8 | #include <stdarg.h> |
12 | #include <string.h> | 9 | #include <errno.h> |
13 | #include <sys/mman.h> | 10 | #include <signal.h> |
14 | #include "user.h" | 11 | #include <strings.h> |
15 | #include "signal_kern.h" | ||
16 | #include "sysdep/sigcontext.h" | ||
17 | #include "sysdep/barrier.h" | ||
18 | #include "sigcontext.h" | ||
19 | #include "os.h" | 12 | #include "os.h" |
13 | #include "sysdep/barrier.h" | ||
14 | #include "sysdep/sigcontext.h" | ||
15 | #include "user.h" | ||
20 | 16 | ||
21 | /* These are the asynchronous signals. SIGVTALRM and SIGARLM are handled | 17 | /* |
18 | * These are the asynchronous signals. SIGVTALRM and SIGARLM are handled | ||
22 | * together under SIGVTALRM_BIT. SIGPROF is excluded because we want to | 19 | * together under SIGVTALRM_BIT. SIGPROF is excluded because we want to |
23 | * be able to profile all of UML, not just the non-critical sections. If | 20 | * be able to profile all of UML, not just the non-critical sections. If |
24 | * profiling is not thread-safe, then that is not my problem. We can disable | 21 | * profiling is not thread-safe, then that is not my problem. We can disable |
@@ -33,7 +30,8 @@ | |||
33 | #define SIGALRM_BIT 2 | 30 | #define SIGALRM_BIT 2 |
34 | #define SIGALRM_MASK (1 << SIGALRM_BIT) | 31 | #define SIGALRM_MASK (1 << SIGALRM_BIT) |
35 | 32 | ||
36 | /* These are used by both the signal handlers and | 33 | /* |
34 | * These are used by both the signal handlers and | ||
37 | * block/unblock_signals. I don't want modifications cached in a | 35 | * block/unblock_signals. I don't want modifications cached in a |
38 | * register - they must go straight to memory. | 36 | * register - they must go straight to memory. |
39 | */ | 37 | */ |
@@ -45,7 +43,7 @@ void sig_handler(int sig, struct sigcontext *sc) | |||
45 | int enabled; | 43 | int enabled; |
46 | 44 | ||
47 | enabled = signals_enabled; | 45 | enabled = signals_enabled; |
48 | if(!enabled && (sig == SIGIO)){ | 46 | if (!enabled && (sig == SIGIO)) { |
49 | pending |= SIGIO_MASK; | 47 | pending |= SIGIO_MASK; |
50 | return; | 48 | return; |
51 | } | 49 | } |
@@ -61,16 +59,16 @@ static void real_alarm_handler(int sig, struct sigcontext *sc) | |||
61 | { | 59 | { |
62 | struct uml_pt_regs regs; | 60 | struct uml_pt_regs regs; |
63 | 61 | ||
64 | if(sig == SIGALRM) | 62 | if (sig == SIGALRM) |
65 | switch_timers(0); | 63 | switch_timers(0); |
66 | 64 | ||
67 | if(sc != NULL) | 65 | if (sc != NULL) |
68 | copy_sc(®s, sc); | 66 | copy_sc(®s, sc); |
69 | regs.is_user = 0; | 67 | regs.is_user = 0; |
70 | unblock_signals(); | 68 | unblock_signals(); |
71 | timer_handler(sig, ®s); | 69 | timer_handler(sig, ®s); |
72 | 70 | ||
73 | if(sig == SIGALRM) | 71 | if (sig == SIGALRM) |
74 | switch_timers(1); | 72 | switch_timers(1); |
75 | } | 73 | } |
76 | 74 | ||
@@ -79,8 +77,8 @@ void alarm_handler(int sig, struct sigcontext *sc) | |||
79 | int enabled; | 77 | int enabled; |
80 | 78 | ||
81 | enabled = signals_enabled; | 79 | enabled = signals_enabled; |
82 | if(!signals_enabled){ | 80 | if (!signals_enabled) { |
83 | if(sig == SIGVTALRM) | 81 | if (sig == SIGVTALRM) |
84 | pending |= SIGVTALRM_MASK; | 82 | pending |= SIGVTALRM_MASK; |
85 | else pending |= SIGALRM_MASK; | 83 | else pending |= SIGALRM_MASK; |
86 | 84 | ||
@@ -99,7 +97,7 @@ void set_sigstack(void *sig_stack, int size) | |||
99 | .ss_sp = (__ptr_t) sig_stack, | 97 | .ss_sp = (__ptr_t) sig_stack, |
100 | .ss_size = size - sizeof(void *) }); | 98 | .ss_size = size - sizeof(void *) }); |
101 | 99 | ||
102 | if(sigaltstack(&stack, NULL) != 0) | 100 | if (sigaltstack(&stack, NULL) != 0) |
103 | panic("enabling signal stack failed, errno = %d\n", errno); | 101 | panic("enabling signal stack failed, errno = %d\n", errno); |
104 | } | 102 | } |
105 | 103 | ||
@@ -109,7 +107,7 @@ void remove_sigstack(void) | |||
109 | .ss_sp = NULL, | 107 | .ss_sp = NULL, |
110 | .ss_size = 0 }); | 108 | .ss_size = 0 }); |
111 | 109 | ||
112 | if(sigaltstack(&stack, NULL) != 0) | 110 | if (sigaltstack(&stack, NULL) != 0) |
113 | panic("disabling signal stack failed, errno = %d\n", errno); | 111 | panic("disabling signal stack failed, errno = %d\n", errno); |
114 | } | 112 | } |
115 | 113 | ||
@@ -133,26 +131,27 @@ void handle_signal(int sig, struct sigcontext *sc) | |||
133 | * with this interrupt. | 131 | * with this interrupt. |
134 | */ | 132 | */ |
135 | bail = to_irq_stack(&pending); | 133 | bail = to_irq_stack(&pending); |
136 | if(bail) | 134 | if (bail) |
137 | return; | 135 | return; |
138 | 136 | ||
139 | nested = pending & 1; | 137 | nested = pending & 1; |
140 | pending &= ~1; | 138 | pending &= ~1; |
141 | 139 | ||
142 | while((sig = ffs(pending)) != 0){ | 140 | while ((sig = ffs(pending)) != 0){ |
143 | sig--; | 141 | sig--; |
144 | pending &= ~(1 << sig); | 142 | pending &= ~(1 << sig); |
145 | (*handlers[sig])(sig, sc); | 143 | (*handlers[sig])(sig, sc); |
146 | } | 144 | } |
147 | 145 | ||
148 | /* Again, pending comes back with a mask of signals | 146 | /* |
147 | * Again, pending comes back with a mask of signals | ||
149 | * that arrived while tearing down the stack. If this | 148 | * that arrived while tearing down the stack. If this |
150 | * is non-zero, we just go back, set up the stack | 149 | * is non-zero, we just go back, set up the stack |
151 | * again, and handle the new interrupts. | 150 | * again, and handle the new interrupts. |
152 | */ | 151 | */ |
153 | if(!nested) | 152 | if (!nested) |
154 | pending = from_irq_stack(nested); | 153 | pending = from_irq_stack(nested); |
155 | } while(pending); | 154 | } while (pending); |
156 | } | 155 | } |
157 | 156 | ||
158 | extern void hard_handler(int sig); | 157 | extern void hard_handler(int sig); |
@@ -170,18 +169,18 @@ void set_handler(int sig, void (*handler)(int), int flags, ...) | |||
170 | sigemptyset(&action.sa_mask); | 169 | sigemptyset(&action.sa_mask); |
171 | 170 | ||
172 | va_start(ap, flags); | 171 | va_start(ap, flags); |
173 | while((mask = va_arg(ap, int)) != -1) | 172 | while ((mask = va_arg(ap, int)) != -1) |
174 | sigaddset(&action.sa_mask, mask); | 173 | sigaddset(&action.sa_mask, mask); |
175 | va_end(ap); | 174 | va_end(ap); |
176 | 175 | ||
177 | action.sa_flags = flags; | 176 | action.sa_flags = flags; |
178 | action.sa_restorer = NULL; | 177 | action.sa_restorer = NULL; |
179 | if(sigaction(sig, &action, NULL) < 0) | 178 | if (sigaction(sig, &action, NULL) < 0) |
180 | panic("sigaction failed - errno = %d\n", errno); | 179 | panic("sigaction failed - errno = %d\n", errno); |
181 | 180 | ||
182 | sigemptyset(&sig_mask); | 181 | sigemptyset(&sig_mask); |
183 | sigaddset(&sig_mask, sig); | 182 | sigaddset(&sig_mask, sig); |
184 | if(sigprocmask(SIG_UNBLOCK, &sig_mask, NULL) < 0) | 183 | if (sigprocmask(SIG_UNBLOCK, &sig_mask, NULL) < 0) |
185 | panic("sigprocmask failed - errno = %d\n", errno); | 184 | panic("sigprocmask failed - errno = %d\n", errno); |
186 | } | 185 | } |
187 | 186 | ||
@@ -192,13 +191,14 @@ int change_sig(int signal, int on) | |||
192 | sigemptyset(&sigset); | 191 | sigemptyset(&sigset); |
193 | sigaddset(&sigset, signal); | 192 | sigaddset(&sigset, signal); |
194 | sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old); | 193 | sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old); |
195 | return(!sigismember(&old, signal)); | 194 | return !sigismember(&old, signal); |
196 | } | 195 | } |
197 | 196 | ||
198 | void block_signals(void) | 197 | void block_signals(void) |
199 | { | 198 | { |
200 | signals_enabled = 0; | 199 | signals_enabled = 0; |
201 | /* This must return with signals disabled, so this barrier | 200 | /* |
201 | * This must return with signals disabled, so this barrier | ||
202 | * ensures that writes are flushed out before the return. | 202 | * ensures that writes are flushed out before the return. |
203 | * This might matter if gcc figures out how to inline this and | 203 | * This might matter if gcc figures out how to inline this and |
204 | * decides to shuffle this code into the caller. | 204 | * decides to shuffle this code into the caller. |
@@ -210,27 +210,31 @@ void unblock_signals(void) | |||
210 | { | 210 | { |
211 | int save_pending; | 211 | int save_pending; |
212 | 212 | ||
213 | if(signals_enabled == 1) | 213 | if (signals_enabled == 1) |
214 | return; | 214 | return; |
215 | 215 | ||
216 | /* We loop because the IRQ handler returns with interrupts off. So, | 216 | /* |
217 | * We loop because the IRQ handler returns with interrupts off. So, | ||
217 | * interrupts may have arrived and we need to re-enable them and | 218 | * interrupts may have arrived and we need to re-enable them and |
218 | * recheck pending. | 219 | * recheck pending. |
219 | */ | 220 | */ |
220 | while(1){ | 221 | while(1) { |
221 | /* Save and reset save_pending after enabling signals. This | 222 | /* |
223 | * Save and reset save_pending after enabling signals. This | ||
222 | * way, pending won't be changed while we're reading it. | 224 | * way, pending won't be changed while we're reading it. |
223 | */ | 225 | */ |
224 | signals_enabled = 1; | 226 | signals_enabled = 1; |
225 | 227 | ||
226 | /* Setting signals_enabled and reading pending must | 228 | /* |
229 | * Setting signals_enabled and reading pending must | ||
227 | * happen in this order. | 230 | * happen in this order. |
228 | */ | 231 | */ |
229 | mb(); | 232 | mb(); |
230 | 233 | ||
231 | save_pending = pending; | 234 | save_pending = pending; |
232 | if(save_pending == 0){ | 235 | if (save_pending == 0) { |
233 | /* This must return with signals enabled, so | 236 | /* |
237 | * This must return with signals enabled, so | ||
234 | * this barrier ensures that writes are | 238 | * this barrier ensures that writes are |
235 | * flushed out before the return. This might | 239 | * flushed out before the return. This might |
236 | * matter if gcc figures out how to inline | 240 | * matter if gcc figures out how to inline |
@@ -243,24 +247,26 @@ void unblock_signals(void) | |||
243 | 247 | ||
244 | pending = 0; | 248 | pending = 0; |
245 | 249 | ||
246 | /* We have pending interrupts, so disable signals, as the | 250 | /* |
251 | * We have pending interrupts, so disable signals, as the | ||
247 | * handlers expect them off when they are called. They will | 252 | * handlers expect them off when they are called. They will |
248 | * be enabled again above. | 253 | * be enabled again above. |
249 | */ | 254 | */ |
250 | 255 | ||
251 | signals_enabled = 0; | 256 | signals_enabled = 0; |
252 | 257 | ||
253 | /* Deal with SIGIO first because the alarm handler might | 258 | /* |
259 | * Deal with SIGIO first because the alarm handler might | ||
254 | * schedule, leaving the pending SIGIO stranded until we come | 260 | * schedule, leaving the pending SIGIO stranded until we come |
255 | * back here. | 261 | * back here. |
256 | */ | 262 | */ |
257 | if(save_pending & SIGIO_MASK) | 263 | if (save_pending & SIGIO_MASK) |
258 | sig_handler_common_skas(SIGIO, NULL); | 264 | sig_handler_common_skas(SIGIO, NULL); |
259 | 265 | ||
260 | if(save_pending & SIGALRM_MASK) | 266 | if (save_pending & SIGALRM_MASK) |
261 | real_alarm_handler(SIGALRM, NULL); | 267 | real_alarm_handler(SIGALRM, NULL); |
262 | 268 | ||
263 | if(save_pending & SIGVTALRM_MASK) | 269 | if (save_pending & SIGVTALRM_MASK) |
264 | real_alarm_handler(SIGVTALRM, NULL); | 270 | real_alarm_handler(SIGVTALRM, NULL); |
265 | } | 271 | } |
266 | } | 272 | } |
@@ -273,11 +279,11 @@ int get_signals(void) | |||
273 | int set_signals(int enable) | 279 | int set_signals(int enable) |
274 | { | 280 | { |
275 | int ret; | 281 | int ret; |
276 | if(signals_enabled == enable) | 282 | if (signals_enabled == enable) |
277 | return enable; | 283 | return enable; |
278 | 284 | ||
279 | ret = signals_enabled; | 285 | ret = signals_enabled; |
280 | if(enable) | 286 | if (enable) |
281 | unblock_signals(); | 287 | unblock_signals(); |
282 | else block_signals(); | 288 | else block_signals(); |
283 | 289 | ||