Skip to content

Commit b7a2156

Browse files
committed
rtos/mutex.h: add wrappers for Zephyr sys/mutex.h interface
To enable use of Zephyr sys/mutex.h interface in SOF audio pipeline code, add a rtos/mutex.h wrapper for this. In Zephyr build, the native Zephyr interface is used and in posix builds (e.g. testbench), a no-op implementation is provided (similarly that already exists for k_mutex). Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 5cf6f9c commit b7a2156

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

posix/include/rtos/mutex.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,26 @@ static inline int k_mutex_unlock(struct k_mutex *mutex)
4040
return 0;
4141
}
4242

43+
/* provide a no-op implementation for zephyr/sys/mutex.h */
44+
45+
struct sys_mutex {
46+
};
47+
48+
#define SYS_MUTEX_DEFINE(name) \
49+
struct sys_mutex name
50+
51+
static inline void sys_mutex_init(struct sys_mutex *mutex)
52+
{
53+
}
54+
55+
static inline int sys_mutex_lock(struct sys_mutex *mutex, k_timeout_t timeout)
56+
{
57+
return 0;
58+
}
59+
60+
static inline int sys_mutex_unlock(struct sys_mutex *mutex)
61+
{
62+
return 0;
63+
}
64+
4365
#endif

zephyr/include/rtos/mutex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
#define __ZEPHYR_RTOS_MUTEX_H__
88

99
#include <zephyr/kernel.h> /* k_mutex_*() */
10+
#include <zephyr/sys/mutex.h> /* for sys_mutex */
1011

1112
#endif /* __ZEPHYR_RTOS_MUTEX_H__ */

0 commit comments

Comments
 (0)