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
798 B
C

/* linuxu: SHIM (third_party/linux/include/linux/gcd.h) */
#ifndef __LINUX_GCD_H
#define __LINUX_GCD_H
#include <stdint.h>
static inline uint32_t __gcd32(uint32_t a, uint32_t b)
{
while (b) {
uint32_t t = a % b;
a = b;
b = t;
}
return a;
}
static inline uint64_t __gcd64(uint64_t a, uint64_t b)
{
while (b) {
uint64_t t = a % b;
a = b;
b = t;
}
return a;
}
static inline uint32_t gcd(uint32_t a, uint32_t b)
{
return __gcd32(a, b);
}
static inline uint64_t gcd64(uint64_t a, uint64_t b)
{
return __gcd64(a, b);
}
static inline uint32_t lcm(uint32_t a, uint32_t b)
{
if (!a || !b)
return 0;
return a / __gcd32(a, b) * b;
}
static inline uint64_t lcm64(uint64_t a, uint64_t b)
{
if (!a || !b)
return 0;
return a / __gcd64(a, b) * b;
}
#endif /* __LINUX_GCD_H */