]> Pileus Git - ~andy/linux/blobdiff - arch/um/os-Linux/process.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[~andy/linux] / arch / um / os-Linux / process.c
index ba9ca1cc790a52d6f7940fc9515d77e471f39328..7f5e2dac2a35ddc3a14eee73613a17d2e9911269 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <signal.h>
+#include <setjmp.h>
 #include <linux/unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include "os.h"
 #include "user.h"
 #include "user_util.h"
+#include "process.h"
+#include "irq_user.h"
+#include "kern_util.h"
+#include "longjmp.h"
 
 #define ARBITRARY_ADDR -1
 #define FAILURE_PID    -1
@@ -114,8 +119,10 @@ void os_usr1_process(int pid)
        kill(pid, SIGUSR1);
 }
 
-/*Don't use the glibc version, which caches the result in TLS. It misses some
- * syscalls, and also breaks with clone(), which does not unshare the TLS.*/
+/* Don't use the glibc version, which caches the result in TLS. It misses some
+ * syscalls, and also breaks with clone(), which does not unshare the TLS.
+ */
+
 inline _syscall0(pid_t, getpid)
 
 int os_getpid(void)
@@ -123,6 +130,11 @@ int os_getpid(void)
        return(getpid());
 }
 
+int os_getpgrp(void)
+{
+       return getpgrp();
+}
+
 int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len,
                  int r, int w, int x)
 {
@@ -159,13 +171,48 @@ int os_unmap_memory(void *addr, int len)
         return(0);
 }
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
+{
+       int flags = 0, pages;
+
+       if(sig_stack != NULL){
+               pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER);
+               set_sigstack(sig_stack, pages * page_size());
+               flags = SA_ONSTACK;
+       }
+       if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1);
+}
+
+void init_new_thread_signals(int altstack)
+{
+       int flags = altstack ? SA_ONSTACK : 0;
+
+       set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGFPE, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGILL, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGBUS, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGUSR2, (__sighandler_t) sig_handler,
+                   flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       signal(SIGHUP, SIG_IGN);
+
+       init_irq_signals(altstack);
+}
+
+int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
+{
+       sigjmp_buf buf;
+       int n, enable;
+
+       *jmp_ptr = &buf;
+       n = UML_SIGSETJMP(&buf, enable);
+       if(n != 0)
+               return(n);
+       (*fn)(arg);
+       return(0);
+}