Manual merge with Linus
[linux-2.6] / 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
13 void sc_to_sc(void *to_ptr, void *from_ptr)
14 {
15         struct sigcontext *to = to_ptr, *from = from_ptr;
16
17         memcpy(to, from, sizeof(*to) + sizeof(struct _fpstate));
18         if(from->fpstate != NULL)
19                 to->fpstate = (struct _fpstate *) (to + 1);
20 }
21
22 unsigned long *sc_sigmask(void *sc_ptr)
23 {
24         struct sigcontext *sc = sc_ptr;
25         return &sc->oldmask;
26 }
27
28 int sc_get_fpregs(unsigned long buf, void *sc_ptr)
29 {
30         struct sigcontext *sc = sc_ptr;
31         struct _fpstate *from = sc->fpstate, *to = (struct _fpstate *) buf;
32         int err = 0;
33
34         if(from == NULL){
35                 err |= clear_user_proc(&to->cw, sizeof(to->cw));
36                 err |= clear_user_proc(&to->sw, sizeof(to->sw));
37                 err |= clear_user_proc(&to->tag, sizeof(to->tag));
38                 err |= clear_user_proc(&to->ipoff, sizeof(to->ipoff));
39                 err |= clear_user_proc(&to->cssel, sizeof(to->cssel));
40                 err |= clear_user_proc(&to->dataoff, sizeof(to->dataoff));
41                 err |= clear_user_proc(&to->datasel, sizeof(to->datasel));
42                 err |= clear_user_proc(&to->_st, sizeof(to->_st));
43         }
44         else {
45                 err |= copy_to_user_proc(&to->cw, &from->cw, sizeof(to->cw));
46                 err |= copy_to_user_proc(&to->sw, &from->sw, sizeof(to->sw));
47                 err |= copy_to_user_proc(&to->tag, &from->tag, 
48                                          sizeof(to->tag));
49                 err |= copy_to_user_proc(&to->ipoff, &from->ipoff, 
50                                          sizeof(to->ipoff));
51                 err |= copy_to_user_proc(&to->cssel,& from->cssel, 
52                                          sizeof(to->cssel));
53                 err |= copy_to_user_proc(&to->dataoff, &from->dataoff, 
54                                     sizeof(to->dataoff));
55                 err |= copy_to_user_proc(&to->datasel, &from->datasel, 
56                                     sizeof(to->datasel));
57                 err |= copy_to_user_proc(to->_st, from->_st, sizeof(to->_st));
58         }
59         return(err);
60 }
61
62 /*
63  * Overrides for Emacs so that we follow Linus's tabbing style.
64  * Emacs will notice this stuff at the end of the file and automatically
65  * adjust the settings for this buffer only.  This must remain at the end
66  * of the file.
67  * ---------------------------------------------------------------------------
68  * Local variables:
69  * c-file-style: "linux"
70  * End:
71  */