windows-mutex.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Plain mutexes (native Windows implementation).
  2. Copyright (C) 2005-2020 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. This program 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 General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <https://www.gnu.org/licenses/>. */
  13. /* Written by Bruno Haible <bruno@clisp.org>, 2005.
  14. Based on GCC's gthr-win32.h. */
  15. #ifndef _WINDOWS_MUTEX_H
  16. #define _WINDOWS_MUTEX_H
  17. #define WIN32_LEAN_AND_MEAN /* avoid including junk */
  18. #include <windows.h>
  19. #include "windows-initguard.h"
  20. typedef struct
  21. {
  22. glwthread_initguard_t guard; /* protects the initialization */
  23. CRITICAL_SECTION lock;
  24. }
  25. glwthread_mutex_t;
  26. #define GLWTHREAD_MUTEX_INIT { GLWTHREAD_INITGUARD_INIT }
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. extern void glwthread_mutex_init (glwthread_mutex_t *mutex);
  31. extern int glwthread_mutex_lock (glwthread_mutex_t *mutex);
  32. extern int glwthread_mutex_trylock (glwthread_mutex_t *mutex);
  33. extern int glwthread_mutex_unlock (glwthread_mutex_t *mutex);
  34. extern int glwthread_mutex_destroy (glwthread_mutex_t *mutex);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif /* _WINDOWS_MUTEX_H */