qemu-thread-common.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Common qemu-thread implementation header file.
  3. *
  4. * Copyright Red Hat, Inc. 2018
  5. *
  6. * Authors:
  7. * Peter Xu <peterx@redhat.com>,
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. */
  12. #ifndef QEMU_THREAD_COMMON_H
  13. #define QEMU_THREAD_COMMON_H
  14. #include "qemu/thread.h"
  15. #include "trace.h"
  16. static inline void qemu_mutex_post_init(QemuMutex *mutex)
  17. {
  18. #ifdef CONFIG_DEBUG_MUTEX
  19. mutex->file = NULL;
  20. mutex->line = 0;
  21. #endif
  22. mutex->initialized = true;
  23. }
  24. static inline void qemu_mutex_pre_lock(QemuMutex *mutex,
  25. const char *file, int line)
  26. {
  27. trace_qemu_mutex_lock(mutex, file, line);
  28. }
  29. static inline void qemu_mutex_post_lock(QemuMutex *mutex,
  30. const char *file, int line)
  31. {
  32. #ifdef CONFIG_DEBUG_MUTEX
  33. mutex->file = file;
  34. mutex->line = line;
  35. #endif
  36. trace_qemu_mutex_locked(mutex, file, line);
  37. }
  38. static inline void qemu_mutex_pre_unlock(QemuMutex *mutex,
  39. const char *file, int line)
  40. {
  41. #ifdef CONFIG_DEBUG_MUTEX
  42. mutex->file = NULL;
  43. mutex->line = 0;
  44. #endif
  45. trace_qemu_mutex_unlock(mutex, file, line);
  46. }
  47. #endif