td_thr_set_event.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <stddef.h>
  17. #include "thread_dbP.h"
  18. td_err_e
  19. td_thr_set_event (const td_thrhandle_t *th, td_thr_events_t *event)
  20. {
  21. td_err_e err;
  22. psaddr_t eventmask;
  23. void *copy = NULL;
  24. LOG ("td_thr_set_event");
  25. /* Fetch the old event mask from the inferior and modify it in place. */
  26. err = DB_GET_FIELD_ADDRESS (eventmask, th->th_ta_p,
  27. th->th_unique, pthread, eventbuf_eventmask, 0);
  28. if (err == TD_OK)
  29. err = DB_GET_STRUCT (copy, th->th_ta_p, eventmask, td_thr_events_t);
  30. if (err == TD_OK)
  31. {
  32. uint32_t idx;
  33. for (idx = 0; idx < TD_EVENTSIZE; ++idx)
  34. {
  35. psaddr_t word;
  36. uint32_t mask;
  37. err = DB_GET_FIELD_LOCAL (word, th->th_ta_p, copy,
  38. td_thr_events_t, event_bits, idx);
  39. if (err != TD_OK)
  40. break;
  41. mask = (uintptr_t) word;
  42. mask |= event->event_bits[idx];
  43. word = (psaddr_t) (uintptr_t) mask;
  44. err = DB_PUT_FIELD_LOCAL (th->th_ta_p, copy,
  45. td_thr_events_t, event_bits, idx, word);
  46. if (err != TD_OK)
  47. break;
  48. }
  49. if (err == TD_NOAPLIC)
  50. {
  51. err = TD_OK;
  52. while (idx < TD_EVENTSIZE)
  53. if (event->event_bits[idx++] != 0)
  54. {
  55. err = TD_NOEVENT;
  56. break;
  57. }
  58. }
  59. if (err == TD_OK)
  60. /* Now write it back to the inferior. */
  61. err = DB_PUT_STRUCT (th->th_ta_p, eventmask, td_thr_events_t, copy);
  62. }
  63. return err;
  64. }