qemu-thread.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef __QEMU_THREAD_H
  2. #define __QEMU_THREAD_H 1
  3. #include <inttypes.h>
  4. #include <stdbool.h>
  5. typedef struct QemuMutex QemuMutex;
  6. typedef struct QemuCond QemuCond;
  7. typedef struct QemuThread QemuThread;
  8. #ifdef _WIN32
  9. #include "qemu-thread-win32.h"
  10. #else
  11. #include "qemu-thread-posix.h"
  12. #endif
  13. #define QEMU_THREAD_JOINABLE 0
  14. #define QEMU_THREAD_DETACHED 1
  15. void qemu_mutex_init(QemuMutex *mutex);
  16. void qemu_mutex_destroy(QemuMutex *mutex);
  17. void qemu_mutex_lock(QemuMutex *mutex);
  18. int qemu_mutex_trylock(QemuMutex *mutex);
  19. void qemu_mutex_unlock(QemuMutex *mutex);
  20. #define rcu_read_lock() do { } while (0)
  21. #define rcu_read_unlock() do { } while (0)
  22. void qemu_cond_init(QemuCond *cond);
  23. void qemu_cond_destroy(QemuCond *cond);
  24. /*
  25. * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
  26. * and pthread_cond_broadcast can be called except while the same mutex is
  27. * held as in the corresponding pthread_cond_wait calls!
  28. */
  29. void qemu_cond_signal(QemuCond *cond);
  30. void qemu_cond_broadcast(QemuCond *cond);
  31. void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
  32. void qemu_thread_create(QemuThread *thread,
  33. void *(*start_routine)(void *),
  34. void *arg, int mode);
  35. void *qemu_thread_join(QemuThread *thread);
  36. void qemu_thread_get_self(QemuThread *thread);
  37. bool qemu_thread_is_self(QemuThread *thread);
  38. void qemu_thread_exit(void *retval);
  39. #endif