mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
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.
38 lines
777 B
C
38 lines
777 B
C
/* linuxu: SHIM (third_party/linux/include/linux/bsearch.h, AS-IS) */
|
|
#ifndef _LINUX_BSEARCH_H
|
|
#define _LINUX_BSEARCH_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/compiler.h> /* __always_inline */
|
|
|
|
static __always_inline
|
|
void *__inline_bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp)
|
|
{
|
|
const char *pivot;
|
|
int result;
|
|
|
|
while (num > 0) {
|
|
pivot = base + (num >> 1) * size;
|
|
result = cmp(key, pivot);
|
|
|
|
if (result == 0)
|
|
return (void *)pivot;
|
|
|
|
if (result > 0) {
|
|
base = pivot + size;
|
|
num--;
|
|
}
|
|
num >>= 1;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static inline void *bsearch(const void *key, const void *base, size_t num,
|
|
size_t size, cmp_func_t cmp)
|
|
{
|
|
return __inline_bsearch(key, base, num, size, cmp);
|
|
}
|
|
|
|
#endif /* _LINUX_BSEARCH_H */
|