aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/process.c
diff options
context:
space:
mode:
authorGennady Sharapov <gennady.v.sharapov@intel.com>2005-09-03 18:57:47 -0400
committerLinus Torvalds <torvalds@evo.osdl.org>2005-09-05 03:06:24 -0400
commit60d339f6fe0831060600c62418b71a62ad26c281 (patch)
treea2f9527bbcfe85b3eb7c063b8af7d2f499ba4cbb /arch/um/os-Linux/process.c
parent09ace81c1d737bcbb2423db235ac980cac4d5de9 (diff)
[PATCH] uml: move libc-dependent startup and signal code
The serial UML OS-abstraction layer patch (um/kernel dir). This moves all systemcalls from process.c file under os-Linux dir and join process.c and process_kern.c files. Signed-off-by: Gennady Sharapov <gennady.v.sharapov@intel.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux/process.c')
-rw-r--r--arch/um/os-Linux/process.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
index 1e126bfd31a7..d32413e4b4ce 100644
--- a/arch/um/os-Linux/process.c
+++ b/arch/um/os-Linux/process.c
@@ -3,10 +3,10 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <unistd.h>
7#include <stdio.h> 6#include <stdio.h>
8#include <errno.h> 7#include <errno.h>
9#include <signal.h> 8#include <signal.h>
9#include <setjmp.h>
10#include <linux/unistd.h> 10#include <linux/unistd.h>
11#include <sys/mman.h> 11#include <sys/mman.h>
12#include <sys/wait.h> 12#include <sys/wait.h>
@@ -14,6 +14,10 @@
14#include "os.h" 14#include "os.h"
15#include "user.h" 15#include "user.h"
16#include "user_util.h" 16#include "user_util.h"
17#include "signal_user.h"
18#include "process.h"
19#include "irq_user.h"
20#include "kern_util.h"
17 21
18#define ARBITRARY_ADDR -1 22#define ARBITRARY_ADDR -1
19#define FAILURE_PID -1 23#define FAILURE_PID -1
@@ -114,8 +118,10 @@ void os_usr1_process(int pid)
114 kill(pid, SIGUSR1); 118 kill(pid, SIGUSR1);
115} 119}
116 120
117/*Don't use the glibc version, which caches the result in TLS. It misses some 121/* Don't use the glibc version, which caches the result in TLS. It misses some
118 * syscalls, and also breaks with clone(), which does not unshare the TLS.*/ 122 * syscalls, and also breaks with clone(), which does not unshare the TLS.
123 */
124
119inline _syscall0(pid_t, getpid) 125inline _syscall0(pid_t, getpid)
120 126
121int os_getpid(void) 127int os_getpid(void)
@@ -164,6 +170,52 @@ int os_unmap_memory(void *addr, int len)
164 return(0); 170 return(0);
165} 171}
166 172
173void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
174{
175 int flags = 0, pages;
176
177 if(sig_stack != NULL){
178 pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER);
179 set_sigstack(sig_stack, pages * page_size());
180 flags = SA_ONSTACK;
181 }
182 if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1);
183}
184
185void init_new_thread_signals(int altstack)
186{
187 int flags = altstack ? SA_ONSTACK : 0;
188
189 set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags,
190 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
191 set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags,
192 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
193 set_handler(SIGFPE, (__sighandler_t) sig_handler, flags,
194 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
195 set_handler(SIGILL, (__sighandler_t) sig_handler, flags,
196 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
197 set_handler(SIGBUS, (__sighandler_t) sig_handler, flags,
198 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
199 set_handler(SIGUSR2, (__sighandler_t) sig_handler,
200 flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
201 signal(SIGHUP, SIG_IGN);
202
203 init_irq_signals(altstack);
204}
205
206int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
207{
208 sigjmp_buf buf;
209 int n;
210
211 *jmp_ptr = &buf;
212 n = sigsetjmp(buf, 1);
213 if(n != 0)
214 return(n);
215 (*fn)(arg);
216 return(0);
217}
218
167/* 219/*
168 * Overrides for Emacs so that we follow Linus's tabbing style. 220 * Overrides for Emacs so that we follow Linus's tabbing style.
169 * Emacs will notice this stuff at the end of the file and automatically 221 * Emacs will notice this stuff at the end of the file and automatically