ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / um / sys-i386 / sigcontext.c
1 /* 
2  * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #include <stddef.h>
7 #include <string.h>
8 #include <asm/ptrace.h>
9 #include <asm/sigcontext.h>
10 #include "sysdep/ptrace.h"
11 #include "kern_util.h"
12 #include "frame_user.h"
13
14 int sc_size(void *data)
15 {
16         struct arch_frame_data *arch = data;
17
18         return(sizeof(struct sigcontext) + arch->fpstate_size);
19 }
20
21 void sc_to_sc(void *to_ptr, void *from_ptr)
22 {
23         struct sigcontext *to = to_ptr, *from = from_ptr;
24         int size = sizeof(*to) + signal_frame_sc.common.arch.fpstate_size;
25
26         memcpy(to, from, size);
27         if(from->fpstate != NULL) to->fpstate = (struct _fpstate *) (to + 1);
28 }
29
30 unsigned long *sc_sigmask(void *sc_ptr)
31 {
32         struct sigcontext *sc = sc_ptr;
33
34         return(&sc->oldmask);
35 }
36
37 int sc_get_fpregs(unsigned long buf, void *sc_ptr)
38 {
39         struct sigcontext *sc = sc_ptr;
40         struct _fpstate *from = sc->fpstate, *to = (struct _fpstate *) buf;
41         int err = 0;
42
43         if(from == NULL){
44                 err |= clear_user_proc(&to->cw, sizeof(to->cw));
45                 err |= clear_user_proc(&to->sw, sizeof(to->sw));
46                 err |= clear_user_proc(&to->tag, sizeof(to->tag));
47                 err |= clear_user_proc(&to->ipoff, sizeof(to->ipoff));
48                 err |= clear_user_proc(&to->cssel, sizeof(to->cssel));
49                 err |= clear_user_proc(&to->dataoff, sizeof(to->dataoff));
50                 err |= clear_user_proc(&to->datasel, sizeof(to->datasel));
51                 err |= clear_user_proc(&to->_st, sizeof(to->_st));
52         }
53         else {
54                 err |= copy_to_user_proc(&to->cw, &from->cw, sizeof(to->cw));
55                 err |= copy_to_user_proc(&to->sw, &from->sw, sizeof(to->sw));
56                 err |= copy_to_user_proc(&to->tag, &from->tag, 
57                                          sizeof(to->tag));
58                 err |= copy_to_user_proc(&to->ipoff, &from->ipoff, 
59                                          sizeof(to->ipoff));
60                 err |= copy_to_user_proc(&to->cssel,& from->cssel, 
61                                          sizeof(to->cssel));
62                 err |= copy_to_user_proc(&to->dataoff, &from->dataoff, 
63                                     sizeof(to->dataoff));
64                 err |= copy_to_user_proc(&to->datasel, &from->datasel, 
65                                     sizeof(to->datasel));
66                 err |= copy_to_user_proc(to->_st, from->_st, sizeof(to->_st));
67         }
68         return(err);
69 }
70
71 /*
72  * Overrides for Emacs so that we follow Linus's tabbing style.
73  * Emacs will notice this stuff at the end of the file and automatically
74  * adjust the settings for this buffer only.  This must remain at the end
75  * of the file.
76  * ---------------------------------------------------------------------------
77  * Local variables:
78  * c-file-style: "linux"
79  * End:
80  */