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

38 lines
781 B
C

/* linuxu: SHIM (third_party/linux/include/linux/minmax.h)
*
* 3- and 4-argument min/max forms. Reuses the 2-arg min()/max() from
* <linux/bitops.h>; "careful" pairwise combine as in vendor minmax.h.
*/
#ifndef __LINUX_MAX_H
#define __LINUX_MAX_H
#define __careful_min(a, b) \
({ \
typeof(a) __a = (a); \
typeof(b) __b = (b); \
(void) (&__a == &__b); \
__a <= __b ? __a : __b; \
})
#define __careful_max(a, b) \
({ \
typeof(a) __a = (a); \
typeof(b) __b = (b); \
(void) (&__a == &__b); \
__a >= __b ? __a : __b; \
})
#define min3(x, y, z) \
min(__careful_min(x, y), z)
#define max3(x, y, z) \
max(__careful_max(x, y), z)
#define min4(x, y, z, w) \
min(min3(x, y, z), w)
#define max4(x, y, z, w) \
max(max3(x, y, z), w)
#endif /* __LINUX_MAX_H */