db_mutex.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_mutex.c
  15. *
  16. * This file contains APIs that provides operations of mutexes.
  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
  24. DkMutexCreate (PAL_NUM initialCount)
  25. {
  26. ENTER_PAL_CALL(DkMutexCreate);
  27. PAL_HANDLE handle = NULL;
  28. int ret = _DkMutexCreate(&handle, initialCount);
  29. if (ret < 0) {
  30. _DkRaiseFailure(-ret);
  31. handle = NULL;
  32. }
  33. TRACE_HEAP(handle);
  34. LEAVE_PAL_CALL_RETURN(handle);
  35. }
  36. void DkMutexRelease (PAL_HANDLE handle)
  37. {
  38. ENTER_PAL_CALL(DkMutexRelease);
  39. if (!handle ||
  40. !IS_HANDLE_TYPE(handle, mutex)) {
  41. _DkRaiseFailure(PAL_ERROR_INVAL);
  42. LEAVE_PAL_CALL();
  43. }
  44. _DkMutexRelease (handle);
  45. LEAVE_PAL_CALL();
  46. }