td_thr_clear_event.c 2.2 KB

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