db_events.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 "api.h"
  19. #include "pal.h"
  20. #include "pal_defs.h"
  21. #include "pal_error.h"
  22. #include "pal_internal.h"
  23. PAL_HANDLE DkNotificationEventCreate(PAL_BOL initialState) {
  24. ENTER_PAL_CALL(DkNotificationEventCreate);
  25. PAL_HANDLE handle = NULL;
  26. int ret = _DkEventCreate(&handle, initialState, true);
  27. if (ret < 0) {
  28. _DkRaiseFailure(-ret);
  29. handle = NULL;
  30. }
  31. LEAVE_PAL_CALL_RETURN(handle);
  32. }
  33. PAL_HANDLE DkSynchronizationEventCreate(PAL_BOL initialState) {
  34. ENTER_PAL_CALL(DkSynchronizationEventCreate);
  35. PAL_HANDLE handle = NULL;
  36. int ret = _DkEventCreate(&handle, initialState, false);
  37. if (ret < 0) {
  38. _DkRaiseFailure(-ret);
  39. handle = NULL;
  40. }
  41. LEAVE_PAL_CALL_RETURN(handle);
  42. }
  43. /* DkEventDestroy deprecated, replaced by DkObjectClose */
  44. void DkEventSet(PAL_HANDLE handle) {
  45. ENTER_PAL_CALL(DkEventSet);
  46. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  47. _DkRaiseFailure(PAL_ERROR_INVAL);
  48. LEAVE_PAL_CALL();
  49. }
  50. int ret = _DkEventSet(handle, -1);
  51. if (ret < 0)
  52. _DkRaiseFailure(-ret);
  53. LEAVE_PAL_CALL();
  54. }
  55. void DkEventWait(PAL_HANDLE handle) {
  56. ENTER_PAL_CALL(DkEventWait);
  57. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  58. _DkRaiseFailure(PAL_ERROR_INVAL);
  59. LEAVE_PAL_CALL();
  60. }
  61. int ret = _DkEventWait(handle);
  62. if (ret < 0)
  63. _DkRaiseFailure(-ret);
  64. LEAVE_PAL_CALL();
  65. }
  66. void DkEventClear(PAL_HANDLE handle) {
  67. ENTER_PAL_CALL(DkEventClear);
  68. if (!handle || !IS_HANDLE_TYPE(handle, event)) {
  69. _DkRaiseFailure(PAL_ERROR_INVAL);
  70. LEAVE_PAL_CALL();
  71. }
  72. int ret = _DkEventClear(handle);
  73. if (ret < 0)
  74. _DkRaiseFailure(-ret);
  75. LEAVE_PAL_CALL();
  76. }