]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
[PATCH] uml: move libc-dependent code from signal_user.c
authorGennady Sharapov <Gennady.V.Sharapov@intel.com>
Sun, 8 Jan 2006 09:01:29 +0000 (01:01 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 9 Jan 2006 04:13:39 +0000 (20:13 -0800)
The serial UML OS-abstraction layer patch (um/kernel dir).

This moves all systemcalls from signal_user.c file under os-Linux dir

Signed-off-by: Gennady Sharapov <Gennady.V.Sharapov@intel.com>
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>
24 files changed:
arch/um/include/kern_util.h
arch/um/include/os.h
arch/um/include/signal_user.h [deleted file]
arch/um/kernel/Makefile
arch/um/kernel/irq_user.c
arch/um/kernel/process_kern.c
arch/um/kernel/signal_kern.c
arch/um/kernel/signal_user.c [deleted file]
arch/um/kernel/skas/include/skas.h
arch/um/kernel/skas/process.c
arch/um/kernel/skas/process_kern.c
arch/um/kernel/skas/trap_user.c
arch/um/kernel/time.c
arch/um/kernel/trap_user.c
arch/um/kernel/tt/exec_kern.c
arch/um/kernel/tt/process_kern.c
arch/um/kernel/tt/tracer.c
arch/um/kernel/tt/trap_user.c
arch/um/os-Linux/main.c
arch/um/os-Linux/process.c
arch/um/os-Linux/signal.c
arch/um/os-Linux/start_up.c
arch/um/os-Linux/tt.c
arch/um/sys-i386/signal.c

index e5fec5570199851967a4d501aa683932c4164900..58c0b10fcf2ddbf2990956f3998c5bacce731221 100644 (file)
@@ -51,8 +51,6 @@ extern void timer_handler(int sig, union uml_pt_regs *regs);
 extern int set_signals(int enable);
 extern void force_sigbus(void);
 extern int pid_to_processor_id(int pid);
-extern void block_signals(void);
-extern void unblock_signals(void);
 extern void deliver_signals(void *t);
 extern int next_syscall_index(int max);
 extern int next_trap_index(int max);
index c279ee6d89e44d33a4207b13e52b0096dfd674b1..cfc806e4610b58141dcaf9ebd920f61906c3deb4 100644 (file)
@@ -219,4 +219,14 @@ extern int umid_file_name(char *name, char *buf, int len);
 extern int set_umid(char *name);
 extern char *get_umid(void);
 
+/* signal.c */
+extern void set_sigstack(void *sig_stack, int size);
+extern void remove_sigstack(void);
+extern void set_handler(int sig, void (*handler)(int), int flags, ...);
+extern int change_sig(int signal, int on);
+extern void block_signals(void);
+extern void unblock_signals(void);
+extern int get_signals(void);
+extern int set_signals(int enable);
+
 #endif
diff --git a/arch/um/include/signal_user.h b/arch/um/include/signal_user.h
deleted file mode 100644 (file)
index b075e54..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* 
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __SIGNAL_USER_H__
-#define __SIGNAL_USER_H__
-
-extern int signal_stack_size;
-
-extern int change_sig(int signal, int on);
-extern void set_sigstack(void *stack, int size);
-extern void set_handler(int sig, void (*handler)(int), int flags, ...);
-extern int set_signals(int enable);
-extern int get_signals(void);
-
-#endif
-
-/*
- * 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:
- */
index 6f7700593a6fe362448bbab3122f60723f9f0352..9ce6c57747a8e67632474ff1d1a7515abc298578 100644 (file)
@@ -9,7 +9,7 @@ clean-files :=
 obj-y = config.o exec_kern.o exitcode.o \
        init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \
        process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \
-       signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \
+       signal_kern.o smp.o syscall_kern.o sysrq.o time.o \
        time_kern.o tlb.o trap_kern.o trap_user.o uaccess.o um_arch.o umid.o \
        user_util.o
 
index 50a2aa35cda96b762b5ea315566da7e2671f6adb..0e32f5f4a887ba99cdc316899afd92859a81cd34 100644 (file)
@@ -15,7 +15,6 @@
 #include "kern_util.h"
 #include "user.h"
 #include "process.h"
-#include "signal_user.h"
 #include "sigio.h"
 #include "irq_user.h"
 #include "os.h"
index 651abf255bc592b2163977269fdadd9bd4524fad..d2d3f256778cb4371ab8f5a3b060a6885f757271 100644 (file)
@@ -36,7 +36,6 @@
 #include "kern_util.h"
 #include "kern.h"
 #include "signal_kern.h"
-#include "signal_user.h"
 #include "init.h"
 #include "irq_user.h"
 #include "mem_user.h"
index 03618bd13d55f1521fb59a9b29224dd7fd0fd9f3..7b0e0e81c16196d7244819316a2b0cf725f1e62e 100644 (file)
@@ -22,7 +22,6 @@
 #include "asm/ucontext.h"
 #include "kern_util.h"
 #include "signal_kern.h"
-#include "signal_user.h"
 #include "kern.h"
 #include "frame_kern.h"
 #include "sigcontext.h"
diff --git a/arch/um/kernel/signal_user.c b/arch/um/kernel/signal_user.c
deleted file mode 100644 (file)
index 62f4578..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/* 
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/mman.h>
-#include "user_util.h"
-#include "kern_util.h"
-#include "user.h"
-#include "signal_user.h"
-#include "signal_kern.h"
-#include "sysdep/sigcontext.h"
-#include "sigcontext.h"
-
-void set_sigstack(void *sig_stack, int size)
-{
-       stack_t stack = ((stack_t) { .ss_flags  = 0,
-                                    .ss_sp     = (__ptr_t) sig_stack,
-                                    .ss_size   = size - sizeof(void *) });
-
-       if(sigaltstack(&stack, NULL) != 0)
-               panic("enabling signal stack failed, errno = %d\n", errno);
-}
-
-void set_handler(int sig, void (*handler)(int), int flags, ...)
-{
-       struct sigaction action;
-       va_list ap;
-       int mask;
-
-       va_start(ap, flags);
-       action.sa_handler = handler;
-       sigemptyset(&action.sa_mask);
-       while((mask = va_arg(ap, int)) != -1){
-               sigaddset(&action.sa_mask, mask);
-       }
-       va_end(ap);
-       action.sa_flags = flags;
-       action.sa_restorer = NULL;
-       if(sigaction(sig, &action, NULL) < 0)
-               panic("sigaction failed");
-}
-
-int change_sig(int signal, int on)
-{
-       sigset_t sigset, old;
-
-       sigemptyset(&sigset);
-       sigaddset(&sigset, signal);
-       sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old);
-       return(!sigismember(&old, signal));
-}
-
-/* Both here and in set/get_signal we don't touch SIGPROF, because we must not
- * disable profiling; it's safe because the profiling code does not interact
- * with the kernel code at all.*/
-
-static void change_signals(int type)
-{
-       sigset_t mask;
-
-       sigemptyset(&mask);
-       sigaddset(&mask, SIGVTALRM);
-       sigaddset(&mask, SIGALRM);
-       sigaddset(&mask, SIGIO);
-       if(sigprocmask(type, &mask, NULL) < 0)
-               panic("Failed to change signal mask - errno = %d", errno);
-}
-
-void block_signals(void)
-{
-       change_signals(SIG_BLOCK);
-}
-
-void unblock_signals(void)
-{
-       change_signals(SIG_UNBLOCK);
-}
-
-/* These are the asynchronous signals.  SIGVTALRM and SIGARLM are handled
- * together under SIGVTALRM_BIT.  SIGPROF is excluded because we want to
- * be able to profile all of UML, not just the non-critical sections.  If
- * profiling is not thread-safe, then that is not my problem.  We can disable
- * profiling when SMP is enabled in that case.
- */
-#define SIGIO_BIT 0
-#define SIGVTALRM_BIT 1
-
-static int enable_mask(sigset_t *mask)
-{
-       int sigs;
-
-       sigs = sigismember(mask, SIGIO) ? 0 : 1 << SIGIO_BIT;
-       sigs |= sigismember(mask, SIGVTALRM) ? 0 : 1 << SIGVTALRM_BIT;
-       sigs |= sigismember(mask, SIGALRM) ? 0 : 1 << SIGVTALRM_BIT;
-       return(sigs);
-}
-
-int get_signals(void)
-{
-       sigset_t mask;
-       
-       if(sigprocmask(SIG_SETMASK, NULL, &mask) < 0)
-               panic("Failed to get signal mask");
-       return(enable_mask(&mask));
-}
-
-int set_signals(int enable)
-{
-       sigset_t mask;
-       int ret;
-
-       sigemptyset(&mask);
-       if(enable & (1 << SIGIO_BIT)) 
-               sigaddset(&mask, SIGIO);
-       if(enable & (1 << SIGVTALRM_BIT)){
-               sigaddset(&mask, SIGVTALRM);
-               sigaddset(&mask, SIGALRM);
-       }
-
-       /* This is safe - sigprocmask is guaranteed to copy locally the
-        * value of new_set, do his work and then, at the end, write to
-        * old_set.
-        */
-       if(sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0)
-               panic("Failed to enable signals");
-       ret = enable_mask(&mask);
-       sigemptyset(&mask);
-       if((enable & (1 << SIGIO_BIT)) == 0) 
-               sigaddset(&mask, SIGIO);
-       if((enable & (1 << SIGVTALRM_BIT)) == 0){
-               sigaddset(&mask, SIGVTALRM);
-               sigaddset(&mask, SIGALRM);
-       }
-       if(sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
-               panic("Failed to block signals");
-
-       return(ret);
-}
-
-/*
- * 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:
- */
index daa2f85b684c7dd14845b6d1a63560abad1de67c..01d489de3986d76b4bea09f3fdd9986112a9a53a 100644 (file)
@@ -22,7 +22,6 @@ extern int start_idle_thread(void *stack, void *switch_buf_ptr,
 extern int user_thread(unsigned long stack, int flags);
 extern void userspace(union uml_pt_regs *regs);
 extern void new_thread_proc(void *stack, void (*handler)(int sig));
-extern void remove_sigstack(void);
 extern void new_thread_handler(int sig);
 extern void handle_syscall(union uml_pt_regs *regs);
 extern int map(struct mm_id * mm_idp, unsigned long virt,
index 599d679bd4fcb3bfdebff8355d69e8d5b7a13274..9264d4021dfe23f73c0adb02d65fdf3eeea25914 100644 (file)
@@ -31,7 +31,6 @@
 #include "proc_mm.h"
 #include "skas_ptrace.h"
 #include "chan_user.h"
-#include "signal_user.h"
 #include "registers.h"
 #include "mem.h"
 #include "uml-config.h"
@@ -514,16 +513,6 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
        siglongjmp(**switch_buf, 1);
 }
 
-void remove_sigstack(void)
-{
-       stack_t stack = ((stack_t) { .ss_flags  = SS_DISABLE,
-                                    .ss_sp     = NULL,
-                                    .ss_size   = 0 });
-
-       if(sigaltstack(&stack, NULL) != 0)
-               panic("disabling signal stack failed, errno = %d\n", errno);
-}
-
 void initial_thread_cb_skas(void (*proc)(void *), void *arg)
 {
        sigjmp_buf here;
index 9c990253966c596af858b1dbd176084012cd48d2..09790ccb161ca7ddae9c91136ed805a2dc62a8dc 100644 (file)
@@ -14,7 +14,6 @@
 #include "asm/atomic.h"
 #include "kern_util.h"
 #include "time_user.h"
-#include "signal_user.h"
 #include "skas.h"
 #include "os.h"
 #include "user_util.h"
index 9950a6716fe5b015dd51365adfa312c5c2226d60..28403d2cafe6dc50a59065b0468771fe47836711 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <signal.h>
 #include <errno.h>
-#include "signal_user.h"
 #include "user_util.h"
 #include "kern_util.h"
 #include "task.h"
@@ -14,6 +13,7 @@
 #include "ptrace_user.h"
 #include "sysdep/ptrace.h"
 #include "sysdep/ptrace_user.h"
+#include "os.h"
 
 void sig_handler_common_skas(int sig, void *sc_ptr)
 {
index c40b611e3d936dbcd120f65961e18a65ec8a4c87..11f518a7e1562538e1cf75e5b87af1c609d50009 100644 (file)
@@ -14,9 +14,9 @@
 #include "kern_util.h"
 #include "user.h"
 #include "process.h"
-#include "signal_user.h"
 #include "time_user.h"
 #include "kern_constants.h"
+#include "os.h"
 
 /* XXX This really needs to be declared and initialized in a kernel file since
  * it's in <linux/time.h>
index e9ccd6b8d3c78d1092b07c4cb93cda92f9559f9d..e551107251248fad0f4584bc572fb58521aa877b 100644 (file)
@@ -17,7 +17,6 @@
 #include "sigcontext.h"
 #include "sysdep/sigcontext.h"
 #include "irq_user.h"
-#include "signal_user.h"
 #include "time_user.h"
 #include "task.h"
 #include "mode.h"
index 065b504a653b1d9cbe87998e92cf7f85486427fe..136e54c47d37fd1052304d5f11164fe53b2c15a8 100644 (file)
@@ -14,7 +14,6 @@
 #include "kern_util.h"
 #include "irq_user.h"
 #include "time_user.h"
-#include "signal_user.h"
 #include "mem_user.h"
 #include "os.h"
 #include "tlb.h"
index cfaa373a6e77df4190a2721b467a29fd94c5f4c3..14d4622a5fb86ffbd9750f9d8ce6adf34dbf03b6 100644 (file)
@@ -13,7 +13,6 @@
 #include "asm/ptrace.h"
 #include "asm/tlbflush.h"
 #include "irq_user.h"
-#include "signal_user.h"
 #include "kern_util.h"
 #include "user_util.h"
 #include "os.h"
index d11e7399d7a1a894097ec0b0a45360803eae10b5..71daae24e48a8b8125b203fafc74ee40ea39c81d 100644 (file)
@@ -19,7 +19,6 @@
 #include "sigcontext.h"
 #include "sysdep/sigcontext.h"
 #include "os.h"
-#include "signal_user.h"
 #include "user_util.h"
 #include "mem_user.h"
 #include "process.h"
index fc108615beafbaf894f0fe3e4c2eb55338084030..7501900f8941feecb59ed63700962c6087a54262 100644 (file)
@@ -8,11 +8,11 @@
 #include <signal.h>
 #include "sysdep/ptrace.h"
 #include "sysdep/sigcontext.h"
-#include "signal_user.h"
 #include "user_util.h"
 #include "kern_util.h"
 #include "task.h"
 #include "tt.h"
+#include "os.h"
 
 void sig_handler_common_tt(int sig, void *sc_ptr)
 {
index 23da27d22569da2308b373f0edd42a2b5757c710..172c8474453c9c4baa229d66c0d619ba243d40f3 100644 (file)
@@ -16,7 +16,6 @@
 #include "user_util.h"
 #include "kern_util.h"
 #include "mem_user.h"
-#include "signal_user.h"
 #include "time_user.h"
 #include "irq_user.h"
 #include "user.h"
index d9c52387c4a16c4dea868f0de58201092d0c967f..39815c6b5e4510ecd0fdaef22c73fc87a82c06ef 100644 (file)
@@ -15,7 +15,6 @@
 #include "os.h"
 #include "user.h"
 #include "user_util.h"
-#include "signal_user.h"
 #include "process.h"
 #include "irq_user.h"
 #include "kern_util.h"
index c7bfd5ee392573b5a79c9eb8dc676b00306c7046..c1f46a0fef13d14c8740d80091fb18a2cf0690d7 100644 (file)
@@ -4,9 +4,22 @@
  */
 
 #include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/mman.h>
+#include "user_util.h"
+#include "kern_util.h"
+#include "user.h"
+#include "signal_kern.h"
+#include "sysdep/sigcontext.h"
+#include "sysdep/signal.h"
+#include "sigcontext.h"
 #include "time_user.h"
 #include "mode.h"
-#include "sysdep/signal.h"
 
 void sig_handler(ARCH_SIGHDLR_PARAM)
 {
@@ -36,13 +49,138 @@ void alarm_handler(ARCH_SIGHDLR_PARAM)
                switch_timers(1);
 }
 
-/*
- * 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 set_sigstack(void *sig_stack, int size)
+{
+       stack_t stack = ((stack_t) { .ss_flags  = 0,
+                                    .ss_sp     = (__ptr_t) sig_stack,
+                                    .ss_size   = size - sizeof(void *) });
+
+       if(sigaltstack(&stack, NULL) != 0)
+               panic("enabling signal stack failed, errno = %d\n", errno);
+}
+
+void remove_sigstack(void)
+{
+       stack_t stack = ((stack_t) { .ss_flags  = SS_DISABLE,
+                                    .ss_sp     = NULL,
+                                    .ss_size   = 0 });
+
+       if(sigaltstack(&stack, NULL) != 0)
+               panic("disabling signal stack failed, errno = %d\n", errno);
+}
+
+void set_handler(int sig, void (*handler)(int), int flags, ...)
+{
+       struct sigaction action;
+       va_list ap;
+       int mask;
+
+       va_start(ap, flags);
+       action.sa_handler = handler;
+       sigemptyset(&action.sa_mask);
+       while((mask = va_arg(ap, int)) != -1){
+               sigaddset(&action.sa_mask, mask);
+       }
+       va_end(ap);
+       action.sa_flags = flags;
+       action.sa_restorer = NULL;
+       if(sigaction(sig, &action, NULL) < 0)
+               panic("sigaction failed");
+}
+
+int change_sig(int signal, int on)
+{
+       sigset_t sigset, old;
+
+       sigemptyset(&sigset);
+       sigaddset(&sigset, signal);
+       sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old);
+       return(!sigismember(&old, signal));
+}
+
+/* Both here and in set/get_signal we don't touch SIGPROF, because we must not
+ * disable profiling; it's safe because the profiling code does not interact
+ * with the kernel code at all.*/
+
+static void change_signals(int type)
+{
+       sigset_t mask;
+
+       sigemptyset(&mask);
+       sigaddset(&mask, SIGVTALRM);
+       sigaddset(&mask, SIGALRM);
+       sigaddset(&mask, SIGIO);
+       if(sigprocmask(type, &mask, NULL) < 0)
+               panic("Failed to change signal mask - errno = %d", errno);
+}
+
+void block_signals(void)
+{
+       change_signals(SIG_BLOCK);
+}
+
+void unblock_signals(void)
+{
+       change_signals(SIG_UNBLOCK);
+}
+
+/* These are the asynchronous signals.  SIGVTALRM and SIGARLM are handled
+ * together under SIGVTALRM_BIT.  SIGPROF is excluded because we want to
+ * be able to profile all of UML, not just the non-critical sections.  If
+ * profiling is not thread-safe, then that is not my problem.  We can disable
+ * profiling when SMP is enabled in that case.
  */
+#define SIGIO_BIT 0
+#define SIGVTALRM_BIT 1
+
+static int enable_mask(sigset_t *mask)
+{
+       int sigs;
+
+       sigs = sigismember(mask, SIGIO) ? 0 : 1 << SIGIO_BIT;
+       sigs |= sigismember(mask, SIGVTALRM) ? 0 : 1 << SIGVTALRM_BIT;
+       sigs |= sigismember(mask, SIGALRM) ? 0 : 1 << SIGVTALRM_BIT;
+       return(sigs);
+}
+
+int get_signals(void)
+{
+       sigset_t mask;
+
+       if(sigprocmask(SIG_SETMASK, NULL, &mask) < 0)
+               panic("Failed to get signal mask");
+       return(enable_mask(&mask));
+}
+
+int set_signals(int enable)
+{
+       sigset_t mask;
+       int ret;
+
+       sigemptyset(&mask);
+       if(enable & (1 << SIGIO_BIT))
+               sigaddset(&mask, SIGIO);
+       if(enable & (1 << SIGVTALRM_BIT)){
+               sigaddset(&mask, SIGVTALRM);
+               sigaddset(&mask, SIGALRM);
+       }
+
+       /* This is safe - sigprocmask is guaranteed to copy locally the
+        * value of new_set, do his work and then, at the end, write to
+        * old_set.
+        */
+       if(sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0)
+               panic("Failed to enable signals");
+       ret = enable_mask(&mask);
+       sigemptyset(&mask);
+       if((enable & (1 << SIGIO_BIT)) == 0)
+               sigaddset(&mask, SIGIO);
+       if((enable & (1 << SIGVTALRM_BIT)) == 0){
+               sigaddset(&mask, SIGVTALRM);
+               sigaddset(&mask, SIGALRM);
+       }
+       if(sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
+               panic("Failed to block signals");
+
+       return(ret);
+}
index 29a9e3f4376368caa56610e423d9e189eec79e4d..b47e5e71d1a5d14d0ebefef0589ceef269a20851 100644 (file)
@@ -24,7 +24,6 @@
 #include "kern_util.h"
 #include "user.h"
 #include "signal_kern.h"
-#include "signal_user.h"
 #include "sysdep/ptrace.h"
 #include "sysdep/sigcontext.h"
 #include "irq_user.h"
index a6db8877931a8cbc06a39911e35d61059c58c61f..37828e5b35269903eff04e79f6885cee56c4e6b8 100644 (file)
@@ -23,7 +23,6 @@
 #include "kern_util.h"
 #include "user.h"
 #include "signal_kern.h"
-#include "signal_user.h"
 #include "sysdep/ptrace.h"
 #include "sysdep/sigcontext.h"
 #include "irq_user.h"
index 16bc19928b3c53c49d93ca825798d42d256fdc06..7cd1a82dc8c24fd086cd8c3e3a82ef6433640673 100644 (file)
@@ -10,7 +10,6 @@
 #include "asm/uaccess.h"
 #include "asm/unistd.h"
 #include "frame_kern.h"
-#include "signal_user.h"
 #include "sigcontext.h"
 #include "registers.h"
 #include "mode.h"