Files
geramyloveless 953cf0149c mac_linuxgpu: upstream Linux amdgpu on macOS
Runs the unmodified upstream Linux amdgpu and amdkfd drivers on Apple
Silicon Macs inside a DriverKit system extension, for AMD GPUs attached
over Thunderbolt. The Linux sources come from a pinned submodule and are
compiled against linuxu, a userspace implementation of the Linux kernel
APIs they use. Includes the HSA runtime, the host installer app, the
setup and firmware fetch scripts, and the offline test suite.
2026-10-02 18:49:17 -07:00

54 lines
1.3 KiB
C

/* linuxu: SHIM (third_party/linux/include/linux/rtmutex.h) - rwsem-backed for userspace */
#ifndef _LINUX_RT_MUTEX_H
#define _LINUX_RT_MUTEX_H
#include <linux/rwsem.h>
#include <linux/types.h>
struct rt_mutex {
struct rw_semaphore lock;
};
struct rt_mutex_base {
struct rw_semaphore lock;
};
#define __RT_MUTEX_INITIALIZER(lockname) { .lock = RWSEM_INITIALIZER(lockname.lock) }
#define DEFINE_RT_MUTEX(name) struct rt_mutex name = __RT_MUTEX_INITIALIZER(name)
#define RT_MUTEX_INITIALIZER(name) __RT_MUTEX_INITIALIZER(name)
static inline void rt_mutex_init(struct rt_mutex *m)
{
init_rwsem(&m->lock);
}
/* Exclusive sleeping lock; no priority inheritance in userspace. */
static inline void rt_mutex_lock(struct rt_mutex *lock)
{
down_write(&lock->lock);
}
static inline void rt_mutex_unlock(struct rt_mutex *lock)
{
up_write(&lock->lock);
}
static inline int rt_mutex_trylock(struct rt_mutex *lock)
{
return down_write_trylock(&lock->lock);
}
static inline int rt_mutex_lock_interruptible(struct rt_mutex *lock)
{
down_write(&lock->lock);
return 0;
}
static inline void rt_mutex_lock_nested(struct rt_mutex *lock, int n)
{
rt_mutex_lock(lock);
}
static inline int rt_mutex_trylock_nested(struct rt_mutex *lock, int n)
{
return rt_mutex_trylock(lock);
}
#endif /* _LINUX_RT_MUTEX_H */