From 5b26bebcf4e58d04b6dfd43aea53a1649b3a2f37 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Sat, 11 Nov 2023 10:14:57 -0800 Subject: [PATCH] venus: add vn_gettid helper Signed-off-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_common.c | 5 ++--- src/virtio/vulkan/vn_common.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/virtio/vulkan/vn_common.c b/src/virtio/vulkan/vn_common.c index 0dc7d55a986..00962790443 100644 --- a/src/virtio/vulkan/vn_common.c +++ b/src/virtio/vulkan/vn_common.c @@ -11,7 +11,6 @@ #include "vn_common.h" #include -#include #include "util/log.h" #include "util/os_misc.h" @@ -139,7 +138,7 @@ vn_watchdog_timeout(const struct vn_watchdog *watchdog) static inline void vn_watchdog_release(struct vn_watchdog *watchdog) { - if (syscall(SYS_gettid) == watchdog->tid) { + if (vn_gettid() == watchdog->tid) { watchdog->tid = 0; mtx_unlock(&watchdog->mutex); } @@ -148,7 +147,7 @@ vn_watchdog_release(struct vn_watchdog *watchdog) static bool vn_watchdog_acquire(struct vn_watchdog *watchdog, bool alive) { - pid_t tid = syscall(SYS_gettid); + pid_t tid = vn_gettid(); if (!watchdog->tid && tid != watchdog->tid && mtx_trylock(&watchdog->mutex) == thrd_success) { /* register as the only waiting thread that monitors the ring. */ diff --git a/src/virtio/vulkan/vn_common.h b/src/virtio/vulkan/vn_common.h index ca26694df3b..6b65cf547d6 100644 --- a/src/virtio/vulkan/vn_common.h +++ b/src/virtio/vulkan/vn_common.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "c11/threads.h" @@ -458,4 +459,14 @@ vn_object_get_id(const void *obj, VkObjectType type) } } +static inline pid_t +vn_gettid(void) +{ +#ifdef ANDROID + return gettid(); +#else + return syscall(SYS_gettid); +#endif +} + #endif /* VN_COMMON_H */