td_thr_set_event.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Enable specific event for thread.
  2. Copyright (C) 1999,2001,2002,2003 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #include <stddef.h>
  18. #include "thread_dbP.h"
  19. td_err_e
  20. td_thr_set_event (th, event)
  21. const td_thrhandle_t *th;
  22. td_thr_events_t *event;
  23. {
  24. td_err_e err;
  25. psaddr_t eventmask;
  26. void *copy = NULL;
  27. LOG ("td_thr_set_event");
  28. /* Fetch the old event mask from the inferior and modify it in place. */
  29. err = DB_GET_FIELD_ADDRESS (eventmask, th->th_ta_p,
  30. th->th_unique, pthread, eventbuf_eventmask, 0);
  31. if (err == TD_OK)
  32. err = DB_GET_STRUCT (copy, th->th_ta_p, eventmask, td_thr_events_t);
  33. if (err == TD_OK)
  34. {
  35. uint32_t idx;
  36. for (idx = 0; idx < TD_EVENTSIZE; ++idx)
  37. {
  38. psaddr_t word;
  39. uint32_t mask;
  40. err = DB_GET_FIELD_LOCAL (word, th->th_ta_p, copy,
  41. td_thr_events_t, event_bits, idx);
  42. if (err != TD_OK)
  43. break;
  44. mask = (uintptr_t) word;
  45. mask |= event->event_bits[idx];
  46. word = (psaddr_t) (uintptr_t) mask;
  47. err = DB_PUT_FIELD_LOCAL (th->th_ta_p, copy,
  48. td_thr_events_t, event_bits, idx, word);
  49. if (err != TD_OK)
  50. break;
  51. }
  52. if (err == TD_NOAPLIC)
  53. {
  54. err = TD_OK;
  55. while (idx < TD_EVENTSIZE)
  56. if (event->event_bits[idx++] != 0)
  57. {
  58. err = TD_NOEVENT;
  59. break;
  60. }
  61. }
  62. if (err == TD_OK)
  63. /* Now write it back to the inferior. */
  64. err = DB_PUT_STRUCT (th->th_ta_p, eventmask, td_thr_events_t, copy);
  65. }
  66. return err;
  67. }