compat_mutex_winthreads.c 727 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. #include "lib/lock/compat_mutex.h"
  6. #include "lib/err/torerr.h"
  7. void
  8. tor_locking_init(void)
  9. {
  10. }
  11. void
  12. tor_mutex_init(tor_mutex_t *m)
  13. {
  14. InitializeCriticalSection(&m->mutex);
  15. }
  16. void
  17. tor_mutex_init_nonrecursive(tor_mutex_t *m)
  18. {
  19. InitializeCriticalSection(&m->mutex);
  20. }
  21. void
  22. tor_mutex_uninit(tor_mutex_t *m)
  23. {
  24. DeleteCriticalSection(&m->mutex);
  25. }
  26. void
  27. tor_mutex_acquire(tor_mutex_t *m)
  28. {
  29. raw_assert(m);
  30. EnterCriticalSection(&m->mutex);
  31. }
  32. void
  33. tor_mutex_release(tor_mutex_t *m)
  34. {
  35. LeaveCriticalSection(&m->mutex);
  36. }