db_events.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS 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
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * db_event.c
  17. *
  18. * This file contains implementation of Drawbridge event synchronization APIs.
  19. */
  20. #include "pal_defs.h"
  21. #include "pal.h"
  22. #include "pal_internal.h"
  23. #include "pal_error.h"
  24. #include "api.h"
  25. PAL_HANDLE DkNotificationEventCreate (PAL_BOL initialState)
  26. {
  27. ENTER_PAL_CALL(DkNotificationEventCreate);
  28. PAL_HANDLE handle = NULL;
  29. int ret = _DkEventCreate(&handle, initialState, true);
  30. if (ret < 0) {
  31. _DkRaiseFailure(-ret);
  32. handle = NULL;
  33. }
  34. TRACE_HEAP(handle);
  35. LEAVE_PAL_CALL_RETURN(handle);
  36. }
  37. PAL_HANDLE DkSynchronizationEventCreate (PAL_BOL initialState)
  38. {
  39. ENTER_PAL_CALL(DkSynchronizationEventCreate);
  40. PAL_HANDLE handle = NULL;
  41. int ret = _DkEventCreate(&handle, initialState, false);
  42. if (ret < 0) {
  43. _DkRaiseFailure(-ret);
  44. handle = NULL;
  45. }
  46. TRACE_HEAP(handle);
  47. LEAVE_PAL_CALL_RETURN(handle);
  48. }
  49. /* DkEventDestroy deprecated, replaced by DkObjectClose */
  50. void DkEventSet (PAL_HANDLE handle)
  51. {
  52. ENTER_PAL_CALL(DkEventSet);
  53. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  54. _DkRaiseFailure(PAL_ERROR_INVAL);
  55. LEAVE_PAL_CALL();
  56. }
  57. int ret = _DkEventSet(handle, -1);
  58. if (ret < 0)
  59. _DkRaiseFailure(-ret);
  60. LEAVE_PAL_CALL();
  61. }
  62. void DkEventWait (PAL_HANDLE handle)
  63. {
  64. ENTER_PAL_CALL(DkEventWait);
  65. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  66. _DkRaiseFailure(PAL_ERROR_INVAL);
  67. LEAVE_PAL_CALL();
  68. }
  69. int ret = _DkEventWait(handle);
  70. if (ret < 0)
  71. _DkRaiseFailure(-ret);
  72. LEAVE_PAL_CALL();
  73. }
  74. void DkEventClear (PAL_HANDLE handle)
  75. {
  76. ENTER_PAL_CALL(DkEventClear);
  77. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  78. _DkRaiseFailure(PAL_ERROR_INVAL);
  79. LEAVE_PAL_CALL();
  80. }
  81. int ret = _DkEventClear(handle);
  82. if (ret < 0)
  83. _DkRaiseFailure(-ret);
  84. LEAVE_PAL_CALL();
  85. }