db_events.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Copyright (C) 2014 Stony Brook University
  2. This file is part of Graphene Library OS.
  3. Graphene Library OS is free software: you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public License
  5. as published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. Graphene Library OS is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /*
  14. * db_event.c
  15. *
  16. * This file contains implementation of Drawbridge event synchronization APIs.
  17. */
  18. #include "pal_defs.h"
  19. #include "pal.h"
  20. #include "pal_internal.h"
  21. #include "pal_error.h"
  22. #include "api.h"
  23. PAL_HANDLE DkNotificationEventCreate (PAL_BOL initialState)
  24. {
  25. ENTER_PAL_CALL(DkNotificationEventCreate);
  26. PAL_HANDLE handle = NULL;
  27. int ret = _DkEventCreate(&handle, initialState, true);
  28. if (ret < 0) {
  29. _DkRaiseFailure(-ret);
  30. handle = NULL;
  31. }
  32. TRACE_HEAP(handle);
  33. LEAVE_PAL_CALL_RETURN(handle);
  34. }
  35. PAL_HANDLE DkSynchronizationEventCreate (PAL_BOL initialState)
  36. {
  37. ENTER_PAL_CALL(DkSynchronizationEventCreate);
  38. PAL_HANDLE handle = NULL;
  39. int ret = _DkEventCreate(&handle, initialState, false);
  40. if (ret < 0) {
  41. _DkRaiseFailure(-ret);
  42. handle = NULL;
  43. }
  44. TRACE_HEAP(handle);
  45. LEAVE_PAL_CALL_RETURN(handle);
  46. }
  47. /* DkEventDestroy deprecated, replaced by DkObjectClose */
  48. void DkEventSet (PAL_HANDLE handle)
  49. {
  50. ENTER_PAL_CALL(DkEventSet);
  51. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  52. _DkRaiseFailure(PAL_ERROR_INVAL);
  53. LEAVE_PAL_CALL();
  54. }
  55. int ret = _DkEventSet(handle, -1);
  56. if (ret < 0)
  57. _DkRaiseFailure(-ret);
  58. LEAVE_PAL_CALL();
  59. }
  60. void DkEventWait (PAL_HANDLE handle)
  61. {
  62. ENTER_PAL_CALL(DkEventWait);
  63. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  64. _DkRaiseFailure(PAL_ERROR_INVAL);
  65. LEAVE_PAL_CALL();
  66. }
  67. int ret = _DkEventWait(handle);
  68. if (ret < 0)
  69. _DkRaiseFailure(-ret);
  70. LEAVE_PAL_CALL();
  71. }
  72. void DkEventClear (PAL_HANDLE handle)
  73. {
  74. ENTER_PAL_CALL(DkEventClear);
  75. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  76. _DkRaiseFailure(PAL_ERROR_INVAL);
  77. LEAVE_PAL_CALL();
  78. }
  79. int ret = _DkEventClear(handle);
  80. if (ret < 0)
  81. _DkRaiseFailure(-ret);
  82. LEAVE_PAL_CALL();
  83. }