sigcontext.c 2.2 KB

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