Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] uml: Turn literal numbers into symbolic constants

So, there I was, looking at my own code, wondering what the magic setjmp
return values did. This patch turns the constants that are used to make
requests of the initial thread into meaningful symbols.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jeff Dike and committed by
Linus Torvalds
675dffc9 37f02b63

+22 -13
+22 -13
arch/um/kernel/skas/process.c
··· 201 201 } 202 202 } 203 203 } 204 + #define INIT_JMP_NEW_THREAD 0 205 + #define INIT_JMP_REMOVE_SIGSTACK 1 206 + #define INIT_JMP_CALLBACK 2 207 + #define INIT_JMP_HALT 3 208 + #define INIT_JMP_REBOOT 4 204 209 205 210 void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, 206 211 void (*handler)(int)) ··· 241 236 *switch_buf = &buf; 242 237 fork_buf = fb; 243 238 if(sigsetjmp(buf, 1) == 0) 244 - siglongjmp(*fork_buf, 1); 239 + siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK); 245 240 } 246 241 247 242 void switch_threads(void *me, void *next) ··· 271 266 272 267 *fork_buf_ptr = &initial_jmpbuf; 273 268 n = sigsetjmp(initial_jmpbuf, 1); 274 - if(n == 0) 275 - new_thread_proc((void *) stack, new_thread_handler); 276 - else if(n == 1) 277 - remove_sigstack(); 278 - else if(n == 2){ 269 + switch(n){ 270 + case INIT_JMP_NEW_THREAD: 271 + new_thread_proc((void *) stack, new_thread_handler); 272 + break; 273 + case INIT_JMP_REMOVE_SIGSTACK: 274 + remove_sigstack(); 275 + break; 276 + case INIT_JMP_CALLBACK: 279 277 (*cb_proc)(cb_arg); 280 278 siglongjmp(*cb_back, 1); 281 - } 282 - else if(n == 3){ 279 + break; 280 + case INIT_JMP_HALT: 283 281 kmalloc_ok = 0; 284 282 return(0); 285 - } 286 - else if(n == 4){ 283 + case INIT_JMP_REBOOT: 287 284 kmalloc_ok = 0; 288 285 return(1); 286 + default: 287 + panic("Bad sigsetjmp return in start_idle_thread - %d\n", n); 289 288 } 290 289 siglongjmp(**switch_buf, 1); 291 290 } ··· 314 305 315 306 block_signals(); 316 307 if(sigsetjmp(here, 1) == 0) 317 - siglongjmp(initial_jmpbuf, 2); 308 + siglongjmp(initial_jmpbuf, INIT_JMP_CALLBACK); 318 309 unblock_signals(); 319 310 320 311 cb_proc = NULL; ··· 325 316 void halt_skas(void) 326 317 { 327 318 block_signals(); 328 - siglongjmp(initial_jmpbuf, 3); 319 + siglongjmp(initial_jmpbuf, INIT_JMP_HALT); 329 320 } 330 321 331 322 void reboot_skas(void) 332 323 { 333 324 block_signals(); 334 - siglongjmp(initial_jmpbuf, 4); 325 + siglongjmp(initial_jmpbuf, INIT_JMP_REBOOT); 335 326 } 336 327 337 328 void switch_mm_skas(int mm_fd)