提交 ad28e029 编写于 作者: J Jeff Dike 提交者: Linus Torvalds

[PATCH] uml: change sigjmp_buf to jmp_buf

Clean up the jmpbuf code.  Since softints, we no longer use sig_setjmp, so
the UML_SIGSETJMP wrapper now has a misleading name.  Also, I forgot to
change the buffers from sigjmp_buf to jmp_buf.
Signed-off-by: NJeff Dike <jdike@addtoit.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 4127272c
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
#include <setjmp.h> #include <setjmp.h>
#include "os.h" #include "os.h"
#define UML_SIGLONGJMP(buf, val) do { \ #define UML_LONGJMP(buf, val) do { \
longjmp(*buf, val); \ longjmp(*buf, val); \
} while(0) } while(0)
#define UML_SIGSETJMP(buf, enable) ({ \ #define UML_SETJMP(buf, enable) ({ \
int n; \ int n; \
enable = get_signals(); \ enable = get_signals(); \
n = setjmp(*buf); \ n = setjmp(*buf); \
......
...@@ -266,11 +266,11 @@ void init_new_thread_signals(int altstack) ...@@ -266,11 +266,11 @@ void init_new_thread_signals(int altstack)
int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr) int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
{ {
sigjmp_buf buf; jmp_buf buf;
int n, enable; int n, enable;
*jmp_ptr = &buf; *jmp_ptr = &buf;
n = UML_SIGSETJMP(&buf, enable); n = UML_SETJMP(&buf, enable);
if(n != 0) if(n != 0)
return(n); return(n);
(*fn)(arg); (*fn)(arg);
......
...@@ -434,7 +434,7 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, ...@@ -434,7 +434,7 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
void (*handler)(int)) void (*handler)(int))
{ {
unsigned long flags; unsigned long flags;
sigjmp_buf switch_buf, fork_buf; jmp_buf switch_buf, fork_buf;
int enable; int enable;
*switch_buf_ptr = &switch_buf; *switch_buf_ptr = &switch_buf;
...@@ -450,7 +450,7 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, ...@@ -450,7 +450,7 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
*/ */
flags = get_signals(); flags = get_signals();
block_signals(); block_signals();
if(UML_SIGSETJMP(&fork_buf, enable) == 0) if(UML_SETJMP(&fork_buf, enable) == 0)
new_thread_proc(stack, handler); new_thread_proc(stack, handler);
remove_sigstack(); remove_sigstack();
...@@ -466,35 +466,35 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, ...@@ -466,35 +466,35 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
void thread_wait(void *sw, void *fb) void thread_wait(void *sw, void *fb)
{ {
sigjmp_buf buf, **switch_buf = sw, *fork_buf; jmp_buf buf, **switch_buf = sw, *fork_buf;
int enable; int enable;
*switch_buf = &buf; *switch_buf = &buf;
fork_buf = fb; fork_buf = fb;
if(UML_SIGSETJMP(&buf, enable) == 0) if(UML_SETJMP(&buf, enable) == 0)
siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK); siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK);
} }
void switch_threads(void *me, void *next) void switch_threads(void *me, void *next)
{ {
sigjmp_buf my_buf, **me_ptr = me, *next_buf = next; jmp_buf my_buf, **me_ptr = me, *next_buf = next;
int enable; int enable;
*me_ptr = &my_buf; *me_ptr = &my_buf;
if(UML_SIGSETJMP(&my_buf, enable) == 0) if(UML_SETJMP(&my_buf, enable) == 0)
UML_SIGLONGJMP(next_buf, 1); UML_LONGJMP(next_buf, 1);
} }
static sigjmp_buf initial_jmpbuf; static jmp_buf initial_jmpbuf;
/* XXX Make these percpu */ /* XXX Make these percpu */
static void (*cb_proc)(void *arg); static void (*cb_proc)(void *arg);
static void *cb_arg; static void *cb_arg;
static sigjmp_buf *cb_back; static jmp_buf *cb_back;
int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
{ {
sigjmp_buf **switch_buf = switch_buf_ptr; jmp_buf **switch_buf = switch_buf_ptr;
int n, enable; int n, enable;
set_handler(SIGWINCH, (__sighandler_t) sig_handler, set_handler(SIGWINCH, (__sighandler_t) sig_handler,
...@@ -502,7 +502,7 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) ...@@ -502,7 +502,7 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
SIGVTALRM, -1); SIGVTALRM, -1);
*fork_buf_ptr = &initial_jmpbuf; *fork_buf_ptr = &initial_jmpbuf;
n = UML_SIGSETJMP(&initial_jmpbuf, enable); n = UML_SETJMP(&initial_jmpbuf, enable);
switch(n){ switch(n){
case INIT_JMP_NEW_THREAD: case INIT_JMP_NEW_THREAD:
new_thread_proc((void *) stack, new_thread_handler); new_thread_proc((void *) stack, new_thread_handler);
...@@ -512,7 +512,7 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) ...@@ -512,7 +512,7 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
break; break;
case INIT_JMP_CALLBACK: case INIT_JMP_CALLBACK:
(*cb_proc)(cb_arg); (*cb_proc)(cb_arg);
UML_SIGLONGJMP(cb_back, 1); UML_LONGJMP(cb_back, 1);
break; break;
case INIT_JMP_HALT: case INIT_JMP_HALT:
kmalloc_ok = 0; kmalloc_ok = 0;
...@@ -523,12 +523,12 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) ...@@ -523,12 +523,12 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
default: default:
panic("Bad sigsetjmp return in start_idle_thread - %d\n", n); panic("Bad sigsetjmp return in start_idle_thread - %d\n", n);
} }
UML_SIGLONGJMP(*switch_buf, 1); UML_LONGJMP(*switch_buf, 1);
} }
void initial_thread_cb_skas(void (*proc)(void *), void *arg) void initial_thread_cb_skas(void (*proc)(void *), void *arg)
{ {
sigjmp_buf here; jmp_buf here;
int enable; int enable;
cb_proc = proc; cb_proc = proc;
...@@ -536,8 +536,8 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg) ...@@ -536,8 +536,8 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
cb_back = &here; cb_back = &here;
block_signals(); block_signals();
if(UML_SIGSETJMP(&here, enable) == 0) if(UML_SETJMP(&here, enable) == 0)
UML_SIGLONGJMP(&initial_jmpbuf, INIT_JMP_CALLBACK); UML_LONGJMP(&initial_jmpbuf, INIT_JMP_CALLBACK);
unblock_signals(); unblock_signals();
cb_proc = NULL; cb_proc = NULL;
...@@ -548,13 +548,13 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg) ...@@ -548,13 +548,13 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
void halt_skas(void) void halt_skas(void)
{ {
block_signals(); block_signals();
UML_SIGLONGJMP(&initial_jmpbuf, INIT_JMP_HALT); UML_LONGJMP(&initial_jmpbuf, INIT_JMP_HALT);
} }
void reboot_skas(void) void reboot_skas(void)
{ {
block_signals(); block_signals();
UML_SIGLONGJMP(&initial_jmpbuf, INIT_JMP_REBOOT); UML_LONGJMP(&initial_jmpbuf, INIT_JMP_REBOOT);
} }
void switch_mm_skas(struct mm_id *mm_idp) void switch_mm_skas(struct mm_id *mm_idp)
......
...@@ -35,7 +35,7 @@ void os_fill_handlinfo(struct kern_handlers h) ...@@ -35,7 +35,7 @@ void os_fill_handlinfo(struct kern_handlers h)
void do_longjmp(void *b, int val) void do_longjmp(void *b, int val)
{ {
sigjmp_buf *buf = b; jmp_buf *buf = b;
UML_SIGLONGJMP(buf, val); UML_LONGJMP(buf, val);
} }
...@@ -16,9 +16,9 @@ unsigned long __do_user_copy(void *to, const void *from, int n, ...@@ -16,9 +16,9 @@ unsigned long __do_user_copy(void *to, const void *from, int n,
unsigned long *faddrp = (unsigned long *) fault_addr, ret; unsigned long *faddrp = (unsigned long *) fault_addr, ret;
int enable; int enable;
sigjmp_buf jbuf; jmp_buf jbuf;
*fault_catcher = &jbuf; *fault_catcher = &jbuf;
if(UML_SIGSETJMP(&jbuf, enable) == 0){ if(UML_SETJMP(&jbuf, enable) == 0){
(*op)(to, from, n); (*op)(to, from, n);
ret = 0; ret = 0;
*faulted_out = 0; *faulted_out = 0;
......
...@@ -104,7 +104,7 @@ void setup_hostinfo(void) ...@@ -104,7 +104,7 @@ void setup_hostinfo(void)
int setjmp_wrapper(void (*proc)(void *, void *), ...) int setjmp_wrapper(void (*proc)(void *, void *), ...)
{ {
va_list args; va_list args;
sigjmp_buf buf; jmp_buf buf;
int n; int n;
n = sigsetjmp(buf, 1); n = sigsetjmp(buf, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册