Build on Linux: compile locally, link/sign on the iPhone; FFmpeg audio decoders; SDK stub patching
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
8e6f8a86a4
commit
66f4e7e3ea
1 changed files with 700 additions and 48 deletions
31
Native/compat.c
Normal file
31
Native/compat.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Runtime helpers that Xcode's compiler-rt normally provides (absent from the Linux toolchain).
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
static int32_t os_major = -1, os_minor, os_patch;
|
||||
|
||||
static void load_version(void) {
|
||||
char buf[32] = {0};
|
||||
size_t n = sizeof buf - 1;
|
||||
os_major = 0;
|
||||
if (sysctlbyname("kern.osproductversion", buf, &n, NULL, 0) != 0) return;
|
||||
char *p = buf;
|
||||
os_major = (int32_t)strtol(p, &p, 10);
|
||||
if (*p == '.') os_minor = (int32_t)strtol(p + 1, &p, 10);
|
||||
if (*p == '.') os_patch = (int32_t)strtol(p + 1, &p, 10);
|
||||
}
|
||||
|
||||
/// Backs `if #available(...)` / `@available` checks. Platform is ignored: this binary only runs on iOS.
|
||||
int32_t __isPlatformVersionAtLeast(uint32_t platform, uint32_t major, uint32_t minor, uint32_t subminor) {
|
||||
(void)platform;
|
||||
if (os_major < 0) load_version();
|
||||
if (os_major != (int32_t)major) return os_major > (int32_t)major;
|
||||
if (os_minor != (int32_t)minor) return os_minor > (int32_t)minor;
|
||||
return os_patch >= (int32_t)subminor;
|
||||
}
|
||||
|
||||
/// Older form used by `__builtin_available` in C.
|
||||
int32_t __isOSVersionAtLeast(int32_t major, int32_t minor, int32_t subminor) {
|
||||
return __isPlatformVersionAtLeast(2, (uint32_t)major, (uint32_t)minor, (uint32_t)subminor);
|
||||
}
|
||||
Loading…
Reference in a new issue